/*
=========================================================
 Diet Tracker App - Main Stylesheet (v3.0)
 This file contains all desktop styles.
 Mobile/responsive styles are in _header.php
=========================================================
*/

/* --- Base & Variables --- */
:root {
    --primary-purple: #6a11cb;
    --secondary-purple: #f3e5f5;
    --light-purple-bg: #faf7ff;
    --white: #ffffff;
    --dark-text: #333333;
    --light-text: #666666;
    --border-color: #e0e0e0;
    --success-green: #4CAF50;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--light-purple-bg);
    color: var(--dark-text);
    display: flex;
    min-height: 100vh;
}

/* --- Login Page --- */
.login-container {
    width: 100%;
    max-width: 400px;
    margin: auto;
    padding: 2rem;
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
}
.login-container h2 {
    color: var(--primary-purple);
    margin-bottom: 1.5rem;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}
.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-sizing: border-box; /* Important for padding */
}

/* --- Buttons --- */
.btn {
    width: 100%;
    padding: 0.85rem;
    border: none;
    border-radius: 8px;
    background: var(--primary-purple);
    color: var(--white);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}
.btn:hover {
    background-color: #5a0eb3;
}

/* --- Main App Layout --- */
.sidebar {
    width: 250px;
    background: var(--white);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 999;
    transition: transform 0.3s ease-in-out;
}
.sidebar-header {
    padding: 1.5rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}
.sidebar-header h2 {
    margin: 0;
    color: var(--primary-purple);
}
.sidebar-nav {
    flex-grow: 1;
    list-style: none;
    padding: 0;
    margin: 1rem 0;
}
.sidebar-nav li {
    padding: 0.75rem 1.5rem;
}
.sidebar-nav a {
    text-decoration: none;
    color: var(--dark-text);
    font-weight: 500;
    display: block;
    padding: 0.75rem;
    border-radius: 8px;
    transition: background-color 0.3s ease;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
    background-color: var(--secondary-purple);
    color: var(--primary-purple);
}
.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
}
.sidebar-footer a {
    color: var(--light-text);
    text-decoration: none;
    font-size: 0.9rem;
}

.main-content {
    margin-left: 250px; /* Same as sidebar width */
    width: 100%;
    padding: 2rem;
    flex-grow: 1;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}
.header h1 {
    margin: 0;
    color: var(--dark-text);
}

.card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.card:last-child {
    margin-bottom: 0;
}

/* --- Mobile Toggle Buttons & Overlay --- */
.hamburger-btn {
    display: none; /* Hidden on desktop */
    background: var(--secondary-purple);
    color: var(--primary-purple);
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    cursor: pointer;
    margin-right: 1rem;
}

.sidebar-close-btn {
    display: none; /* Hidden on desktop */
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2.5rem;
    color: var(--light-text);
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 997;
}
.sidebar-overlay.open {
    display: block;
}


/*
=========================================================
 ALL OTHER STYLES
=========================================================
*/

/* --- Toasts --- */
.toast-success {
    background-color: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #4CAF50;
    padding: 1rem;
    border-radius: 8px;
}
.toast-error {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #f44336;
    padding: 1rem;
    border-radius: 8px;
}
.error-message {
    color: red;
    background: #ffebee;
    border: 1px solid red;
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

/* --- Meal Form --- */
.meal-form .form-row {
    display: flex;
    gap: 1.5rem;
}
.meal-form .form-row .form-group {
    flex: 1;
}
.meal-form select,
.meal-form textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 1rem;
}
.meal-form textarea {
    resize: vertical;
}
.form-group-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.form-group-checkbox input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
}

/* --- Meal List --- */
.meal-category {
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}
.meal-category:last-child { border-bottom: none; margin-bottom: 0; }
.meal-category h4 { color: var(--primary-purple); margin-top: 0; margin-bottom: 1rem; }
.meal-list { list-style: none; padding: 0; margin: 0; }
.meal-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-top: 1px solid #f0f0f0;
}
.meal-list li:first-child { border-top: none; }
.meal-info {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    margin-right: 1rem;
}
.meal-info strong { font-weight: 500; color: var(--dark-text); }
.meal-info span { font-size: 0.9rem; color: var(--light-text); }
.meal-actions { display: flex; gap: 0.5rem; align-items: center; }
.btn-delete {
    background: #ffebee;
    color: #c62828;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
}
.btn-edit {
    background: #e3f2fd;
    color: #0d47a1;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
}
.btn-cancel {
    display: inline-block;
    background: #f1f1ff;
    color: #333;
    padding: 0.85rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    margin-left: 1rem;
    text-align: center;
}

/* --- Weekly Planner --- */
.week-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.week-nav .btn {
    width: auto; /* Override default 100% width */
    padding-left: 1rem;
    padding-right: 1rem;
    font-size: 0.9rem; /* Make button text smaller */
    flex-shrink: 0; /* Stop buttons from shrinking */
}
.week-nav h3 {
    padding: 0 0.5rem; /* Add spacing around date */
    font-size: 1.1rem;
    line-height: 1.3;
    margin: 0; 
    color: var(--primary-purple); 
    text-align: center;
}
.plan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}
.day-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}
.day-header {
    background: var(--secondary-purple);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}
.day-header h3 { margin: 0; color: var(--primary-purple); }
.day-header span { font-weight: 500; color: var(--light-text); }
.btn-fasting {
    background: #fff3e0;
    color: #e65100;
    border: none;
    padding: 0.75rem;
    margin: 1rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}
.meal-slot {
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.day-card .meal-slot:last-child { border-bottom: none; padding-bottom: 1.5rem; }
.meal-slot label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}
.meal-slot select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: #fcfcfc;
}
.btn-large-save {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    width: auto;
}

/* --- Dashboard --- */
.dash-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: -1.5rem; 
}
.dash-layout .card { margin-bottom: 1.5rem; }
.card-large { flex: 2; min-width: 300px; }
.card-small { flex: 1; min-width: 250px; }
.meal-list-dash { list-style: none; padding: 0; margin: 0; }
.meal-list-dash li {
    display: flex;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}
.meal-list-dash li:last-child { border-bottom: none; }
.meal-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--secondary-purple);
    color: var(--primary-purple);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.2rem;
    margin-right: 1rem;
}
.meal-cals { text-align: right; }
.meal-cals strong { font-size: 1.1rem; color: var(--primary-purple); font-weight: 600; }
.meal-cals span { font-size: 0.85rem; color: var(--light-text); display: block; }
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--border-color);
}
.stat-row:last-of-type { border-bottom: 1px solid var(--border-color); }
.stat-row span { font-size: 0.95rem; color: var(--light-text); }
.stat-row strong { font-size: 1.1rem; font-weight: 600; color: var(--dark-text); }

/* --- Daily Tracking --- */
.track-layout {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1.5rem;
}
#track-stats .btn { width: 100%; }
.tracking-meal-list { list-style: none; padding: 0; margin: 0; }
.meal-log-item {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 1rem;
    transition: background-color 0.3s ease;
}
.meal-log-item:last-child { margin-bottom: 0; }
.meal-log-item.checked { background-color: var(--light-purple-bg); }
.meal-log-header { display: flex; align-items: center; }
.meal-log-check { margin-right: 1rem; }
.meal-log-check input[type="checkbox"] {
    width: 1.5rem;
    height: 1.5rem;
    cursor: pointer;
}
.meal-log-upload-area {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border-color);
}
.meal-log-upload-area .btn-small {
    width: auto;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}
.meal-log-upload-area input[type="file"] {
    width: 100%;
    margin-bottom: 0.5rem;
}
.meal-photo { padding-top: 0.5rem; }
.meal-photo p { font-weight: 600; margin: 0 0 0.5rem 0; }
.meal-photo img {
    max-width: 200px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

/* --- Gallery Page Styles --- */
/* The layout rules (grid-template-columns) are in _header.php */
.gallery-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden; /* Clips the image to the border radius */
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
    background: var(--white);
    transition: box-shadow 0.3s ease;
}
.gallery-item:hover {
    box-shadow: var(--shadow);
}
.gallery-item img {
    width: 100%;
    height: 200px;
    object-fit: cover; /* This scales and crops the image to fit */
    display: block;
    border-bottom: 1px solid var(--border-color);
}
.gallery-info {
    padding: 0.75rem;
}
.gallery-info strong {
    display: block;
    font-size: 0.9rem;
    color: var(--dark-text);
}
.gallery-info span {
    font-size: 0.8rem;
    color: var(--light-text);
}

/*
=========================================================
 MOBILE RESPONSIVE
=========================================================
*/
@media (max-width: 768px) {
    /* All mobile styles are now in _header.php
     This block is intentionally left empty.
    */
}
/*
=========================================================
 NEW: Daily Tracking Enhancements
=========================================================
*/

/* --- This makes the layout responsive --- */
.track-layout {
    display: grid;
    grid-template-columns: 1fr 2fr; /* 1/3 for stats, 2/3 for meals */
    gap: 1.5rem;
}

/* This will be handled by the mobile styles in _header.php */
#track-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

#track-stats .btn {
    width: 100%;
}

/* --- Real-time Calorie Counter --- */
.meal-log-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.calorie-counter {
    text-align: right;
}
.calorie-counter strong {
    font-size: 1.8rem;
    color: var(--primary-purple);
    font-weight: 700;
}
.calorie-counter span {
    font-size: 1rem;
    color: var(--light-text);
    font-weight: 500;
}

/* --- Styles for "Extra" meal type --- */
.meal-log-item[data-meal-type="Extra"] {
    background-color: #fffaf0; /* A light orange to stand out */
}

/* ---
   Clean up old styles
   (We are replacing the old .track-layout rule)
--- */
.track-layout {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1.5rem;
}
//*
=========================================================
 NEW: Weekly Planner Action Buttons
=========================================================
*/
.week-nav-container {
    padding-bottom: 0.75rem; /* Tighter padding */
}
.week-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* This container now uses flexbox */
.week-actions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    
    /* NEW: Flexbox for centering */
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Base style for action buttons */
.week-actions .btn {
    width: auto;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Copy Last Week Button */
.btn-secondary {
    background-color: #f1f1f1;
    color: #333;
}
.btn-secondary:hover {
    background-color: #e0e0e0;
}

/* NEW: AI Button Style */
.btn-ai {
    background: linear-gradient(to right, #6a11cb, #2575fc);
    color: white;
    font-weight: 700;
}
.btn-ai:hover {
    opacity: 0.9;
    background: linear-gradient(to right, #5a0eb3, #1565e0);
}
.btn-ai:disabled {
    opacity: 0.7;
    cursor: wait;
}
/*
=========================================================
 NEW: Gallery Header Styles
=========================================================
*/
.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.gallery-header p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--light-text);
}
.gallery-header .btn-secondary {
    width: auto;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    background-color: #f1f1f1;
    color: #333;
}
.gallery-header .btn-secondary:hover {
    background-color: #e0e0e0;
}
/*
=========================================================
 NEW: Settings Page Layout
=========================================================
*/
.settings-layout {
    display: grid;
    grid-template-columns: 2fr 1fr; /* 2/3 for profile, 1/3 for password */
    gap: 1.5rem;
}

.settings-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.btn-save {
    width: auto;
    padding-left: 2rem;
    padding-right: 2rem;
}

/* Add styles for disabled age input */
#age:disabled {
    background-color: #f1f1f1;
    color: #555;
    cursor: not-allowed;
}

/* This is already in your header, but we add it to style.css for mobile */
@media (max-width: 768px) {
    .settings-layout {
        grid-template-columns: 1fr;
    }
}
/*
=========================================================
 NEW: Login Page Background & Glass Effect
=========================================================
*/

/* 1. New page background gradient */
.login-page-bg {
    background: linear-gradient(120deg, #f3e5f5 0%, #faf7ff 100%);
    display: flex; /* Keeps the login box centered */
    min-height: 100vh;
}

/* 2. Override the solid white login container */
.login-container {
    background: rgba(255, 255, 255, 0.6); /* Semi-transparent */
    -webkit-backdrop-filter: blur(15px); /* Frosted glass effect */
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2); /* Subtle border */
    box-shadow: 0 8px 32px 0 rgba(106, 17, 203, 0.15); /* Softer shadow */
}

/* 3. Make form inputs also slightly transparent */
.login-container .form-group input {
    background: rgba(255, 255, 255, 0.5);
    border-color: rgba(255, 255, 255, 0.3);
}
/*
=========================================================
 NEW: Share Plan Card (Settings)
=========================================================
*/
#share-link[readonly] {
    background-color: #f1f1f1;
    cursor: text;
    font-size: 0.9rem;
    color: var(--light-text);
}