:root {
    /* Colors - Dark Theme */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(30, 30, 45, 0.6);
    --bg-card-hover: rgba(40, 40, 60, 0.8);

    /* Accent Colors */
    --accent-primary: #10b981;
    --accent-secondary: #34d399;
    --accent-glow: rgba(16, 185, 129, 0.4);
    --accent-calories: #f59e0b;
    --accent-protein: #8b5cf6;
    --accent-carbs: #06b6d4;
    --accent-fat: #f43f5e;

    /* Text Colors */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Borders & Shadows */
    --border-color: rgba(255, 255, 255, 0.08);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px var(--accent-glow);

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
body.light {
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-card-hover: rgba(255, 255, 255, 1);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.1);
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(16, 185, 129, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(6, 182, 212, 0.05) 0%, transparent 60%);
    pointer-events: none;
    z-index: -1;
}

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    padding: 0 var(--spacing-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
}

body.light .navbar {
    background: rgba(248, 250, 252, 0.9);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-primary);
    text-decoration: none;
    transition: var(--transition-normal);
}

.logo:hover {
    text-shadow: var(--shadow-glow);
}

.logo-icon {
    font-size: 1.6rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    transition: var(--transition-normal);
}

.nav-links a:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-links a.active {
    color: var(--accent-primary);
    background: rgba(16, 185, 129, 0.1);
}

.theme-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-normal);
}

.theme-btn:hover {
    border-color: var(--accent-primary);
    background: rgba(16, 185, 129, 0.1);
}


.mobile-menu-btn {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 10px;
}

.mobile-menu-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    transition: var(--transition-fast);
}

.mobile-menu {
    display: none;
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    padding: var(--spacing-md);
    flex-direction: column;
    gap: var(--spacing-sm);
    z-index: 999;
}

.mobile-menu.active {
    display: flex;
}

.mobile-menu a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    padding: var(--spacing-sm);
    border-radius: var(--radius-sm);
    transition: var(--transition-normal);
}

.mobile-menu a:hover,
.mobile-menu a.active {
    color: var(--accent-primary);
    background: rgba(16, 185, 129, 0.1);
}


.dashboard {
    padding: 100px var(--spacing-lg) var(--spacing-xl);
    max-width: 1400px;
    margin: 0 auto;
}


.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: var(--spacing-lg);
}

.welcome-text h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
}

.date-display {
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.stat-card {
    position: relative;
    padding: var(--spacing-md);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    transition: var(--transition-slow);
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    opacity: 0;
    transition: var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(16, 185, 129, 0.3);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card.calories::before {
    background: linear-gradient(90deg, var(--accent-calories), #fbbf24);
}

.stat-card.protein::before {
    background: linear-gradient(90deg, var(--accent-protein), #a78bfa);
}

.stat-card.carbs::before {
    background: linear-gradient(90deg, var(--accent-carbs), #22d3ee);
}

.stat-icon {
    font-size: 2rem;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-unit {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.stat-trend {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-full);
}

.stat-trend.up {
    color: var(--accent-primary);
    background: rgba(16, 185, 129, 0.15);
}

.stat-trend.down {
    color: var(--accent-fat);
    background: rgba(244, 63, 94, 0.15);
}

.stat-badge {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-primary);
}

/* Progress Ring */
.progress-ring {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    width: 44px;
    height: 44px;
}

.progress-ring svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.ring-bg {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 3;
}

.ring-progress {
    fill: none;
    stroke: var(--accent-protein);
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dasharray 0.8s ease;
}

.ring-progress.carbs-ring {
    stroke: var(--accent-carbs);
}

/* CHART SECTION */

.chart-section {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--spacing-md);
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.chart-title h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.chart-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.time-selector {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px;
    border-radius: var(--radius-full);
}

body.light .time-selector {
    background: rgba(0, 0, 0, 0.05);
}

.time-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition-fast);
}

.time-btn:hover {
    color: var(--text-primary);
}

.time-btn.active {
    background: var(--accent-primary);
    color: #022c22;
}

.chart-container {
    display: flex;
    gap: var(--spacing-md);
}

.chart-stats {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    min-width: 140px;
}

.chart-stat {
    display: flex;
    flex-direction: column;
    padding: var(--spacing-sm);
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
}

body.light .chart-stat {
    background: rgba(0, 0, 0, 0.03);
}

.chart-stat-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chart-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.chart-stat-unit {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.chart-wrapper {
    flex: 1;
    position: relative;
    min-height: 280px;
}

#calorieChart {
    width: 100%;
    height: 100%;
    display: block;
}

.chart-tooltip {
    position: absolute;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 10;
}

.chart-tooltip .tooltip-date {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-bottom: 4px;
}

.chart-tooltip .tooltip-value {
    display: block;
    color: var(--accent-primary);
    font-size: 1.1rem;
    font-weight: 700;
}

.bottom-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: var(--spacing-md);
}

.recent-meals-card,
.nutrition-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: var(--spacing-md);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.view-all-btn {
    color: var(--accent-primary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    background: rgba(16, 185, 129, 0.1);
    transition: var(--transition-normal);
}

.view-all-btn:hover {
    background: rgba(16, 185, 129, 0.2);
}

/* Meals List */
.meals-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    max-height: 320px;
    overflow-y: auto;
}

.meal-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm);
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

body.light .meal-item {
    background: rgba(0, 0, 0, 0.03);
}

.meal-item:hover {
    background: rgba(0, 0, 0, 0.3);
}

body.light .meal-item:hover {
    background: rgba(0, 0, 0, 0.06);
}

.meal-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.meal-emoji {
    font-size: 1.5rem;
}

.meal-details {
    display: flex;
    flex-direction: column;
}

.meal-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    text-transform: capitalize;
}

.meal-meta {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.meal-calories {
    font-weight: 700;
    color: var(--accent-calories);
    font-size: 0.95rem;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl);
    text-align: center;
}

.empty-icon {
    font-size: 3rem;
    opacity: 0.5;
    margin-bottom: var(--spacing-sm);
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: var(--spacing-sm);
}

.add-meal-link {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
}

/* Nutrition Bars */
.nutrition-bars {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.nutrition-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nutrition-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.nutrition-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    overflow: hidden;
}

body.light .nutrition-bar {
    background: rgba(0, 0, 0, 0.1);
}

.nutrition-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.protein-fill {
    background: linear-gradient(90deg, var(--accent-protein), #a78bfa);
}

.carbs-fill {
    background: linear-gradient(90deg, var(--accent-carbs), #22d3ee);
}

.fat-fill {
    background: linear-gradient(90deg, var(--accent-fat), #fb7185);
}

/* Macro Circles */
.macro-circles {
    display: flex;
    justify-content: space-around;
    padding-top: var(--spacing-sm);
    border-top: 1px solid var(--border-color);
}

.macro-circle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.macro-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.macro-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.protein-circle .macro-value {
    color: var(--accent-protein);
}

.carbs-circle .macro-value {
    color: var(--accent-carbs);
}

.fat-circle .macro-value {
    color: var(--accent-fat);
}

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    .bottom-grid {
        grid-template-columns: 1fr;
    }

    .chart-container {
        flex-direction: column;
    }

    .chart-stats {
        flex-direction: row;
        min-width: auto;
    }

    .chart-stat {
        flex: 1;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 0 var(--spacing-sm);
    }

    .nav-links {
        display: none;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .dashboard {
        padding: 90px var(--spacing-sm) var(--spacing-lg);
    }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm);
    }

    .welcome-text h1 {
        font-size: 1.5rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        flex-direction: row;
        align-items: center;
    }

    .stat-icon {
        font-size: 1.5rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .chart-header {
        flex-direction: column;
    }

    .time-selector {
        align-self: flex-start;
    }

    .chart-stats {
        flex-wrap: wrap;
    }

    .chart-stat {
        min-width: calc(50% - var(--spacing-xs));
    }
}

@media (max-width: 480px) {

    .stat-trend,
    .stat-badge,
    .progress-ring {
        display: none;
    }

    .time-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
}

/* ---------- ANIMATIONS ---------- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.stat-card {
    animation: fadeInUp 0.5s ease backwards;
}

.stat-card:nth-child(1) {
    animation-delay: 0.1s;
}

.stat-card:nth-child(2) {
    animation-delay: 0.2s;
}

.stat-card:nth-child(3) {
    animation-delay: 0.3s;
}

.stat-card:nth-child(4) {
    animation-delay: 0.4s;
}

.chart-section {
    animation: fadeInUp 0.5s ease 0.3s backwards;
}

.bottom-grid>* {
    animation: fadeInUp 0.5s ease 0.5s backwards;
}