/*
 * astendo UI System
 * Verbindliche Basis fuer Buttons, Cards, Tabellen, Modals und Icons.
 * Siehe DESIGN.md fuer Regeln und Migrationsvorgaben.
 */

:root {
    --ui-color-primary: #dc3545;
    --ui-color-primary-hover: #bb2d3b;
    --ui-color-success: var(--bs-success);
    --ui-color-warning: var(--bs-warning);
    --ui-color-danger: var(--bs-danger);
    --ui-color-info: var(--bs-info);

    --ui-radius-sm: 0;
    --ui-radius-md: 0;
    --ui-radius-lg: 0;

    --ui-space-1: 4px;
    --ui-space-2: 8px;
    --ui-space-3: 12px;
    --ui-space-4: 16px;
    --ui-space-5: 24px;
    --ui-space-6: 32px;

    --ui-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --ui-shadow-md: 0 8px 24px rgba(0, 0, 0, 0.12);
    --ui-border-default: 1px solid var(--bs-border-color);

    --ui-glass-light-bg: rgba(255, 255, 255, 0.85);
    --ui-glass-dark-bg: rgba(42, 52, 71, 0.85);
}

[data-bs-theme="dark"] {
    --ui-shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.25);
    --ui-shadow-md: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* Buttons */
.btn {
    border-radius: var(--ui-radius-sm);
    font-weight: 600;
}

.btn-sm {
    border-radius: var(--ui-radius-sm);
}

.btn-lg {
    border-radius: var(--ui-radius-md);
}

.btn-primary,
.btn-danger {
    background-color: var(--ui-color-primary);
    border-color: var(--ui-color-primary);
}

.btn-primary:hover,
.btn-danger:hover,
.btn-primary:focus,
.btn-danger:focus {
    background-color: var(--ui-color-primary-hover);
    border-color: var(--ui-color-primary-hover);
}

.btn:focus-visible {
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

/* Icons */
iconify-icon,
.btn i,
.btn iconify-icon {
    vertical-align: middle;
}

.ui-icon-sm {
    font-size: 0.875rem;
}

.ui-icon-md {
    font-size: 1rem;
}

.ui-icon-lg {
    font-size: 1.25rem;
}

/* Cards */
.card {
    border: var(--ui-border-default);
    border-radius: var(--ui-radius-md);
    box-shadow: var(--ui-shadow-sm);
}

.card-header,
.card-footer {
    border-color: var(--bs-border-color);
}

/* Stat cards (global, verbindlich) */
html body .stat-card-filter {
    cursor: pointer;
    border-radius: var(--ui-radius-md);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

html body .stat-card-filter > .card-body .me-3 {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

html body .stat-card-filter iconify-icon,
html body .stat-card-filter .card-body .me-3 i {
    display: block;
    line-height: 1;
}

/* Stat Card Figma-Layout (vertikal)
 * Figma StatCard.tsx: p-2.5, bg-muted/50, w-5 h-5 Icon
 * text-xs uppercase tracking-wide, text-2xl font-bold
 * ================================================================ */

/* Icon-Box */
.stat-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Verhaeltnis wie .btn-status-badge in den Tabellen: 32px Box, 16px Glyph */
    width: 32px;
    height: 32px;
    font-size: 1rem;
    line-height: 1;
    border-radius: var(--ui-radius-sm);
    background-color: var(--bs-secondary);
    color: #fff !important;
}

html body .stat-card-icon,
html body .stat-card-icon iconify-icon,
html body .stat-card-icon i {
    color: #fff !important;
}

/* Glyph verbindlich 16px in der 32px-Kachel - gleiches Verhaeltnis wie
 * .btn-status-badge in den Tabellen. !important schlaegt die Alt-Regeln,
 * die iconify-icon in Stat-Cards auf 2rem gesetzt haben. */
html body .stat-card-icon iconify-icon,
html body .stat-card-icon i {
    font-size: 1rem !important;
    width: 1rem;
    height: 1rem;
    line-height: 1;
}

html body .stat-card-icon.text-primary   { background-color: var(--ui-color-primary); }
html body .stat-card-icon.text-danger    { background-color: var(--bs-danger); }
html body .stat-card-icon.text-success   { background-color: var(--bs-success); }
html body .stat-card-icon.text-info      { background-color: var(--bs-info); }
html body .stat-card-icon.text-secondary { background-color: var(--bs-secondary); }
html body .stat-card-icon.text-warning   { background-color: var(--bs-warning); }
html body .stat-card-icon.text-dark      { background-color: var(--bs-dark); }
html body .stat-card-icon.text-muted     { background-color: var(--bs-secondary); }

/* Label: Figma → text-xs text-muted-foreground mb-1.5 font-medium uppercase tracking-wide */
.stat-card-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bs-secondary-color);
    margin-bottom: 0.125rem !important;
    font-weight: 500;
    line-height: 1;
}

/* Value: Figma → text-2xl font-bold */
.stat-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0 !important;
    padding-bottom: 0;
    line-height: 1;
}

html body .stat-card-filter.negated {
    border-style: dashed !important;
    border-color: var(--ui-color-warning);
}

/* DataTables */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    min-height: 36px;
    border-radius: var(--ui-radius-sm);
}

.dataTables_wrapper .dataTables_paginate .pagination .page-link {
    border-radius: var(--ui-radius-sm);
}

/* Keep DataTables within container width to avoid horizontal desktop scrollbars */
table.dataTable {
    width: 100% !important;
}

@media (min-width: 992px) {
    .table-responsive {
        overflow-x: hidden;
    }
}

/* Disable zebra striping globally (uniform table rows) */
html body .table.table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-accent-bg: transparent;
    background-color: transparent;
}

/* DataTable row accents: robust against striped row backgrounds */
table.dataTable tbody tr.dt-row-accent-success > td:first-child,
table.dataTable tbody tr.dt-row-accent-warning > td:first-child,
table.dataTable tbody tr.dt-row-accent-danger > td:first-child {
    position: relative;
}

table.dataTable tbody tr.dt-row-accent-success > td:first-child::before,
table.dataTable tbody tr.dt-row-accent-warning > td:first-child::before,
table.dataTable tbody tr.dt-row-accent-danger > td:first-child::before {
    content: "";
    position: absolute;
    left: 0;
    top: -1px;
    bottom: -1px;
    width: 4px;
    pointer-events: none;
}

table.dataTable tbody tr.dt-row-accent-success > td:first-child::before {
    background-color: var(--bs-success);
}

table.dataTable tbody tr.dt-row-accent-warning > td:first-child::before {
    background-color: var(--bs-warning);
}

table.dataTable tbody tr.dt-row-accent-danger > td:first-child::before {
    background-color: var(--bs-danger);
}

/* DataTable text colors: lesbare Farben auf Glassmorphism-Hintergrund */
/* !important damit Bootstrap-Defaults auf ALLEN Seiten überschrieben werden (Referenz: Hyper-V) */
table.dataTable tbody td,
table.dataTable tbody td *:not(.badge):not(i):not(iconify-icon):not(.btn) {
    color: #000 !important;
}

[data-bs-theme="dark"] table.dataTable tbody td,
[data-bs-theme="dark"] table.dataTable tbody td *:not(.badge):not(i):not(iconify-icon):not(.btn) {
    color: #fff !important;
}

/* Links in DataTables: gleiche Farbe, kein Underline (außer Hover) */
table.dataTable tbody a,
table.dataTable tbody a:hover,
table.dataTable tbody a:visited {
    color: #000 !important;
    text-decoration: none;
}

[data-bs-theme="dark"] table.dataTable tbody a,
[data-bs-theme="dark"] table.dataTable tbody a:hover,
[data-bs-theme="dark"] table.dataTable tbody a:visited {
    color: #fff !important;
    text-decoration: none;
}

table.dataTable tbody a:hover {
    text-decoration: underline;
}

table.dataTable tbody td small.text-muted,
table.dataTable tbody td .fst-italic.text-muted {
    color: var(--bs-secondary) !important;
}

table.dataTable tbody tr {
    background-color: transparent !important;
}

table.dataTable tbody tr:hover {
    background-color: rgba(220, 53, 69, 0.03) !important;
}

[data-bs-theme="dark"] table.dataTable tbody tr:hover {
    background-color: rgba(220, 53, 69, 0.08) !important;
}

/* Table Header (Figma: text-xs font-bold uppercase tracking-wider) */
.table thead th {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

/* DataTable Card: kompakter Abstand zwischen Header und Controls (global) */
.card > .card-body .dataTables_wrapper {
    padding: 0;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    padding: 0.25rem 0 0.5rem;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    padding: 0.5rem 0 0.25rem;
}

.dataTables_wrapper .dataTables_paginate .pagination .page-item.active .page-link {
    background-color: var(--ui-color-primary);
    border-color: var(--ui-color-primary);
}

/* Modals */
.modal-content {
    border: var(--ui-border-default);
    border-radius: var(--ui-radius-md);
    box-shadow: var(--ui-shadow-md);
}

.modal-header,
.modal-footer {
    border-color: var(--bs-border-color);
}

.modal-title {
    display: flex;
    align-items: center;
    gap: var(--ui-space-2);
}

.modal-footer .btn + .btn {
    margin-left: var(--ui-space-2);
}

/* (ui-modal-* classes removed - now using ast-modal-* from app-modal.css) */

/* Outline Buttons → Solid (Figma: keine Outline-Buttons) */
.btn-outline-primary {
    background-color: var(--bs-primary);
    color: #fff;
    border-color: var(--bs-primary);
}

.btn-outline-danger {
    background-color: var(--bs-danger);
    color: #fff;
    border-color: var(--bs-danger);
}

.btn-outline-success {
    background-color: var(--bs-success);
    color: #fff;
    border-color: var(--bs-success);
}

.btn-outline-warning {
    background-color: var(--bs-warning);
    color: #fff;
    border-color: var(--bs-warning);
}

.btn-outline-secondary {
    background-color: var(--bs-secondary);
    color: #fff;
    border-color: var(--bs-secondary);
}

.btn-outline-info {
    background-color: var(--bs-primary);
    color: #fff;
    border-color: var(--bs-primary);
}

/* Segmented radio groups: the filled outline buttons above would make every
   option look selected, so only the checked one gets the red fill. The
   !important answers app-custom.css, which fills .btn-outline-*:hover and
   .active with !important and loads later; these selectors are more specific
   (:not(:checked) lifts the light base to (0,3,0) above .active).
   Contrast pairs are checked in tests/js/segmentedChoiceCss.test.js. */
.btn-check:not(:checked) + .btn-outline-secondary,
.btn-check:not(:checked) + .btn-outline-primary {
    background-color: #ffffff !important;
    color: #111827 !important;
    border-color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .btn-check + .btn-outline-secondary,
[data-bs-theme="dark"] .btn-check + .btn-outline-primary {
    background-color: #334155 !important;
    color: #f1f5f9 !important;
    border-color: #475569 !important;
}

.btn-check:checked + .btn-outline-secondary,
.btn-check:checked + .btn-outline-primary {
    background-color: var(--ui-color-primary) !important;
    color: #ffffff !important;
    border-color: var(--ui-color-primary) !important;
}

/* app-custom.css fills .btn-outline-*:hover with !important and loads later;
   these selectors are more specific, so !important here wins. Checked hover
   comes after dark hover because both have the same specificity. */
.btn-check + .btn-outline-secondary:hover,
.btn-check + .btn-outline-primary:hover {
    background-color: #f1f5f9 !important;
    color: #111827 !important;
    border-color: #94a3b8 !important;
}

[data-bs-theme="dark"] .btn-check + .btn-outline-secondary:hover,
[data-bs-theme="dark"] .btn-check + .btn-outline-primary:hover {
    background-color: #3e4c63 !important;
    color: #f1f5f9 !important;
    border-color: #64748b !important;
}

.btn-check:checked + .btn-outline-secondary:hover,
.btn-check:checked + .btn-outline-primary:hover {
    background-color: var(--ui-color-primary-hover) !important;
    color: #ffffff !important;
    border-color: var(--ui-color-primary-hover) !important;
}

.btn-check:focus-visible + .btn-outline-secondary,
.btn-check:focus-visible + .btn-outline-primary {
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.35);
}

/* Autocomplete (AgentControls.entity): the clear button sits where Bootstrap
   draws the invalid icon; the red border and the message mark the state. */
.ast-entity .form-control.is-invalid {
    background-image: none;
}

/* Notify lists page (.ast-notify). The theme body grey (#98A4AE) and the
   global red "off" switch made this page unreadable; colours here are scoped
   and pinned by tests/js/notifyListsCss.test.js. Light rules must stay ahead
   of their dark twins, the test finds the first matching selector. */
.ast-notify .ast-notify-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    line-height: 1.35;
    color: #334155;
    background-color: #f1f5f9;
}

.ast-notify .ast-notify-panel {
    height: 100%;
    padding: 1.25rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
}

.ast-notify .ast-notify-panel-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.ast-notify .ast-notify-panel-head > div {
    flex: 1 1 auto;
    min-width: 0;
}

.ast-notify .ast-notify-state {
    flex-shrink: 0;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.35;
}

.ast-notify .ast-notify-state.is-on {
    color: #166534;
    background-color: #dcfce7;
}

.ast-notify .ast-notify-state.is-off {
    color: #334155;
    background-color: #f1f5f9;
}

.ast-notify .ast-notify-state.is-blocked {
    color: #92400e;
    background-color: #fef3c7;
}

.ast-notify .ast-notify-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.625rem;
    font-size: 1.25rem;
    color: #334155;
    background-color: #f1f5f9;
}

.ast-notify .ast-notify-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
}

.ast-notify .ast-notify-sub {
    margin: 0;
    font-size: 0.8125rem;
    color: #4b5563;
}

.ast-notify .form-check-label,
.ast-notify .ast-notify-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #4b5563;
}

.ast-notify .ast-notify-settings {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.ast-notify .ast-notify-setting {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
}

.ast-notify .ast-notify-setting-text {
    flex: 1 1 12rem;
    min-width: 0;
}

.ast-notify .ast-notify-setting-title {
    display: block;
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #111827;
}

.ast-notify .ast-notify-setting-hint {
    margin: 0;
    font-size: 0.8125rem;
    color: #4b5563;
}

.ast-notify .ast-notify-setting .form-check {
    margin-bottom: 0;
    padding-left: 2.5em;
    min-height: 0;
}

.ast-notify .ast-notify-setting .form-check-input {
    width: 2.25em;
    height: 1.25em;
    cursor: pointer;
}

.ast-notify .ast-notify-setting .invalid-feedback {
    flex-basis: 100%;
}

.ast-notify .ast-notify-recipients-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.ast-notify .ast-notify-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5rem;
    color: #1f2937;
    background-color: #e2e8f0;
}

.ast-notify .ast-notify-rows {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ast-notify .ast-notify-row {
    display: grid;
    grid-template-columns: auto minmax(0, 3fr) minmax(0, 2fr) auto;
    gap: 0.5rem 0.75rem;
    align-items: center;
}

.ast-notify .ast-notify-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #115e59;
    background-color: #ccfbf1;
}

.ast-notify .ast-notify-email,
.ast-notify .ast-notify-name {
    overflow-wrap: anywhere;
    font-size: 0.875rem;
}

.ast-notify .ast-notify-empty {
    margin: 0 0 0.5rem;
    font-size: 0.875rem;
    color: #4b5563;
}

.ast-notify .ast-notify-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 0;
    color: #475569;
    background-color: transparent;
}

.ast-notify .ast-notify-remove:hover,
.ast-notify .ast-notify-remove:focus-visible {
    color: #b91c1c;
    background-color: #fef2f2;
}

.ast-notify .ast-notify-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    border: 1px dashed #94a3b8;
    color: #334155;
    background-color: transparent;
}

.ast-notify .ast-notify-add {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    width: 100%;
    margin-top: 0.5rem;
    border: 1px dashed #94a3b8;
    color: #334155;
    background-color: transparent;
}

.ast-notify .ast-notify-add:hover,
.ast-notify .ast-notify-btn:hover {
    border-style: solid;
    background-color: #f1f5f9;
}

.ast-notify .ast-notify-revoke {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    border: 1px solid transparent;
    color: #b91c1c;
    background-color: transparent;
}

.ast-notify .ast-notify-revoke:hover {
    border-color: #fca5a5;
}

.ast-notify .ast-notify-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.ast-notify .ast-notify-dirty {
    font-size: 0.8125rem;
    color: #4b5563;
}

.ast-notify .ast-notify-footer.is-dirty .ast-notify-dirty {
    font-weight: 600;
    color: #b45309;
}

.ast-notify .ast-notify-optin {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: 0.5rem;
}

.ast-notify .ast-notify-optin.is-granted {
    color: #14532d;
    background-color: #f0fdf4;
    border-color: #86efac;
}

.ast-notify .ast-notify-optin.is-missing {
    color: #78350f;
    background-color: #fffbeb;
    border-color: #fcd34d;
}

.ast-notify .ast-notify-optin-icon {
    flex-shrink: 0;
    margin-top: 0.125rem;
    font-size: 1.25rem;
}

.ast-notify .ast-notify-optin-body {
    flex: 1 1 auto;
    min-width: 0;
}

.ast-notify .ast-notify-optin-title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
}

.ast-notify .ast-notify-optin-text {
    margin: 0;
    font-size: 0.8125rem;
    overflow-wrap: anywhere;
}

.ast-notify .ast-notify-optin .btn {
    flex-shrink: 0;
    align-self: center;
}

@media (max-width: 575.98px) {
    .ast-notify .ast-notify-row {
        grid-template-columns: auto minmax(0, 1fr) auto;
    }

    .ast-notify .ast-notify-row .ast-notify-avatar {
        grid-column: 1;
        grid-row: 1 / span 2;
    }

    .ast-notify .ast-notify-row [data-role="name"],
    .ast-notify .ast-notify-row .ast-notify-name {
        grid-column: 2;
        grid-row: 2;
    }

    .ast-notify .ast-notify-row .ast-notify-remove {
        grid-column: 3;
        grid-row: 1 / span 2;
    }

    .ast-notify .ast-notify-optin {
        flex-wrap: wrap;
    }
}

[data-bs-theme="dark"] .ast-notify .ast-notify-pill {
    color: #e2e8f0;
    background-color: #334155;
}

[data-bs-theme="dark"] .ast-notify .ast-notify-panel,
[data-bs-theme="dark"] .ast-notify .ast-notify-settings,
[data-bs-theme="dark"] .ast-notify .ast-notify-footer {
    border-color: #334155;
}

[data-bs-theme="dark"] .ast-notify .ast-notify-icon {
    color: #e2e8f0;
    background-color: #334155;
}

[data-bs-theme="dark"] .ast-notify .ast-notify-title {
    color: #f1f5f9;
}

[data-bs-theme="dark"] .ast-notify .ast-notify-sub {
    color: #cbd5e1;
}

[data-bs-theme="dark"] .ast-notify .form-check-label,
[data-bs-theme="dark"] .ast-notify .ast-notify-label {
    color: #cbd5e1;
}

[data-bs-theme="dark"] .ast-notify .ast-notify-empty {
    color: #cbd5e1;
}

[data-bs-theme="dark"] .ast-notify .ast-notify-count {
    color: #f1f5f9;
    background-color: #334155;
}

[data-bs-theme="dark"] .ast-notify .ast-notify-optin.is-granted {
    color: #bbf7d0;
    background-color: #14321f;
    border-color: #166534;
}

[data-bs-theme="dark"] .ast-notify .ast-notify-optin.is-missing {
    color: #fde68a;
    background-color: #3a2a0a;
    border-color: #92400e;
}

[data-bs-theme="dark"] .ast-notify .ast-notify-remove {
    color: #cbd5e1;
}

[data-bs-theme="dark"] .ast-notify .ast-notify-remove:hover,
[data-bs-theme="dark"] .ast-notify .ast-notify-remove:focus-visible {
    color: #fca5a5;
    background-color: #3b1d24;
}

[data-bs-theme="dark"] .ast-notify .ast-notify-add {
    color: #e2e8f0;
}

[data-bs-theme="dark"] .ast-notify .ast-notify-btn {
    color: #e2e8f0;
}

[data-bs-theme="dark"] .ast-notify .ast-notify-add:hover,
[data-bs-theme="dark"] .ast-notify .ast-notify-btn:hover {
    background-color: #334155;
}

[data-bs-theme="dark"] .ast-notify .ast-notify-revoke {
    color: #fca5a5;
}

[data-bs-theme="dark"] .ast-notify .ast-notify-state.is-on {
    color: #bbf7d0;
    background-color: #14532d;
}

[data-bs-theme="dark"] .ast-notify .ast-notify-state.is-off {
    color: #e2e8f0;
    background-color: #334155;
}

[data-bs-theme="dark"] .ast-notify .ast-notify-state.is-blocked {
    color: #fde68a;
    background-color: #451a03;
}

[data-bs-theme="dark"] .ast-notify .ast-notify-setting-title {
    color: #f1f5f9;
}

[data-bs-theme="dark"] .ast-notify .ast-notify-setting-hint {
    color: #cbd5e1;
}

[data-bs-theme="dark"] .ast-notify .ast-notify-dirty {
    color: #cbd5e1;
}

[data-bs-theme="dark"] .ast-notify .ast-notify-footer.is-dirty .ast-notify-dirty {
    color: #fcd34d;
}

[data-bs-theme="dark"] .ast-notify .ast-notify-avatar {
    color: #ccfbf1;
    background-color: #134e4a;
}

.ui-hidden {
    display: none;
}

/* Offcanvas */
.offcanvas {
    border-right: var(--ui-border-default);
}

/* Einheitliche Glasflaechen-Helfer */
.ui-glass {
    background: var(--ui-glass-light-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

[data-bs-theme="dark"] .ui-glass {
    background: var(--ui-glass-dark-bg);
}

/* =============================================================================
 * Footer (Design-System konform: eckig, border-radius: 0)
 * Volle Breite, border-top als Trenner, Theme-aware Farben
 * ============================================================================= */
.ast-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    margin-top: 2rem;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.ast-footer-content {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1.25rem;
    font-size: 0.75rem;
    color: var(--ast-text-muted, #b0b0b0);
    letter-spacing: 0.02em;
    background: var(--ast-card-bg, #37404a);
    border: 1px solid var(--bs-border-color);
}

[data-bs-theme="light"] .ast-footer-content {
    color: var(--ast-text-muted, #6c757d);
    background: var(--ast-card-bg, #ffffff);
}

.ast-footer-brand {
    font-weight: 600;
    color: var(--ast-text, #ffffff);
    opacity: 0.8;
}

[data-bs-theme="light"] .ast-footer-brand {
    color: var(--ast-text, #212529);
}

.ast-footer-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.ast-footer-icon {
    font-size: 0.85rem;
    opacity: 0.5;
}

.ast-footer-divider {
    width: 1px;
    height: 14px;
    background: var(--bs-border-color);
    opacity: 0.5;
}

/* =============================================================================
 * Scroll-to-Top Button (Figma App.tsx)
 * fixed bottom-6 right-6 p-3 bg-red-600 hover:bg-red-700 hover:scale-110
 * Smooth show/hide Animation statt d-none Toggle
 * ============================================================================= */
.ast-scroll-top {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 50;
    padding: 0.75rem;
    background: #dc3545;
    color: #fff;
    border: 1px solid rgba(220, 53, 69, 0.6);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    opacity: 0;
    visibility: hidden;
    transform: translateY(1rem);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.ast-scroll-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.ast-scroll-top:hover {
    background: #b02a37;
    transform: translateY(0) scale(1.1);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.ast-scroll-top iconify-icon {
    display: block;
}

/* =============================================================================
 * Tooltips (global, eckig wie Design-System)
 * ============================================================================= */
.tooltip.show {
    opacity: 1 !important;
}

.tooltip .tooltip-inner {
    background: #1e293b;
    color: #f1f5f9;
    font-size: 0.813rem;
    line-height: 1.5;
    padding: 0.5rem 0.75rem;
    border-radius: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    max-width: 350px;
    text-align: left;
}

.tooltip .tt-title {
    font-weight: 600;
    color: #fff;
}

.tooltip .tt-title + .tt-detail {
    margin-top: 4px;
}

.tooltip .tt-detail {
    color: #cbd5e1;
    font-size: 0.75rem;
    line-height: 1.4;
}

.tooltip .tt-detail + .tt-detail {
    margin-top: 2px;
}

[data-bs-theme="light"] .tooltip .tooltip-inner {
    background: #0f172a;
    color: #f8fafc;
}

.tooltip .tooltip-arrow::before {
    border-top-color: #1e293b !important;
}

.tooltip[data-popper-placement^="bottom"] .tooltip-arrow::before {
    border-bottom-color: #1e293b !important;
}

.tooltip[data-popper-placement^="left"] .tooltip-arrow::before {
    border-left-color: #1e293b !important;
}

.tooltip[data-popper-placement^="right"] .tooltip-arrow::before {
    border-right-color: #1e293b !important;
}

[data-bs-theme="light"] .tooltip .tooltip-arrow::before {
    border-top-color: #0f172a !important;
}

[data-bs-theme="light"] .tooltip[data-popper-placement^="bottom"] .tooltip-arrow::before {
    border-bottom-color: #0f172a !important;
}

[data-bs-theme="light"] .tooltip[data-popper-placement^="left"] .tooltip-arrow::before {
    border-left-color: #0f172a !important;
}

[data-bs-theme="light"] .tooltip[data-popper-placement^="right"] .tooltip-arrow::before {
    border-right-color: #0f172a !important;
}

/* =============================================================================
 * Notification Dropdown (Figma NotificationMenu.tsx)
 * w-96, bg-card/95, backdrop-blur, max-h-500
 * ============================================================================= */
.ast-notification-dropdown {
    width: 400px;
    max-height: 560px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--bs-border-color);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 0;
}

.ast-notification-dropdown.show {
    display: flex;
    flex-direction: column;
}

[data-bs-theme="dark"] .ast-notification-dropdown {
    background: rgba(30, 41, 59, 0.95);
}

.ast-notification-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--bs-border-color);
    background: rgba(0, 0, 0, 0.03);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

[data-bs-theme="dark"] .ast-notification-header {
    background: rgba(255, 255, 255, 0.03);
}

.ast-notification-header h6 {
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--bs-secondary-color);
}

.ast-notification-header-count {
    padding: 0 0.4375rem;
    border-radius: 999px;
    background: var(--bs-danger);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    line-height: 1.125rem;
    font-variant-numeric: tabular-nums;
}

.ast-notification-header-count.is-quiet {
    background: rgba(0, 0, 0, 0.08);
    color: var(--bs-secondary-color);
}

[data-bs-theme="dark"] .ast-notification-header-count.is-quiet {
    background: rgba(255, 255, 255, 0.12);
}

/* overflow-x hart aus: eine einzige nicht schrumpfbare Zeile wuerde sonst das
 * ganze Dropdown waagerecht rollbar machen */
.ast-notification-body {
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    max-height: 440px;
    padding: 0.25rem 0;
}

.ast-notification-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    padding-left: calc(1rem + 4px);
    text-decoration: none;
    color: inherit;
    transition: background-color 0.15s ease;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    position: relative;
}

.ast-notification-item.is-read {
    opacity: 0.55;
}

.ast-notification-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--bs-secondary);
}

.ast-notification-item.accent-danger::before {
    background: var(--bs-danger);
}

.ast-notification-item.accent-warning::before {
    background: var(--bs-warning);
}

.ast-notification-item.accent-success::before {
    background: var(--bs-success);
}

.ast-notification-item.accent-info::before {
    background: var(--bs-info);
}

[data-bs-theme="dark"] .ast-notification-item {
    border-bottom-color: rgba(255, 255, 255, 0.04);
}

.ast-notification-item:hover {
    background: rgba(0, 0, 0, 0.04);
    color: inherit;
    text-decoration: none;
}

[data-bs-theme="dark"] .ast-notification-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.ast-notification-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.ast-notification-icon.icon-warning {
    background: rgba(234, 179, 8, 0.1);
    color: #eab308;
    border: 1px solid rgba(234, 179, 8, 0.2);
}

.ast-notification-icon.icon-success {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.ast-notification-icon.icon-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.ast-notification-icon.icon-info {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.ast-notification-title {
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 0.125rem;
    line-height: 1.3;
}

.ast-notification-text {
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
    margin: 0;
    line-height: 1.4;
}

.ast-notification-time {
    font-size: 0.6875rem;
    color: var(--bs-secondary-color);
    opacity: 0.6;
    white-space: nowrap;
    flex-shrink: 0;
}

.ast-notification-section + .ast-notification-section {
    border-top: 1px solid rgba(0, 0, 0, 0.07);
}

[data-bs-theme="dark"] .ast-notification-section + .ast-notification-section {
    border-top-color: rgba(255, 255, 255, 0.08);
}

.ast-notification-section-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.4375rem 0.75rem;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    text-align: left;
}

.ast-notification-section-head:hover {
    background: rgba(0, 0, 0, 0.03);
}

[data-bs-theme="dark"] .ast-notification-section-head:hover {
    background: rgba(255, 255, 255, 0.05);
}

.ast-notification-section-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Dringlichkeitszeichen: gleiche Chips wie in der Befundtafel, dort ueber
 * severityGlyph() in app-common.js erzeugt */
.findings-sev {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 1.5rem;
    padding: 0 0.375rem;
    border-radius: 0.375rem;
    border: 1px solid transparent;
    font-size: 0.8125rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.05em;
}

.findings-sev--now {
    background: var(--bs-danger);
    color: #fff;
}

.findings-sev--soon {
    background: var(--bs-warning);
    color: #1c1c1c;
}

/* weisser Chip auch im Dark Mode - deshalb feste Vordergrundfarbe, sonst
 * verschwindet das Icon in der hellen Dark-Mode-Textfarbe */
.findings-sev--watch {
    background: #fff;
    color: #5a6a85;
    border-color: rgba(0, 0, 0, 0.15);
    letter-spacing: 0;
}

.findings-sev--watch iconify-icon {
    font-size: 0.9375rem;
}

.findings-sev--unknown {
    background: var(--bs-secondary-bg);
    color: var(--bs-secondary-color);
}

.ast-notification-section-head .findings-sev {
    flex: 0 0 auto;
    min-width: 1.625rem;
    height: 1.125rem;
    padding: 0 0.3125rem;
    border-radius: 0.25rem;
    font-size: 0.6875rem;
}

.ast-notification-section-head .findings-sev--watch iconify-icon {
    font-size: 0.8125rem;
}

/* Zaehler als Pille: rechte Kante bleibt damit auf allen Ebenen buendig */
.ast-notification-count {
    flex: 0 0 auto;
    min-width: 1.5rem;
    padding: 0 0.375rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.06);
    color: var(--bs-body-color);
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.25rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

[data-bs-theme="dark"] .ast-notification-count {
    background: rgba(255, 255, 255, 0.1);
}

.ast-notification-section.accent-danger .ast-notification-section-head .ast-notification-count {
    background: var(--bs-danger-bg-subtle);
    color: var(--bs-danger-text-emphasis);
}

.ast-notification-section.accent-warning .ast-notification-section-head .ast-notification-count {
    background: var(--bs-warning-bg-subtle);
    color: var(--bs-warning-text-emphasis);
}

/* Falten ohne Neuaufbau: der Pfeil ist reines CSS, weil ein neu erzeugtes
   iconify-Element auf die Icon-Aufloesung wartet */
.ast-notification-chevron {
    flex: 0 0 auto;
    width: 0.4375rem;
    height: 0.4375rem;
    margin-left: 0.125rem;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.12s ease;
    opacity: 0.45;
}

.ast-notification-section:not(.is-collapsed) .ast-notification-section-head .ast-notification-chevron,
.ast-notification-group-wrap.is-open .ast-notification-group .ast-notification-chevron {
    transform: rotate(45deg);
}

.ast-notification-section.is-collapsed .ast-notification-section-body,
.ast-notification-group-wrap:not(.is-open) .ast-notification-group-body {
    display: none;
}

/* Farbschiene statt Einrueckung: die Zugehoerigkeit zur Stufe bleibt sichtbar,
 * ohne dass jede Ebene Platz nach rechts kostet */
.ast-notification-section-body {
    padding-left: 0.75rem;
    border-left: 2px solid transparent;
    margin-left: 0.75rem;
}

.ast-notification-section.accent-danger .ast-notification-section-body {
    border-left-color: var(--bs-danger-border-subtle);
}

.ast-notification-section.accent-warning .ast-notification-section-body {
    border-left-color: var(--bs-warning-border-subtle);
}

.ast-notification-section.accent-info .ast-notification-section-body {
    border-left-color: var(--bs-border-color);
}

.ast-notification-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.3125rem 0.75rem 0.3125rem 0.25rem;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 0.8125rem;
    text-align: left;
}

.ast-notification-group:hover {
    background: rgba(0, 0, 0, 0.03);
}

[data-bs-theme="dark"] .ast-notification-group:hover {
    background: rgba(255, 255, 255, 0.05);
}

.ast-notification-group-label {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ast-notification-group-body {
    padding-bottom: 0.25rem;
}

/* Zwei Zeilen pro Befund: Objekt oben, Kunde unten. Vorher standen Objekt und
 * Kunde nebeneinander und beide waren nowrap - das erzwang den waagerechten
 * Rollbalken im Dropdown */
.ast-notification-subitem {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem 0.25rem 1.25rem;
    text-decoration: none;
    color: inherit;
    border-radius: 0.25rem;
}

.ast-notification-subitem:hover {
    background: rgba(0, 0, 0, 0.04);
    color: inherit;
}

[data-bs-theme="dark"] .ast-notification-subitem:hover {
    background: rgba(255, 255, 255, 0.06);
}

.ast-notification-subitem-main {
    flex: 1;
    min-width: 0;
}

.ast-notification-subitem-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ast-notification-subitem-meta {
    display: block;
    color: var(--bs-secondary-color);
    font-size: 0.6875rem;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ast-notification-subitem-side {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding-top: 0.0625rem;
}

.ast-notification-age {
    color: var(--bs-secondary-color);
    font-size: 0.6875rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.ast-notification-ack {
    padding: 0 0.3125rem;
    border-radius: 999px;
    background: var(--bs-success-bg-subtle);
    color: var(--bs-success-text-emphasis);
    font-size: 0.625rem;
    font-weight: 600;
    line-height: 1rem;
    white-space: nowrap;
}

.ast-notification-more {
    display: block;
    padding: 0.25rem 0.75rem 0.375rem 1.25rem;
    color: var(--bs-primary);
    font-size: 0.6875rem;
    text-decoration: none;
}

.ast-notification-more:hover {
    text-decoration: underline;
}

.ast-notification-empty {
    padding: 2rem 1rem;
    text-align: center;
}

.ast-notification-empty iconify-icon {
    font-size: 2.5rem;
    color: var(--bs-success);
    margin-bottom: 0.5rem;
    display: block;
}

.ast-notification-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--bs-border-color);
    background: rgba(0, 0, 0, 0.03);
    color: var(--bs-secondary-color);
    font-size: 0.6875rem;
    flex-shrink: 0;
}

.ast-notification-footer-link {
    color: var(--bs-primary);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.ast-notification-footer-link:hover {
    text-decoration: underline;
}

[data-bs-theme="dark"] .ast-notification-footer {
    background: rgba(255, 255, 255, 0.03);
}

/* =============================================================================
 * PWA Install Button (Figma App.tsx)
 * bg-red-600 hover:bg-red-700 px-4 py-2 text-white
 * ============================================================================= */
.ast-pwa-install {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #dc3545;
    color: #fff;
    border: none;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
    white-space: nowrap;
}

.ast-pwa-install:hover {
    background: #b02a37;
    color: #fff;
}

.ast-pwa-install iconify-icon {
    font-size: 1rem;
}

/* =============================================================================
   Inbox-Kacheln (Mails / Tickets) - Dashboard und Fallboard
   ============================================================================= */
.card.dash-inbox-card {
    border: none !important;
    overflow: hidden;
    padding: 0 !important;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s;
}

.card.dash-inbox-card .card-body {
    padding: 0 !important;
}

.dash-inbox-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(220, 53, 69, .35);
}

.dash-inbox-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    height: 100%;
}

.dash-inbox-cell {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1.5rem .5rem;
    background: #198754;
    border-right: 1px solid rgba(255, 255, 255, .3);
    transition: background .3s;
}

.dash-inbox-cell:last-child {
    border-right: none;
}

.dash-inbox-cell.cell-danger {
    background: #dc3545;
}

.dash-inbox-cell.cell-warning {
    background: #e67e22;
}

.dash-inbox-label {
    color: rgba(255, 255, 255, .7);
    font-size: .75rem;
    text-align: center;
}

.dash-inbox-value {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
}

.dash-inbox-icon {
    font-size: 1.5rem;
    color: rgba(255, 255, 255, .85);
}

/* =============================================================================
   Inbox-Liste (Mails / Tickets) - Dashboard und Fallboard
   ============================================================================= */
.inbox-list-item { padding: .75rem 1rem; border-bottom: 1px solid #e5e7eb; }
.inbox-list-item:last-child { border-bottom: none; }
.inbox-list-header { display: flex; justify-content: space-between; align-items: center; }
.inbox-list-sender { display: flex; align-items: center; gap: .5rem; }
.inbox-list-avatar { font-size: 1.25rem; color: #6c757d; background: #e9ecef; padding: .35rem; border-radius: 8px; }
.inbox-list-sender-info { display: flex; flex-direction: column; }
.inbox-list-from-name { font-weight: 600; font-size: .875rem; color: #111827; }
.inbox-list-from-email { font-size: .75rem; color: #6c757d; }
.inbox-list-date { font-size: .75rem; color: #6c757d; white-space: nowrap; }
.inbox-list-subject { font-size: .85rem; color: #374151; margin-top: .35rem; font-weight: 500; }
.inbox-list-preview { font-size: .8rem; color: #6b7280; margin-top: .25rem; }
.inbox-list-link { font-size: .8rem; display: inline-block; margin-top: .35rem; color: #dc3545; text-decoration: none; }
.inbox-list-link:hover { text-decoration: underline; }
.inbox-ticket-overdue .inbox-list-date { color: #dc3545; font-weight: 600; }

[data-bs-theme="dark"] .inbox-list-item { border-color: #334155; }
[data-bs-theme="dark"] .inbox-list-from-name,
[data-bs-theme="dark"] .inbox-list-subject { color: #e2e8f0; }
[data-bs-theme="dark"] .inbox-list-preview { color: #94a3b8; }
[data-bs-theme="dark"] .inbox-list-avatar { background: #334155; color: #94a3b8; }
