/* --- 1. VARIABLES --- */
:root {
    --primary: #0078d4;
    --primary-hover: #0063b1;
    --bg-color: #f3f2f1;
    --surface: #ffffff;
    --border-color: #d2d0ce;
    --text-main: #201f1e;
    --text-secondary: #605e5c;
    --input-bg: #ffffff;
    --header-bg: #eff6fc;
    --danger: #ef4444;
    --success: #10b981;
}

body.dark-mode {
    --primary: #878ddb;
    --primary-hover: #6d75eb;
    --bg-color: #121212;
    --surface: #1e1e1e;
    --border-color: #333333;
    --text-main: #e1dfdd;
    --text-secondary: #a19f9d;
    --input-bg: #252526;
    --header-bg: #2d2d30;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif; }

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- 2. LAYOUT --- */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* Header */
.app-header {
    background-color: var(--surface);
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 2rem;
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}
.header-left h1 { color: var(--primary); font-size: 1.4rem; font-weight: 700; margin: 0; }
.nav-menu { display: flex; gap: 20px; align-items: center; }
.nav-link { text-decoration: none; color: var(--text-secondary); font-weight: 600; font-size: 0.95rem; transition: 0.2s; }
.nav-link:hover, .nav-link.active { color: var(--primary); }

/* Toggle Switch */
.switch { position: relative; display: inline-block; width: 46px; 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: #ccc; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 4px; bottom: 4px; background-color: white; border-radius: 50%; transition: .4s; }
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(22px); }

/* --- 3. DASHBOARD GRID --- */
.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}
@media (min-width: 900px) {
    .dashboard-layout { grid-template-columns: 1fr 1fr; align-items: start; }
    .full-width-section { grid-column: 1 / -1; }
}

/* --- 4. CARDS --- */
.card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    margin-bottom: 0;
}
.card-header {
    background: var(--header-bg);
    padding: 12px 18px;
    font-weight: 700;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.5px;
    display: flex; justify-content: space-between; align-items: center;
}
.card-body { padding: 20px; }

/* --- 5. COMPONENTS --- */
.time-row { display: flex; align-items: flex-start; gap: 15px; padding: 15px 0; border-bottom: 1px dashed var(--border-color); }
.time-row:last-child { border-bottom: none; }
.time-label { font-size: 0.85rem; font-weight: bold; color: var(--primary); width: 50px; flex-shrink: 0; padding-top: 4px; }
.action-content { flex-grow: 1; }
.action-label { font-size: 0.95rem; display: block; margin-bottom: 4px; cursor: pointer; color: var(--text-main); }

.macro-box { display: inline-flex; gap: 5px; background: var(--bg-color); padding: 4px 8px; border-radius: 4px; border: 1px solid var(--border-color); margin-top: 8px; float: right; }
.macro-opt { display: flex; align-items: center; gap: 4px; font-size: 0.75rem; color: var(--text-secondary); cursor: pointer; }

/* Inputs */
input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="time"], textarea, select {
    background: var(--input-bg); color: var(--text-main);
    border: 1px solid var(--border-color); border-radius: 6px; padding: 10px; width: 100%;
    font-size: 0.9rem;
}
.meal-input { margin-top: 5px; margin-bottom: 5px; border-left: 3px solid var(--primary); }
input[type="checkbox"] { accent-color: var(--primary); transform: scale(1.1); cursor: pointer; }

/* Buttons */
.btn-submit {
    background: var(--primary); color: white; border: none; padding: 15px;
    width: 100%; border-radius: 8px; font-size: 1rem; font-weight: bold; cursor: pointer;
    margin-top: 10px;
}
.btn-submit:hover { background: var(--primary-hover); }

/* Utils */
.supp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 5px; }
.section-title { color: var(--primary); font-weight: 700; margin-bottom: 10px; border-bottom: 2px solid var(--border-color); padding-bottom: 5px; }

/* --- 6. PAGE SPECIFIC STYLES --- */

/* Login Page */
.login-wrapper {
    min-height: 100vh; display: flex; justify-content: center; align-items: center;
    background: linear-gradient(135deg, var(--bg-color) 0%, var(--border-color) 100%);
    padding: 20px;
}
.login-card {
    background: var(--surface); padding: 40px; border-radius: 12px;
    width: 100%; max-width: 400px; border: 1px solid var(--border-color); text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
}
.login-input-group { margin-bottom: 15px; text-align: left; }
.login-label { display: block; font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 5px; font-weight: 600; }

/* Report Page */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 30px; }
.stat-card { background: var(--surface); padding: 20px; border-radius: 8px; border: 1px solid var(--border-color); text-align: center; }
.stat-val { font-size: 2rem; font-weight: 800; color: var(--primary); display: block; }
.stat-label { font-size: 0.85rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; }

.day-report { background: var(--surface); border: 1px solid var(--border-color); border-radius: 8px; margin-bottom: 20px; overflow: hidden; }
.day-header { background: var(--header-bg); padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); }

.meal-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin-bottom: 15px; }
.meal-table td { padding: 6px 0; border-bottom: 1px dashed var(--border-color); vertical-align: top; }
.ex-tag { display: inline-block; background: #dcfce7; color: #166534; padding: 4px 8px; border-radius: 4px; font-size: 0.85rem; font-weight: 600; margin-right: 5px; }

/* --- 7. MODALS (Unified) --- */
.modal {
    display: none;
    position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.5); 
    align-items: center; justify-content: center;
    backdrop-filter: blur(2px);
}
.modal.show { display: flex !important; }

.modal-card {
    background: var(--surface);
    width: 90%; max-width: 320px;
    padding: 30px; border-radius: 12px;
    text-align: center;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.modal-title { color: var(--primary); margin-bottom: 10px; font-size: 1.2rem; font-weight: bold; }
.modal-text { color: var(--text-secondary); margin-bottom: 25px; font-size: 0.95rem; }
.success-icon { font-size: 3rem; margin-bottom: 15px; display: block; }

.btn-group { display: flex; gap: 10px; justify-content: space-between; }
.btn-modal-cancel { flex: 1; background: var(--bg-color); color: var(--text-main); border: 1px solid var(--border-color); padding: 10px; border-radius: 6px; cursor: pointer; }
.btn-modal-logout { flex: 1; background: var(--danger); color: white; padding: 10px; border-radius: 6px; text-decoration: none; font-weight: bold; display: flex; align-items: center; justify-content: center; }
.btn-modal-continue { width: 100%; background: var(--primary); color: white; border: none; padding: 12px; border-radius: 6px; font-weight: bold; cursor: pointer; }
.btn-modal-continue:hover { background: var(--primary-hover); }