/*
 * SaQura Tresor — Admin.Blazor: globale Styles
 *
 * Brand-Farben:
 *   Sumi-Tinte (Text-Default)   #1A1815
 *   Washi Paper (Card-Bg)       #FAFAF7
 *   Hanko Sumi-Red (Akzent)     #8B2A1F
 *   Senso-Grau (Muted)          #7A7670
 *   Akzent-Blau (Active)        #1F6FEB
 *   Content-Bg                  #F4F5F7
 *
 * Bewusst KEIN Bootstrap-Reset hier — die Default-Bootstrap-CSS bleibt fuer
 * Form-Controls etc., wir ueberschreiben nur typografische und visuelle
 * Default-Werte fuer den Tresor-Look.
 */

html, body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    color: #1A1815;
    -webkit-text-size-adjust: 100%;
}

body.no-scroll {
    overflow: hidden;
}

h1, h2, h3 {
    color: #1A1815;
    letter-spacing: -0.015em;
}

h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
}

h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.lead {
    color: #4A4F57;
    margin-bottom: 1.5rem;
}

.muted {
    color: #7A7670;
    font-size: 0.875rem;
}

.muted.footer {
    text-align: right;
    margin-top: 0.5rem;
}

code, .mono {
    font-family: SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8125rem;
}

a, .btn-link {
    color: #1F6FEB;
}

h1:focus {
    outline: none;
}

/* ===== Daten-Tabellen ===== */
.table-wrap {
    background: white;
    border: 1px solid #E1E4E8;
    border-radius: 6px;
    overflow: auto;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table thead {
    background: #F4F5F7;
    border-bottom: 1px solid #E1E4E8;
}

.data-table th {
    text-align: left;
    padding: 0.625rem 0.875rem;
    color: #4A4F57;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.data-table th.num,
.data-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.data-table tbody tr {
    border-bottom: 1px solid #F0F1F4;
}

.data-table tbody tr:last-child {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background-color: #FAFBFD;
}

.data-table td {
    padding: 0.625rem 0.875rem;
    color: #1A1815;
    vertical-align: middle;
}

/* ===== Status-Pills ===== */
.pill {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: white;
    background: #7A7670;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.pill-active { background: #2E8B57; }
.pill-grace { background: #E8B33B; color: #1A1815; }
.pill-expired { background: #E15B5B; }
.pill-revoked { background: #8B2A1F; }
.pill-none { background: #C7CCD3; color: #1A1815; }

/* ===== Alerts ===== */
.alert-success,
.alert-error,
.alert-info {
    border-radius: 4px;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.alert-success {
    background: #E8F5E9;
    color: #1F6B3C;
    border: 1px solid #A5D6A7;
}

.alert-error {
    background: #FCEBE9;
    color: #8B2A1F;
    border: 1px solid #E8A89F;
}

.alert-info {
    background: #E8F0FE;
    color: #1F4787;
    border: 1px solid #A5C0E1;
}

/* ===== Card ===== */
.card {
    background: white;
    border: 1px solid #E1E4E8;
    border-radius: 6px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* ===== Blazor-Defaults ===== */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: #FCEBE9;
    color: #8B2A1F;
    padding: 1rem 1.25rem;
    border-radius: 4px;
}

.blazor-error-boundary::after {
    content: "Ein Fehler ist aufgetreten."
}

/* ============================================================
 * Responsive — Mobile/Tablet-Anpassungen
 * ============================================================
 * Tabellen scrollen horizontal mit Hint-Schatten am rechten Rand;
 * Forms wrappen und ihre Inputs werden volle Breite; Status-Pills
 * bleiben gleich; Touch-Targets >= 44px.
 */

@media (max-width: 1023px) {
    h1 {
        font-size: 1.375rem;
    }

    h2 {
        font-size: 1rem;
    }

    .lead {
        font-size: 0.9375rem;
        margin-bottom: 1.25rem;
    }

    /* Tabellen-Wrapper bekommt einen Schatten-Hint am rechten Rand,
       der suggeriert dass nach rechts gescrollt werden kann. */
    .table-wrap {
        position: relative;
        -webkit-overflow-scrolling: touch;
    }

    .table-wrap::after {
        content: "";
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 28px;
        background: linear-gradient(to left, rgba(255, 255, 255, 0.95), transparent);
        pointer-events: none;
        border-radius: 0 6px 6px 0;
    }

    .data-table {
        font-size: 0.8125rem;
    }

    .data-table th {
        padding: 0.5rem 0.625rem;
        font-size: 0.6875rem;
    }

    .data-table td {
        padding: 0.5rem 0.625rem;
    }
}

@media (max-width: 640px) {
    .data-table {
        font-size: 0.75rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.4375rem 0.5rem;
    }

    .pill {
        font-size: 0.625rem;
        padding: 0.125rem 0.375rem;
    }
}

/* ===== Phone-Card-Layout =====
 * Unter 600px verlieren horizontal scrollende Tabellen ihre Usability.
 * Jede Zeile wird zu einer gestapelten Karte; jede Zelle zeigt ihr
 * Spalten-Label (data-label) links und den Wert rechts. Der <thead>
 * bleibt visuell-versteckt fuer Screenreader erhalten. */
@media (max-width: 600px) {
    .table-wrap {
        overflow: visible;
        border: none;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }

    /* Scroll-Hint-Schatten entfaellt im Card-Modus */
    .table-wrap::after {
        display: none;
    }

    /* thead a11y-konform verstecken statt entfernen */
    .data-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
        border: 0;
    }

    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
        /* border-box: Padding/Border zaehlen in die 100% — sonst addiert
           das Prozent-Padding der Zellen und sprengt den Viewport. */
        box-sizing: border-box;
    }

    .data-table tr {
        background: white;
        border: 1px solid #E1E4E8;
        border-radius: 6px;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
        margin-bottom: 0.75rem;
        padding: 0.25rem 0.875rem;
    }

    /* Hover-Highlight im Card-Modus neutralisieren */
    .data-table tbody tr:hover {
        background: white;
    }

    /* Block-Zelle mit linkem Label-Gutter (absolut positioniert) — KEIN
       Flex, um die min-width:auto-Overflow-Falle zu vermeiden. Wert ist
       rechtsbuendig und bricht bei Bedarf um. */
    .data-table td {
        display: block;
        position: relative;
        padding: 0.5rem 0 0.5rem 42%;
        border-bottom: 1px solid #F0F1F4;
        text-align: right;
        overflow-wrap: anywhere;
        min-height: 1.25rem;
    }

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

    /* Spalten-Label aus data-label im linken Gutter */
    .data-table td[data-label]::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        top: 0.5rem;
        width: 38%;
        text-align: left;
        font-weight: 600;
        font-size: 0.6875rem;
        line-height: 1.3;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: #4A4F57;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    /* Aktionen-Zellen: Label oben, Buttons/Forms volle Breite darunter */
    .data-table td.actions {
        padding-left: 0;
        text-align: left;
    }

    .data-table td.actions[data-label]::before {
        position: static;
        display: block;
        width: auto;
        margin-bottom: 0.375rem;
    }

    .data-table td.actions .row-actions {
        justify-content: flex-start;
    }
}

/* ===== Mobile-Baseline fuer Form-Controls + Touch-Targets (global) =====
 * Greift seitenuebergreifend, auch ueber Component-scoped CSS hinweg
 * (font-size via !important schlaegt die hoehere Scope-Specificity). */
@media (max-width: 640px) {
    /* iOS Safari zoomt beim Fokus rein, sobald ein Form-Control < 16px
       Schriftgroesse hat. 16px global erzwingen verhindert den stoerenden
       Zoom-Sprung auf allen Formular-Seiten (Mandanten, Benutzer, Audit,
       Lizenz). 16px == 1rem; rem hier bewusst nicht genutzt, falls jemand
       die Root-Schrift skaliert. */
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    select,
    textarea {
        font-size: 16px !important;
    }

    /* Komfortable Touch-Targets fuer Buttons, wo die Seiten-CSS keine
       eigene Mindesthoehe setzt (Seiten mit eigener Regel gewinnen via
       hoeherer Scope-Specificity und bleiben unveraendert). */
    .btn-primary,
    .btn-secondary,
    .btn-danger {
        min-height: 44px;
    }

    /* Volle Breite fuer primaere Formular-Buttons auf schmalen Phones,
       damit sie nicht verloren wirken. */
    .form-actions {
        flex-wrap: wrap;
    }
}


/* Sprach-Umschalter (de/en) */
.lang-switch { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.lang-switch a { color: #8995A6; text-decoration: none; padding: 2px 4px; border-radius: 4px; }
.lang-switch a:hover { color: #fff; }
.lang-switch a.lang-active { color: #fff; font-weight: 600; background: #3A4659; }
.lang-switch .lang-sep { color: #5A6473; }
