/* =========================================
   EazyMail UI System
   Zentrale Design-Definition für konsistentes UI
   (Adapted from WireBuddy UI System)
   ========================================= */

/* =========================
     DESIGN TOKENS
========================= */
:root {
    /* === UNIFIED DESIGN TOKENS === */
    --color-primary: #0A2A66;
    --color-primary-hover: #081f4d;
    --color-success: #16a34a;
    --color-danger: #dc2626;
    --color-warning: #d97706;
    --color-info: #2563eb;
    --color-neutral: #6b7280;

    --bg-primary: #f4f7fb;
    --bg-secondary: #eef3f9;
    --bg-card: #ffffff;
    --bg-input: #ffffff;

    --text-primary: #0b1f3a;
    --text-secondary: #243b5a;
    --text-muted: #6b7c93;
    --text-strong: #0b1f3a;

    --border: rgba(15, 23, 42, 0.12);
    --border-hover: rgba(15, 23, 42, 0.22);

    /* Compatibility aliases used across existing styles */
    --bg: var(--bg-primary);
    --text: var(--text-primary);
    --muted: var(--text-muted);
    --card-bg: var(--bg-card);

    /* Spacing System (UI-Lint: VERTICAL_GAP 22-26px, target: 24px) */
    --space-1: 6px;
    --space-2: 12px;
    --space-3: 24px;
    --space-4: 32px;
    --space-5: 40px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;

    --wb-space-1: 6px;
    --wb-space-2: 12px;
    --wb-space-3: 24px;
    --wb-space-4: 32px;
    --wb-space-5: 40px;
    --wb-space-inline-mobile: 16px;
    --wb-space-inline-desktop: 32px;
    --wb-space-card-y: 16px;
    --wb-space-card-x: 24px;
    --wb-space-row: 16px;
    --wb-space-table-y: 12px;
    --wb-space-table-x: 16px;
    --wb-space-1: var(--space-1);
    --wb-space-2: var(--space-2);
    --wb-space-3: var(--space-3);
    --wb-space-4: var(--space-4);
    --wb-space-5: var(--space-5);

    /* Layout: Footer height for padding calculations (set via JS if dynamic) */
    --em-footer-height: 48px;

    /* Focus */
    --focus-ring: 0 0 0 3px rgba(10, 42, 102, 0.15);

    /* Z-index system */
    --z-navbar: 1040;
    --z-backdrop: 1050;
    --z-modal: 1055;
    --z-toast: 2000;

    /* === ANIMATION SYSTEM === */
    --anim-fast: 120ms ease;
    --anim-normal: 200ms ease;
    --anim-slow: 320ms ease;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in: cubic-bezier(0.4, 0, 1, 1);

    /* Typography */
    --wb-font-xs: 0.75rem;
    --wb-font-base: 0.875rem;
    --wb-font-sm: 0.75rem;
    --wb-font-lg: 1rem;
    --wb-font-xl: 1.25rem;
    --wb-font-2xl: 1.5rem;
    --wb-font-label: 0.8125rem;
    --wb-font-table-head: 0.6875rem;
    --wb-font-table-cell: 0.8125rem;

    /* Heading system */
    --wb-heading-page: 1.25rem;
    --wb-heading-section: 1.1rem;
    --wb-heading-card: 0.95rem;
    --wb-heading-weight: 600;
    --wb-heading-shadow: 0 1px 0 rgba(255, 255, 255, 0.6), 0 1px 2px rgba(15, 23, 42, 0.06);

    /* Radius */
    --wb-radius-sm: 6px;
    --wb-radius-md: 10px;
    --wb-radius-lg: 12px;

    /* Shadows */
    --wb-shadow-1: 0 4px 12px rgba(0, 0, 0, 0.06);
    --wb-shadow-2: 0 8px 20px rgba(0, 0, 0, 0.08);

    /* Muted backgrounds */
    --wb-muted-bg: rgba(15, 23, 42, 0.04);
    --wb-hover-bg: rgba(10, 42, 102, 0.04);

    /* Transitions (specific for better performance) */
    --wb-transition-shadow: box-shadow 0.2s ease;
    --wb-transition-bg: background-color 0.2s ease;
    --wb-transition-transform: transform 0.2s ease;
}

@media (min-width: 992px) {
    :root {
        --wb-font-table-head: 0.75rem;
        --wb-font-table-cell: 0.875rem;
    }
}

[data-bs-theme="dark"] {
    --bg-primary: #182130;
    --bg-secondary: #202b3d;
    --bg-card: #1f2937;
    --bg-input: #243248;

    --text-primary: #e4ebf5;
    --text-secondary: #b3bfd0;
    --text-muted: #90a0b5;
    --text-strong: #f0f4f8;

    --border: rgba(148, 163, 184, 0.14);
    --border-hover: rgba(148, 163, 184, 0.24);

    --bg: var(--bg-primary);
    --text: var(--text-primary);
    --muted: var(--text-muted);
    --card-bg: var(--bg-card);

    --wb-shadow-1: 0 2px 8px rgba(0, 0, 0, 0.55);
    --wb-shadow-2: 0 4px 18px rgba(0, 0, 0, 0.65);
    --wb-muted-bg: rgba(255, 255, 255, 0.06);
    --wb-hover-bg: rgba(255, 255, 255, 0.04);
    --wb-heading-shadow: 0 1px 0 rgba(0, 0, 0, 0.24), 0 1px 2px rgba(0, 0, 0, 0.22);

    /* Semantic color tokens — dark mode variants */
    --color-primary: #8cb7ff;
    --color-success: #22c55e;
    --color-danger: #f87171;
    --color-warning: #fbbf24;
    --color-info: #60a5fa;
    --color-neutral: #9ca3af;
}

body {
    background: var(--bg);
    color: var(--text);
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

/* =========================
     APP SHELL
========================= */
.main-content {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.content-area {
    flex: 1 1 auto;
    min-width: 0;
    padding: var(--wb-space-3);
}

.sidebar {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
}

.sidebar-footer {
    margin-top: auto;
}

/* =========================
     TOP BAR (FIXED)
========================= */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 20px;
    background: var(--card-bg);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--border);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* =========================
     CARD / TABLE
========================= */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
}

.data-table tr {
    border-bottom: 1px solid var(--border);
}

.data-table {
    table-layout: fixed;
    width: 100%;
    overflow: hidden;
}

@media (min-width: 769px) {
    .data-table th,
    .data-table td {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* Responsive table card layout (shared across pages) */
@media (max-width: 768px) {
    .responsive-table thead {
        display: none;
    }

    .responsive-table {
        border: none;
        overflow-x: hidden;
    }

    .responsive-table tbody {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .responsive-table tr {
        display: block;
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm, var(--wb-radius-md));
        padding: 10px 12px;
        overflow: hidden;
        min-height: 72px;
        contain: layout paint;
    }

    .responsive-table td {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        padding: 3px 0;
        border: none;
        align-items: flex-start;
        overflow-wrap: anywhere;
        word-break: break-word;
        width: 100%;
    }

    .responsive-table td::before {
        content: attr(data-label);
        font-weight: 500;
        color: var(--text-muted);
        flex-shrink: 0;
        width: 110px;
    }

    .responsive-table td > * {
        min-width: 0;
        text-align: right;
    }

    .responsive-table td[data-label="Domain"],
    .responsive-table td[data-label="Email"] {
        flex-direction: column;
        align-items: flex-start;
    }

    .responsive-table td[data-label="Domain"]::before,
    .responsive-table td[data-label="Email"]::before {
        display: none;
    }

    .responsive-table td[data-label="Domain"] > *,
    .responsive-table td[data-label="Email"] > * {
        text-align: left;
    }

    .responsive-table td[data-label="Actions"] {
        justify-content: flex-end;
        padding-top: 10px;
    }

    .responsive-table td[data-label="Actions"]::before {
        display: none;
    }

    .responsive-table .action-group {
        display: flex;
        gap: 6px;
        flex-wrap: nowrap;
        min-width: max-content;
        justify-content: flex-end;
    }

    .responsive-table .action-group .btn,
    .responsive-table .material-icons {
        flex-shrink: 0;
    }

    .card-header {
        overflow: hidden;
    }

    .card-header {
        overflow: hidden;
    }

    .card-header .d-flex.ms-auto {
        width: auto;
        flex: 1;
        justify-content: flex-end;
    }
}

.domain-name-cell {
    display: flex;
    flex-direction: column;
    min-height: 40px;
}

.domain-geo-secondary {
    min-height: 16px;
    display: flex;
    align-items: center;
}

.dns-status-cell {
    min-width: 140px;
}

.dns-badges {
    min-width: 120px;
}

.dns-loading {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 16px;
    background: var(--wb-muted-bg);
    border-radius: 6px;
}

.dns-loading .material-icons {
    font-size: 12px;
    opacity: 0.7;
}

.action-group {
    display: inline-flex;
    gap: 4px;
    flex-wrap: nowrap;
    min-width: max-content;
    justify-content: flex-end;
}

img,
svg {
    display: block;
    max-width: 100%;
}

.ip-geo-cluster {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.ip-geo-inline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ip-geo-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

/* ---------- 2. Base Typography ---------- */

body {
    font-size: var(--wb-font-base);
    font-weight: 400;
    line-height: 1.5;
}

.page-title {
    font-size: var(--wb-heading-page);
    font-weight: var(--wb-heading-weight);
    line-height: 1.2;
    margin: 0;
}

.card-title {
    font-size: var(--wb-heading-card);
    font-weight: var(--wb-heading-weight);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    line-height: 1.2;
}

.small,
small {
    font-size: var(--wb-font-sm);
}


/* ---------- 3. Cards ---------- */

.card {
    border: 1px solid var(--border);
    border-radius: var(--wb-radius-lg);
    box-shadow: var(--wb-shadow-1);
    background: var(--card-bg);
    transition: var(--wb-transition-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card:hover {
    box-shadow: var(--wb-shadow-2);
}

[data-bs-theme="dark"] .card {
    border: 1px solid var(--border);
}

.card-header {
    padding: 0.6rem 1rem;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.02), transparent), var(--wb-muted-bg);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    min-height: 48px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.card-header .d-flex.ms-auto {
    min-width: 260px;
}

.card-header h1,
.card-header h2,
.card-header h3 {
    font-size: var(--wb-heading-card);
    font-weight: var(--wb-heading-weight);
    line-height: 1.3;
    margin: 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    text-shadow: var(--wb-heading-shadow);
}

.card-header .material-icons {
    font-size: 18px;
    opacity: 0.75;
}

[data-bs-theme="dark"] .card-header {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent), var(--card-bg);
}

.card-body {
    padding: 1rem;
}

/* Ensure scrollable card-body respects parent border-radius */
.card-body:last-child {
    border-bottom-left-radius: inherit;
    border-bottom-right-radius: inherit;
}

/* Card is now flex-column; body fills remaining space (works with h-100, equal-height grids) */
.card > .card-body {
    flex: 1 1 auto;
    min-height: 0;
}

/* Opt-in: keep the card body on the card surface so bottom radii stay visible. */
.wb-card-body-surface {
    background-color: inherit;
}


/* ---------- 4. KPI Cards (Dashboard, DNS, etc.) ---------- */

.wb-kpi-card .card-body {
    padding: 1rem;
}

.wb-kpi-icon {
    font-size: 2.2rem;
    opacity: 0.95;
}

[data-bs-theme="dark"] .wb-kpi-icon {
    color: var(--wb-kpi-icon-dark, #e5e7eb);
    opacity: 1;
}

.wb-kpi-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--bs-secondary-color);
}

.wb-kpi-value {
    font-size: 1.5rem;
    font-weight: 600;
}

/* Mobile: slightly smaller icon */
@media (max-width: 575.98px) {
    .wb-kpi-icon {
        font-size: 2rem;
    }
}


/* ---------- 5. Buttons ---------- */

.btn {
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.4rem 0.8rem;
    border-radius: var(--wb-radius-md);
    transition: var(--wb-transition-bg), var(--wb-transition-shadow);
}

.btn:hover {
    box-shadow: var(--wb-shadow-2);
}

/* Cancel / secondary outline button (no Bootstrap variant, used project-wide) */
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    background: var(--wb-hover-bg);
    border-color: var(--border);
    color: var(--text);
    box-shadow: none;
}

.btn-sm {
    padding: 0.3rem 0.65rem;
}

.btn .material-icons {
    font-size: 1rem;
    vertical-align: middle;
    line-height: 1;
    pointer-events: none;
    /* Ensure touch events pass through to button */
}

/* Buttons with text + icon: add right margin to icon */
.btn .material-icons:not(:only-child) {
    margin-right: 0.35rem;
}

/* Icon-only buttons: center the icon */
.btn .material-icons:only-child {
    display: inline-flex;
    margin: 0;
}

/* Icon-only buttons */
.btn-icon {
    padding: 0.3rem 0.5rem;
    min-width: 38px;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Fix: input-group buttons must match form-control height exactly
   form-control: content = 0.85rem × 1.5 = 1.275rem, padding = 0.75rem, border = 2px
   button icon:  content = 1.125rem (18px), needs extra 0.075rem padding per side
   → button padding = 0.375rem + 0.075rem = 0.45rem */
.input-group .btn-icon {
    padding: 0.45rem 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Enforce consistent height for input-group elements (UI-lint requirement: 44px ±2px)
   Base height is set globally on .form-control/.form-select (Section 8).
   This rule ensures .btn inside input-groups also matches. */
.input-group .btn {
    height: 44px;
}

.input-group .btn-icon .material-icons {
    font-size: 1.125rem;
    /* 18px */
    line-height: 1;
}

.btn-icon .material-icons {
    margin-right: 0;
}

/* Disabled danger buttons should appear gray, not light red */
.btn-danger:disabled,
.btn-danger.disabled {
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--bs-secondary);
    --bs-btn-disabled-border-color: var(--bs-secondary);
}

/* Checkbox and switch touch target improvement (44px minimum) */
.form-check-input {
    width: 1.25em;
    height: 1.25em;
    min-width: 24px;
    min-height: 24px;
    margin-top: 0;
}

/* Restore switch toggle proportions (Bootstrap default: 2em × 1em) */
.form-switch .form-check-input {
    width: 2.71em;
    height: 1.1em;
    min-width: 44px;
    min-height: 22px;
    margin-left: 0;
}

.form-check {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-left: 0;
}

.form-check .form-check-input {
    float: none;
    margin-left: 0;
    margin-right: 0;
}

.form-check-label {
    margin-bottom: 0;
}


/* ---------- 6. Tables ---------- */

.table {
    font-size: var(--wb-font-table-cell);
    margin-bottom: 0;
}

.table thead th {
    font-size: var(--wb-font-table-head);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border-bottom-width: 1px;
}

.table tbody tr {
    transition: var(--wb-transition-bg);
}

.table tbody tr:hover {
    background-color: var(--wb-hover-bg);
}


/* ---------- 7. Badges ---------- */

.badge {
    --wb-badge-bg: #f1f5f9;
    --wb-badge-fg: #334155;
    --wb-badge-border: #e2e8f0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    max-width: 100%;
    padding: 0.2rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
    border-radius: 999px;
    border: 1px solid var(--wb-badge-border);
    white-space: nowrap;
    background: var(--wb-badge-bg);
    color: var(--wb-badge-fg);
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.06),
        0 1px 1px rgba(0, 0, 0, 0.04);
    transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
    vertical-align: middle;
}

.badge .material-icons {
    font-size: 12px;
    margin-right: 4px;
    opacity: 0.85;
}

.badge-success,
.badge[data-status="success"] {
    --wb-badge-bg: #e7f6ec;
    --wb-badge-fg: #166534;
    --wb-badge-border: #bbf7d0;
}

.badge-danger,
.badge[data-status="danger"],
.badge[data-status="error"] {
    --wb-badge-bg: #fdecea;
    --wb-badge-fg: #991b1b;
    --wb-badge-border: #fecaca;
}

.badge-warning,
.badge[data-status="warning"] {
    --wb-badge-bg: #fff4e5;
    --wb-badge-fg: #92400e;
    --wb-badge-border: #fde68a;
}

.badge-info,
.badge[data-status="info"] {
    --wb-badge-bg: #e8f0ff;
    --wb-badge-fg: #1e40af;
    --wb-badge-border: #bfdbfe;
}

.badge-neutral,
.badge[data-status="neutral"] {
    --wb-badge-bg: #f1f5f9;
    --wb-badge-fg: #334155;
    --wb-badge-border: #e2e8f0;
}

.badge-sm {
    font-size: 0.65rem;
    padding: 0.15rem 0.45rem;
}

[data-bs-theme="dark"] .badge {
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] .badge-success,
[data-bs-theme="dark"] .badge[data-status="success"] {
    --wb-badge-bg: rgba(34, 197, 94, 0.15);
    --wb-badge-fg: #86efac;
    --wb-badge-border: rgba(34, 197, 94, 0.35);
}

[data-bs-theme="dark"] .badge-danger,
[data-bs-theme="dark"] .badge[data-status="danger"],
[data-bs-theme="dark"] .badge[data-status="error"] {
    --wb-badge-bg: rgba(239, 68, 68, 0.15);
    --wb-badge-fg: #fca5a5;
    --wb-badge-border: rgba(239, 68, 68, 0.35);
}

[data-bs-theme="dark"] .badge-warning,
[data-bs-theme="dark"] .badge[data-status="warning"] {
    --wb-badge-bg: rgba(245, 158, 11, 0.15);
    --wb-badge-fg: #fcd34d;
    --wb-badge-border: rgba(245, 158, 11, 0.35);
}

[data-bs-theme="dark"] .badge-info,
[data-bs-theme="dark"] .badge[data-status="info"] {
    --wb-badge-bg: rgba(59, 130, 246, 0.15);
    --wb-badge-fg: #93c5fd;
    --wb-badge-border: rgba(59, 130, 246, 0.35);
}

[data-bs-theme="dark"] .badge-neutral,
[data-bs-theme="dark"] .badge[data-status="neutral"] {
    --wb-badge-bg: rgba(148, 163, 184, 0.12);
    --wb-badge-fg: #cbd5e1;
    --wb-badge-border: rgba(148, 163, 184, 0.25);
}


/* ---------- 8. Form Controls ---------- */

.form-control,
.form-select {
    font-size: 0.85rem;
    min-height: 44px;
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--wb-radius-md);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--bs-primary, #0A2A66);
    box-shadow: 0 0 0 3px rgba(10, 42, 102, 0.15);
}

/* Small variants use Bootstrap's natural height (compact headers/toolbars) */
.form-control-sm,
.form-select-sm {
    height: auto;
}

/* Search inputs in card headers must match adjacent btn-sm height */
.card-header .form-control-sm {
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
    line-height: 1.5;
}

/* Header action buttons (e.g. Add Domain/Add Account) must stay single-line */
.card-header .btn.btn-sm {
    white-space: nowrap;
}

/* Multi-line textareas must grow freely */
textarea.form-control {
    height: auto;
}

summary {
    cursor: pointer;
}


/* ---------- 9. Section Spacing ---------- */

.wb-section {
    margin-bottom: var(--wb-space-3);
}

.wb-page {
    padding-top: var(--wb-space-3);
    padding-bottom: var(--wb-space-3);
}

@media (min-width: 992px) {
    .wb-main-grid>[class*="col-"] {
        margin-top: 0;
    }
}


/* ---------- 10. Subtle Panels ---------- */

.wb-muted-panel {
    background: var(--wb-muted-bg);
    border-radius: var(--wb-radius-md);
    padding: 0.75rem 1rem;
}

.wb-surface-success {
    background: #eef9f1;
    border-color: #cdebd7;
}

.wb-surface-danger {
    background: #fdf0ef;
    border-color: #f5c9c3;
}

.wb-surface-warning {
    background: #fff7e8;
    border-color: #f8ddb0;
}

.wb-surface-info {
    background: #eef4ff;
    border-color: #cbdcff;
}

.wb-surface-neutral {
    background: #f7f9fc;
    border-color: #dce4ef;
}

[data-bs-theme="dark"] .wb-surface-success {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.24);
}

[data-bs-theme="dark"] .wb-surface-danger {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.24);
}

[data-bs-theme="dark"] .wb-surface-warning {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.24);
}

[data-bs-theme="dark"] .wb-surface-info {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.24);
}

[data-bs-theme="dark"] .wb-surface-neutral {
    background: rgba(148, 163, 184, 0.08);
    border-color: rgba(148, 163, 184, 0.18);
}


/* ---------- 11. Page Header ---------- */

.wb-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--wb-space-3);
}

.wb-page-header .page-title {
    margin-bottom: 0;
}


/* ---------- 12. Stat Cards ---------- */

.wb-stat-card {
    text-align: center;
}

.wb-stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.2;
}

.wb-stat-card .stat-label {
    font-size: var(--wb-font-sm);
    color: var(--bs-secondary-color);
}


/* ---------- 13. Icon Consistency ---------- */

/* Prevent layout shift during font loading - use line-height instead of
   fixed width/height to avoid clipping in flex layouts and baseline alignment issues */
.material-icons {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    vertical-align: middle;
    color: currentColor;
}

.material-icons.icon-sm {
    font-size: 1rem;
}

.material-icons.icon-md {
    font-size: 1.25rem;
}

.material-icons.icon-lg {
    font-size: 1.5rem;
}

/* Standard icon spacing in text */
.material-icons+span,
span+.material-icons {
    margin-left: 0.35rem;
}


/* ---------- 14. List Groups ---------- */

.list-group-item {
    font-size: var(--wb-font-base);
    padding: 0.6rem 1rem;
    transition: var(--wb-transition-bg);
}


/* ---------- 15. Alerts ---------- */

.alert {
    font-size: var(--wb-font-base);
    border-radius: var(--wb-radius-md);
    padding: 0.75rem 1rem;
}


/* ---------- 16. Dropdowns ---------- */

.dropdown-menu {
    font-size: var(--wb-font-base);
    border-radius: var(--wb-radius-md);
    box-shadow: var(--wb-shadow-2);
}

.dropdown-item {
    padding: 0.4rem 1rem;
    transition: var(--wb-transition-bg);
}


/* ---------- 17. Modal Consistency ---------- */

.modal-content {
    border-radius: var(--wb-radius-lg);
    box-shadow: var(--wb-shadow-2);
}

.modal-header {
    padding: 1rem 1.25rem;
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    padding: 0.75rem 1.25rem;
}


/* ---------- 18. Nav Tabs ---------- */

.nav-tabs .nav-link {
    font-size: var(--wb-font-base);
    padding: 0.5rem 1rem;
    border-radius: var(--wb-radius-md) var(--wb-radius-md) 0 0;
    transition: var(--wb-transition-bg), border-color 0.2s ease;
}


/* ---------- 19. Progress Bars ---------- */

.progress {
    height: 0.5rem;
    border-radius: var(--wb-radius-sm);
}


/* ---------- 20. Tooltips ---------- */

.tooltip-inner {
    font-size: var(--wb-font-sm);
    border-radius: var(--wb-radius-sm);
    padding: 0.35rem 0.6rem;
}


/* ---------- 21. Utility Classes ---------- */

.text-muted-light {
    color: var(--bs-secondary-color) !important;
}

.bg-muted-light {
    background-color: var(--wb-muted-bg) !important;
}

.rounded-wb {
    border-radius: var(--wb-radius-md) !important;
}

.rounded-wb-lg {
    border-radius: var(--wb-radius-lg) !important;
}


/* ---------- 22. Bootstrap Grid Gutter Overrides ---------- */

/* Map Bootstrap gutter classes to design spacing tokens
   so g-3 = 24px (layout gap) matches UI-Lint VERTICAL_GAP 22-26px */

.g-1 {
    --bs-gutter-x: var(--wb-space-1);
    --bs-gutter-y: var(--wb-space-1);
}

.g-2 {
    --bs-gutter-x: var(--wb-space-2);
    --bs-gutter-y: var(--wb-space-2);
}

.g-3 {
    --bs-gutter-x: var(--wb-space-3);
    --bs-gutter-y: var(--wb-space-3);
}

.g-4 {
    --bs-gutter-x: var(--wb-space-4);
    --bs-gutter-y: var(--wb-space-4);
}

.gx-1 {
    --bs-gutter-x: var(--wb-space-1);
}

.gx-2 {
    --bs-gutter-x: var(--wb-space-2);
}

.gx-3 {
    --bs-gutter-x: var(--wb-space-3);
}

.gx-4 {
    --bs-gutter-x: var(--wb-space-4);
}

.gy-1 {
    --bs-gutter-y: var(--wb-space-1);
}

.gy-2 {
    --bs-gutter-y: var(--wb-space-2);
}

.gy-3 {
    --bs-gutter-y: var(--wb-space-3);
}

.gy-4 {
    --bs-gutter-y: var(--wb-space-4);
}


/* ---------- 23. Project Margin Utilities ---------- */

/* Prefer project-scoped spacing utilities over global Bootstrap overrides.
   This keeps Bootstrap semantics intact for vendor components and future updates. */

.wb-mb-1 {
    margin-bottom: var(--wb-space-1) !important;
}

.wb-mb-2 {
    margin-bottom: var(--wb-space-2) !important;
}

.wb-mb-3 {
    margin-bottom: var(--wb-space-3) !important;
}

.wb-mb-4 {
    margin-bottom: var(--wb-space-4) !important;
}

.wb-mt-1 {
    margin-top: var(--wb-space-1) !important;
}

.wb-mt-2 {
    margin-top: var(--wb-space-2) !important;
}

.wb-mt-3 {
    margin-top: var(--wb-space-3) !important;
}

.wb-mt-4 {
    margin-top: var(--wb-space-4) !important;
}

.wb-my-1 {
    margin-top: var(--wb-space-1) !important;
    margin-bottom: var(--wb-space-1) !important;
}

.wb-my-2 {
    margin-top: var(--wb-space-2) !important;
    margin-bottom: var(--wb-space-2) !important;
}

.wb-my-3 {
    margin-top: var(--wb-space-3) !important;
    margin-bottom: var(--wb-space-3) !important;
}

.wb-my-4 {
    margin-top: var(--wb-space-4) !important;
    margin-bottom: var(--wb-space-4) !important;
}


/* ---------- 24. Mobile Optimizations ---------- */

/* Reduzierte Seitenabstände für bessere Viewport-Nutzung auf mobilen Geräten */
@media (max-width: 767.98px) {

    /* Content area handles page spacing; shell container stays layout-only. */
    .content-area {
        padding-top: 0.75rem;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        padding-bottom: calc(1rem + var(--em-footer-height));
    }

    /* Grid Rows - nur horizontale Gutters reduziert; vertikale bleiben
       beim Layout-Standard (24px) für konsistente Kachelabstände. */
    .row.g-3,
    .row.g-4 {
        --bs-gutter-x: 0.75rem;
    }

    /* Container - minimales Padding für mehr Platz */
    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    /* Navbar container - Logo bündig mit Kacheln, Buttons mit Abstand vom Rand */
    .navbar .container-fluid {
        padding-left: 0.5rem !important;
        padding-right: 1rem !important;
    }

    /* Navbar controls - zusätzlicher Abstand vom rechten Rand */
    .navbar .navbar-controls {
        margin-right: 0.5rem;
    }

    /* Navbar brand - Logo mit leichtem Einzug vom linken Viewport-Rand */
    .navbar .navbar-brand {
        margin-left: 0.8rem;
    }

    /* Page wrapper - angepasstes vertikales Padding (spacing-2 = 12px) */
    .wb-page {
        padding-top: var(--wb-space-2);
        padding-bottom: var(--wb-space-2);
    }

    /* Page header - kompakteres Layout */
    .wb-page-header {
        margin-bottom: var(--wb-space-2);
        gap: 0.5rem;
    }

    /* Sections - reduzierter Abstand */
    .wb-section {
        margin-bottom: var(--wb-space-2);
    }

    /* Cards - kompakteres Padding */
    .card-header {
        padding: 0.5rem 0.75rem;
    }

    .card-body {
        padding: 0.75rem;
    }
}

/* Keep footer spacing consistent with dashboard on small phones */
@media (max-width: 575.98px) {
    .wb-page {
        padding-bottom: 2rem;
    }
}

/* Tablet-Optimierungen für mittlere Bildschirmgrößen */
@media (min-width: 768px) and (max-width: 991.98px) {

    /* Grid Rows - nur horizontale Gutters angepasst; vertikale bleiben
       beim Layout-Standard (24px) für konsistente Kachelabstände. */
    .row.g-3,
    .row.g-4 {
        --bs-gutter-x: 1rem;
    }

    /* Content area handles page spacing; shell container stays layout-only. */
    .content-area {
        padding-top: 1rem;
        padding-left: 1rem;
        padding-right: 1rem;
        padding-bottom: calc(1.25rem + var(--em-footer-height));
    }

    /* Container - moderates Padding */
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    /* Navbar container */
    .navbar .container-fluid {
        padding-left: 0.75rem !important;
        padding-right: 1.25rem !important;
    }

    /* Navbar controls - moderater Abstand */
    .navbar .navbar-controls {
        margin-right: 0.5rem;
    }

    /* Navbar brand - Logo Alignment */
    .navbar .navbar-brand {
        margin-left: 0.25rem;
    }

    /* Page wrapper - spacing-3 like desktop */
    .wb-page {
        padding-top: var(--wb-space-3);
        padding-bottom: var(--wb-space-3);
    }
}


/* ---------- 25. Read-Only Mode (Non-Admin) ---------- */

/* Container class applied to settings content when user is not admin.
   Disables all interactive elements uniformly while keeping content visible.
   
   SECURITY NOTE: pointer-events:none only blocks mouse/touch — keyboard users
   can still Tab into inputs and modify values. For true read-only enforcement:
   1. Apply `inert` attribute to the container in HTML/JS, OR
   2. Set `tabindex="-1"` + `aria-disabled="true"` on each input
   3. ALWAYS enforce authorization server-side — CSS is UI-only */

.wb-readonly .btn:not(.nav-link):not([data-bs-toggle="tab"]) {
    pointer-events: none;
    opacity: 0.45;
    filter: grayscale(40%);
    cursor: default;
    box-shadow: none;
}

.wb-readonly .form-control,
.wb-readonly .form-select,
.wb-readonly textarea.form-control {
    pointer-events: none;
    background-color: var(--bs-secondary-bg);
    opacity: 0.65;
}

.wb-readonly .form-check-input {
    pointer-events: none;
    opacity: 0.45;
}

.wb-readonly .form-range {
    pointer-events: none;
    opacity: 0.45;
}

.wb-readonly .input-group .btn {
    pointer-events: none;
    opacity: 0.45;
}

/* Dark mode: ensure readonly inputs have visible contrast */
[data-bs-theme="dark"] .wb-readonly .form-control,
[data-bs-theme="dark"] .wb-readonly .form-select,
[data-bs-theme="dark"] .wb-readonly textarea.form-control {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
}


/* ---------- 26. Accessibility — Reduced Motion ---------- */

/* Respect user's motion preferences for decorative animations.
   Preserves functional transitions (focus rings, collapse indicators) while
   disabling potentially disorienting decorative animations. */
@media (prefers-reduced-motion: reduce) {

    /* Decorative animation classes */
    .flow-line,
    .pulse-marker,
    .wb-animate,
    [data-animate] {
        animation: none !important;
    }

    /* Disable scroll-behavior site-wide */
    html {
        scroll-behavior: auto !important;
    }
}


/* ---------- 27. Visually Hidden (Screen Reader Only) ---------- */

/* Bootstrap provides .visually-hidden; .sr-only is included for legacy
   compatibility with older templates using the Bootstrap 4 class name. */
.visually-hidden,
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
