/*
 * Basis-Farben/Karten aus der Zeiterfassungsapp übernommen (Skill
 * mc-dashboard-design). Die Navigation weicht aber bewusst vom Skill
 * responsive-layout ab: feste Bottom-Tab-Bar statt Hamburger/Off-Canvas-
 * Sidebar, weil es hier nur 3 gleichrangige Ziele gibt - siehe nav.php.
 * "Responsive" heißt laut CLAUDE.md schlicht "Handy-App-Layout", die .page
 * bleibt darum auch auf großen Bildschirmen schmal wie ein Handy-Screen.
 */
:root {
    --color-bg: #e8eef8;
    --color-surface: #ffffff;
    --color-text: #1e293b;
    --color-muted: #64748b;
    --color-primary: #3b82f6;
    --color-primary-dark: #2563eb;
    --color-danger: #dc2626;
    --color-border: #e2e8f0;
    --shadow-card: 0 2px 20px rgba(99, 114, 196, 0.1);
    --radius: 14px;
    --tab-bar-height: 4.2rem;
    --wallpaper-tile: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cg stroke='%23c7d2e0' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'%3E%3Cg transform='translate(20,26) rotate(-14)'%3E%3Cpath d='M0 10c4-1.5 8-.5 11 1.5 3-2 7-3 11-1.5v15c-4-1.5-8-.5-11 1.5-3-2-7-3-11-1.5Z'/%3E%3Cpath d='M11 11.5V27'/%3E%3C/g%3E%3Cg transform='translate(100,92) rotate(24)'%3E%3Cpath d='M0 20l4-12 12-12 8 8-12 12-12 4Z'/%3E%3Cpath d='M12 4l8 8'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Segoe UI', Calibri, Arial, sans-serif;
    background-color: var(--color-bg);
    background-image: var(--wallpaper-tile);
    background-repeat: repeat;
    color: var(--color-text);
    min-height: 100vh;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

.muted {
    color: var(--color-muted);
    font-size: 0.9rem;
}

.hidden {
    display: none !important;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    min-height: 44px;
}

.btn-large {
    width: 100%;
    font-size: 1.1rem;
    padding: 1rem;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
}

.btn-text {
    background: none;
    padding: 0.4rem 0;
    color: var(--color-primary);
    min-height: auto;
}

/* Ladekreis neben Deuten-Buttons, während die KI-Anfrage läuft (nimmt ein
   paar Sekunden) - nutzt currentColor, damit derselbe Spinner auf dem
   primären wie auf dem Text-Button passt. */
.btn .spinner {
    display: none;
    width: 14px;
    height: 14px;
    margin-left: 0.5rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    opacity: 0.7;
    vertical-align: -2px;
    animation: spin 0.6s linear infinite;
}

.is-loading .spinner {
    display: inline-block;
}

.is-loading .btn-label {
    opacity: 0.7;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--color-muted);
    cursor: pointer;
}

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

.icon-btn-danger:hover {
    color: var(--color-danger);
}

/* App-Shell: Content + feste Bottom-Tab-Bar */
.app-shell {
    min-height: 100vh;
}

.app-main {
    padding-bottom: var(--tab-bar-height);
}

.tab-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    display: flex;
    background: var(--color-surface);
    box-shadow: 0 -2px 20px rgba(99, 114, 196, 0.12);
    padding: 0.35rem 0.5rem calc(0.35rem + env(safe-area-inset-bottom));
}

.tab-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.35rem 0;
    border-radius: 10px;
    color: var(--color-muted);
    font-size: 0.72rem;
    font-weight: 600;
}

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

.tab-link-active {
    color: var(--color-primary);
}

.tab-icon {
    display: flex;
}

.page {
    max-width: 480px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.page-title {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
}

/* Überschrift beim Traum-Eintragen ist der Seitentitel selbst (antippbar/
   veränderbar), statt eines separaten Felds - sieht bis zum Antippen aus wie
   eine normale Überschrift, Platzhalter bewusst nicht ausgegraut. Das
   Stift-Icon macht die Bearbeitbarkeit zusätzlich sofort erkennbar, statt
   sich erst beim Antippen über den Unterstrich zu zeigen. */
.page-header .page-title-field {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.page-title-edit-icon {
    flex-shrink: 0;
    display: flex;
    color: var(--color-muted);
}

input.page-title-input {
    border: none;
    background: transparent;
    padding: 0;
    font-family: inherit;
    color: inherit;
    min-width: 0;
    /* Breite passt sich dem eingegebenen Text an, statt wie vorher per
       width:100% den ganzen Platz bis zum Logo einzunehmen - sonst landet
       der Stift immer am Logo statt direkt hinter der Überschrift. */
    width: auto;
    max-width: 100%;
    field-sizing: content;
}

input.page-title-input:focus {
    outline: none;
    border-bottom: 1.5px solid var(--color-border);
}

input.page-title-input::placeholder {
    color: var(--color-text);
    opacity: 1;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-header .page-title {
    flex: 1;
    min-width: 0;
}

.page-logo {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.intro-text {
    text-align: center;
}

/* Deckt die Tapete lokal ab (gleicher Farbton wie body), damit hinter der
   Überschrift immer eine freie, ungestörte Fläche bleibt. */
.page-header {
    background: var(--color-bg);
}

.card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
}

/* Login/Registrieren - noch kein app-shell (keine Tab-Bar, ist ja noch nicht
   eingeloggt), darum eine eigene zentrierte Karte statt .page. */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.auth-card {
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.auth-logo {
    width: 48px;
    height: 48px;
    margin-bottom: 0.75rem;
}

.auth-card h1 {
    margin: 0 0 0.25rem;
    font-size: 1.3rem;
}

.auth-subtitle {
    margin: 0 0 1.25rem;
}

.auth-card form {
    text-align: left;
}

.auth-switch {
    margin-top: 1rem;
    font-size: 0.9rem;
}

/* Startseite: Begrüßung etwas tiefer, mit mehr Abstand zur "Letzte Träume"-
   Gruppe darunter, damit klar getrennt ist, was zusammengehört. */
.page-header-start {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Beide letzten Träume zusammen in einer Kachel statt als zwei getrennte
   Karten - macht sichtbar, dass sie als Gruppe gehören. */
.preview-card-group {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.preview-card-group-label {
    padding-bottom: 0.4rem;
}

.preview-dream-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.5rem 0;
    color: var(--color-text);
}

.preview-dream-row:not(:last-child) {
    border-bottom: 1px solid var(--color-border);
}

.preview-dream-row .entry-headline {
    color: var(--color-primary);
    margin: 0;
}

/* "Wie läuft die Woche?" - Schnell-Check-in auf der Startseite, landet direkt
   beim Befinden. Reicht dieselbe Chat-Optik wie den fixen Composer unten. */
.weekly-check-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.6rem;
}

.composer-row {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

/* Hauptaktion: neuen Traum anlegen (wie der Play-Button in der Zeiterfassungsapp) -
   fest in der Daumenzone, oberhalb der Tab-Bar. */
.start-page {
    padding-bottom: 13rem;
}

.mobile-action-dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--tab-bar-height) + 0.75rem);
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

.round-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    width: 56px;
    height: 56px;
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
    color: var(--color-text);
}

.round-btn-large {
    width: 96px;
    height: 96px;
}

.round-btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.round-btn-primary:hover {
    background: var(--color-primary-dark);
}

.action-label {
    font-weight: 600;
    color: var(--color-muted);
}

/* Einträge (Träume/Befinden) als Karten-Liste, mit Ausklappen + Aktionen */
.entry-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.entry-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-card);
}

.entry-card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
}

.entry-headline {
    font-weight: 700;
    margin: 0;
}

.entry-date {
    color: var(--color-muted);
    font-size: 0.85rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.entry-body {
    margin: 0.35rem 0 0;
    color: var(--color-muted);
    font-size: 0.95rem;
    white-space: pre-line;
}

.entry-body-full {
    display: none;
}

.entry-expanded .entry-body-short {
    display: none;
}

.entry-expanded .entry-body-full {
    display: inline;
}

.entry-toggle {
    border: none;
    background: none;
    color: var(--color-primary);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.35rem 0 0;
    cursor: pointer;
}

/* Chevron unter dem Textfeld zum Ausklappen (Träume) - die gekappte Vorschau
   bleibt dabei der optische Fokus, der Chevron ist nur die Aktion. */
.entry-expand-toggle {
    border: none;
    background: none;
    color: var(--color-muted);
    padding: 0.35rem 0 0;
    cursor: pointer;
    display: flex;
}

.entry-expand-toggle .icon {
    transition: transform 0.2s ease;
}

.entry-expanded .entry-expand-toggle .icon {
    transform: rotate(180deg);
}

.entry-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--color-border);
    padding-top: 0.5rem;
}

.entry-actions-with-analysis {
    justify-content: space-between;
}

.entry-actions-icons {
    display: flex;
    gap: 0.25rem;
}

.analysis-link {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-primary);
    padding: 0.4rem 0.1rem;
}

.entry-delete-form {
    display: contents;
}

/* Composer (Textfeld zum Eintragen, z.B. Traum-Volltext) */
.composer-textarea {
    width: 100%;
    min-height: 120px;
    font-family: inherit;
    font-size: 1rem;
    padding: 0.85rem;
    border-radius: 10px;
    border: 1.5px solid var(--color-border);
    resize: vertical;
}

.entry-page .composer-textarea {
    min-height: 220px;
}

.entry-submit {
    margin-top: 1rem;
}

.reality-link-field {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.reality-link-field label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.reality-link-field textarea {
    min-height: 70px;
}

.field-group {
    margin-bottom: 1rem;
}

.field-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.field-hint {
    margin: -0.15rem 0 0.6rem;
}

.text-input {
    width: 100%;
    font-family: inherit;
    font-size: 1rem;
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    border: 1.5px solid var(--color-border);
}

.card-title {
    margin: 0 0 0.75rem;
    font-size: 1rem;
}

.error {
    color: var(--color-danger);
    font-size: 0.9rem;
    margin: 0 0 0.75rem;
}

.success {
    color: #16a34a;
    font-size: 0.9rem;
    margin: 0 0 0.75rem;
}

/* Abmelden-Link am Seitenende des Profil-Tabs - bewusst dezent/rot statt als
   großer Primär-Button, damit er nicht mit "Speichern" verwechselt wird. */
.logout-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    color: var(--color-danger);
    font-weight: 600;
}

/* Wöchentliches Befinden: fester Eingabe-Riegel unten (wie ein
   Chat-Eingabefeld) - dünn im Ruhezustand, wird beim Antippen größer. */
.wellbeing-page {
    padding-bottom: 8rem;
}

.composer-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--tab-bar-height);
    z-index: 70;
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: var(--color-surface);
    box-shadow: 0 -2px 16px rgba(99, 114, 196, 0.12);
    padding: 0.6rem 1rem;
}

.composer-input {
    flex: 1;
    resize: none;
    font-family: inherit;
    font-size: 0.95rem;
    padding: 0.55rem 0.9rem;
    border-radius: 18px;
    border: 1.5px solid var(--color-border);
    min-height: 2.4rem;
    max-height: 2.4rem;
    overflow-y: hidden;
    transition: max-height 0.2s ease, border-radius 0.2s ease;
}

.composer-input:focus {
    min-height: 7rem;
    max-height: 40vh;
    overflow-y: auto;
    border-radius: 14px;
}

.composer-send {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.composer-send:hover {
    background: var(--color-primary-dark);
}

/* Mikrofon-Button fürs Diktieren (Web Speech API, siehe nav.js) - startet
   per Klasse "hidden" unsichtbar und wird von nav.js nur dann eingeblendet,
   wenn der Browser SpeechRecognition wirklich unterstützt (progressive
   enhancement statt Browser-Weiche im PHP). */
.mic-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--color-bg);
    color: var(--color-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

.mic-btn-active {
    background: var(--color-danger);
    color: #fff;
    animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {
    50% {
        box-shadow: 0 0 0 6px rgba(220, 38, 38, 0.25);
    }
}

/* Kleinere Variante über großen Textfeldern (Traumtext, Bezug zu einem
   realen Erlebnis) statt in einer Chat-Eingabe-Zeile. */
.textarea-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.4rem;
}

.mic-btn-small {
    width: 32px;
    height: 32px;
}
