:root {
  --red: #e53e3e;
  --blue: #3182ce;
  --green: #38a169;
  --purple: #d754ee;
  --black: #2d3748;
  --bg-light: #f8fafc;
  --text-light: #1e293b;
  --bg-dark: #0f172a;
  --bg-medium: #131e38;
  --text-dark: #f8fafc;
  --accent: #6366f1;
  --accentlight: #afb0ec;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --border-color: #e2e8f0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  padding: 0;
  background: var(--bg-light);
  color: var(--text-light);
  transition: background 0.3s, color 0.3s;
  line-height: 1.5;
  min-height: 100vh;
}

.dark-mode {
  background: var(--bg-dark);
  color: var(--text-dark);
  --blue: #87abcd;  /* Change blue color in dark mode */
}

.dark-mode .header {
  background: #1a202c;
  border-bottom: 1px solid #2d3748;
}

.dark-mode .card {
  background: #1a202c;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.dark-mode .entry {
  border-bottom: 1px solid #2d3748;
}

.dark-mode select, .dark-mode button {
  background: #2d3748;
  color: #f8fafc;
  border-color: #4a5568;
}

.dark-mode .calendar-days a:hover {
  background: #2d3748;
}

.dark-mode .disabled-nav {
  color: #4a5568;
}

/* Fix for black text in dark mode */
.dark-mode .entry-black {
  color: #e2e8f0;
}

.header {
  background: #fff;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.nav-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.page-navigation {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.language-switch {
  font-size: 0.8em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.language-switch a {
  text-decoration: none;
  color: inherit;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr 4fr;
  gap: 2rem;
}

.sidebar {
  max-width: 220px;
}

.content-area {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  gap: 2rem;
  min-height: 400px; /* Ensure container is tall enough */
}

.content-area canvas {
  width: 100% !important;
  height: 400px !important;  /* Explicit height for the chart */
}

.card {
  background: white;
  border-radius: 0.5rem;
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Breadcrumbs styling */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  padding: 0.75rem 0;
  margin-bottom: 1rem;
  list-style: none;
  background-color: transparent;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
}

.breadcrumb-item a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumb-item a:hover {
  text-decoration: underline;
}

.breadcrumb-item + .breadcrumb-item {
  padding-left: 0.5rem;
}

.breadcrumb-item + .breadcrumb-item::before {
  display: inline-block;
  padding-right: 0.5rem;
  color: var(--text-light);
  content: ">";
}

.breadcrumb-item.active {
  color: var(--text-light);
}

/* Dark mode adjustments for breadcrumbs */
.dark-mode .breadcrumb-item + .breadcrumb-item::before,
.dark-mode .breadcrumb-item.active {
  color: var(--text-dark);
}

.entry {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
}

.entry:last-child {
  border-bottom: none;
}

.entry-red { color: var(--red); }
.entry-blue { color: var(--blue); }
.entry-green { color: var(--green); }
.entry-black { color: var(--black); }
.entry-purple { color: var(--purple); }

.disabled-nav {
  color: #ccc;
  cursor: not-allowed;
}

.order-switch {
  margin-bottom: 1rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.order-switch a {
  color: var(--accent);
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
}

.order-switch a:hover {
  background: rgba(99, 102, 241, 0.1);
}

.month-calendar {
  margin-bottom: 1.5rem;
  text-align: center;
}

.month-calendar h2 {
  font-size: 1rem;
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.20rem;
}

.calendar-days a, .calendar-days span {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 1.4rem;
  height: 1.6rem;
  border-radius: 50%;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.8rem;
}

.calendar-days a {
  color: inherit;
  transition: background 0.2s;
}

.calendar-days a:hover {
  background: rgba(0, 0, 0, 0.05);
}

.calendar-days a.current {
  background: var(--accent);
  color: white;
  font-weight: bold;
}

.calendar-days span.dim {
  color: #aaa;
  opacity: 0.6;
}

button, select {
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  border: 1px solid var(--border-color);
  background: white;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s;
}

button:hover, select:hover {
  border-color: var(--accent);
}

a {
  color: var(--accent);
}

.day-scan {
  max-width: 600px;
}

.day-scan img {
  width: 100%;
  height: auto;
  border-radius: 0.375rem;
  box-shadow: var(--shadow);
}

.category-heading {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--accent);
  color: var(--accent);
  font-size: 1.1rem;
}

.entry-content p:first-child {
  margin-top: 0;
}

.entry-content p:last-child {
  margin-bottom: 0;
}

/* Theme toggle styles */
.theme-toggle {
  position: relative;
  display: flex;
  align-items: center;
  cursor: pointer;
  height: 24px;
}

.theme-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-icons {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 24px;
}

.sun-icon, .moon-icon {
  position: absolute;
  width: 20px;
  height: 20px;
  transition: opacity 0.3s, transform 0.3s;
}

.sun-icon {
  opacity: 1;
}

.moon-icon {
  opacity: 0;
}

html.dark-mode .sun-icon {
  opacity: 0;
}

html.dark-mode .moon-icon {
  opacity: 1;
}

.edit-icon {
  display: none;
  font-size: 1em;
  text-decoration: none;
  color: gray;
  margin-left: 5px;
}

.entry:hover .edit-icon {
  display: inline;
}

.dark-mode .edit-icon {
  color: #bbb;
}

.dark-mode .edit-icon:hover {
  color: #fff;
}

.nutrition-bar {
  display: flex;
  height: 10px;
  margin-bottom: 10px;
  align-items: center;
}

.protein-bar {
  background-color: #0077B6;
  height: 10px;
}

.carbs-bar {
  background-color: #FBC02D;
  height: 10px;
}

.fats-bar {
  background-color: #D32F2F;
  height: 10px;
}

.calories {
  margin-left: 10px;
}

.daily-pie-chart {
    width: 120px;   /* Should match the svg width */
    height: auto;  /* Let it expand to accommodate the calories text */
    margin: 20px auto;
    text-align: center;
}

.daily-pie-chart svg {
    display: block;
    margin: 0 auto;
    border-radius: 50%;  /* Makes the SVG round */
}

.daily-calories {
    margin-top: 10px;
    text-align: center;
    font-size: 1em;  /* Smaller font size */
    font-weight: normal;  /* Not bold */
}

.macro-legend {
    display: none;
    margin-top: 10px;
    text-align: center;
}

.macro-item {
    display: flex;
    align-items: center;
    justify-content: center;  /* Center the items */
    margin-bottom: 5px;
}

.macro-color {
    width: 12px;
    height: 12px;
    display: inline-block;
    margin-right: 5px;
}

.daily-pie-chart:hover .macro-legend {
    display: block;
}

/* Add styles for the home page */
select#year-select {
    padding: 10px;
    border-radius: 5px;
    font-size: 1em;
    margin-top: 10px;
}

/* Modern Navigation Bar */
.site-navbar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background-color: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}

html.dark-mode .site-navbar {
    background-color: #1e293b;
    border-bottom: 1px solid #334155;
}

/* Logo Styling */
.site-logo a {
    font-size: 1.5rem;
    font-weight: 600;
    color: #334155;
    text-decoration: none;
    letter-spacing: -0.025em;
}

html.dark-mode .site-logo a {
    color: #f1f5f9;
}

.site-logo a:hover {
    color: #0ea5e9;
}

/* Main Navigation */
.main-nav ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 2rem;
}

.main-nav li a {
    display: inline-block;
    padding: 0.5rem 0;
    font-size: 1rem;
    color: #64748b;
    text-decoration: none;
    position: relative;
}

.main-nav li.active a {
    font-weight: 600;
    color: #334155;
}

html.dark-mode .main-nav li a {
    color: #94a3b8;
}

html.dark-mode .main-nav li.active a {
    color: #f1f5f9;
}

.main-nav li a::after {
    content: '';
    position: absolute;
    width: 100%;
    transform: scaleX(0);
    height: 2px;
    bottom: 0;
    left: 0;
    background-color: #0ea5e9;
    transform-origin: bottom right;
    transition: transform 0.25s ease-out;
}

.main-nav li a:hover::after {
    transform: scaleX(1);
    transform-origin: bottom left;
}

.main-nav li.active a::after {
    transform: scaleX(1);
}

/* Right Controls */
.nav-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.language-switch {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.language-switch a {
    color: #64748b;
    text-decoration: none;
}

html.dark-mode .language-switch a {
    color: #94a3b8;
}

.language-switch a:hover {
    color: #0ea5e9;
}

/* Page header if needed */
.page-header {
    padding: 1rem 2rem;
    text-align: center;
}

/* Theme toggle styles */
.theme-toggle {
    cursor: pointer;
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.theme-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-icons {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: #e2e8f0;
    border-radius: 24px;
    transition: 0.3s;
}

.toggle-icons::after {
    content: "";
    position: absolute;
    left: 2px;
    top: 2px;
    height: 20px;
    width: 20px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Move slider to right when checked */
input:checked + .toggle-icons::after {
    left: calc(100% - 22px);
    background-color: #0f172a;
}

/* Change background color when checked */
input:checked + .toggle-icons {
    background-color: #334155;
}

/* Icons positioning */
.sun-icon, .moon-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
}

.sun-icon {
    right: 5px;
    color: #d97706; /* Amber color for better contrast */
}

.moon-icon {
    left: 5px;
    color: #1e293b; /* Dark blue for contrast on light */
}

input:checked + .toggle-icons .sun-icon {
    color: #fbbf24; /* Brighter amber on dark background */
}

input:checked + .toggle-icons .moon-icon {
    color: #f1f5f9; /* Light color on dark background */
}

/* Responsive design - for smaller screens */
@media (max-width: 768px) {
    .site-navbar {
        flex-direction: column;
        padding: 0.5rem;
        gap: 0.75rem;
    }
    
    .main-nav ul {
        gap: 1rem;
    }
    
    .nav-controls {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 768px) {
  main {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .content-area {
    grid-template-columns: 1fr;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
  }

  .nav-controls {
    width: 100%;
    justify-content: space-between;
  }

  .sidebar {
    max-width: 100%;
  }
}

.chart-container {
    width: 100%;
    /* Remove grid styling inherited from .content-area if necessary */
    display: block;
    margin: 0 auto;
}
.chart-container canvas {
    width: 100% !important;
    height: 400px !important;  /* Adjust as needed */
}
.chart-container-small canvas {
    height: 250px !important;  /* Adjust as needed */
}

.full-width {
    grid-column: 1 / -1;  /* Span all columns in the grid */
}

.nutrition-toggle {
    background: transparent;
    border: none;
    color: var(--blue);
    cursor: pointer;
    font-size: 0.8rem;
    margin-top: 0.5rem;
    padding: 0;
    text-decoration: underline;
}

.nutrition-table-container {
    margin-top: 0.75rem;
    overflow-x: auto;
}

.nutrition-table {
    border-collapse: collapse;
    font-size: 0.85rem;
    width: 100%;
}

.nutrition-table th,
.nutrition-table td {
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem;
    text-align: right;
}

.nutrition-table th:first-child,
.nutrition-table td:first-child,
.nutrition-table th:nth-child(2),
.nutrition-table td:nth-child(2),
.nutrition-table th:nth-child(3),
.nutrition-table td:nth-child(3) {
    text-align: left;
}

.nutrition-table th {
    background-color: var(--light-bg);
    font-weight: 600;
}

/* Dark mode adjustments */
.dark-mode .nutrition-table th {
    background-color: var(--dark-nav);
}

.food-entry {
    cursor: pointer;
}

.nutrition-table-container {
    margin-top: 0.75rem;
    overflow-x: auto;
}

.nutrition-table {
    border-collapse: collapse;
    font-size: 0.85rem;
    width: 100%;
}

.nutrition-table th,
.nutrition-table td {
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem;
    text-align: right;
}

.nutrition-table th:first-child,
.nutrition-table td:first-child,
.nutrition-table th:nth-child(2),
.nutrition-table td:nth-child(2),
.nutrition-table th:nth-child(3),
.nutrition-table td:nth-child(3) {
    text-align: left;
}

.nutrition-table th {
    background-color: var(--light-bg);
    font-weight: 600;
}

/* Dark mode adjustments */
.dark-mode .nutrition-table th {
    background-color: var(--dark-nav);
}