/*
 * Tierhalter-Portal — Stylesheet
 *
 * Schlicht, responsiv, mobile-first. Praxis-Branding kommt über die CSS-Variablen
 * unten und wird zur Laufzeit aus den API-Antworten gesetzt (portal.js →
 * applyBranding). Die Standardwerte sind das neutrale Portal-Theme, KEIN
 * praxisspezifisches Branding.
 */

:root {
    --primary: #6B5E54;       /* Marke / Kopf */
    --primary-dark: #5C5149;  /* Hover / Verlauf */
    --btn-bg: #6B5E54;        /* Buttons */
    --btn-bg-dark: #5C5149;   /* Button-Hover (abgeleitet aus Button-Farbe) */
    --accent: #6B5E54;        /* Auswahl / Fokus / Links */
    --focus: #6B5E54;         /* Fokus-Ring */
    --header-text: #ffffff;   /* Text/Logo auf der Kopfleiste (kontrast-abhängig gesetzt) */
    --btn-text: #ffffff;      /* Text auf Primär-Buttons (kontrast-abhängig gesetzt) */
    --accent-text: #ffffff;   /* Text auf Akzent-Flächen (Zähler, Badges) */
    --page-bg: #f4f5f7;       /* Seitenhintergrund (neutral, nicht gebrandet) */
    --card-bg: #ffffff;       /* große Panels (immer weiß) */
    --tile-bg: #ffffff;       /* Kacheln/Zeilen (immer weiß) */
    --text: #23201d;
    --muted: #6b7280;
    --border: #e5e7eb;
    --danger: #b91c1c;
    --danger-bg: #fef2f2;
    --success: #166534;
    --success-bg: #f0fdf4;
    --radius: 14px;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
}

[x-cloak] { display: none !important; }

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

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

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== Kopf ===== */
.portal-header {
    background: var(--primary);
    color: var(--header-text);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
}
.portal-header__inner {
    position: relative;
    max-width: 60rem;
    margin: 0 auto;
    padding: 0.8rem 3.5rem; /* Platz rechts für den Logout-Button, damit die Mitte echt zentriert bleibt */
    display: flex;
    align-items: center;
    justify-content: center; /* Logo/Titel zentriert */
    gap: 1rem;
    min-height: 5.5rem;
    text-align: center;
}
.portal-header__logo {
    /* Feste Höhe erzwingt das Hochskalieren auch kleiner Quell-Logos (max-height allein deckelt nur). */
    height: 3.75rem;
    max-width: 22rem;
    width: auto;
    object-fit: contain;
}
.portal-header__title {
    font-weight: 600;
    font-size: 1.1rem;
}
.portal-header__logout {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: color-mix(in srgb, var(--header-text) 15%, transparent);
    color: var(--header-text);
    border: 1px solid color-mix(in srgb, var(--header-text) 40%, transparent);
    border-radius: 8px;
    padding: 0.4rem 0.9rem;
    font-size: 0.9rem;
    cursor: pointer;
}
.portal-header__logout:hover { background: color-mix(in srgb, var(--header-text) 28%, transparent); }

/* ===== Layout ===== */
.portal-main {
    flex: 1;
    width: 100%;
    max-width: 60rem;
    margin: 0 auto;
    padding: 1.5rem 1rem 2.5rem;
}

.portal-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.8rem;
    padding: 1.5rem 1rem 2.25rem;
}
.portal-footer__brand { display: inline-flex; }
.portal-footer__logo {
    height: 2rem;
    width: auto;
    max-width: 160px;
    object-fit: contain;
    opacity: 0.9;
}
.portal-footer__text { color: var(--muted); }

/* ===== Karten ===== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.75rem;
}
.card--narrow {
    max-width: 26rem;
    margin: 2rem auto 0;
}
.card__title {
    margin: 0 0 0.5rem;
    font-size: 1.4rem;
    color: var(--text);
}
.muted { color: var(--muted); margin: 0 0 1rem; }

/* ===== Formulare ===== */
.form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.25rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field__label { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.field__input {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    background: #fff;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.field__input:focus {
    outline: none;
    border-color: var(--focus);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent);
}
.field__input[readonly] { background: #f6f7f9; color: var(--muted); }
.field__input--code {
    letter-spacing: 0.35em;
    text-align: center;
    font-size: 1.3rem;
    font-variant-numeric: tabular-nums;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.1rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, opacity .15s;
}
.btn--primary { background: var(--btn-bg); color: var(--btn-text); }
.btn--primary:hover { background: var(--btn-bg-dark); }
.btn--primary:disabled { background: #9ca3af; cursor: not-allowed; }
.btn--ghost {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    margin-top: 1rem;
}
.btn--ghost:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
/* Dezente Zurück-Navigation (kein Aktions-Button) */
.btn--back {
    background: transparent;
    border: none;
    color: var(--muted);
    padding: 0.35rem 0;
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    align-self: flex-start;
}
.btn--back:hover { color: var(--accent); }
.link {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.25rem 0;
    align-self: center;
    text-decoration: underline;
}

/* ===== Meldungen ===== */
.alert {
    border-radius: 10px;
    padding: 0.65rem 0.85rem;
    font-size: 0.9rem;
    margin: 0;
}
.alert--error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.alert--success { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }

/* ===== Ladeindikator ===== */
.loader { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; padding: 1.5rem 0; color: var(--muted); }
.spinner {
    width: 2rem; height: 2rem;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Praxis-Auswahl ===== */
.practice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
    gap: 1rem;
    margin-top: 1.25rem;
}
.practice-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-align: left;
    background: var(--tile-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, transform .05s;
}
.practice-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.practice-card:active { transform: translateY(1px); }
.practice-card:disabled { opacity: 0.6; cursor: wait; }
.practice-card__logo {
    width: 3.25rem; height: 3.25rem;
    flex: 0 0 auto;
    border-radius: 10px;
    background: #f3f4f6;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.practice-card__logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.practice-card__initial { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.practice-card__body { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.practice-card__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.practice-card__meta { font-size: 0.85rem; color: var(--muted); }

/* ===== Dashboard ===== */
.dashboard {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.75rem;
    max-width: 60rem;
    margin: 1rem auto 0;
}
.dashboard__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}
.tile {
    background: var(--tile-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    text-align: center;
    opacity: 0.85;
}
.tile__icon { font-size: 1.8rem; line-height: 1; }
.tile__label { font-weight: 600; }
.tile__soon {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-text);
    background: var(--accent);
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
}

/* Klickbare Kachel (Feature öffnen) */
.tile--action {
    cursor: pointer;
    font: inherit;
    opacity: 1;
    position: relative;
    transition: border-color .15s, box-shadow .15s, transform .05s;
}
.tile--action:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.tile--action:active { transform: translateY(1px); }
.tile__count {
    min-width: 1.4rem;
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-text);
    font-size: 0.8rem;
    font-weight: 700;
}

/* ===== Feature-Detailansicht ===== */
.feature__head {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.feature__head .card__title { margin: 0; }
.feature__back { margin-top: 0; padding: 0.45rem 0.9rem; }

.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.rows__group { margin: 1.75rem 0 0.75rem; font-size: 1.05rem; color: var(--text); }
.row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    background: var(--tile-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.row--muted { opacity: 0.6; }
.row__main { flex: 1; min-width: 0; }
.row__title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.row__sub { font-size: 0.85rem; color: var(--muted); margin-top: 0.15rem; }
.badge {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #4b5563;
    background: #eef0f2;
    border-radius: 999px;
    padding: 0.12rem 0.55rem;
    white-space: nowrap;
}
.btn--sm { padding: 0.45rem 0.9rem; font-size: 0.9rem; flex: 0 0 auto; margin-top: 0; }
.badge--ok { color: var(--success); background: var(--success-bg); }
.badge--no { color: var(--danger); background: var(--danger-bg); }
.field__hint { font-size: 0.8rem; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.chip {
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--tile-bg);
    color: var(--text);
    cursor: pointer;
    font-size: 0.9rem;
}
.chip:hover { border-color: var(--accent); }
.chip:disabled { opacity: 0.5; cursor: wait; }

/* Stempelkarten */
.stamps { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.55rem 0 0.3rem; }
.stamp { width: 1.05rem; height: 1.05rem; border-radius: 50%; border: 2px solid var(--accent); background: transparent; }
.stamp--on { background: var(--accent); }

/* Ungelesen-Badge (Akzentfarbe) */
.badge--unread { color: var(--accent-text); background: var(--accent); min-width: 1.4rem; text-align: center; }

/* Chat */
.chat {
    display: flex; flex-direction: column; gap: 0.6rem;
    max-height: 55vh; overflow-y: auto;
    padding: 0.5rem 0.25rem; margin-top: 0.5rem;
}
.chat__msg { display: flex; flex-direction: column; max-width: 82%; }
.chat__msg--me { align-self: flex-end; align-items: flex-end; }
.chat__msg--practice { align-self: flex-start; align-items: flex-start; }
.chat__bubble {
    padding: 0.6rem 0.85rem; border-radius: 14px;
    font-size: 0.95rem; white-space: pre-wrap; word-break: break-word;
}
.chat__msg--me .chat__bubble { background: var(--btn-bg); color: var(--btn-text); border-bottom-right-radius: 4px; }
.chat__msg--practice .chat__bubble { background: #eef0f2; color: var(--text); border-bottom-left-radius: 4px; }
.chat__meta { font-size: 0.72rem; color: var(--muted); margin-top: 0.2rem; }
.chat__form { display: flex; gap: 0.5rem; margin-top: 0.85rem; }
.chat__form .field__input { flex: 1; }
.chat__form .btn { flex: 0 0 auto; }
select.field__input { appearance: none; -webkit-appearance: none; background-image: none; }

/* ===== Responsiv ===== */
@media (max-width: 480px) {
    .card { padding: 1.25rem; }
    .card--narrow { margin-top: 1rem; }
    .dashboard { padding: 1.25rem; border-radius: 0; margin-top: 0; }
    .portal-main { padding: 1rem 0.75rem 2rem; }
}
