/* General Layout & Colors */
body {
    font-family: Arial, sans-serif;
    background-color: #f1f5f9;
    color: #333;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.dashboard {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

h1 {
    font-size: 28px;
    color: #333;
    margin: 0;
}

h2 {
    font-size: 22px;
    color: #444;
    margin-bottom: 15px;
}

h3 {
    font-size: 18px;
    color: #333;
    margin-top: 0;
    margin-bottom: 10px;
}

/* Header and Navigation */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.user-info {
    display: flex;
    gap: 10px;
    align-items: center;
}

.username {
    font-weight: 600;
    color: #667eea;
}

/* Buttons */
.btn {
    padding: 8px 15px;
    border: 1px solid #667eea;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-primary {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.btn-primary:hover {
    background: #5a67d8;
    border-color: #5a67d8;
}

.btn-secondary {
    background: white;
    color: #667eea;
    border-color: #e1e8ed;
}

.btn-secondary:hover {
    background: #f1f5f9;
    border-color: #667eea;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
    display: block;
    padding: 12px;
    font-size: 16px;
    margin-top: 20px;
}

/* Forms */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    color: #667eea;
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 16px;
    transition: border-color 0.2s;
}

input:focus,
select:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.form-row {
    display: flex;
    gap: 20px;
}

.form-row > .form-group {
    flex: 1;
}

/* Progress & Stats */
.progress-section {
    background: #f8fafc;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 25px;
    border-left: 4px solid #667eea;
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
}

.progress-bar-container {
    height: 12px;
    background: #e1e8ed;
    border-radius: 6px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s;
}

.progress-percentage {
    text-align: right;
    font-size: 14px;
    color: #667eea;
    margin-top: 5px;
    font-weight: 600;
}

/* Meal List */
.meal-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 10px;
    border-bottom: 1px solid #eee;
}

.meal-entry:last-child {
    border-bottom: none;
}

.meal-info {
    flex-grow: 1;
}

.food-name {
    font-weight: 600;
    color: #333;
    font-size: 16px;
}

.food-category {
    font-size: 11px;
    font-weight: 400;
    color: white;
    background: #94a3b8;
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 8px;
    text-transform: uppercase;
}

.food-details {
    font-size: 13px;
    color: #666;
    margin-top: 2px;
}

.meal-calories {
    font-weight: bold;
    color: #667eea;
    margin-right: 15px;
    white-space: nowrap;
}

.meal-type-section {
    background: #f8fafc;
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
}

.meal-type-header {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 18px;
    color: #667eea;
    border-bottom: 1px dashed #e1e8ed;
    padding-bottom: 5px;
}

.meal-type-total {
    font-size: 14px;
    color: #667eea;
}

/* Alerts */
.alert {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Auth & Empty States */
.auth-box {
    max-width: 400px;
    margin: 60px auto;
    padding: 30px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.auth-box .subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: #666;
}

.empty-state {
    text-align: center;
    padding: 30px;
    background: #f8fafc;
    border: 1px dashed #e1e8ed;
    border-radius: 8px;
    margin-top: 20px;
}

.empty-state p {
    color: #666;
}

/* History/Analytics Summary */
.history-summary {
    display: flex;
    justify-content: space-around;
    gap: 15px;
    margin-bottom: 30px;
    padding: 15px;
    background: #f8fafc;
    border-radius: 8px;
}

.stat-card {
    text-align: center;
    padding: 10px;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* History Card */
.history-card {
    background: white;
    border: 1px solid #e1e8ed;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    transition: box-shadow 0.2s;
}

.history-card:hover {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.history-card h3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0;
}

.history-date {
    font-size: 16px;
    color: #333;
}

.history-total {
    font-size: 18px;
    font-weight: bold;
}

/* --- MOBILE MENU STYLES (from index.php) --- */

.mobile-menu-btn {
    display: none; /* Hidden by default on desktop */
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 20px;
    cursor: pointer;
}

.menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.menu-overlay.active {
    display: block;
}

.side-menu {
    position: fixed;
    top: 0;
    left: -300px; /* Hidden off-screen */
    width: 280px;
    height: 100vh;
    background: white;
    z-index: 1000;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    overflow-y: auto;
}

.side-menu.active {
    left: 0;
}

.side-menu-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.side-menu-header h2 {
    margin: 0;
    font-size: 18px;
}

.close-menu-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 24px;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
}

.side-menu-body {
    padding: 20px;
}

.menu-section {
    margin-bottom: 25px;
}

.menu-section-title {
    font-size: 11px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    font-weight: 600;
}

.menu-item {
    display: block;
    padding: 12px;
    margin-bottom: 6px;
    background: #f1f5f9;
    border-radius: 6px;
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: all 0.2s;
}

.menu-item:hover {
    background: #e1e8ed;
    transform: translateX(4px);
}

.menu-item.active {
    background: #667eea;
    color: white;
}

.menu-item.danger {
    background: #fee2e2;
    color: #dc2626;
}

/* --- CALENDAR STYLES (from calendar.php) --- */

.calendar-container {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 10px;
}

.calendar-nav {
    display: flex;
    gap: 15px;
    align-items: center;
}

.calendar-title {
    font-size: 24px;
    color: #667eea;
    font-weight: bold;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    margin-bottom: 30px;
}

.calendar-day-header {
    text-align: center;
    font-weight: bold;
    padding: 10px;
    color: #667eea;
    font-size: 14px;
}

.calendar-day {
    aspect-ratio: 1;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 80px;
    text-decoration: none;
}

.calendar-day:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.calendar-day.empty {
    background: #f8fafc;
    cursor: default;
    border-color: transparent;
}

.calendar-day.empty:hover {
    transform: none;
    box-shadow: none;
}

.calendar-day.today {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea10 0%, #764ba210 100%);
}

.calendar-day.has-data {
    background: linear-gradient(135deg, #667eea05 0%, #764ba205 100%);
}

.day-number {
    font-weight: bold;
    color: #333;
    font-size: 16px;
    margin-bottom: 5px;
}

.day-calories {
    font-size: 12px;
    color: #667eea;
    font-weight: 600;
    margin-top: auto;
}

.day-status {
    font-size: 10px;
    margin-top: 2px;
}

.day-status.over {
    color: #ef4444;
}

.day-status.under {
    color: #f59e0b;
}

.day-status.good {
    color: #10b981;
}

.selected-day-details {
    background: #f8fafc;
    border-radius: 10px;
    padding: 25px;
    margin-top: 30px;
}

/* NEW: Mobile List View for Calendar */
.calendar-mobile-list {
    display: none;
    margin-top: 20px;
}
.calendar-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #e1e8ed;
    text-decoration: none;
    color: #333;
    transition: background 0.2s;
}
.calendar-list-item:hover {
    background: #f1f5f9;
}
.calendar-list-item-date {
    font-weight: bold;
    flex-basis: 50%;
}
.calendar-list-item-status {
    font-size: 12px;
    font-weight: 600;
    text-align: right;
}

/* --- ANALYTICS STYLES (from analytics.php) --- */
.analytics-container {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.analytics-nav {
    display: flex;
    gap: 15px;
    align-items: center;
}

.analytics-title {
    font-size: 24px;
    color: #667eea;
    font-weight: bold;
}

.chart-wrapper {
    /* New wrapper for horizontal scrolling */
    overflow-x: auto; 
    padding: 10px 0;
    margin: 30px 0;
    background: #f8fafc;
    border-radius: 10px;
}

.chart-title {
    font-size: 18px;
    color: #333;
    margin-bottom: 20px;
    font-weight: 600;
    padding: 0 20px;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 5px;
    height: 300px;
    padding: 10px 20px; /* Add horizontal padding back to the chart */
    position: relative;
    min-width: 100%; /* Ensure it takes at least full width */
}

.bar-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    min-width: 0;
}

.bar {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px 4px 0 0;
    transition: all 0.3s;
    cursor: pointer;
    position: relative;
}

.bar:hover {
    opacity: 0.8;
    transform: translateY(-2px);
}

.bar-stacked {
    width: 100%;
    border-radius: 4px 4px 0 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.bar-segment {
    width: 100%;
    transition: opacity 0.3s;
}

.bar-segment.breakfast { background: #fbbf24; }
.bar-segment.lunch { background: #3b82f6; }
.bar-segment.dinner { background: #8b5cf6; }
.bar-segment.snack { background: #10b981; }

.bar-wrapper:hover .bar-segment {
    opacity: 0.8;
}

.bar-label {
    margin-top: 8px;
    font-size: 11px;
    color: #666;
    text-align: center;
    word-break: break-all;
}

.bar-value {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 600;
    color: #667eea;
    white-space: nowrap;
}

.goal-line {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 2px dashed #ef4444;
    pointer-events: none;
}

.goal-label {
    position: absolute;
    right: 10px;
    top: -10px;
    background: #ef4444;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}


/* --- MOBILE RESPONSIVENESS (Media Queries) --- */

@media (max-width: 768px) {
    /* General */
    .container {
        padding: 10px;
    }
    .dashboard {
        padding: 15px;
    }
    h1 {
        font-size: 24px;
    }
    
    /* Navigation */
    .mobile-menu-btn {
        display: block; /* Show hamburger */
    }
    .user-info {
        display: none !important; /* Hide desktop nav */
    }
    .history-summary {
        flex-direction: column; /* Stack stats vertically */
        gap: 10px;
    }
    
    /* Forms */
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    /* History Card */
    .history-card h3 {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    .history-total {
        font-size: 16px;
    }

    /* CALENDAR MOBILE VIEW */
    .calendar-grid {
        display: none; /* Hide the grid on small screens */
    }
    .calendar-mobile-list {
        display: block; /* Show the list view on small screens */
    }
    .calendar-header {
        flex-direction: column;
        align-items: stretch;
    }
    .calendar-nav {
        width: 100%;
        justify-content: space-between;
        margin-bottom: 10px;
    }
    .calendar-title {
        font-size: 20px;
    }

    /* ANALYTICS CHART MOBILE VIEW */
    .bar-chart {
        height: 200px; /* Reduced height for mobile */
        min-width: 600px; /* Force minimum width to enable scrolling */
        padding: 10px 5px;
    }
    .bar-wrapper {
        min-width: 20px; /* Minimum width for each bar */
    }
    .bar-label {
        font-size: 8px;
        white-space: nowrap;
    }
    .bar-value {
        font-size: 9px;
    }
    .chart-title {
        padding: 0 10px;
    }
    
}