:root {
    /* Color Palette */
    --bg-base: #1a7878;
    --bg-gradient-start: #1d8e8e;
    --bg-gradient-end: #136060;
    
    --primary: #7a101e;
    --primary-hover: #961526;
    --primary-shadow: rgba(122, 16, 30, 0.4);
    --secondary: #3b82f6;
    
    --text-main: #ffffff;
    --text-muted: #e2e8f0;
    
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-highlight: rgba(255, 255, 255, 0.3);
    
    --success: #10b981;
    --danger: #ef4444;
    
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background: radial-gradient(circle at top left, var(--bg-gradient-start), var(--bg-gradient-end));
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.5;
    overflow-x: hidden;
}

/* Glassmorphism Utilities */
.glass-header, .glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.glass-card {
    border-radius: var(--radius-lg);
    padding: 2rem;
    transition: var(--transition);
}

.glass-card:hover {
    border-color: var(--glass-highlight);
    transform: translateY(-2px);
}

.glass-card.glow {
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.1);
}

/* Layout */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header.glass-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    border-radius: 100px;
    margin-bottom: 3rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-main);
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Views */
.view {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Auth Card */
.auth-card {
    max-width: 400px;
    margin: 4rem auto;
    text-align: center;
}

.auth-card h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.auth-toggle {
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Forms & Inputs */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    text-align: left;
}

.input-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"] {
    width: 100%;
    padding: 1rem;
    background: #cccadb;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-md);
    color: #1e293b;
    font-weight: 600;
    font-size: 1.05rem;
    transition: var(--transition);
    outline: none;
}

input::placeholder {
    color: rgba(30, 41, 59, 0.6);
    font-weight: 400;
}

input:focus {
    border-color: var(--primary);
    background: #cccadb;
    box-shadow: 0 0 0 3px var(--primary-shadow);
}

/* Buttons */
button {
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    transition: var(--transition);
}

.btn-primary {
    width: 100%;
    padding: 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    box-shadow: 0 4px 6px var(--primary-shadow);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--primary-shadow);
}

.btn-secondary {
    padding: 0.8rem 1.5rem;
    background: var(--primary);
    border: none;
    color: white;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 6px var(--primary-shadow);
}

.btn-secondary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--primary-shadow);
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-main);
    font-weight: 600;
}

.btn-text:hover {
    color: white;
    text-shadow: 0 0 10px rgba(255,255,255,0.5);
}

.btn-icon {
    background: var(--primary);
    border: none;
    color: white;
    border-radius: var(--radius-sm);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px var(--primary-shadow);
    transition: var(--transition);
}
.btn-icon:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--primary-shadow);
}

/* Dashboard Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

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

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.flex-row {
    display: flex;
    gap: 1rem;
}

.flex-row input {
    margin-bottom: 0;
}

.w-full { width: 100%; }
.mt-4 { margin-top: 2rem; }

/* Stats Row */
.stats-row {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: #cccadb;
    border-radius: var(--radius-md);
    color: #1e293b;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-item .label {
    font-size: 0.8rem;
    color: rgba(30, 41, 59, 0.7);
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

.trend.positive { color: var(--danger); } /* More calories = bad trend visually, or depends on goal */
.trend.negative { color: var(--success); }

/* Macro Grid */
.macro-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    transition: var(--transition);
}

.macro-grid.disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* Checkbox Toggle Switch */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0,0,0,0.5);
    transition: .4s;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px; width: 18px;
    left: 3px; bottom: 3px;
    background-color: var(--text-muted);
    transition: .4s;
}
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); background-color: white;}
.slider.round { border-radius: 24px; }
.slider.round:before { border-radius: 50%; }

/* Meal List */
.meal-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.meal-list::-webkit-scrollbar { width: 6px; }
.meal-list::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 10px; }

.meal-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(0,0,0,0.15);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.meal-item:hover {
    background: rgba(0,0,0,0.3);
    border-color: var(--glass-highlight);
}

.meal-info h4 { margin-bottom: 0.25rem; }
.meal-meta { font-size: 0.8rem; color: var(--text-muted); display: flex; gap: 1rem;}
.meal-cal { font-weight: 700; color: var(--primary); font-size: 1.2rem; }
.meal-delete { color: var(--text-muted); cursor: pointer; background: none; border: none; padding: 0.5rem;}
.meal-delete:hover { color: var(--danger); }

/* Comparison List */
.comparison-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.comp-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--glass-border);
}
.comp-item:last-child { border-bottom: none; }
.comp-day { font-weight: 500; width: 100px;}
.comp-vals { display: flex; gap: 2rem; color: var(--text-muted); font-size: 0.9rem;}
.comp-vals span.active { color: var(--text-main); font-weight: 600;}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 1000;
}

.toast {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.error { border-left: 4px solid var(--danger); }
.toast.success { border-left: 4px solid var(--success); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
    background: var(--bg-gradient-start); /* Darker background for the modal so it pops */
}

.modal-content::-webkit-scrollbar { width: 6px; }
.modal-content::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 10px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1rem;
}

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--text-main);
}

.profile-section {
    padding: 1rem 0;
    border-bottom: 1px dashed var(--glass-border);
}
.profile-section:last-child {
    border-bottom: none;
}

.profile-section h4 {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}
