:root {
    --primary: #10B981;
    --primary-dark: #059669;
    --primary-light: #34D399;
    --primary-subtle: rgba(16, 185, 129, 0.1);
    --bg-page: #F8FAFC;
    --bg-surface: #FFFFFF;
    --bg-card: #FFFFFF;
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --border: #E2E8F0;
    --border-light: #F1F5F9;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;
    --purple: #8B5CF6;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --radius-sm: 0.5rem;
    --radius: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
}

[data-theme="dark"] {
    --bg-page: #0F172A;
    --bg-surface: #1E293B;
    --bg-card: #1E293B;
    --text-primary: #F1F5F9;
    --text-secondary: #CBD5E1;
    --text-muted: #64748B;
    --border: #334155;
    --border-light: #1E293B;
    --primary-subtle: rgba(16, 185, 129, 0.2);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    margin: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    color: var(--text-primary);
}

.app-container { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #FFFFFF 0%, #F8FAFC 100%);
    border-right: 1px solid var(--border);
    position: fixed;
    height: 100vh;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 1.5rem;
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 1.35rem;
    color: var(--primary);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-brand i { font-size: 1.5rem; }

.sidebar-nav { padding: 1rem 0.75rem; flex: 1; overflow-y: auto; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.sidebar-link:hover { background: var(--primary-subtle); color: var(--primary); }

.sidebar-link.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.sidebar-link i { font-size: 1.15rem; width: 24px; text-align: center; }

.sidebar-divider { height: 1px; background: var(--border); margin: 0.75rem 1rem; }

/* Top Navbar */
.top-navbar {
    position: fixed;
    top: 0;
    left: 260px;
    right: 0;
    height: 70px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    z-index: 99;
}

.top-navbar h4 { margin: 0; font-size: 1.1rem; font-weight: 600; }

/* Menu Toggle - Hidden on desktop by default */
.menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--primary);
    border: none;
    color: white;
    padding: 0.75rem;
    border-radius: var(--radius);
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.menu-toggle:hover { background: var(--primary-dark); }

/* Main Content */
.main-content {
    margin-left: 260px;
    margin-top: 70px;
    padding: 1.5rem 2rem 2rem;
    flex: 1;
    width: calc(100% - 260px);
    min-height: calc(100vh - 70px);
}

.page-header { margin-bottom: 1.5rem; }
.page-header h2 { font-size: 1.5rem; margin-bottom: 0.25rem; }
.page-header p { color: var(--text-muted); margin: 0; font-size: 0.9rem; }

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.25rem;
    transition: box-shadow 0.2s ease;
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 1.25rem;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h5 { margin: 0; font-size: 0.95rem; font-weight: 600; }
.card-body { padding: 1.25rem; }

/* Stat Cards */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    margin-bottom: 1rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stat-card:hover::before { opacity: 1; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    margin-bottom: 0.75rem;
}

.stat-icon-calories { background: rgba(16, 185, 129, 0.15); color: var(--primary); }
.stat-icon-protein { background: rgba(139, 92, 246, 0.15); color: var(--purple); }
.stat-icon-carbs { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.stat-icon-fat { background: rgba(236, 72, 153, 0.15); color: #EC4899; }

.stat-value { font-size: 1.75rem; font-weight: 700; font-family: 'Poppins', sans-serif; line-height: 1.2; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }

/* Progress Bars */
.progress { height: 8px; border-radius: 100px; background: var(--border-light); overflow: hidden; }
.progress-bar { border-radius: 100px; transition: width 0.6s ease; }
.progress-bar-calories { background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%); }
.progress-bar-protein { background: linear-gradient(90deg, var(--purple) 0%, #A78BFA 100%); }
.progress-bar-carbs { background: linear-gradient(90deg, var(--warning) 0%, #FCD34D 100%); }
.progress-bar-fat { background: linear-gradient(90deg, #EC4899 0%, #F472B6 100%); }

/* Welcome Banner */
.welcome-banner {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius-xl);
    padding: 1.75rem 2rem;
    color: white;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.25);
}

.welcome-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.welcome-banner h2 { color: white; font-size: 1.35rem; margin-bottom: 0.25rem; }
.welcome-banner p { color: rgba(255, 255, 255, 0.85); margin: 0; }

/* Buttons */
.btn { font-weight: 500; padding: 0.5rem 1rem; border-radius: var(--radius); transition: all 0.2s ease; display: inline-flex; align-items: center; gap: 0.5rem; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
    color: white;
}

.btn-primary:hover { background: linear-gradient(135deg, var(--primary-dark) 0%, #047857 100%); transform: translateY(-1px); color: white; }
.btn-outline-success { color: var(--primary); border-color: var(--primary); background: transparent; }
.btn-outline-success:hover { background: var(--primary); border-color: var(--primary); color: white; }
.btn-light { background: rgba(255, 255, 255, 0.2); border: 1px solid rgba(255, 255, 255, 0.3); color: white; }
.btn-light:hover { background: rgba(255, 255, 255, 0.3); color: white; }
.btn-icon { width: 36px; height: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius); border: none; background: transparent; color: var(--text-secondary); transition: all 0.2s; }
.btn-icon:hover { background: var(--primary-subtle); color: var(--primary); }
.btn-success { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); border: none; color: white; }
.btn-success:hover { background: linear-gradient(135deg, var(--primary-dark) 0%, #047857 100%); color: white; }
.btn-danger { background: linear-gradient(135deg, var(--danger) 0%, #DC2626 100%); border: none; color: white; }
.btn-danger:hover { background: linear-gradient(135deg, #DC2626 0%, #B91C1C 100%); color: white; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.875rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1.1rem; }
.btn-block { width: 100%; justify-content: center; }

/* Quick Add FAB */
.quick-add-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
    z-index: 50;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.quick-add-btn:hover { transform: scale(1.1); box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5); }

/* User Avatar */
.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

/* Food Search */
.search-container { position: relative; }
.search-input-group { position: relative; }
.search-input-group .form-control { padding-left: 2.5rem; }
.search-input-group .search-icon { position: absolute; left: 0.875rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    margin-top: 0.25rem;
}
.search-results.show { display: block; }
.search-result-item {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background 0.15s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--primary-subtle); }
.search-result-item:active { background: rgba(16, 185, 129, 0.2); }
.search-result-name { font-weight: 500; color: var(--text-primary); margin-bottom: 0.125rem; }
.search-result-meta { font-size: 0.8rem; color: var(--text-muted); }
.search-result-calories { font-weight: 600; color: var(--primary); font-size: 0.9rem; }

/* Selected Food Card */
.selected-food-card {
    background: linear-gradient(135deg, var(--primary-subtle) 0%, rgba(139, 92, 246, 0.1) 100%);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-top: 1rem;
}
.selected-food-card h5 { color: var(--primary); margin-bottom: 0.5rem; font-size: 0.95rem; }

/* Barcode Scanner */
.scanner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}
.scanner-overlay.show { display: flex; }
.scanner-box {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

/* Forms */
.form-label { font-weight: 500; font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 0.375rem; }
.form-control { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.625rem 0.875rem; font-size: 0.9rem; transition: all 0.2s; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15); outline: none; }
.form-select { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.625rem 0.875rem; font-size: 0.9rem; background-color: white; }
.form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15); outline: none; }
.form-range::-webkit-slider-thumb { background: var(--primary); }
.form-text { font-size: 0.8rem; color: var(--text-muted); }
.input-group-text { background: var(--border-light); border: 1px solid var(--border); color: var(--text-secondary); font-size: 0.9rem; }

/* Calorie Ring */
.calorie-ring-container { position: relative; width: 180px; height: 180px; margin: 0 auto; }
.calorie-ring-bg { fill: none; stroke: var(--border-light); stroke-width: 12; }
.calorie-ring-progress { fill: none; stroke: var(--primary); stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset 1s ease; }
.calorie-ring-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; }
.calorie-ring-value { font-size: 2rem; font-weight: 700; font-family: 'Poppins', sans-serif; color: var(--text-primary); line-height: 1; }
.calorie-ring-label { font-size: 0.8rem; color: var(--text-muted); }

/* Goals Form */
.goal-input-group { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.goal-input-group label { min-width: 120px; font-weight: 500; margin: 0; }
.goal-input-group .form-control { flex: 1; }
.goal-unit { font-size: 0.85rem; color: var(--text-muted); min-width: 40px; }

/* Calendar / History */
.calendar-container { background: var(--bg-card); border-radius: var(--radius-lg); padding: 1.25rem; border: 1px solid var(--border-light); }
.calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.calendar-title { font-size: 1.1rem; font-weight: 600; font-family: 'Poppins', sans-serif; }
.calendar-nav { display: flex; gap: 0.5rem; }
.calendar-nav-btn { background: transparent; border: 1px solid var(--border); border-radius: var(--radius); padding: 0.375rem 0.75rem; cursor: pointer; transition: all 0.2s; color: var(--text-secondary); }
.calendar-nav-btn:hover { background: var(--primary-subtle); border-color: var(--primary); color: var(--primary); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.25rem; }
.calendar-day-header { text-align: center; font-size: 0.75rem; font-weight: 600; color: var(--text-muted); padding: 0.5rem 0; text-transform: uppercase; }
.calendar-day { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: var(--radius); font-size: 0.9rem; cursor: pointer; transition: all 0.15s; position: relative; }
.calendar-day:hover:not(.empty):not(.other-month) { background: var(--primary-subtle); }
.calendar-day.today { background: var(--primary); color: white; font-weight: 600; }
.calendar-day.selected { background: var(--primary-subtle); border: 2px solid var(--primary); }
.calendar-day.empty { cursor: default; }
.calendar-day.other-month { color: var(--text-muted); opacity: 0.5; }
.calendar-day.has-log::after { content: ''; position: absolute; bottom: 4px; width: 5px; height: 5px; background: var(--primary); border-radius: 50%; }
.calendar-day.today.has-log::after { background: white; }
.calendar-legend { display: flex; gap: 1rem; margin-top: 1rem; font-size: 0.8rem; color: var(--text-muted); align-items: center; }
.calendar-legend-item { display: flex; align-items: center; gap: 0.375rem; }

/* History Chart */
.history-chart-container { height: 250px; }

/* Dashboard Grid */
.dashboard-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.dashboard-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.dashboard-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }

/* Macro Summary */
.macro-summary { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.macro-item { display: flex; align-items: center; gap: 0.5rem; }
.macro-dot { width: 10px; height: 10px; border-radius: 50%; }
.macro-dot-protein { background: var(--purple); }
.macro-dot-carbs { background: var(--warning); }
.macro-dot-fat { background: #EC4899; }
.macro-value { font-weight: 600; font-size: 0.95rem; }
.macro-label { font-size: 0.8rem; color: var(--text-muted); }

/* Alert Boxes */
.alert { padding: 1rem 1.25rem; border-radius: var(--radius); margin-bottom: 1rem; border: none; }
.alert-success { background: rgba(16, 185, 129, 0.15); color: #047857; border-left: 4px solid var(--primary); }
.alert-danger { background: rgba(239, 68, 68, 0.15); color: #DC2626; border-left: 4px solid var(--danger); }
.alert-warning { background: rgba(245, 158, 11, 0.15); color: #B45309; border-left: 4px solid var(--warning); }
.alert-info { background: rgba(59, 130, 246, 0.15); color: #1D4ED8; border-left: 4px solid var(--info); }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 0.75rem 1rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); border-bottom: 2px solid var(--border); }
.table td { padding: 0.875rem 1rem; border-bottom: 1px solid var(--border-light); font-size: 0.9rem; }
.table tbody tr:hover { background: var(--border-light); }
.table-responsive { overflow-x: auto; }

/* Badges */
.badge { display: inline-block; padding: 0.25rem 0.625rem; font-size: 0.75rem; font-weight: 500; border-radius: 100px; }
.badge-primary { background: var(--primary-subtle); color: var(--primary); }
.badge-success { background: rgba(16, 185, 129, 0.15); color: #047857; }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: #DC2626; }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #B45309; }
.badge-info { background: rgba(59, 130, 246, 0.15); color: #1D4ED8; }
.badge-purple { background: rgba(139, 92, 246, 0.15); color: #7C3AED; }

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.me-1 { margin-right: 0.25rem; }
.me-2 { margin-right: 0.5rem; }
.me-3 { margin-right: 1rem; }
.ms-1 { margin-left: 0.25rem; }
.ms-2 { margin-left: 0.5rem; }
.ms-3 { margin-left: 1rem; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.d-flex { display: flex; }
.d-block { display: block; }
.d-inline-flex { display: inline-flex; }
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.gap-4 { gap: 1.5rem; }
.w-100 { width: 100%; }
.flex-1 { flex: 1; }
.overflow-hidden { overflow: hidden; }
.cursor-pointer { cursor: pointer; }

/* Responsive - Tablet/Mobile */
@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); box-shadow: var(--shadow-xl); }
    .sidebar-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.5); z-index: 99; display: none; }
    .sidebar-overlay.show { display: block; }
    .menu-toggle { display: block; }
    .top-navbar { left: 0; }
    .main-content { margin-left: 0; width: 100%; padding: 1rem; margin-top: 70px; }
    .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid-3 { grid-template-columns: 1fr; }
    .dashboard-grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .welcome-banner { flex-direction: column; text-align: center; }
    .calorie-ring-container { width: 150px; height: 150px; }
    .calendar-grid { gap: 0.125rem; }
    .calendar-day { font-size: 0.8rem; }
    .quick-add-btn { bottom: 1.5rem; right: 1.5rem; width: 50px; height: 50px; font-size: 1.25rem; }
    .main-content { padding: 0.75rem; }
    .card-body { padding: 1rem; }
    .goal-input-group { flex-direction: column; align-items: stretch; }
    .goal-input-group label { min-width: auto; }
} 
