: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-danger: #f43f5e;
    --accent-warning: #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);

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --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 */
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;
}

/* Background gradient effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(16, 185, 129, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(139, 92, 246, 0.08) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    padding: 0 32px;
    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: 10px;
    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: 16px;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 8px 16px;
    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 Button */
.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: 16px;
    flex-direction: column;
    gap: 8px;
    z-index: 999;
    border-bottom: 1px solid var(--border-color);
}

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

.mobile-menu a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    padding: 12px 16px;
    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);
}

.tracker-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 100px 20px 40px;
    gap: 24px;
}

.history-btn {
    position: fixed;
    top: 90px;
    right: 24px;
    width: 50px;
    height: 50px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-normal);
    z-index: 100;
}

.history-btn:hover {
    transform: scale(1.05);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-md);
}

.tracker-card {
    width: 100%;
    max-width: 500px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 32px;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.5s ease;
}

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

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

.card-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
}

.header-icon {
    width: 56px;
    height: 56px;
    background: rgba(16, 185, 129, 0.15);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

.header-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

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

.input-section {
    margin-bottom: 24px;
}

.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 14px 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition-normal);
}

body.light .input-group input,
body.light .input-group select {
    background: rgba(0, 0, 0, 0.03);
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.input-group input::placeholder {
    color: var(--text-muted);
}

.search-wrapper {
    display: flex;
    gap: 8px;
}

.search-wrapper input {
    flex: 1;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.search-btn {
    padding: 14px 20px;
    background: var(--accent-primary);
    border: none;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    color: #022c22;
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition-normal);
}

.search-btn:hover {
    background: var(--accent-secondary);
}

.input-hint {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.api-badge {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-primary);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.7rem;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.search-results {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    overflow: hidden;
}

body.light .search-results {
    background: rgba(0, 0, 0, 0.05);
}

.search-results.hidden {
    display: none;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border-color);
}

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

.close-results {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: var(--transition-fast);
}

.close-results:hover {
    color: var(--accent-danger);
}

.results-list {
    max-height: 240px;
    overflow-y: auto;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition-fast);
}

.result-item:last-child {
    border-bottom: none;
}

.result-item:hover {
    background: rgba(16, 185, 129, 0.1);
}

.result-info {
    flex: 1;
}

.result-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    text-transform: capitalize;
    margin-bottom: 4px;
}

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

.result-calories {
    font-weight: 700;
    color: var(--accent-warning);
    font-size: 1rem;
    white-space: nowrap;
    margin-left: 12px;
}

.result-add {
    background: var(--accent-primary);
    color: #022c22;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    margin-left: 12px;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-add:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px var(--accent-glow);
}

.results-loading,
.results-error {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
}

.results-loading.hidden,
.results-error.hidden {
    display: none;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    margin: 0 auto 12px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.error-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 8px;
}

.manual-toggle {
    margin-bottom: 16px;
}

.toggle-btn {
    background: transparent;
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    justify-content: center;
    transition: var(--transition-normal);
}

.toggle-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.manual-entry {
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}

body.light .manual-entry {
    background: rgba(0, 0, 0, 0.03);
}

.manual-entry.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.add-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--accent-primary) 0%, #059669 100%);
    border: none;
    border-radius: var(--radius-md);
    color: #022c22;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition-normal);
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3);
}

.add-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px rgba(16, 185, 129, 0.4);
}

.add-btn:active {
    transform: translateY(0);
}

.add-btn.secondary {
    background: transparent;
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: none;
}

.add-btn.secondary:hover {
    background: rgba(16, 185, 129, 0.1);
}

.btn-icon {
    font-size: 1.4rem;
    font-weight: 700;
}

.total-section {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    margin-bottom: 24px;
}

.total-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.total-value {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.total-value #totalCalories {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--accent-primary);
    line-height: 1;
}

.total-unit {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.macros-summary {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.macro-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
}

.macro-pill.protein {
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-protein);
}

.macro-pill.carbs {
    background: rgba(6, 182, 212, 0.15);
    color: var(--accent-carbs);
}

.macro-pill.fat {
    background: rgba(244, 63, 94, 0.15);
    color: var(--accent-fat);
}

.food-list-section {
    position: relative;
}

.list-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.food-list {
    list-style: none;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 4px;
}

.food-list li {
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    transition: var(--transition-normal);
    animation: fadeIn 0.3s ease;
}

body.light .food-list li {
    background: rgba(0, 0, 0, 0.03);
}

.food-list li:hover {
    background: rgba(0, 0, 0, 0.3);
}

body.light .food-list li:hover {
    background: rgba(0, 0, 0, 0.06);
}

.food-list li>div {
    flex: 1;
}

.food-list li strong {
    color: var(--text-primary);
    font-weight: 600;
    text-transform: capitalize;
}

.food-list li br+* {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.remove {
    color: var(--accent-danger);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: var(--transition-normal);
    flex-shrink: 0;
}

.remove:hover {
    background: rgba(244, 63, 94, 0.15);
    transform: scale(1.1);
}

.empty-state {
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
    text-align: center;
}

.empty-state.visible {
    display: flex;
}

.empty-icon {
    font-size: 3rem;
    opacity: 0.5;
    margin-bottom: 12px;
}

.empty-state p {
    color: var(--text-muted);
}

.empty-hint {
    font-size: 0.85rem;
    margin-top: 4px;
}

.food-list::-webkit-scrollbar,
.results-list::-webkit-scrollbar {
    width: 4px;
}

.food-list::-webkit-scrollbar-track,
.results-list::-webkit-scrollbar-track {
    background: transparent;
}

.food-list::-webkit-scrollbar-thumb,
.results-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}

.dashboard-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 28px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition-normal);
}

.dashboard-link:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.dashboard-link .arrow {
    transition: var(--transition-normal);
}

.dashboard-link:hover .arrow {
    transform: translateX(4px);
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.8rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-normal);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent-danger);
}

.history-list {
    padding: 20px 24px;
    max-height: 400px;
    overflow-y: auto;
}

.history-list>div {
    padding: 14px 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

body.light .history-list>div {
    background: rgba(0, 0, 0, 0.03);
}

.history-list strong {
    color: var(--text-primary);
}

/* API Setup Modal */
.api-setup {
    max-width: 440px;
}

.api-setup-content {
    padding: 24px;
}

.api-setup-content>p {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.api-steps {
    margin: 0 0 20px 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.api-steps li {
    margin-bottom: 8px;
}

.api-steps a {
    color: var(--accent-primary);
}

.api-buttons {
    display: flex;
    gap: 12px;
}

.api-buttons .add-btn {
    flex: 1;
}

.api-note {
    margin-top: 16px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}


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

    .nav-links {
        display: none;
    }

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

    .tracker-container {
        padding: 90px 16px 32px;
    }

    .tracker-card {
        padding: 24px;
    }

    .history-btn {
        top: 80px;
        right: 16px;
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }

    .header-icon {
        width: 48px;
        height: 48px;
        font-size: 1.6rem;
    }

    .header-text h1 {
        font-size: 1.3rem;
    }

    .api-buttons {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .input-row {
        grid-template-columns: 1fr;
    }

    .total-value #totalCalories {
        font-size: 2rem;
    }

    .macros-summary {
        flex-direction: column;
        align-items: center;
    }
}