/* Diet T-OV — Dark theme, mobile-first */

:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-hover: #242736;
    --border: #2a2d3a;
    --text: #e4e4e7;
    --text-dim: #9ca3af;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --green: #22c55e;
    --yellow: #eab308;
    --red: #ef4444;
    --protein: #3b82f6;
    --fat: #f59e0b;
    --carb: #8b5cf6;
    --kcal: #22c55e;
    --orange: #f97316;
    --orange-hover: #fb923c;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* Auth */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 440px;
    width: 90%;
    box-shadow: var(--shadow);
}

.auth-modal {
    text-align: center;
}

.auth-modal h2 {
    font-size: 28px;
    margin-bottom: 4px;
    background: linear-gradient(135deg, var(--accent), var(--green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-subtitle {
    color: var(--text-dim);
    margin-bottom: 24px;
    font-size: 14px;
}

.auth-modal input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.auth-modal input:focus {
    border-color: var(--accent);
}

button, .btn {
    padding: 10px 20px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
}

button:hover, .btn:hover {
    background: var(--accent-hover);
}

.auth-modal button {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    margin-top: 4px;
}

.error {
    color: var(--red);
    font-size: 13px;
    margin-top: 8px;
}

/* Header */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 16px;
    flex-wrap: wrap;
}

header h1 {
    font-size: 20px;
    white-space: nowrap;
    background: linear-gradient(135deg, var(--accent), var(--green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

nav {
    display: flex;
    gap: 4px;
}

.tab {
    padding: 8px 16px;
    background: transparent;
    color: var(--text-dim);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.tab.active {
    color: var(--text);
    background: var(--accent);
}

.logout-btn {
    padding: 6px 14px;
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
    font-size: 13px;
}

.logout-btn:hover {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}

/* Tab content */
.tab-content {
    display: none;
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

.tab-content.active {
    display: block;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
}

.card h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.card h4 {
    font-size: 14px;
    margin: 16px 0 8px;
    color: var(--text-dim);
}

/* Dashboard grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.today-progress {
    grid-column: 1;
}

.today-meals {
    grid-column: 2;
    grid-row: 1 / 3;
    max-height: 500px;
    overflow-y: auto;
}

.week-chart {
    grid-column: 1;
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .today-meals {
        grid-column: 1;
        grid-row: auto;
    }
    .week-chart {
        grid-column: 1;
    }
    header { padding: 8px 12px; }
    .tab { padding: 6px 10px; font-size: 13px; }
    .tab-content { padding: 12px; }
    nav { order: 3; width: 100%; justify-content: center; }
}

/* Progress bars */
.progress-item {
    margin-bottom: 12px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 4px;
}

.progress-label span:first-child {
    color: var(--text-dim);
}

.progress-bar {
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.progress-fill.kcal { background: var(--kcal); }
.progress-fill.protein { background: var(--protein); }
.progress-fill.fat { background: var(--fat); }
.progress-fill.carb { background: var(--carb); }

/* Over target: red */
.progress-fill.over {
    background: var(--red) !important;
}

/* Streak badge */
.streak-badge {
    margin-top: 16px;
    padding: 8px 16px;
    background: linear-gradient(135deg, rgba(234,179,8,0.15), rgba(234,179,8,0.05));
    border: 1px solid rgba(234,179,8,0.3);
    border-radius: 8px;
    font-size: 14px;
    color: var(--yellow);
    text-align: center;
}

#streak-count {
    font-weight: 700;
    font-size: 20px;
}

/* Meals list */
.meals-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.meal-card {
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.meal-card:hover {
    background: var(--bg-hover);
}

.meal-info {
    flex: 1;
}

.meal-time {
    font-size: 12px;
    color: var(--text-dim);
}

.meal-desc {
    font-size: 14px;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 250px;
}

.meal-kcal {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    margin-left: 12px;
}

.empty-state {
    color: var(--text-dim);
    text-align: center;
    padding: 32px;
    font-size: 14px;
}

/* Week bars */
.week-bars {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 120px;
    padding-top: 8px;
}

.week-bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.week-bar {
    width: 100%;
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    transition: height 0.5s ease;
}

.week-bar-label {
    font-size: 11px;
    color: var(--text-dim);
}

.week-bar-value {
    font-size: 11px;
    color: var(--text);
}

/* History */
.history-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.history-controls input[type="date"] {
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-day {
    margin-bottom: 16px;
}

.history-day-header {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

/* Analytics */
.analytics-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.period-btn {
    padding: 8px 16px;
    background: var(--bg-card);
    color: var(--text-dim);
    border: 1px solid var(--border);
    font-size: 13px;
}

.period-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .analytics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

.stat-value {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-dim);
}

.chart-card {
    margin-bottom: 16px;
}

/* Settings */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

.form-row {
    margin-bottom: 12px;
}

.form-row label {
    display: block;
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.form-row input, .form-row select, .form-row textarea {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
    border-color: var(--accent);
}

.form-row-inline {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.form-row-inline label {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 2px;
    display: block;
}

.form-row-inline input {
    width: 100%;
    padding: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    outline: none;
}

@media (max-width: 768px) {
    .form-row-inline {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Reminder items */
.reminder-item {
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.reminder-info {
    flex: 1;
}

.reminder-type {
    font-size: 13px;
    color: var(--text-dim);
}

.reminder-time {
    font-size: 16px;
    font-weight: 600;
}

.reminder-msg {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 2px;
}

.toggle {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
    border: none;
    padding: 0;
}

.toggle.active {
    background: var(--green);
}

.toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle.active::after {
    transform: translateX(20px);
}

/* Meal detail modal */
.meal-detail-modal {
    max-width: 560px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.close-btn {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
}

.close-btn:hover {
    color: var(--text);
    background: none;
}

.meal-detail-header {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.meal-detail-components {
    margin-bottom: 16px;
}

.component-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.meal-detail-totals {
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 16px;
    font-weight: 600;
}

.meal-detail-comment {
    padding: 12px;
    background: rgba(99,102,241,0.1);
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.meal-detail-image {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 16px;
}

.meal-detail-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.btn-danger {
    background: var(--red);
}

.btn-danger:hover {
    background: #dc2626;
}

/* Module switcher */
.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.module-switcher {
    display: flex;
    background: var(--bg);
    border-radius: 8px;
    padding: 2px;
}

.module-btn {
    padding: 6px 14px;
    background: transparent;
    color: var(--text-dim);
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.module-btn:hover {
    color: var(--text);
}

.module-btn.active[data-module="diet"] {
    background: var(--accent);
    color: #fff;
}

.module-btn.active[data-module="trener"] {
    background: var(--orange);
    color: #fff;
}

/* Trener accent */
.trener-accent {
    color: var(--orange) !important;
}

.trener-comment {
    background: rgba(249,115,22,0.1) !important;
    border-left-color: var(--orange) !important;
}

/* Trener dashboard blocks */
.trener-today {
    grid-column: 2;
}

.trener-week-chart {
    grid-column: 2;
}

@media (max-width: 768px) {
    .trener-today, .trener-week-chart {
        grid-column: 1;
    }
    .module-switcher { margin-left: 0; }
}

.trener-streak-badge {
    margin-top: 12px;
    padding: 8px 16px;
    background: linear-gradient(135deg, rgba(249,115,22,0.15), rgba(249,115,22,0.05));
    border: 1px solid rgba(249,115,22,0.3);
    border-radius: 8px;
    font-size: 14px;
    color: var(--orange);
    text-align: center;
}

.trener-streak-badge span {
    font-weight: 700;
    font-size: 20px;
}

/* Workout card */
.workout-card {
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.workout-card:hover {
    background: var(--bg-hover);
}

/* Workout detail modal */
.workout-detail-modal {
    max-width: 560px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.workout-sets-table {
    margin-bottom: 16px;
}

.exercise-group {
    margin-bottom: 12px;
}

.exercise-name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
    color: var(--orange);
}

.set-row {
    padding: 4px 12px;
    font-size: 14px;
    color: var(--text);
}

.set-row.warmup-set {
    color: var(--text-dim);
    font-size: 13px;
}

.warmup-badge {
    display: inline-block;
    padding: 1px 6px;
    background: rgba(156,163,175,0.2);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-dim);
    margin-right: 4px;
}

/* PR items */
.pr-item {
    padding: 8px 12px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.pr-exercise {
    flex: 1;
    font-size: 14px;
}

.pr-value {
    font-weight: 700;
    font-size: 16px;
    color: var(--orange);
}

.pr-detail {
    font-size: 12px;
    color: var(--text-dim);
}

/* Dashboard grid 2x2 for trener blocks */
.dashboard-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
}
