/*
 * littlemedreq — Design System
 *
 * Farben: 2 Markenfarben (Teal als Primärfarbe, warme Off-Whites als Flächen).
 * Typographie: System-Font-Stack (schnell, nativ, konsistent).
 * Icons: Unicode/Inline-SVG minimal — nur wo funktional sinnvoll.
 */

:root {
    --teal:           #0E5A50;
    --teal-hover:     #0A4A42;
    --teal-soft:      #E8F1EF;

    --bg:             #F8F6F2;
    --surface:        #FFFFFF;
    --surface-muted:  #F2EFE9;

    --text:           #1A1A1A;
    --text-muted:     #6B6B6B;

    --border:         #E5E2DB;
    --border-strong:  #C8C4BA;

    --danger:         #8A2E2E;
    --danger-soft:    #F5E4E4;

    --radius-sm:      8px;
    --radius-md:      12px;
    --radius-lg:      16px;

    --shadow-sm:      0 1px 2px rgba(0,0,0,0.04);
    --shadow:         0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg:      0 8px 24px rgba(0,0,0,0.08);

    --sp-1: 4px;  --sp-2: 8px;   --sp-3: 12px;  --sp-4: 16px;
    --sp-5: 24px; --sp-6: 32px;  --sp-7: 48px;

    --fs-xs: 12px; --fs-sm: 13px; --fs-base: 15px;
    --fs-md: 16px; --fs-lg: 18px; --fs-xl: 22px; --fs-xxl: 28px;
}

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

html, body { height: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: var(--fs-md);
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
}

button, input, textarea, select {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

/* ─── Layout ─── */

.app-container {
    min-height: 100vh;
    max-width: 560px;
    margin: 0 auto;
    background: var(--bg);
    display: flex;
    flex-direction: column;
}

.content {
    flex: 1;
    padding: var(--sp-5) var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

/* ─── Header ─── */

.header {
    background: var(--teal);
    color: #fff;
    padding: var(--sp-5) var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    min-height: 28px;
}

.header-badge {
    font-size: var(--fs-xs);
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
    letter-spacing: 0.02em;
}

.header-back {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    margin-left: -8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.header-back:hover { background: rgba(255,255,255,0.12); }

.header-title {
    font-size: var(--fs-xl);
    font-weight: 600;
    letter-spacing: -0.01em;
}

.header-sub {
    font-size: var(--fs-sm);
    font-weight: 400;
    opacity: 0.85;
}

/* ─── Typography / Text ─── */

.intro-text {
    color: var(--text-muted);
    font-size: var(--fs-base);
    line-height: 1.55;
}

.section-title {
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: var(--sp-2);
}

.divider {
    height: 1px;
    background: var(--border);
    margin: var(--sp-2) 0;
    border: none;
}

/* ─── Form-Elemente ─── */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-muted);
}

.form-input,
.freitext,
.search-input {
    width: 100%;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 13px 16px;
    font-size: var(--fs-md);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus,
.freitext:focus,
.search-input:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-soft);
}

.freitext {
    min-height: 96px;
    resize: vertical;
    line-height: 1.5;
}

/* ─── Buttons ─── */

.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: 14px 20px;
    font-size: var(--fs-base);
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1.5px solid transparent;
    cursor: pointer;
    min-height: 48px;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
    width: 100%;
}

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

.btn-primary:hover:not(:disabled) { background: var(--teal-hover); }

.btn-primary:disabled {
    background: var(--border-strong);
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-secondary {
    background: var(--surface);
    color: var(--teal);
    border-color: var(--border);
}

.btn-secondary:hover {
    border-color: var(--teal);
    background: var(--teal-soft);
}

.btn-sm {
    padding: 10px 16px;
    font-size: var(--fs-sm);
    min-height: 40px;
}

/* ─── Suche ─── */

.search-container {
    position: relative;
}

.search-input {
    padding-left: 44px;
}

.search-icon {
    position: absolute;
    top: 50%;
    left: 14px;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    width: 18px;
    height: 18px;
}

.search-results {
    margin-top: var(--sp-2);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    max-height: 360px;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.search-result-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

.search-result-item:last-child { border-bottom: none; }

.search-result-item:hover,
.search-result-item:active { background: var(--teal-soft); }

.search-result-info { min-width: 0; flex: 1; }

.search-result-name {
    font-size: var(--fs-base);
    font-weight: 500;
    color: var(--text);
}

.search-result-detail {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin-top: 2px;
}

.search-result-add {
    background: var(--teal);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ─── Warenkorb ─── */

.basket-empty {
    padding: var(--sp-5);
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: var(--fs-sm);
    text-align: center;
    line-height: 1.6;
}

.basket-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: var(--sp-2);
}

.basket-item-info { min-width: 0; flex: 1; }

.basket-item-name {
    font-size: var(--fs-base);
    font-weight: 500;
}

.basket-item-detail {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin-top: 2px;
}

.basket-item-remove {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.basket-item-remove:hover {
    background: var(--bg);
    color: var(--text);
}

/* ─── Dauermedikation ─── */

.dauer-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    padding: 12px 16px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: var(--fs-base);
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    width: 100%;
    text-align: left;
}

.dauer-toggle:hover { border-color: var(--teal); }

.dauer-badge {
    background: var(--teal);
    color: #fff;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: var(--fs-xs);
    font-weight: 600;
    min-width: 24px;
    text-align: center;
}

.dauer-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--sp-3);
    margin-top: var(--sp-2);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dauer-select-all {
    background: transparent;
    border: none;
    color: var(--teal);
    font-weight: 600;
    font-size: var(--fs-sm);
    cursor: pointer;
    text-align: left;
    padding: 6px 0 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.dauer-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 8px 4px;
    cursor: pointer;
    border-radius: 6px;
}

.dauer-item:hover { background: var(--surface-muted); }

.dauer-checkbox {
    width: 20px;
    height: 20px;
    border: 1.5px solid var(--border-strong);
    border-radius: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    font-size: 14px;
    line-height: 1;
    transition: all 0.15s;
}

.dauer-item.selected .dauer-checkbox,
.dauer-checkbox.checked {
    background: var(--teal);
    border-color: var(--teal);
    color: #fff;
}

.dauer-name { font-size: var(--fs-base); font-weight: 500; }
.dauer-detail { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 2px; }

/* ─── Zusammenfassung ─── */

.summary-patient {
    background: var(--teal-soft);
    padding: var(--sp-4);
    border-radius: var(--radius-md);
}

.summary-patient-name {
    font-size: var(--fs-lg);
    font-weight: 600;
}

.summary-patient-dob {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin-top: 2px;
}

.summary-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.summary-item:last-child { border-bottom: none; }

.summary-item-name { font-size: var(--fs-base); font-weight: 500; }

.summary-item-detail {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin-top: 2px;
}

.summary-freitext {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: var(--fs-sm);
    color: var(--text);
    white-space: pre-wrap;
    line-height: 1.5;
}

/* ─── Datenschutz ─── */

.privacy-notice {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--sp-4);
    font-size: var(--fs-sm);
    line-height: 1.6;
    color: var(--text-muted);
}

.privacy-notice strong {
    color: var(--text);
    display: block;
    margin-bottom: var(--sp-2);
    font-weight: 600;
}

.privacy-check {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    margin-top: var(--sp-3);
    padding-top: var(--sp-3);
    border-top: 1px solid var(--border);
    cursor: pointer;
    font-size: var(--fs-sm);
    color: var(--text);
    user-select: none;
}

.privacy-checkbox {
    width: 22px;
    height: 22px;
    border: 1.5px solid var(--border-strong);
    border-radius: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    font-size: 15px;
    line-height: 1;
    margin-top: 1px;
    transition: all 0.15s;
}

.privacy-checkbox.checked {
    background: var(--teal);
    border-color: var(--teal);
    color: #fff;
}

/* ─── Status / Confirm ─── */

.status-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--teal);
    border-radius: var(--radius-md);
    padding: var(--sp-5);
    text-align: center;
}

.status-card.muted {
    border-left-color: var(--border-strong);
    opacity: 0.85;
}

.status-card.warn {
    border-left-color: var(--danger);
    background: var(--danger-soft);
}

.status-card.warn .status-mark {
    background: #fff;
    color: var(--danger);
}

.status-card.warn .status-title { color: var(--danger); }

.status-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--teal-soft);
    color: var(--teal);
    margin-bottom: var(--sp-3);
}

.status-mark svg { width: 28px; height: 28px; }

.status-title {
    font-size: var(--fs-lg);
    font-weight: 600;
    margin-bottom: var(--sp-2);
}

.status-text {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    line-height: 1.6;
}

.status-token {
    display: inline-block;
    background: var(--surface-muted);
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
    font-size: var(--fs-sm);
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
    letter-spacing: 0.04em;
    margin: var(--sp-3) 0;
}

.success-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--teal);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--sp-3);
}

.success-icon svg { width: 32px; height: 32px; }

.success-title {
    font-size: var(--fs-xl);
    font-weight: 600;
    margin-bottom: var(--sp-2);
}

.info-text {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    line-height: 1.6;
    margin: var(--sp-3) 0;
}

.cooldown-hint {
    text-align: center;
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin-top: var(--sp-3);
}

/* ─── Feedback ─── */

.error-msg {
    background: var(--danger-soft);
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: var(--fs-sm);
    line-height: 1.5;
}

.loading {
    text-align: center;
    padding: var(--sp-7) var(--sp-4);
    color: var(--text-muted);
    font-size: var(--fs-sm);
}

/* ─── Testphase-Strip (persistent, alle Screens) ─── */

.testphase-strip {
    background: var(--surface-muted);
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    text-align: center;
    padding: 6px 14px;
    font-size: var(--fs-xs);
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* ─── Info-Card (Bestandspatienten-Hinweis etc.) ─── */

.info-card {
    background: var(--teal-soft);
    border-left: 3px solid var(--teal);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: var(--fs-sm);
    line-height: 1.55;
    color: var(--text);
}

.info-card strong {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    color: var(--teal);
}

/* ─── iOS-Install-Banner ─── */

.ios-banner {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: 540px;
    margin: 0 auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 12px 14px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    z-index: 1000;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.ios-banner-text {
    flex: 1;
    font-size: var(--fs-sm);
    color: var(--text-muted);
    line-height: 1.5;
}

.ios-banner-text strong {
    display: block;
    color: var(--text);
    font-weight: 600;
    margin-bottom: 2px;
}

.ios-banner-dismiss {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.ios-banner-dismiss:hover {
    background: var(--bg);
    color: var(--text);
}

/* ─── Footer ─── */

.practice-bar {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: var(--sp-3) var(--sp-4);
    font-size: var(--fs-xs);
    color: var(--text-muted);
    text-align: center;
    margin-top: auto;
    line-height: 1.5;
}
