/*
 * 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: Figma → p-2.5 bg-muted/50 + getStatusColor() auf Text */
.stat-card-icon {
    padding: 0.625rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    line-height: 1;
    background-color: rgba(45, 53, 72, 0.5);
}

[data-bs-theme="light"] .stat-card-icon {
    background-color: rgba(233, 236, 239, 0.5);
}

/* 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);
}

.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: 384px;
    max-height: 500px;
    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.875rem;
    font-weight: 600;
}

.ast-notification-body {
    overflow-y: auto;
    flex: 1;
    max-height: 380px;
}

.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::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-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 {
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--bs-border-color);
    background: rgba(0, 0, 0, 0.03);
    flex-shrink: 0;
}

[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;
}
