/*************************************************************
 * Datei:        custom-list.css
 * Zweck:        Styles der Seite „Individueller Druck“ (Konfiguration,
 *               Vorschau, Druckblätter und Druckregeln)
 * Bereich:      Web / Styles
 * Ersteller:    Felix Fuchs
 * Urheberrecht: Copyright (c) 2026 Felix Fuchs
 * Hinweise:     Seitenmaße (A4, 8 mm Rand) müssen mit
 *               CustomListLayoutCalculator übereinstimmen; die @page-Regel
 *               selbst steht in CustomList.razor. Alle Maße der Druckblätter
 *               in mm/pt, damit Messung und Druck identisch sind.
 *************************************************************/

/* ========================================
   SEITENKOPF & STATUS
   ======================================== */

.cl-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.cl-page-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
}

.cl-page-subtitle {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
}

.cl-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.cl-status-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 1.25rem;
    min-height: 2.6rem;
    margin-bottom: 1rem;
    padding: 0.55rem 1rem;
    border: 1px solid var(--border-dark);
    border-radius: 10px;
    background: var(--bg-dark-secondary);
    font-size: 0.9rem;
}

.cl-status-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.cl-status-item > .bi {
    color: var(--text-muted);
}

/* ========================================
   KONFIGURATION
   ======================================== */

.cl-config {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding-right: 0.25rem;
}

.cl-section {
    margin-bottom: 1rem;
    border: 1px solid var(--border-dark);
    border-radius: 12px;
    background: var(--bg-dark-secondary);
}

.cl-section-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border-dark);
    font-weight: 600;
}

.cl-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    font-size: 0.8rem;
}

.cl-section-body {
    padding: 0.9rem 1rem 1rem;
}

.cl-section .form-text {
    color: var(--text-muted);
}

/* ----- Eigene Checkbox (rot, passend zum Grunddesign) -----
   Das native Element bleibt für Tastatur und Screenreader bedienbar und wird nur optisch ersetzt. */
.cl-check-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.cl-check-box {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
    width: 1.05rem;
    height: 1.05rem;
    border: 1.5px solid #6c757d;
    border-radius: 5px;
    background: var(--bg-dark);
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Häkchen als gedrehter Rahmen */
.cl-check-box::after {
    content: "";
    position: absolute;
    top: 45%;
    left: 50%;
    width: 0.3rem;
    height: 0.55rem;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: translate(-50%, -50%) rotate(45deg) scale(0);
    transition: transform 0.15s ease;
}

.cl-check-input:checked + .cl-check-box,
.cl-check-box.is-partial {
    border-color: var(--primary-color);
    background: var(--primary-color);
}

.cl-check-input:checked + .cl-check-box::after {
    transform: translate(-50%, -50%) rotate(45deg) scale(1);
}

/* Teilauswahl („Alle“ nur teilweise gewählt): waagrechter Strich statt Häkchen */
.cl-check-box.is-partial::after {
    top: 50%;
    width: 0.55rem;
    height: 0;
    border-width: 0 0 2px 0;
    transform: translate(-50%, -50%);
}

.cl-check-input:focus-visible + .cl-check-box {
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.45);
}

/* ----- Personengruppen ----- */
.cl-pg-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0.35rem;
    border: 1px solid var(--border-dark);
    border-radius: 12px;
    background: var(--bg-dark);
}

.cl-pg-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin: 0;
    padding: 0.5rem 0.65rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.cl-pg-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.cl-pg-row.is-checked {
    background: rgba(220, 53, 69, 0.12);
}

.cl-pg-row-all {
    font-weight: 600;
}

/* Aktuelle Gruppen eingerückt unter „Alle“ */
.cl-pg-sub {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-left: 1.15rem;
    padding-left: 0.55rem;
    border-left: 1px dashed var(--border-dark);
}

.cl-pg-icon {
    width: 1.1rem;
    color: var(--text-muted);
    text-align: center;
    transition: color 0.15s ease;
}

.cl-pg-row.is-checked .cl-pg-icon {
    color: #ff6b7a;
}

.cl-pg-label {
    flex: 1;
    min-width: 0;
}

.cl-pg-count {
    min-width: 2rem;
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.cl-pg-row.is-checked .cl-pg-count {
    background: var(--primary-color);
    color: #fff;
}

.cl-pg-spinner {
    width: 0.9rem;
    height: 0.9rem;
    color: var(--text-muted);
}

.cl-pg-divider {
    height: 1px;
    margin: 0.3rem 0.5rem;
    background: var(--border-dark);
}

.cl-pg-extra {
    margin: 0.15rem 0 0.35rem 2.6rem;
}

/* Schalter in Rot statt Bootstrap-Blau (Bootstrap 5.3: Knopffarbe über --bs-form-switch-bg) */
.cl-switch .form-check-input:checked {
    border-color: var(--primary-color);
    background-color: var(--primary-color);
}

.cl-switch .form-check-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.3);
}

.cl-switch .form-check-input:focus:not(:checked) {
    --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23ff8a96'/%3e%3c/svg%3e");
}

/* ----- Feldsuche ----- */
.cl-search {
    position: relative;
    margin-bottom: 0.75rem;
}

.cl-search-icon {
    position: absolute;
    top: 50%;
    left: 0.8rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    transform: translateY(-50%);
    pointer-events: none;
}

.cl-search-input {
    width: 100%;
    padding: 0.5rem 0.8rem 0.5rem 2.2rem;
    border: 1px solid var(--border-dark);
    border-radius: 10px;
    background: var(--bg-dark);
    color: var(--text-light);
    font-size: 0.875rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cl-search-input::placeholder {
    color: var(--text-muted);
}

.cl-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.25);
}

/* ----- Datenkategorien ----- */
.cl-cat {
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-dark);
    border-radius: 12px;
    background: var(--bg-dark);
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cl-cat:hover {
    border-color: #555;
}

/* Roter Akzentstreifen, sobald Felder der Kategorie gewählt sind */
.cl-cat.is-active {
    border-color: rgba(220, 53, 69, 0.45);
    box-shadow: inset 3px 0 0 var(--primary-color);
}

.cl-cat-head {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0));
    color: var(--text-light);
    font-weight: 600;
    text-align: left;
    transition: background-color 0.15s ease;
}

.cl-cat-head:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

.cl-cat-head:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}

.cl-cat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    border-radius: 8px;
    background: rgba(220, 53, 69, 0.15);
    color: #ff6b7a;
}

.cl-cat-label {
    flex: 1;
}

.cl-cat-count {
    min-width: 1.6rem;
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.cl-cat.is-active .cl-cat-count {
    background: var(--primary-color);
    color: #fff;
}

.cl-cat-chevron {
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.cl-cat.is-open .cl-cat-chevron {
    transform: rotate(180deg);
}

/* Kategorien, die für die gewählten Gruppen meist leer sind, zurückhaltend darstellen */
.cl-cat.is-dimmed:not(.is-active) .cl-cat-icon {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
}

.cl-cat.is-dimmed:not(.is-active) .cl-cat-label {
    color: var(--text-muted);
}

.cl-cat-body {
    padding: 0.35rem 0.85rem 0.85rem;
    border-top: 1px solid var(--border-dark);
    animation: clSlideDown 0.18s ease;
}

@keyframes clSlideDown {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.cl-cat-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin: 0.4rem 0 0.1rem;
}

.cl-cat-hint {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.cl-cat-actions {
    display: flex;
    gap: 0.35rem;
    margin-left: auto;
}

.cl-mini-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.6rem;
    border: 1px solid var(--border-dark);
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.75rem;
    transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.cl-mini-btn:hover {
    border-color: var(--primary-color);
    background: rgba(220, 53, 69, 0.1);
    color: var(--text-light);
}

.cl-mini-btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Untergruppen-Überschrift mit auslaufender Trennlinie */
.cl-subgroup-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.75rem 0 0.3rem;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.cl-subgroup-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border-dark);
}

.cl-field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 2px 0.5rem;
}

.cl-field {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    margin: 0;
    padding: 0.35rem 0.5rem;
    border-radius: 8px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.cl-field:hover {
    background: rgba(255, 255, 255, 0.05);
}

.cl-field.is-checked {
    background: rgba(220, 53, 69, 0.1);
}

.cl-field .cl-check-box {
    margin-top: 0.12rem;
}

.cl-field-label {
    line-height: 1.3;
}

.cl-field-hint-icon {
    margin-left: 0.15rem;
    color: var(--text-muted);
    font-size: 0.72rem;
}

.cl-free-title {
    width: calc(100% - 2.1rem);
    margin: 0.1rem 0 0.35rem 2.1rem;
}

@media (prefers-reduced-motion: reduce) {
    .cl-cat-body {
        animation: none;
    }

    .cl-cat-chevron,
    .cl-check-box,
    .cl-check-box::after {
        transition: none;
    }
}

/* ========================================
   VORSCHAU
   ======================================== */

.cl-preview {
    border: 1px solid var(--border-dark);
    border-radius: 12px;
    background: #2a2a2a;
}

.cl-preview-toolbar,
.cl-preview-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.9rem;
    font-size: 0.875rem;
}

.cl-preview-toolbar {
    border-bottom: 1px solid var(--border-dark);
}

.cl-preview-footer {
    justify-content: flex-start;
    border-top: 1px solid var(--border-dark);
    color: var(--text-muted);
    font-size: 0.8rem;
}

.cl-zoom-value {
    min-width: 3.2rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.cl-preview-scroll {
    max-height: calc(100vh - 13rem);
    min-height: 20rem;
    overflow: auto;
    padding: 1.25rem;
}

.cl-preview-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8mm;
    transition: opacity 0.2s ease;
}

.cl-preview-stage.is-updating {
    opacity: 0.55;
}

.cl-preview-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    min-height: 18rem;
    color: var(--text-muted);
}

.cl-preview-empty .bi {
    font-size: 2.5rem;
}

/* Papier: nutzbare Fläche + 8 mm Rand wie im Druck */
.cl-paper {
    flex-shrink: 0;
    box-sizing: content-box;
    padding: 8mm;
    background: #fff;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}

.cl-paper.cl-portrait {
    width: 194mm;
    height: 281mm;
}

.cl-paper.cl-landscape {
    width: 281mm;
    height: 194mm;
}

/* Messansicht: im Layout vorhanden (messbar), aber unsichtbar und ohne Einfluss auf die Seitenhöhe */
.cl-measure {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    overflow: hidden;
    visibility: hidden;
    pointer-events: none;
}

/* Hinweis auf Mobilgeräten */
.cl-mobile-hint {
    max-width: 28rem;
    margin: 3rem auto;
    padding: 2rem 1.5rem;
    border: 1px solid var(--border-dark);
    border-radius: 12px;
    background: var(--bg-dark-secondary);
    text-align: center;
}

.cl-mobile-hint > .bi {
    display: block;
    margin-bottom: 0.75rem;
    color: var(--primary-color);
    font-size: 2.5rem;
}

.cl-mobile-hint h2 {
    font-size: 1.35rem;
}

.cl-mobile-hint p {
    color: var(--text-muted);
}

/* ========================================
   DRUCKBLATT (Vorschau, Druck, Messung)
   ======================================== */

.cl-sheet {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
    background: #fff;
    color: #212529;
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: var(--cl-font, 9pt);
    line-height: 1.25;
    text-align: left;
}

.cl-sheet-measure {
    overflow: visible;
}

/* Kopfbereich: Abstand zur Tabelle als Innenabstand, damit er mitgemessen wird */
.cl-head-wrap {
    flex-shrink: 0;
    padding-bottom: 3mm;
}

.cl-head {
    display: flex;
    align-items: center;
    gap: 5mm;
    padding-bottom: 2.5mm;
    border-bottom: 0.8mm solid #212529;
}

.cl-logo {
    flex-shrink: 0;
    height: 15mm;
    width: auto;
}

.cl-title-block {
    flex: 1;
    min-width: 0;
}

.cl-title {
    color: #212529;
    font-size: 17pt;
    font-weight: 700;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.cl-description {
    margin-top: 1mm;
    color: #555;
    font-size: 9.5pt;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.cl-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    min-width: 20mm;
    padding: 2mm 3.5mm;
    border-radius: 3mm;
    background: linear-gradient(135deg, #dc3545, #b02a37);
    color: #fff;
}

.cl-badge-count {
    font-size: 18pt;
    font-weight: 700;
    line-height: 1;
}

.cl-badge-label {
    margin-top: 0.8mm;
    font-size: 6.5pt;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* Tabelle */
.cl-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
}

.cl-table th {
    padding: 1.3mm 1.5mm;
    background: #343a40;
    color: #fff;
    font-size: calc(var(--cl-font, 9pt) - 0.5pt);
    font-weight: 600;
    text-align: left;
    vertical-align: bottom;
    overflow-wrap: anywhere;
    hyphens: auto;
}

.cl-table td {
    padding: 1.1mm 1.5mm;
    border-bottom: 0.2mm solid #dee2e6;
    vertical-align: top;
    overflow-wrap: anywhere;
    hyphens: auto;
}

.cl-table .cl-row-even td {
    background: #f8f9fa;
}

.cl-table .cl-center {
    text-align: center;
}

.cl-table .cl-right {
    text-align: right;
}

.cl-rownum {
    color: #6c757d;
}

.cl-warn {
    color: #b02a37;
    font-weight: 700;
}

.cl-table .cl-group-row td {
    padding-top: 1.6mm;
    padding-bottom: 1.2mm;
    border-bottom: 0.3mm solid #adb5bd;
    border-left: 1mm solid #dc3545;
    background: #e9ecef;
    font-weight: 700;
}

.cl-group-count,
.cl-group-cont {
    color: #6c757d;
    font-weight: 400;
}

/* Blazor entfernt Leerraum zwischen Elementen – Abstand daher per CSS */
.cl-group-cont {
    margin-left: 1.5mm;
    font-style: italic;
}

.cl-table .cl-empty td {
    padding: 8mm;
    color: #6c757d;
    font-style: italic;
    text-align: center;
}

/* Fußzeile: margin-top:auto drückt sie im Blatt fester Höhe nach unten */
.cl-foot-wrap {
    flex-shrink: 0;
    margin-top: auto;
    padding-top: 3mm;
}

.cl-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1.8mm;
    border-top: 0.3mm solid #dee2e6;
    color: #6c757d;
    font-size: 7.5pt;
}

.cl-foot-page {
    color: #343a40;
    font-weight: 600;
}

/* ========================================
   DRUCK
   Format und Ränder setzt CustomList.razor per <HeadContent> als
   seitenspezifische @page-Regel. Benannte Seiten (page: …) werden bewusst
   nicht verwendet: Der Wechsel des Seitennamens gegenüber dem vorangehenden
   Layout-Container (.sidebar) erzwingt sonst eine leere erste Druckseite.
   ======================================== */

@media print {
    /* Ein Blatt entspricht genau einer Druckseite */
    .cl-print-root .cl-sheet {
        break-after: page;
        page-break-after: always;
    }

    .cl-print-root .cl-sheet:last-child {
        break-after: auto;
        page-break-after: auto;
    }

    .cl-print-root .cl-sheet,
    .cl-print-root .cl-sheet * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}
