/*
 * GlukoScout – Basis-CSS
 * Keine externen Ressourcen (REQ-TECH-012).
 * Professionelles UI-Styling folgt in Phase 20.
 */

*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    --gs-primary:    #1a5276;
    --gs-secondary:  #2980b9;
    --gs-success:    #27ae60;
    --gs-warning:    #f39c12;
    --gs-danger:     #c0392b;
    --gs-text:       #222;
    --gs-text-muted: #666;
    --gs-bg:         #f8f9fa;
    --gs-border:     #dee2e6;
    --gs-radius:     6px;
    --gs-font:       system-ui, -apple-system, 'Segoe UI', sans-serif;
    --gs-mono:       'Courier New', monospace;
}

html {
    font-size: 16px;
    line-height: 1.5;
}

body {
    font-family: var(--gs-font);
    color: var(--gs-text);
    background: var(--gs-bg);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Barrierearmut: sichtbarer Fokus (REQ-UI-008) ── */
:focus-visible {
    outline: 3px solid var(--gs-secondary);
    outline-offset: 2px;
}

/* ── Layout ── */
.gs-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ── Header ── */
.gs-header {
    background: var(--gs-primary);
    color: #fff;
    padding: .75rem 0;
}

.gs-header .gs-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.gs-logo {
    color: #fff;
    text-decoration: none;
    font-size: 1.25rem;
}

.gs-logo:hover,
.gs-logo:focus {
    text-decoration: underline;
}

/* ── Hauptnavigation ── */
.gs-nav-main {
    background: var(--gs-primary);
    border-top: 1px solid rgba(255,255,255,.15);
}

.gs-nav-main__list {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    list-style: none;
    margin: 0;
    padding: 0;
}

.gs-nav-main__link {
    display: block;
    padding: .55rem 1.1rem;
    color: rgba(255,255,255,.85);
    text-decoration: none;
    font-size: .9rem;
    font-weight: 500;
    transition: background .15s, color .15s;
}

.gs-nav-main__link:hover,
.gs-nav-main__link:focus {
    background: rgba(255,255,255,.12);
    color: #fff;
}

/* ── Kinder-Subnavigation (Modul-Tabs) ── */
.gs-child-nav {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    margin-bottom: 1.25rem;
    border-bottom: 2px solid var(--gs-border);
    padding-bottom: 0;
}

.gs-child-nav__link {
    display: inline-block;
    padding: .5rem 1rem;
    border-radius: var(--gs-radius) var(--gs-radius) 0 0;
    text-decoration: none;
    font-size: .9rem;
    font-weight: 500;
    color: var(--gs-text-muted);
    border: 1px solid transparent;
    border-bottom: none;
    margin-bottom: -2px;
    transition: color .15s, background .15s;
}

.gs-child-nav__link:hover,
.gs-child-nav__link:focus {
    color: var(--gs-primary);
    background: #f1f4f7;
}

.gs-child-nav__link--active {
    color: var(--gs-primary);
    background: #fff;
    border-color: var(--gs-border);
    font-weight: 700;
}

/* ── Dashboard Modul-Grid ── */
.gs-module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.gs-module-card {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    background: #fff;
    border: 1px solid var(--gs-border);
    border-radius: var(--gs-radius);
    padding: 1.25rem;
    text-decoration: none;
    color: var(--gs-text);
    transition: border-color .15s, box-shadow .15s;
}

.gs-module-card:hover,
.gs-module-card:focus {
    border-color: var(--gs-secondary);
    box-shadow: 0 2px 8px rgba(41,128,185,.15);
}

.gs-module-card__icon {
    font-size: 1.75rem;
    line-height: 1;
}

.gs-module-card__title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--gs-primary);
}

.gs-module-card__desc {
    font-size: .85rem;
    color: var(--gs-text-muted);
    line-height: 1.4;
}

/* ── Badge-Varianten ── */
.gs-badge--admin {
    background: var(--gs-primary);
    color: #fff;
}

/* ── Button-Gruppe ── */
.gs-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
}

.gs-btn-group__form {
    display: contents; /* Form transparent im Flex-Layout – kein Inline-Style nötig */
}

/* ── Kleine Button-Variante ── */
.gs-btn--sm {
    padding: .3rem .8rem;
    font-size: .85rem;
}

/* ── Seitenüberschrift ── */
.gs-page-title {
    margin-bottom: 1.5rem;
    color: var(--gs-primary);
}

/* ── Einwilligungsliste ── */
.gs-consent-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.gs-consent-item {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.gs-consent-item__info {
    flex: 1;
    min-width: 200px;
}

.gs-consent-item__title {
    font-weight: 600;
    color: var(--gs-text);
    margin-bottom: .25rem;
}

.gs-consent-item__meta {
    font-size: .8rem;
    color: var(--gs-text-muted);
}

.gs-consent-item__meta + .gs-consent-item__meta {
    margin-top: .2rem;
}

.gs-consent-item__actions {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-shrink: 0;
}

.gs-consent-status {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .65rem;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.gs-consent-status--active {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

.gs-consent-status--inactive {
    background: #f8f9fa;
    color: #666;
    border-color: var(--gs-border);
}

/* ── Karten-Intro-Text ── */
.gs-card-intro {
    margin: 0;
    color: var(--gs-text-muted);
    font-size: .9rem;
}

/* ── Einfacher Muted-Text ── */
.gs-text-muted {
    margin: 0;
    color: var(--gs-text-muted);
}

/* ── Main ── */
.gs-main {
    flex: 1;
    padding: 2rem 0;
}

/* ── Footer ── */
.gs-footer {
    background: #fff;
    border-top: 1px solid var(--gs-border);
    padding: 1rem 0;
    font-size: .875rem;
    color: var(--gs-text-muted);
}

.gs-footer-links a {
    color: var(--gs-secondary);
}

.gs-disclaimer {
    font-size: .8rem;
    color: var(--gs-text-muted);
    margin-bottom: .5rem;
}

/* ── Alerts / Flash Messages ── */
.gs-alert {
    padding: .875rem 1rem;
    border-radius: var(--gs-radius);
    margin-bottom: 1.25rem;
    border-left: 4px solid transparent;
}

.gs-alert--info    { background: #ebf5fb; border-color: var(--gs-secondary); }
.gs-alert--success { background: #eafaf1; border-color: var(--gs-success); }
.gs-alert--warning { background: #fef9e7; border-color: var(--gs-warning); }
.gs-alert--danger  { background: #fdedec; border-color: var(--gs-danger); }

/* ── Formulare ── */
.gs-form-group {
    margin-bottom: 1rem;
}

.gs-label {
    display: block;
    font-weight: 600;
    margin-bottom: .375rem;
}

.gs-input,
.gs-select,
.gs-textarea {
    display: block;
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid var(--gs-border);
    border-radius: var(--gs-radius);
    font-family: var(--gs-font);
    font-size: 1rem;
    color: var(--gs-text);
    background: #fff;
    transition: border-color .15s;
}

.gs-input:focus,
.gs-select:focus,
.gs-textarea:focus {
    border-color: var(--gs-secondary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(41,128,185,.2);
}

/* ── Buttons ── */
.gs-btn {
    display: inline-block;
    padding: .5rem 1.25rem;
    border-radius: var(--gs-radius);
    border: none;
    font-family: var(--gs-font);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, box-shadow .15s;
    line-height: 1.5;
}

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

.gs-btn--primary:hover,
.gs-btn--primary:focus {
    background: var(--gs-secondary);
}

.gs-btn--secondary {
    background: #fff;
    color: var(--gs-primary);
    border: 1px solid var(--gs-primary);
}

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

/* ── Tabellen ── */
.gs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

.gs-table th,
.gs-table td {
    padding: .6rem .75rem;
    border-bottom: 1px solid var(--gs-border);
    text-align: left;
}

.gs-table th {
    background: #f1f4f7;
    font-weight: 600;
}

/* ── Karten ── */
.gs-card {
    background: #fff;
    border: 1px solid var(--gs-border);
    border-radius: var(--gs-radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.gs-card__title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gs-primary);
    margin: 0 0 .75rem;
}

/* ── Responsive (REQ-UI-002) ── */
@media (max-width: 768px) {
    .gs-header .gs-container {
        flex-direction: column;
        align-items: flex-start;
    }

    .gs-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ══════════════════════════════════════════════════
   Auth-Layout  (Login, MFA, Passwort-Reset, Reauth)
   ══════════════════════════════════════════════════ */

.gs-auth-body {
    background: linear-gradient(150deg, #eaf0f6 0%, #dce8f2 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.gs-auth-main {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

/* Brand-Bereich über der Karte */
.gs-auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
}

.gs-auth-brand-icon {
    width: 58px;
    height: 58px;
    background: var(--gs-primary);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 18px rgba(26,82,118,.28);
}

.gs-auth-brand-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gs-primary);
    letter-spacing: -.02em;
    line-height: 1;
}

.gs-auth-brand-tagline {
    font-size: .75rem;
    color: var(--gs-text-muted);
    letter-spacing: .01em;
}

/* Karte */
.gs-auth-card {
    background: #fff;
    border-radius: 14px;
    padding: 2.25rem 2.5rem 2rem;
    width: 100%;
    box-shadow:
        0 2px 4px rgba(0,0,0,.04),
        0 8px 28px rgba(0,0,0,.09);
}

/* Kartenüberschrift (h1 in den Auth-Views) */
.gs-auth-card h1,
.gs-auth-card-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gs-text);
    margin: 0 0 1.5rem;
    text-align: center;
    letter-spacing: -.01em;
}

/* Disclaimer unter der Karte */
.gs-auth-disclaimer {
    font-size: .7rem;
    color: var(--gs-text-muted);
    text-align: center;
    max-width: 440px;
    line-height: 1.5;
    margin: 0;
}

/* Links unter dem Formular */
.gs-auth-links {
    text-align: center;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--gs-border);
    font-size: .875rem;
}

.gs-auth-links a {
    color: var(--gs-secondary);
    text-decoration: none;
    font-weight: 500;
}

.gs-auth-links a:hover {
    text-decoration: underline;
}

/* ── Formularfelder in Auth-Views ── */
.gs-field {
    margin-bottom: 1.125rem;
}

.gs-field-submit {
    margin-top: 1.5rem;
    margin-bottom: 0;
}

.gs-field label {
    display: block;
    font-size: .875rem;
    font-weight: 600;
    color: var(--gs-text);
    margin-bottom: .45rem;
}

.gs-field input,
.gs-field select,
.gs-field textarea {
    display: block;
    width: 100%;
    padding: .65rem .9rem;
    border: 1.5px solid var(--gs-border);
    border-radius: 8px;
    font-family: var(--gs-font);
    font-size: 1rem;
    color: var(--gs-text);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

.gs-field input::placeholder {
    color: #c0c8d0;
}

.gs-field input:focus,
.gs-field select:focus,
.gs-field textarea:focus {
    border-color: var(--gs-secondary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(41,128,185,.15);
}

/* ── Primärer Auth-Button ── */
.gs-auth-btn-primary {
    display: block;
    width: 100%;
    padding: .8rem 1.5rem;
    background: var(--gs-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: var(--gs-font);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    letter-spacing: .01em;
    box-shadow: 0 2px 8px rgba(26,82,118,.22);
    transition: background .15s, box-shadow .15s, transform .1s;
    -webkit-appearance: none;
    appearance: none;
}

.gs-auth-btn-primary:hover {
    background: var(--gs-secondary);
    box-shadow: 0 4px 14px rgba(41,128,185,.3);
}

.gs-auth-btn-primary:active {
    transform: translateY(1px);
    box-shadow: 0 1px 4px rgba(26,82,118,.15);
}

.gs-auth-btn-primary:focus-visible {
    outline: 3px solid var(--gs-secondary);
    outline-offset: 2px;
}

/* ── Alert-Varianten ── */
.gs-alert {
    padding: .825rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    font-size: .9rem;
    line-height: 1.45;
}

.gs-alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.gs-alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.gs-alert-warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.gs-alert-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

/* ── Legacy-Varianten (für andere Views) ── */
.gs-btn-primary  { background: var(--gs-primary); color: #fff; }
.gs-btn-primary:hover { background: var(--gs-secondary); color: #fff; }
.gs-btn-secondary { background: #fff; color: var(--gs-primary); border: 1px solid var(--gs-primary); }
.gs-btn-danger   { background: var(--gs-danger); color: #fff; }
.gs-btn-full     { display: block; width: 100%; text-align: center; }

/* ── MFA-Setup ── */
.gs-mfa-uri {
    background: #f4f6f8;
    border: 1px solid var(--gs-border);
    border-radius: var(--gs-radius);
    padding: .75rem;
    font-family: var(--gs-mono);
    font-size: .8rem;
    word-break: break-all;
    margin-bottom: 1rem;
}

.gs-mfa-secret {
    font-family: var(--gs-mono);
    font-size: 1rem;
    font-weight: bold;
    letter-spacing: .1em;
    text-align: center;
    margin-bottom: 1rem;
    padding: .5rem;
    background: #f4f6f8;
    border-radius: var(--gs-radius);
}

.gs-recovery-codes {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .375rem;
}

.gs-recovery-codes li {
    font-family: var(--gs-mono);
    font-size: .9rem;
    background: #f4f6f8;
    padding: .25rem .5rem;
    border-radius: 4px;
}

/* ── Öffentliche Notfallseite (REQ-QR-001, REQ-QR-003) ── */

.gs-emergency-body {
    background: #fff;
}

.gs-emergency-wrap {
    max-width: 700px;
    margin: 2rem auto;
    padding: 1rem 1.5rem;
}

.gs-emergency-card {
    border: 2px solid var(--gs-danger);
    border-radius: var(--gs-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.gs-emergency-header {
    border-bottom: 1px solid var(--gs-border);
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
}

.gs-emergency-header h1 {
    color: var(--gs-danger);
    margin: 0 0 .25rem;
}

.gs-emergency-label {
    font-size: 1.1rem;
    font-weight: bold;
    margin: .25rem 0;
}

.gs-emergency-expiry {
    font-size: .85rem;
}

.gs-emergency-section {
    margin-bottom: 1.5rem;
}

.gs-emergency-notes {
    background: #fef9e7;
    border-left: 4px solid var(--gs-warning);
    padding: .75rem 1rem;
    border-radius: 0 var(--gs-radius) var(--gs-radius) 0;
    white-space: pre-wrap;
}

.gs-emergency-error {
    max-width: 520px;
    margin: 3rem auto;
    padding: 1rem;
}

.gs-emergency-pin {
    max-width: 360px;
    margin: 3rem auto;
    padding: 1rem;
}

.gs-emergency-pin__hint {
    font-size: .85rem;
    margin-top: 1rem;
}

.gs-input--pin {
    letter-spacing: .2em;
    font-size: 1.5rem;
    text-align: center;
    max-width: 200px;
}

.gs-emergency-url-box {
    background: #f4f6f8;
    border: 1px solid var(--gs-border);
    border-radius: var(--gs-radius);
    padding: .75rem 1rem;
    word-break: break-all;
    margin-bottom: 1rem;
}

.gs-emergency-url-box code {
    font-family: var(--gs-mono);
    font-size: .85rem;
}

.gs-badge--revoked {
    background: var(--gs-danger);
    color: #fff;
}

.gs-badge--expired {
    background: var(--gs-text-muted);
    color: #fff;
}

/* ── Standalone-Fehlerseiten (403/404/500/503) ── */

.gs-error-page {
    max-width: 520px;
    margin: 80px auto;
    padding: 0 20px;
    font-family: var(--gs-font);
    color: var(--gs-text);
}

.gs-error-page h1 {
    color: var(--gs-primary);
}

.gs-error-page__notice {
    background: #fef9e7;
    border-left: 4px solid var(--gs-warning);
    padding: 12px 16px;
    border-radius: var(--gs-radius);
    margin-bottom: 1rem;
}

.gs-error-page__disclaimer {
    color: var(--gs-text-muted);
    font-size: .85em;
    margin-top: 2em;
}

/* ── Druckansicht (REQ-UI-007) ── */
@media print {
    .gs-header,
    .gs-footer,
    .gs-nav-user,
    .gs-nav-main,
    .gs-child-nav,
    .gs-btn {
        display: none;
    }

    body {
        background: #fff;
        color: #000;
    }

    .gs-main {
        padding: 0;
    }
}
