/* ═══════════════════════════════════════════════════════════════
   UI Polish — vereinheitlichte Buttons, bessere Tables,
   softere Cards, modernere Forms
   ═══════════════════════════════════════════════════════════════ */

/* ── Accessibility: visible focus on ALL interactive elements ── */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
[tabindex]:not([tabindex="-1"]):focus-visible,
.nav-link:focus-visible,
.dropdown-item:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 4px;
}
[data-theme="dark"] a:focus-visible,
[data-theme="dark"] button:focus-visible,
[data-theme="dark"] [role="button"]:focus-visible,
[data-theme="dark"] [tabindex]:not([tabindex="-1"]):focus-visible,
[data-theme="dark"] .nav-link:focus-visible,
[data-theme="dark"] .dropdown-item:focus-visible {
    outline-color: #6ea8fe;
}

/* Skip-to-content link (keyboard-only users) */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #18181b;
    color: #fff;
    padding: 8px 16px;
    z-index: 2000;
    text-decoration: none;
    font-weight: 500;
    transition: top 0.15s ease;
}
.skip-link:focus {
    top: 0;
    color: #fff;
}

/* Screen reader only text */
.visually-hidden,
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0,0,0,0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .btn:hover:not(:disabled):not(.disabled) {
        transform: none !important;
    }
}

/* Disabled state clarity (Material-style) */
.btn:disabled, .btn.disabled,
button:disabled, input:disabled, select:disabled, textarea:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Larger, comfortable touch targets on mobile */
@media (pointer: coarse) {
    .btn-sm {
        min-height: 36px;
        padding: 0.4rem 0.75rem;
    }
    .table tbody tr td:last-child .btn {
        opacity: 1;  /* always visible on touch devices (no hover) */
    }
}


/* ── General typography ── */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.01em;
}

h2 {
    margin-bottom: 1.25rem;
}

/* ═══ 1. BUTTONS ═══════════════════════════════════════════════ */

.btn {
    font-weight: 500;
    letter-spacing: 0.01em;
    border-radius: 8px;
    transition: transform 0.1s ease, box-shadow 0.2s ease, background-color 0.15s ease, border-color 0.15s ease;
    border-width: 1.5px;
}

.btn:hover:not(:disabled):not(.disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}

.btn:active:not(:disabled):not(.disabled) {
    transform: translateY(0);
}

.btn-sm {
    border-radius: 6px;
    font-size: 0.825rem;
    padding: 0.3rem 0.65rem;
}

.btn-lg {
    border-radius: 10px;
}

/* Primary = main action — stärker hervorgehoben */
.btn-primary {
    box-shadow: 0 1px 3px rgba(13, 110, 253, 0.25);
}

/* Secondary/Outline-Buttons dezenter */
.btn-outline-secondary {
    border-color: #d0d5dd;
    color: #475467;
}
.btn-outline-secondary:hover {
    background-color: #f3f4f6;
    border-color: #9ba5b3;
    color: #1f2937;
}

/* Destructive actions — rote Outline statt gefüllt */
.btn-danger {
    box-shadow: 0 1px 3px rgba(220, 53, 69, 0.2);
}

/* Icon + Text Abstand */
.btn > i + *,
.btn > * + i { margin-left: 0.4rem; }

/* ═══ 2. TABLES ════════════════════════════════════════════════ */

.table {
    --bs-table-bg: transparent;
}

.table thead th,
.table thead td {
    background-color: #f8f9fb;
    color: #475467;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid #e5e7eb;
    padding: 0.75rem 0.85rem;
}

.table.table-dark thead th,
.table.table-dark thead td {
    background-color: #2c3040;
    color: #cbd5e1;
    border-bottom-color: #3f4358;
}

.table tbody tr {
    transition: background-color 0.12s ease;
}

.table tbody td {
    padding: 0.7rem 0.85rem;
    vertical-align: middle;
    border-bottom: 1px solid #f3f4f6;
}

/* Softer zebra */
.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: #fafbfc;
    --bs-table-striped-bg: #fafbfc;
}

/* Subtle hover */
.table-hover > tbody > tr:hover > * {
    background-color: #f3f7fc !important;
    --bs-table-hover-bg: #f3f7fc;
}

/* Sticky Navbar */
body > header {
    position: sticky;
    top: 0;
    z-index: 1030;
    background-color: #fff;
}
[data-theme="dark"] body > header {
    background-color: #1a1d23;
}

/* Action-Spalten-Buttons: dezenter, sichtbarer bei Row-Hover */
.table tbody tr td:last-child .btn {
    opacity: 0.75;
    transition: opacity 0.15s ease, transform 0.1s ease, box-shadow 0.2s ease;
}
.table tbody tr:hover td:last-child .btn {
    opacity: 1;
}

/* Clickable rows — Cursor + Akzent */
.table tbody tr[data-href] {
    cursor: pointer;
}

/* ═══ 3. CARDS ═════════════════════════════════════════════════ */

.card {
    border: 1px solid #eef0f3;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02), 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03), 0 4px 16px rgba(0, 0, 0, 0.06);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid #eef0f3;
    padding: 0.9rem 1.25rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

/* KPI-Kacheln nicht mit Hover-Shadow beissen (wenn welche da sind) */
.stapf-tile { box-shadow: none; }
.stapf-tile:hover { box-shadow: 0 6px 20px rgba(0,0,0,.1); }

/* ═══ 4. FORMS ═════════════════════════════════════════════════ */

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #475467;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.35rem;
}

.form-control, .form-select {
    border-radius: 8px;
    border-color: #d0d5dd;
    padding: 0.5rem 0.75rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:hover:not(:focus):not(:disabled),
.form-select:hover:not(:focus):not(:disabled) {
    border-color: #9ba5b3;
}

.form-control:focus, .form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-control.form-control-lg, .form-select.form-select-lg {
    border-radius: 10px;
}

/* Floating Label Polish (für Seiten die .form-floating nutzen) */
.form-floating > label {
    color: #6b7280;
    font-weight: 500;
}
.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label {
    color: #3b82f6;
    font-weight: 600;
    font-size: 0.75rem;
}

/* Checkbox/Radio dezenter */
.form-check-input {
    border-color: #cbd5e1;
}
.form-check-input:checked {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

/* ═══ BADGES ═══════════════════════════════════════════════════ */

.badge {
    font-weight: 600;
    padding: 0.35em 0.65em;
    border-radius: 6px;
    letter-spacing: 0.02em;
}

/* ═══ BREADCRUMBS ══════════════════════════════════════════════ */

.breadcrumb {
    background-color: transparent;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.breadcrumb-item {
    color: #9ca3af;
}

.breadcrumb-item a {
    color: #6b7280;
    text-decoration: none;
    transition: color 0.15s ease;
}

.breadcrumb-item a:hover {
    color: #3b82f6;
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: #374151;
    font-weight: 500;
}

/* ═══ ALERTS ═══════════════════════════════════════════════════ */

.alert {
    border-radius: 10px;
    border: none;
    padding: 0.85rem 1.1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.alert-success {
    background-color: #ecfdf5;
    color: #047857;
}
.alert-danger {
    background-color: #fef2f2;
    color: #b91c1c;
}
.alert-warning {
    background-color: #fffbeb;
    color: #92400e;
}
.alert-info {
    background-color: #eff6ff;
    color: #1e40af;
}
.alert-secondary {
    background-color: #f8f9fa;
    color: #475467;
}

/* ═══ MODAL ════════════════════════════════════════════════════ */

.modal-content {
    border: none;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.modal-header {
    border-bottom-color: #eef0f3;
    padding: 1rem 1.25rem;
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    border-top-color: #eef0f3;
    padding: 0.9rem 1.25rem;
}

/* ═══ DARK MODE OVERRIDES ═════════════════════════════════════ */

[data-theme="dark"] .card {
    border-color: var(--dm-border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
}
[data-theme="dark"] .card:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .card-header {
    border-bottom-color: var(--dm-border);
}

[data-theme="dark"] .table thead th,
[data-theme="dark"] .table thead td {
    background-color: #2c3040 !important;
    color: #94a3b8;
    border-bottom-color: #3f4358;
}
[data-theme="dark"] .table tbody td {
    border-bottom-color: #2f323a;
}
[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: #262932 !important;
    --bs-table-striped-bg: #262932;
}
[data-theme="dark"] .table-hover > tbody > tr:hover > * {
    background-color: #2f323a !important;
    --bs-table-hover-bg: #2f323a;
}

[data-theme="dark"] .form-label {
    color: #94a3b8;
}
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    border-color: #3f4358 !important;
}
[data-theme="dark"] .form-control:hover:not(:focus),
[data-theme="dark"] .form-select:hover:not(:focus) {
    border-color: #52566b !important;
}
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    border-color: #6ea8fe !important;
    box-shadow: 0 0 0 3px rgba(110, 168, 254, 0.2) !important;
}

[data-theme="dark"] .btn-outline-secondary {
    border-color: #52566b;
    color: #cbd5e1;
}
[data-theme="dark"] .btn-outline-secondary:hover {
    background-color: #2f323a;
    border-color: #6b7085;
    color: #fff;
}

[data-theme="dark"] .alert-success { background-color: #0f2e22; color: #6ee7b7; }
[data-theme="dark"] .alert-danger  { background-color: #2e1414; color: #fca5a5; }
[data-theme="dark"] .alert-warning { background-color: #2e2410; color: #fcd34d; }
[data-theme="dark"] .alert-info    { background-color: #0f1e36; color: #93c5fd; }
[data-theme="dark"] .alert-secondary { background-color: #22252b; color: #cbd5e1; }

[data-theme="dark"] .breadcrumb-item { color: #6b7280; }
[data-theme="dark"] .breadcrumb-item a { color: #94a3b8; }
[data-theme="dark"] .breadcrumb-item a:hover { color: #6ea8fe; }
[data-theme="dark"] .breadcrumb-item.active { color: #cbd5e1; }

[data-theme="dark"] .modal-content {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
