/* Base Variables & Theme */
:root {
    --bg-main: #0b0f19;
    --bg-card: rgba(22, 28, 45, 0.7);
    --bg-card-hover: rgba(22, 28, 45, 0.9);
    --bg-input: #121824;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: #10b981;
    
    /* Brand Colors (Emerald/Health Theme) */
    --primary: #10b981;
    --primary-hover: #059669;
    --primary-light: rgba(16, 185, 129, 0.15);
    --accent: #3b82f6;
    --accent-light: rgba(59, 130, 246, 0.1);
    
    /* UI Colors */
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-inverse: #0b0f19;
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.1);
    
    /* Layout */
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.2), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.light-theme, [data-theme="light"] {
    --bg-main: #f3f4f6;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: rgba(255, 255, 255, 0.95);
    --bg-input: #ffffff;
    --border-color: rgba(0, 0, 0, 0.1);
    --border-focus: #10b981;
    
    --primary: #10b981;
    --primary-hover: #059669;
    --primary-light: rgba(16, 185, 129, 0.12);
    --accent: #3b82f6;
    --accent-light: rgba(59, 130, 246, 0.08);
    
    --text-main: #111827;
    --text-muted: #4b5563;
    --text-inverse: #ffffff;
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.08);
    --warning: #d97706;
    --warning-light: rgba(217, 119, 6, 0.08);
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.03);
}

/* Global Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Base Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.form-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input-wrapper {
    position: relative;
    width: 100%;
}

.form-input, select {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    padding: 12px 16px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s ease;
}

.form-input::placeholder {
    color: #4b5563;
}

.form-input:focus, select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.input-invalid {
    border-color: var(--danger) !important;
}

.input-invalid:focus {
    box-shadow: 0 0 0 3px var(--danger-light) !important;
}

.error-msg {
    font-size: 0.8125rem;
    color: var(--danger);
    margin-top: 6px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--text-inverse);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 18px;
    height: 18px;
}

/* Alerts */
.alert {
    display: flex;
    gap: 12px;
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.875rem;
}

.alert-success {
    background-color: var(--primary-light);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
}

.alert-danger {
    background-color: var(--danger-light);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.alert-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.alert-content {
    flex-grow: 1;
}

/* Login Page Styling */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.08) 0%, transparent 40%),
                radial-gradient(circle at 90% 80%, rgba(59, 130, 246, 0.05) 0%, transparent 40%);
}

.login-wrapper {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.brand-header {
    text-align: center;
    margin-bottom: 32px;
}

.brand-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background-color: var(--primary-light);
    color: var(--primary);
    border-radius: 30%;
    margin-bottom: 16px;
    box-shadow: 0 0 20px var(--primary-light);
}

.brand-title {
    font-size: 2.25rem;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 4px;
}

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

.login-card {
    width: 100%;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 32px;
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-lg);
}

.card-title {
    font-size: 1.5rem;
    color: #ffffff;
    margin-bottom: 8px;
}

.card-desc {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 24px;
}

/* Dashboard UI Layout */
.dashboard-layout {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px 80px;
}

.header-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 32px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
    font-weight: 500;
}

.btn-logout {
    padding: 8px 16px;
    font-size: 0.875rem;
}

/* Summary Grid */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

@media (max-width: 900px) {
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

.metric-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.metric-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background-color: var(--text-muted);
}

.metric-card.consumed::after { background-color: var(--accent); }
.metric-card.burned::after { background-color: var(--warning); }
.metric-card.basal::after { background-color: #a855f7; }
.metric-card.balance::after { background-color: var(--primary); }

.metric-card.balance.surplus::after { background-color: var(--danger); }

.metric-title {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.metric-value {
    font-size: 1.75rem;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    color: #ffffff;
    line-height: 1.2;
}

.metric-unit {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 2px;
}

/* Sections Layout */
.dashboard-sections {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 32px;
}

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

.section-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-title {
    font-size: 1.25rem;
    color: #ffffff;
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal-content {
    background-color: #121824;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-close:hover {
    color: #ffffff;
}

/* Lists and Items */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.history-item:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

.item-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.item-img {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
    background-color: var(--bg-input);
}

.item-details h4 {
    font-size: 0.9375rem;
    color: #ffffff;
}

.item-details p {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.item-macros {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.macro-tag {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

.macro-tag.protein { color: #f472b6; }
.macro-tag.carbs { color: #60a5fa; }
.macro-tag.fat { color: #fbbf24; }

.item-val {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    color: #ffffff;
}

/* File Upload Premium Style */
.file-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: rgba(255, 255, 255, 0.01);
}

.file-upload-area:hover {
    border-color: var(--primary);
    background-color: var(--primary-light);
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    margin: 0 auto 12px;
}

.file-upload-area:hover .upload-icon {
    color: var(--primary);
}

.upload-title {
    font-weight: 600;
    margin-bottom: 4px;
}

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

.image-preview-container {
    margin-top: 16px;
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    aspect-ratio: 16/9;
}

.image-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Setup Wizard Style */
.wizard-container {
    max-width: 550px;
    width: 100%;
    margin: 10vh auto;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 36px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(16px);
}

.wizard-step-title {
    font-size: 1.75rem;
    margin-bottom: 8px;
    color: #ffffff;
}

.wizard-step-desc {
    color: var(--text-muted);
    font-size: 0.9375rem;
    margin-bottom: 28px;
}

/* General Utilities */
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* Loading Animation */
.loading-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    background-color: currentColor;
    border-radius: 50%;
    animation: loading-dot-blink 1.4s infinite both;
}

.loading-dots span:nth-child(2) { animation-delay: .2s; }
.loading-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes loading-dot-blink {
    0% { opacity: .2; }
    20% { opacity: 1; }
    100% { opacity: .2; }
}

.pulse-animation {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}

/* Light Theme Overrides */
.light-theme .brand-title,
.light-theme .card-title,
.light-theme .section-title,
.light-theme .wizard-step-title,
.light-theme .metric-value,
.light-theme .item-details h4,
.light-theme .item-val,
.light-theme .upload-title,
.light-theme .modal-content h3 {
    color: var(--text-main) !important;
}

.light-theme .form-input::placeholder {
    color: #9ca3af;
}

.light-theme .history-item {
    background-color: rgba(0, 0, 0, 0.02);
}
.light-theme .history-item:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.light-theme .modal-content {
    background-color: #ffffff;
}

/* Floating Theme Toggle */
.theme-toggle-floating {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(12px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle-floating:hover {
    background-color: var(--primary-light);
    border-color: var(--primary);
    transform: translateY(-2px) scale(1.05);
}

.file-upload-area.uploading {
    pointer-events: none;
    cursor: default;
    border-color: var(--primary);
    background-color: var(--primary-light);
    opacity: 0.85;
}

/* Navigation bar responsive styles */
.nav-container {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    width: 100%;
    position: relative;
    backdrop-filter: blur(12px);
    transition: all 0.3s ease;
}

.nav-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Hamburger toggle button */
.nav-hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: background-color 0.2s;
}

.nav-hamburger:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.light-theme .nav-hamburger:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.nav-menu {
    display: none; /* Hidden by default on mobile */
    flex-direction: column;
    width: 100%;
    margin-top: 4px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    align-items: stretch;
    gap: 10px;
}

.nav-menu.open {
    display: flex; /* Shown when toggled */
}

.nav-menu button, .nav-menu form, .nav-menu form button {
    width: 100%;
}

/* Desktop styles */
@media (min-width: 769px) {
    .nav-container {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 12px 24px;
    }
    
    .nav-header-row {
        width: auto;
    }
    
    .nav-hamburger {
        display: none; /* Hidden on desktop */
    }
    
    .nav-menu {
        display: flex; /* Always shown on desktop */
        flex-direction: row;
        width: auto;
        margin-top: 0;
        padding-top: 0;
        border-top: none;
        align-items: center;
        gap: 8px;
    }
    
    .nav-menu button, .nav-menu form, .nav-menu form button {
        width: auto;
    }
}



