/* ═══════════════════════════════════════════════════════
   SimpleCal – style.css
   Dark UI: tiefes Blau-Grau, orange Borders, grüne Akzente
   ═══════════════════════════════════════════════════════ */

/* ── Variablen ─────────────────────────────────────────── */
:root {
    --bg:            #1a1d2e;   /* Seiten-Hintergrund */
    --card:          #22253a;   /* Karten-Hintergrund */
    --card-hover:    #272b40;
    --border:        #f97316;   /* orange Border/Akzent */
    --border-dim:    #3a3f5c;   /* subtile innere Borders */
    --accent:        #f97316;   /* orange (Gauge, Buttons) */
    --accent-green:  #22c55e;   /* grün (Protein-Balken, grüne Buttons) */
    --text:          #e8eaf0;   /* Haupttext */
    --muted:         #8b92b0;   /* Sekundärtext */
    --danger:        #ef4444;   /* Fehlermeldungen */
    --input-bg:      #1a1d2e;   /* Input-Hintergrund */
    --radius:        14px;
    --radius-sm:     8px;
    --font:          'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

table {
    width: 100%;
    border-collapse: collapse;
}

td {
    padding: 10px 6px;
    border-bottom: 1px solid var(--border-dim);
    font-size: 0.95rem;
}

tr:last-child td {
    border-bottom: none;
}

/* ── Header ────────────────────────────────────────────── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 32px;
    background: var(--bg);
    gap: 16px;
}

.header img {
    height: 8vh;
    width: auto;
}

.header h1 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text);
    flex: 1;
    text-align: center;
}

.header h1:first-of-type {
    text-align: left;
    flex: 2;
}

.header-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.1s;
}

.nav-link:hover,
.nav-link:focus-visible {
    background: var(--card-hover);
    border-color: var(--border);
    color: var(--text);
    transform: translateY(-1px);
}

.nav-link-active,
.nav-link-active:hover,
.nav-link-active:focus-visible {
    background: rgba(249, 115, 22, 0.16);
    border-color: var(--accent);
    color: var(--text);
}

.button-settings {
    display: flex;
    align-items: center;
}

.btn-settings {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--border-dim);
    font-size: 1.1rem;
    transition: background 0.2s;
    cursor: pointer;
}

.btn-settings:hover {
    background: var(--border);
}

/* ── Layout ────────────────────────────────────────────── */
.main-window {
    display: flex;
    gap: 3vw;
    padding: 28px 32px;
    max-width: 90vw;
    margin: 0 auto;
    align-items: stretch;   /* gleiche Höhe für beide Karten */
    min-height: 50vh;
    max-height: 80vh; 
}

/* ── Karten (stat-window, today-meals-box, etc.) ───────── */
.stat-window,
.today-meals-box,
.settings-window {
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    min-width: 0;
    box-shadow: 0 0 200px 20px #f974163a; 
}

/* stat-window: 35% breit, today-meals-box: 65% breit */
.stat-window {
    flex: 0 0 42%;
    max-width: 42%;
}

.today-meals-box {
    flex: 0 0 58%;
    max-width: 58%;
    overflow: auto; /* Scrollen innerhalb der Karten wenn nötig */
}

/* ── Login / Register – background-section ─────────────── */
.background-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 80px);
    padding: 24px;
}

.background-section form {
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 32px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 0 200px 20px #f974163a; 
}

.login-actions {
    display: flex;
    gap: 12px;
    width: 100%;
}

.login-actions .btn-primary,
.login-actions .btn-secondary {
    flex: 1;
    width: auto;
}

/* ── Inputs ────────────────────────────────────────────── */
.form-input {
    width: 100%;
    background: var(--input-bg);
    border: 1.5px solid var(--border-dim);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.95rem;
    font-family: var(--font);
    padding: 10px 14px;
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: var(--border);
}

.form-input::placeholder {
    color: var(--muted);
}

/* Zahlen-Input ohne Spinner-Arrows */
input[type="number"].form-input::-webkit-inner-spin-button,
input[type="number"].form-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
}

#eintragen-form{
    width: 95%;
}

/* ── Passwort-Toggle ───────────────────────────────────── */
.btn-show-pw {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--muted);
    padding: 4px;
    line-height: 1;
}

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

/* ── Buttons ───────────────────────────────────────────── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 30px;
    padding: 11px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    text-align: center;
    width: 40%;
}

.btn-primary:hover {
    opacity: 0.88;
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--accent-green);
    border: 2px solid var(--accent-green);
    border-radius: 30px;
    padding: 9px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    text-align: center;
    width: 40%;
}

.btn-secondary:hover {
    background: var(--accent-green);
    color: #fff;
}

/* ── Mikrofon-Button ───────────────────────────────────── */
.btn-mic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    background: var(--accent-green);
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.btn-mic:hover {
    opacity: 0.85;
}

/* Mikrofon-Box (Button + Mic nebeneinander) */
.meal-hinzufügen-box {
    display: flex;
    align-items: center;
    gap: 10px;
}

.meal-hinzufügen-box .btn-primary,
.meal-hinzufügen-box .btn-secondary {
    flex: 1;
}

/* "Meal eintragen" Button: so breit wie hinzufügen-Box + Mic zusammen */
.btn-meal-eintragen {
    width: calc(40% + 44px);
}

/* ── Kalorien-Gauge (Halbkreis-SVG) ───────────────────── */
.cal-window {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.gauge-svg {
    width: 100%;
    max-width: 210px;
    display: block;
    margin: 0 auto;
}

.gauge-label {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 6px;
    color: var(--text);
}

.gauge-label small {
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--muted);
    display: block;
    margin-top: 2px;
}

/* ── Protein-Balken ────────────────────────────────────── */
.prot-window {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.prot-bar-track {
    width: 100%;
    height: 20px;
    background: var(--border-dim);
    border-radius: 10px;
    overflow: hidden;
}

.prot-bar-fill {
    height: 100%;
    background: var(--accent-green);
    border-radius: 10px;
    transition: width 0.7s ease;
    min-width: 0;
}

.prot-label {
    font-size: 0.92rem;
    color: var(--muted);
    text-align: left;
}

/* ── Today-Meals-Tabelle ───────────────────────────────── */
.today-meals-table {
    flex: 1;
    overflow-y: auto;
    width: min(82%, 760px);
    /* Tabelle scrollt intern wenn today-meals-box > 85vh wird */
    min-height: 0;
}

.today-meals-table table {
    table-layout: fixed;
    width: 100%;
}

.today-meals-table td:nth-child(1) {
    width: 38%;
}

.today-meals-table td:nth-child(2) {
    width: 25%;
}

.today-meals-table td:nth-child(3) {
    width: 37%;
}

.today-meals-table td:first-child {
    font-weight: 500;
    color: var(--text);
}

.today-meals-table td:not(:first-child) {
    color: var(--muted);
    text-align: left;
}
/* ── Meal-Liste (eintragen.php) ────────────────────────── */
.meal-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    max-height: 320px;
    margin: 0 -4px;
    padding: 0 4px;
}

/* Form in eintragen.php: Suche oben, Liste wächst, Button unten */
.eintragen-form {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    gap: 12px;
}

.eintragen-form .meal-list {
    flex: 1;
    min-height: 0;
}

.eintragen-submit {
    width: 100%;
    margin-top: auto;
}

/* meal_overview: einzelnes Window zentriert, 2/3 der Viewport-Breite */
.main-window--centered {
    justify-content: center;
    height: auto;
    overflow: visible;
}

.stat-window--wide {
    flex: 0 0 66vw;
    max-width: 66vw;
}

#overview-form {
    width: 55%;
}

.meal-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
    cursor: default;
}

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

.meal-title {
    flex: 1;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text);
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.meal-kcal,
.meal-prot {
    font-size: 0.85rem;
    color: var(--muted);
    white-space: nowrap;
}

.meal-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-green);
    cursor: pointer;
    flex-shrink: 0;
}

.menge-input {
    width: 60px !important;
    padding: 4px 8px !important;
    font-size: 0.85rem !important;
}

/* ── Chat-Interface (hinzufuegen.php) ─────────────────── */
.chat-window {
    min-height: 420px;
    justify-content: space-between;
}

.chat-message {
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    max-width: 90%;
    font-size: 0.92rem;
    line-height: 1.5;
}

.user-message {
    background: var(--accent);
    color: #fff;
    align-self: flex-end;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.ai-message {
    background: var(--border-dim);
    color: var(--text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.ai-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.ai-actions .btn-primary,
.ai-actions .btn-secondary {
    width: auto;
    padding: 8px 18px;
    font-size: 0.88rem;
}

.chat-input-form {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border-dim);
}

.chat-input-form .form-input {
    flex: 1;
}

.btn-submit-chat {
    width: auto !important;
    padding: 10px 18px !important;
    white-space: nowrap;
}

/* ── Einstellungen ─────────────────────────────────────── */
.settings-window {
    max-width: 480px;
    margin: 28px auto;
    flex: none;
    width: 100%;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.settings-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.settings-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.settings-success,
.flash-success {
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid var(--accent-green);
    color: var(--accent-green);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-size: 0.92rem;
    text-align: center;
    margin-bottom: 4px;
}

/* ── Meal Overview & Edit ──────────────────────────────── */
th {
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 8px 6px;
    border-bottom: 2px solid var(--border-dim);
}

input[type="radio"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: block;
    margin-bottom: 4px;
    margin-top: 8px;
}

textarea.form-input,
textarea {
    background: var(--input-bg);
    border: 1.5px solid var(--border-dim);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.95rem;
    font-family: var(--font);
    padding: 10px 14px;
    outline: none;
    resize: vertical;
    width: 100%;
}

textarea:focus {
    border-color: var(--border);
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238b92b0' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    cursor: pointer;
}

/* ── Fehleranzeigen ────────────────────────────────────── */
.form-errors div,
.form-errors p {
    color: var(--danger);
    font-size: 0.88rem;
    padding: 4px 0;
}

/* ── Mikrofon-Pulsieren ────────────────────────────────── */
@keyframes pulse-mic {
    0%   { box-shadow: 0 0 0 0   rgba(220, 38, 38, 0.7); }
    70%  { box-shadow: 0 0 0 10px rgba(220, 38, 38, 0);   }
    100% { box-shadow: 0 0 0 0   rgba(220, 38, 38, 0);    }
}

.mic-recording {
    background-color: #dc2626 !important;
    animation: pulse-mic 1s infinite;
}

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-dim);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 700px) {
    .btn-primary {
        width: 100%;
    }

    .btn-secondary {
        width: 100%;
    }

    .main-window {
        flex-direction: column;
        padding: 16px;
        gap: 16px;
        height: auto;          /* kein festes Viewport-Height auf Mobile */
        overflow: visible;     /* normales Scrollen auf Mobile */
        max-width: 100vw;
    }

    /* beide Karten gleich breit auf Mobile */
    .stat-window,
    .today-meals-box {
        flex: 1 1 100%;
        max-width: 100%;
        width: 100%;
    }

    .header {
        padding: 14px 16px;
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .header h1 {
        font-size: 1rem;
    }

    .header-nav {
        order: 5;
        width: 100%;
        justify-content: flex-start;
    }

    .nav-link {
        flex: 1 1 calc(50% - 8px);
        padding: 8px 10px;
    }

    .today-meals-table {
        max-height: 200px;
        width: 100%;
    }

    .login-actions {
        flex-direction: column;
    }

    .settings-window {
        margin: 16px auto;
    }
}
