/* ========================================
   WORKTRACKER - SPEZIFISCHES CSS
   ======================================== */

/* Kalender: Live-Vorschau beim Ändern der Termindauer (Drag am Rand). Wird per JS an
   document.body gehängt → MUSS global sein, scoped CSS aus Calendar.razor.css greift dort nicht.
   pointer-events:none ist hier essenziell, sonst fängt die Vorschau elementFromPoint ab und das
   Verkürzen funktioniert nicht (man würde nur verlängern können). */
.calendar-appointment-resize-preview {
    position: fixed;
    z-index: 4000;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    border-radius: 10px;
    border: 1.6px solid var(--appt-color, #16181c);
    background: color-mix(in srgb, var(--appt-color, #16181c) 16%, #ffffff);
    box-shadow: 0 10px 22px -10px color-mix(in srgb, var(--appt-color, #16181c) 62%, transparent);
    pointer-events: none;
}

.calendar-appointment-resize-label {
    margin: 0 6px;
    padding: 2px 7px;
    border-radius: 999px;
    background: #16181c;
    color: #ffffff;
    font-size: 0.6rem;
    font-weight: 800;
    white-space: nowrap;
}

/* LineChart-Punkt-Popover (chartTooltip.js hängt es an den <body> → MUSS global sein,
   scoped CSS aus LineChart.razor.css greift dort nicht). */
.lc-pop {
    position: fixed;
    z-index: 100000;
    display: none;
    pointer-events: none;
    min-width: 92px;
    padding: 8px 11px;
    border-radius: 10px;
    background: #16181c;
    color: #fff;
    box-shadow: 0 12px 30px -8px rgba(0, 0, 0, .45);
    font-family: 'Plus Jakarta Sans', -apple-system, "Segoe UI", sans-serif;
    font-size: 12.5px;
    line-height: 1.25;
    white-space: nowrap;
}

    .lc-pop.is-open {
        display: block;
    }

    .lc-pop .lc-pop-row {
        display: flex;
        align-items: center;
        gap: 7px;
        font-weight: 700;
    }

    .lc-pop .lc-pop-dot {
        width: 9px;
        height: 9px;
        border-radius: 50%;
        flex: 0 0 auto;
        /* weißer Ring, damit dunkle Reihen (z. B. Diesel/Temperatur #16181c) auf dem dunklen Popover sichtbar sind */
        box-shadow: 0 0 0 1.5px #fff;
    }

    .lc-pop .lc-pop-label {
        margin-right: 14px;
    }

    .lc-pop .lc-pop-val {
        margin-left: auto;
        font-variant-numeric: tabular-nums;
    }

    .lc-pop .lc-pop-time {
        margin-top: 3px;
        font-size: 11px;
        font-weight: 600;
        color: #aeaeb2;
        font-variant-numeric: tabular-nums;
    }

    /* kleiner Zeiger zum Punkt */
    .lc-pop::after {
        content: "";
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        border: 5px solid transparent;
    }

    .lc-pop:not(.is-below)::after {
        top: 100%;
        border-top-color: #16181c;
    }

    .lc-pop.is-below::after {
        bottom: 100%;
        border-bottom-color: #16181c;
    }

:root {
    /* Höhe der eigentlichen Header-Leiste (ohne Banner). */
    --app-topbar-h: 72px;
    /* Höhe des optionalen Ankündigungs-Banners über dem Header (0 = kein Banner).
       Ist ein Banner aktiv, setzt der AdminBanner zuverlässig die Klasse „has-app-banner" auf <html>
       (per JS-Interop, siehe unten) — nicht mehr per injiziertem \3c style>, das Blazor beim Entfernen
       unzuverlässig aufräumte (Banner weg, Abstand blieb). */
    --app-banner-h: 0px;
    /* Oberes Safe-Area (Notch) im Standalone-PWA — liegt auf dem obersten Element (Header ODER Banner). */
    --app-safe-top: env(safe-area-inset-top, 0px);
    /* Gesamte obere App-Chrome (Banner + Header) — für calc(100vh - var(--app-header-h)) auf Vollbild-Seiten. */
    --app-header-h: calc(var(--app-topbar-h) + var(--app-banner-h) + var(--app-safe-top));
    /* Farbpalette */
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-900: #111827;
    /* Spacing */
    --spacing-sm: 0.5rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    /* Border Radius */
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Ankündigungs-Banner aktiv: Höhe reservieren (Header rutscht über --app-header-h automatisch nach
   unten). Die Klasse wird per JS zuverlässig getoggelt (ruehlSetBanner). */
html.has-app-banner {
    --app-banner-h: calc(40px + env(safe-area-inset-top, 0px));
    --app-safe-top: 0px;
}
@media (max-width: 520px) {
    html.has-app-banner { --app-banner-h: calc(36px + env(safe-area-inset-top, 0px)); }
}

/* Header ist auf schmalen Screens (Mobile-Drawer) niedriger */
@media (max-width: 520px) {
    :root {
        --app-topbar-h: 60px;
    }
}

/* ========== Form Elements ========== */
.form-control, .form-select {
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    background-color: white;
}

    .form-control:focus, .form-select:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
        outline: none;
    }

.form-label {
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: var(--spacing-sm);
    display: block;
    font-size: 0.85rem;
}

.form-control-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* ========== Buttons ========== */
.btn {
    border-radius: var(--radius-md);
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

    .btn:focus, .btn:active:focus {
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
        outline: none;
    }

.btn-primary {
    background-color: var(--primary);
    color: white;
}

    @media (hover: hover) {
        .btn-primary:hover {
            background-color: var(--primary-dark);
            transform: translateY(-2px);
            box-shadow: var(--shadow-lg);
        }
    }

.btn-success {
    background-color: var(--success);
    color: white;
}

    @media (hover: hover) {
        .btn-success:hover {
            background-color: #059669;
            transform: translateY(-2px);
            box-shadow: var(--shadow-lg);
        }
    }

.btn-danger {
    background-color: var(--danger);
    color: white;
}

    @media (hover: hover) {
        .btn-danger:hover {
            background-color: #dc2626;
            transform: translateY(-2px);
            box-shadow: var(--shadow-lg);
        }
    }

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

/* ========== Custom Time Shortcut Button ========== */
.btn-time-shortcut {
    border: 1px solid var(--gray-300);
    background-color: white;
    color: var(--gray-600);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    display: inline-block;
    text-align: center;
}

    @media (hover: hover) {
        .btn-time-shortcut:hover {
            background-color: var(--gray-100);
            border-color: var(--primary);
            color: var(--primary);
            transform: translateY(-1px);
        }
    }

    .btn-time-shortcut:active {
        background-color: var(--gray-200);
        transform: translateY(0);
    }

/* ========== Cards ========== */
.card {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    overflow: hidden;
    background-color: white;
}

    @media (hover: hover) {
        .card:hover {
            box-shadow: var(--shadow-md);
            border-color: var(--gray-300);
        }
    }

.card-body {
    padding: 1.5rem;
}

.card-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

/* ========== Tables ========== */
.table {
    border-collapse: collapse;
    margin-bottom: 0;
}

    .table thead {
        background-color: var(--gray-100);
        border-bottom: 2px solid var(--gray-200);
    }

    .table th {
        font-weight: 600;
        color: var(--gray-700);
        border-color: var(--gray-200);
        padding: 0.5rem;
        font-size: 0.85rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .table td {
        border-color: var(--gray-200);
        padding: 0.5rem;
        color: var(--gray-600);
        border-bottom: 1px solid var(--gray-200);
    }

@media (hover: hover) {
    .table-hover tbody tr:hover {
        background-color: var(--gray-100);
    }
}

.table-responsive {
    overflow-x: auto;
}

/* ========== Alerts ========== */
.alert {
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    border: 1px solid transparent;
}

.alert-info {
    background: #cffafe;
    border: 1px solid #a5f3fc;
    color: #0c7792;
    border-radius: 0.5rem;
}

/* ========== Badge ========== */
.badge {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-md);
}

.bg-primary {
    background-color: var(--primary);
    color: white;
}

/* ========== Layout & Spacing ========== */
.container-fluid {
    padding: var(--spacing-lg);
    max-width: 1200px;
}

.py-4 {
    padding-top: var(--spacing-xl);
    padding-bottom: var(--spacing-xl);
}

.mt-3 {
    margin-top: 1.5rem;
}

.mb-0 {
    margin-bottom: 0;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

.mb-4 {
    margin-bottom: 2rem;
}

/* ========== Grid System ========== */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -0.5rem;
    margin-left: -0.5rem;
}

    .row > * {
        padding-right: 0.5rem;
        padding-left: 0.5rem;
    }

.g-3 > * {
    padding: 0.5rem;
}

.col-md-3,
.col-md-4,
.col-lg-5,
.col-lg-7 {
    flex-basis: auto;
}

.col-md-3 {
    width: calc(25% - 1rem);
}

.col-md-4 {
    width: calc(33.333% - 1rem);
}

@media (min-width: 992px) {
    .col-lg-5 {
        width: calc(41.666% - 1rem);
    }

    .col-lg-7 {
        width: calc(58.333% - 1rem);
    }
}

/* ========== Text Utilities ========== */
.text-muted {
    color: var(--gray-500);
}

.fw-bold {
    font-weight: 600;
    color: var(--gray-800);
}

/* ========== Animations ========== */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

*:focus {
    outline: none !important;
}

/* Mitarbeiterseiten: gemeinsamer Marker `employee-app-page` am Seiten-Root
   (<main class="…-page employee-app-page">) liefert den App-Hintergrund und
   das App-Scrolling ohne sichtbaren Balken (gescrollt wird normal weiter —
   wichtig auch für den Handy-Ausschnitt der Mitarbeiteransicht). Neue
   Employee-Seiten setzen nur diese Klasse; app.css bleibt unangetastet.
   html/body sind aus scoped CSS nicht erreichbar, daher :has hier global. */
.employee-app-page {
    background: #f5f5f7;
}

html:has(.employee-app-page) {
    scrollbar-width: none;
}

html:has(.employee-app-page)::-webkit-scrollbar {
    display: none;
}

/* Profilbilder: An allen Avatar-Stellen wird bei gesetztem Bild ein <img> mit derselben
   CSS-Klasse wie der Initialen-Span gerendert (Größe/Radius kommen aus der jeweiligen
   Klasse). Global hier, weil die Stellen über viele scoped-CSS-Dateien verteilt sind. */
img[src^="/api/user-avatar/"] {
    object-fit: cover;
    padding: 0;
}

/* ========== Rich-Text-Inhalte (.rtc) ==========
   Gemeinsame Styles für HTML aus dem RichTextEditor — genutzt von der Editor-Fläche selbst
   (RichTextEditor: class="rte-area rtc") und allen Anzeige-Stellen (RichTextView: Schwarzes
   Brett, Termin-Notizen). Global statt scoped, weil der Inhalt zur Laufzeit als MarkupString/
   contenteditable entsteht und Blazor-Scope-Attribute dort nicht greifen.
   Erlaubte Tags: siehe RichTextSanitizer (Services/Infrastructure). */
.rtc {
    font-size: 14px;
    line-height: 1.55;
    color: #16181c;
    overflow-wrap: anywhere;
}

.rtc > :first-child { margin-top: 0; }
.rtc > :last-child { margin-bottom: 0; }
.rtc h1 { margin: 8px 0 4px; font-size: 18px; font-weight: 800; color: #16181c; line-height: 1.25; }
.rtc h2 { margin: 8px 0 4px; font-size: 16px; font-weight: 800; color: #16181c; line-height: 1.3; }
.rtc h3 { margin: 7px 0 3px; font-size: 14px; font-weight: 800; color: #16181c; }
.rtc p { margin: 5px 0; }
.rtc ul, .rtc ol { margin: 5px 0; padding-left: 22px; }
.rtc li { margin: 2px 0; }
.rtc strong, .rtc b { font-weight: 800; color: #16181c; }
.rtc a { color: #16181c; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.rtc blockquote { margin: 6px 0; padding: 2px 0 2px 12px; border-left: 3px solid #d1d1d6; color: #6c7077; }
.rtc hr { margin: 12px 0; border: 0; border-top: 2px solid #c7c7cc; border-radius: 999px; }

/* Checkliste: ul[data-checklist] > li[data-checked] — Kästchen als ::before/::after,
   Toggle passiert per JS (Editor bzw. RichTextView). */
.rtc ul[data-checklist] {
    list-style: none;
    padding-left: 2px;
}

.rtc ul[data-checklist] li {
    position: relative;
    padding-left: 27px;
    margin: 4px 0;
}

.rtc ul[data-checklist] li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 1px;
    width: 17px;
    height: 17px;
    border: 2px solid #c7c7cc;
    border-radius: 6px;
    background: #fff;
    box-sizing: border-box;
}

.rtc ul[data-checklist] li[data-checked="true"]::before {
    background: #16181c;
    border-color: #16181c;
}

.rtc ul[data-checklist] li[data-checked="true"]::after {
    content: "";
    position: absolute;
    left: 6px;
    top: 4px;
    width: 5px;
    height: 9px;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(45deg);
}

.rtc ul[data-checklist] li[data-checked="true"] {
    color: #80858d;
    text-decoration: line-through;
}

/* Abhakbare Anzeige (RichTextView mit Toggle): Kästchen als klickbar markieren. */
.rtc--togglable ul[data-checklist] li::before,
.rtc--togglable ul[data-checklist] li::after {
    cursor: pointer;
}

/* Tabellen */
.rtc table {
    width: 100%;
    margin: 8px 0;
    border-collapse: collapse;
    font-size: 13.5px;
}

.rtc th, .rtc td {
    border: 1px solid #e4e4e7;
    padding: 6px 9px;
    text-align: left;
    vertical-align: top;
    min-width: 34px;
}

.rtc th {
    background: #f5f5f7;
    font-weight: 800;
    color: #16181c;
}

/* Hinweis-Boxen (div[data-callout="info|warnung|wichtig"]) */
.rtc div[data-callout] {
    margin: 8px 0;
    padding: 8px 12px 9px 13px;
    border: 1px solid #e4e4e7;
    border-left: 4px solid #16181c;
    border-radius: 10px;
    background: #fafafa;
}

.rtc div[data-callout]::before {
    content: "Info";
    display: block;
    margin-bottom: 2px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #6c7077;
}

.rtc div[data-callout="warnung"] {
    border-left-color: #d97706;
    background: #fdf8ef;
    border-color: #f0e2c8;
}

.rtc div[data-callout="warnung"]::before {
    content: "Warnung";
    color: #b45309;
}

.rtc div[data-callout="wichtig"] {
    border-left-color: #e2483b;
    background: #fdf1f0;
    border-color: #f3d2ce;
}

.rtc div[data-callout="wichtig"]::before {
    content: "Wichtig";
    color: #c2372c;
}

/* Mitarbeiter-Erwähnung (span[data-mention]) */
.rtc span[data-mention] {
    display: inline-block;
    padding: 0 8px;
    border-radius: 999px;
    background: #efeff1;
    color: #16181c;
    font-weight: 700;
    font-size: .92em;
    line-height: 1.5;
    white-space: nowrap;
}

/* Checklisten-Fortschritt: Label („x von y erledigt · z %") + Mini-Balken über der Liste.
   data-progress/--rtc-done werden per JS gesetzt (Editor bzw. RichTextView).
   @property macht die Variable animierbar → der Balken morpht statt zu springen
   (Browser ohne @property-Support springen einfach — kein Schaden). */
@property --rtc-done {
    syntax: '<percentage>';
    inherits: true;
    initial-value: 0%;
}

.rtc ul[data-checklist][data-progress]::before {
    content: attr(data-progress);
    display: block;
    margin: 0 0 6px;
    padding-bottom: 7px;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #80858d;
    background: linear-gradient(to right, #16181c var(--rtc-done, 0%), #e4e4e7 var(--rtc-done, 0%)) left bottom / 140px 3px no-repeat;
    transition: --rtc-done .45s cubic-bezier(.66, 0, .18, 1);
}

/* Frisch gerendertes DOM: Wert ohne Übergang setzen (RichTextView.decorate),
   sonst baut sich der Balken nach jedem Speichern sichtbar von 0 % neu auf. */
.rtc ul[data-checklist].rtc-notrans::before {
    transition: none;
}

/* Rich-Text-Inhalte auf Touch-Geräten (iOS/iPadOS) */
.rtc--togglable ul[data-checklist] li {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

@media (pointer: coarse) {
    /* Größeres Tipp-Ziel fürs Abhaken */
    .rtc ul[data-checklist] li {
        padding-left: 30px;
        min-height: 22px;
    }

    .rtc ul[data-checklist] li::before {
        width: 20px;
        height: 20px;
        top: 0;
    }

    .rtc ul[data-checklist] li[data-checked="true"]::after {
        left: 7px;
        top: 3px;
        width: 6px;
        height: 11px;
    }
}

/* Breite Tabellen auf schmalen Screens horizontal scrollen statt das Layout zu sprengen. */
@media (max-width: 640px) {
    .rtc table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}
