/* ============================================
   NetDiag – AdminLTE Layout & Optik
   Farbschema: Slate-Blaugrau mit roten Akzenten
   ============================================ */

:root {
    color-scheme: light;
    /* Slate-Blaugrau Basis (helles Theme) */
    --nd-bg-main: #f0f2f5;
    --nd-bg-elevated: #ffffff;
    --nd-bg-sidebar: #1a1d27;
    --nd-border-subtle: rgba(15,23,42,0.10);
    --nd-border-strong: rgba(15,23,42,0.20);
    --nd-text-main: #0f172a;
    --nd-text-muted: #64748b;

    /* Rote Akzente */
    --nd-accent: #dc2626;
    --nd-accent-soft: rgba(220,38,38,0.10);
    --nd-accent-strong: rgba(220,38,38,0.22);

    /* Schatten & Transitionen */
    --nd-shadow-card: 0 1px 3px rgba(15,23,42,0.07), 0 4px 12px rgba(15,23,42,0.05);
    --nd-shadow-card-hover: 0 4px 16px rgba(15,23,42,0.13), 0 1px 4px rgba(15,23,42,0.08);
    --nd-transition-fast: 0.15s ease;
    --nd-transition-mid: 0.22s ease;
}

body.theme-dark {
    color-scheme: dark;
    /* Tiefes Nachtblau (dunkles Theme) */
    --nd-bg-main: #0d0f17;
    --nd-bg-elevated: #161922;
    --nd-bg-sidebar: #0b0d14;
    --nd-border-subtle: rgba(148,163,184,0.10);
    --nd-border-strong: rgba(148,163,184,0.18);
    --nd-text-main: #e2e8f0;
    --nd-text-muted: #94a3b8;

    /* Rote Akzente – heller für dunkle Hintergründe */
    --nd-accent: #f87171;
    --nd-accent-soft: rgba(248,113,113,0.14);
    --nd-accent-strong: rgba(248,113,113,0.28);

    --nd-shadow-card: 0 2px 8px rgba(0,0,0,0.40);
    --nd-shadow-card-hover: 0 6px 20px rgba(0,0,0,0.55);
}

body {
    background-color: var(--nd-bg-main);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Skip-Link (Barrierefreiheit) */
a.visually-hidden-focusable:focus {
    z-index: 1100;
}

/* ============================================
   Sidebar – AdminLTE 3 Optik
   Dunkles Grau, Schatten rechts, weiße Schrift, originale Icons, Chevrons
   ============================================ */

/* Container: Tiefdunkler Gradient, weicher Schatten rechts */
.app-sidebar {
    background: linear-gradient(180deg, #1c1f2e 0%, #141720 100%) !important;
    color: #fff;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.22);
    --lte-sidebar-color: #fff;
    --lte-sidebar-hover-color: #fff;
    --lte-sidebar-hover-bg: rgba(255, 255, 255, 0.07);
    --lte-sidebar-menu-active-bg: rgba(255, 255, 255, 0.1);
    --lte-sidebar-menu-active-color: #fff;
    --lte-sidebar-submenu-bg: transparent;
    --lte-sidebar-submenu-color: #fff;
    --lte-sidebar-submenu-hover-bg: rgba(255, 255, 255, 0.06);
    --lte-sidebar-submenu-active-bg: #2d3048;
    --lte-sidebar-header-color: #fff;
}

/* Brand: Trennlinie, ausreichend Padding, weiße Schrift */
.app-sidebar .sidebar-brand {
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
    padding: 0.875rem 1rem;
    background: rgba(0, 0, 0, 0.15);
}
.app-sidebar .sidebar-brand .brand-link,
.app-sidebar .sidebar-brand .brand-text {
    color: #fff;
    font-weight: 300;
}
.app-sidebar .sidebar-brand .brand-link:hover {
    color: #fff;
    opacity: 0.9;
}
.app-sidebar .sidebar-brand .brand-image {
    max-height: 33px;
}

/* Menü-Container */
.app-sidebar .sidebar-wrapper {
    padding: 0.5rem 0 0.75rem 0;
}

/* Oberpunkte (NETWORK, SECURITY, …): einheitlicher Abstand, weiße Schrift */
.app-sidebar .sidebar-menu {
    padding-left: 0;
    list-style: none;
}

/* Aufgeklappter Oberpunkt: etwas hellerer Hintergrund, weiße Schrift, Pfeil nach unten */
.app-sidebar .nav-item.nav-dropdown.menu-open > .nav-link {
    background-color: rgba(220, 38, 38, 0.10);
    color: #fff;
    padding: 0.5rem 1rem;
    padding-left: calc(1rem - 3px);
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-left: 3px solid var(--nd-accent);
}
.app-sidebar .nav-item.nav-dropdown.menu-open > .nav-link .nav-icon,
.app-sidebar .nav-item.nav-dropdown.menu-open > .nav-link p {
    color: #fff;
}

/* Eingeklappter Oberpunkt: Sidebar-Hintergrund, weiße Schrift, Pfeil nach rechts */
.app-sidebar .nav-item.nav-dropdown > .nav-link {
    color: rgba(255,255,255,0.85);
    padding: 0.5rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    min-height: 2.25rem;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: background-color 0.15s ease;
}
.app-sidebar .nav-item.nav-dropdown > .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.06);
    color: #fff;
}
.app-sidebar .nav-item.nav-dropdown > .nav-link .nav-icon {
    color: #fff;
    margin-right: 0.5rem;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.app-sidebar .nav-item.nav-dropdown > .nav-link p {
    margin: 0;
    flex: 1;
    display: flex;
    align-items: center;
    min-width: 0;
}
/* Pfeil fest rechts, gleiche Position zu/auf – wie AdminLTE: absolute + transform */
.app-sidebar .nav-item.nav-dropdown > .nav-link {
    position: relative;
}
.app-sidebar .nav-item.nav-dropdown > .nav-link .nav-arrow {
    position: absolute;
    top: 50%;
    right: 1rem;
    margin-left: 0;
    width: 1rem;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
    transform-origin: center center;
    /* Zu: Pfeil nach rechts (bi-chevron-right), vertikal zentriert */
    transform: translateY(-50%);
}
.app-sidebar .nav-item.nav-dropdown.menu-open > .nav-link .nav-arrow {
    /* Auf: Pfeil nach unten, gleiche Position (nur Rotation) */
    transform: translateY(-50%) rotate(90deg);
}
.app-sidebar .nav-item.nav-dropdown > .nav-link:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: -2px;
}

/* Unterpunkte: eingerückt, originale Icons (Globe, Envelope, …), weiße Schrift */
.app-sidebar .nav-treeview {
    padding-left: 0;
    list-style: none;
    margin-bottom: 0.25rem;
}
.app-sidebar .nav-treeview .nav-item {
    margin: 0;
}
.app-sidebar .nav-treeview .nav-link {
    color: rgba(255,255,255,0.82);
    padding: 0.45rem 1rem 0.45rem 1rem;
    padding-left: 2rem;
    display: flex;
    align-items: center;
    min-height: 2rem;
    font-weight: 400;
    font-size: 0.875rem;
    transition: background-color 0.15s ease, color 0.15s ease, padding-left 0.15s ease;
}
.app-sidebar .nav-treeview .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: #fff;
    padding-left: 2.25rem;
}
.app-sidebar .nav-treeview .nav-link.active {
    background-color: rgba(220, 38, 38, 0.18);
    color: #fff;
    border-left: 3px solid var(--nd-accent);
    box-shadow: inset 3px 0 8px rgba(220,38,38,0.12);
    font-weight: 500;
}

/* Unterpunkte: originale Icons (bi-globe, bi-envelope, …) sichtbar, weiße Farbe */
.app-sidebar .nav-treeview .nav-link .nav-icon {
    color: #fff;
    margin-right: 0.5rem;
    font-size: 1rem;
    opacity: 0.95;
}
.app-sidebar .nav-treeview .nav-link .nav-text {
    color: inherit;
}

/* Suche: ausgeblendete Einträge nicht anzeigen */
.app-sidebar .nav-treeview > li:has(> .nav-dropdown-item.hidden) {
    display: none;
}
.app-sidebar .nav-item.nav-dropdown:not(:has(.nav-dropdown-item:not(.hidden))) {
    display: none !important;
}
.app-sidebar .nav-item.nav-dropdown.hidden {
    display: none !important;
}

/* ---------- Header (Navbar) ---------- */

/* Icon-Buttons in der Navbar */
.nd-nav-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 0.45rem;
    color: var(--nd-text-muted);
    background: transparent;
    border: none;
    font-size: 1.05rem;
    padding: 0;
    transition: background var(--nd-transition-fast), color var(--nd-transition-fast);
    cursor: pointer;
    text-decoration: none;
}
.nd-nav-icon-btn:hover,
.nd-nav-icon-btn:focus-visible {
    background: var(--nd-accent-soft);
    color: var(--nd-accent);
    outline: none;
}
body.theme-dark .nd-nav-icon-btn {
    color: var(--nd-text-muted);
}
body.theme-dark .nd-nav-icon-btn:hover {
    color: var(--nd-accent);
}

/* Sprach-Button: Label sichtbar auf md+ */
.nd-lang-btn {
    width: auto;
    gap: 0.3rem;
    padding: 0 0.5rem;
}
.nd-lang-label {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}
@media (max-width: 575px) {
    .nd-lang-label { display: none; }
    .nd-lang-btn { width: 2.1rem; padding: 0; }
}

/* Bug-Report-Button: subtile Akzentfarbe */
.nd-bugreport-btn:hover {
    background: rgba(234,179,8,0.12);
    color: #b45309;
}
body.theme-dark .nd-bugreport-btn:hover {
    background: rgba(234,179,8,0.12);
    color: #fbbf24;
}

/* Vertikale Trennlinie zwischen Gruppen */
.nd-nav-divider {
    width: 1px;
    height: 1.25rem;
    background: var(--nd-border-strong);
    margin: 0 0.15rem;
    align-self: center;
    pointer-events: none;
}

/* Suchfeld-Wrapper */
.nd-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.nd-search-icon {
    position: absolute;
    left: 0.55rem;
    color: var(--nd-text-muted);
    font-size: 0.8rem;
    pointer-events: none;
    z-index: 1;
}
.nd-search-input {
    width: 175px;
    padding-left: 1.75rem;
    border-radius: 0.45rem;
    border-color: var(--nd-border-subtle);
    background: var(--nd-bg-main);
    color: var(--nd-text-main);
    font-size: 0.875rem;
    transition: width var(--nd-transition-mid), border-color var(--nd-transition-fast), box-shadow var(--nd-transition-fast);
}
.nd-search-input:focus {
    width: 215px;
    border-color: var(--nd-accent);
    box-shadow: 0 0 0 0.18rem var(--nd-accent-soft);
    outline: none;
}
.nd-search-input::placeholder {
    color: var(--nd-text-muted);
    opacity: 0.75;
}
.nd-search-clear {
    position: absolute;
    right: 0.35rem;
    background: none;
    border: none;
    color: var(--nd-text-muted);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 0;
    line-height: 1;
    transition: color var(--nd-transition-fast);
}
.nd-search-clear:hover {
    color: var(--nd-accent);
}

/* Dropdown-Menü: polierter Look */
.nd-dropdown-menu {
    border: 1px solid var(--nd-border-subtle);
    border-radius: 0.5rem;
    box-shadow: var(--nd-shadow-card-hover);
    padding: 0.35rem;
    min-width: 140px;
}
.nd-dropdown-menu .dropdown-item {
    border-radius: 0.35rem;
    font-size: 0.875rem;
    padding: 0.4rem 0.65rem;
    transition: background var(--nd-transition-fast);
}
body.theme-dark .nd-dropdown-menu {
    background: var(--nd-bg-elevated);
    border-color: var(--nd-border-strong);
}
body.theme-dark .nd-dropdown-menu .dropdown-item {
    color: var(--nd-text-main);
}
body.theme-dark .nd-dropdown-menu .dropdown-item:hover {
    background: var(--nd-accent-soft);
    color: var(--nd-accent);
}

/* Dropdown-Toggle ohne Standard-Pfeil-Icon */
.nd-lang-btn.dropdown-toggle::after {
    display: none;
}

.app-header.navbar {
    background: var(--nd-bg-elevated);
    box-shadow: 0 0.125rem 0.75rem rgba(15,23,42,.10);
    border-bottom: 1px solid var(--nd-border-subtle);
    transition: box-shadow 0.2s ease;
}
body.theme-dark .app-header.navbar {
    box-shadow: 0 0.125rem 0.75rem rgba(0,0,0,.35);
}
.app-header .navbar-text {
    color: var(--nd-text-main);
}
.app-header .form-control-sm {
    border-radius: 1.5rem;
    border-color: var(--bs-border-color);
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.app-header .form-control-sm:focus {
    border-color: var(--nd-accent);
    box-shadow: 0 0 0 0.15rem var(--nd-accent-soft);
}

/* ---------- Content-Bereich ---------- */
.app-content-header {
    padding: 0.75rem 0 1rem;
    border-bottom: 2px solid var(--nd-border-subtle);
    margin-bottom: 1.25rem;
    background: linear-gradient(135deg, #fef5f5 0%, #ffffff 50%, #f8fafd 100%);
    box-shadow: 0 1px 3px rgba(220,38,38,0.05), inset 0 -2px 0 0 rgba(220,38,38,0.12);
}

body.theme-dark .app-content-header {
    background: linear-gradient(135deg, #12141f 0%, #161922 60%, #0f1219 100%);
    border-bottom-color: rgba(248,113,113,0.20);
    box-shadow: 0 1px 4px rgba(0,0,0,0.4), inset 0 -2px 0 0 rgba(248,113,113,0.18);
}
.app-content-header .breadcrumb {
    font-size: 0.9rem;
}
.app-content-header .breadcrumb-item.active {
    color: var(--nd-accent);
    font-weight: 500;
}
.app-content {
    padding-bottom: 2rem;
}

/* Cards: moderner Look */
.app-content .card {
    margin-bottom: 1.5rem;
    border: 1px solid var(--nd-border-subtle);
    border-top: 3px solid var(--nd-accent);
    border-radius: 0.5rem;
    box-shadow: var(--nd-shadow-card);
    transition: box-shadow var(--nd-transition-mid), transform var(--nd-transition-fast), border-color var(--nd-transition-fast);
}
.app-content .card:hover {
    box-shadow: var(--nd-shadow-card-hover);
    transform: translateY(-1px);
}
.app-content .card-header {
    background: linear-gradient(135deg, #fdfdfe, #f8fafd);
    border-bottom: 1px solid var(--nd-border-subtle);
    border-radius: 0.4rem 0.4rem 0 0;
    padding: 0.7rem 1rem;
}
.app-content .card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--nd-text-main);
    letter-spacing: 0.01em;
}

body.theme-dark .app-content .card {
    background: var(--nd-bg-elevated);
    border-color: var(--nd-border-subtle);
    border-top-color: var(--nd-accent);
    box-shadow: var(--nd-shadow-card);
}
body.theme-dark .app-content .card:hover {
    box-shadow: var(--nd-shadow-card-hover);
}
body.theme-dark .app-content .card-header {
    background: rgba(255,255,255,0.03);
    border-bottom-color: var(--nd-border-subtle);
}
.app-content .card-body {
    padding: 1.25rem 1rem;
}

/* Formulare */
.app-content .form-group {
    margin-bottom: 1rem;
}
.app-content .form-group .form-label {
    font-weight: 500;
    color: var(--bs-body-color);
}
.app-content .form-control,
.app-content .form-select {
    border-radius: 0.375rem;
    border-color: var(--bs-border-color);
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.app-content .form-control:focus,
.app-content .form-select:focus {
    border-color: var(--nd-accent);
    box-shadow: 0 0 0 0.2rem var(--nd-accent-soft);
}
.app-content .btn-primary {
    border-radius: 0.375rem;
    font-weight: 500;
    padding: 0.5rem 1.1rem;
    background: linear-gradient(135deg, var(--nd-accent), #b91c1c);
    border-color: #b91c1c;
    box-shadow: 0 0.15rem 0.4rem rgba(185,28,28,0.35);
    transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}
.app-content .btn-primary:hover {
    background: linear-gradient(135deg, #b91c1c, #991b1b);
    border-color: #7f1d1d;
    box-shadow: 0 0.3rem 0.65rem rgba(127,29,29,0.50);
    transform: translateY(-1px);
}
.app-content .btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 0.1rem 0.3rem rgba(127,29,29,0.35);
}
.app-content .btn:not(.btn-primary) {
    transition: background 0.18s ease, box-shadow 0.18s ease, transform 0.15s ease;
}
.app-content .btn:not(.btn-primary):hover {
    transform: translateY(-1px);
}

/* Result-Box
   Wichtig: NICHT var(--nd-text-main) für die Standard-Box – die Variable wird bei
   body.theme-dark global hell, während die Box-Hintergrundfarbe aus anderen Gründen
   manchmal hell bleibt → hellgrau auf weiß, unlesbar. Stattdessen lokale --rb-* Variablen. */
.app-content .result-box {
    --rb-surface: #f3f4f6;
    --rb-text: #111827;
    --rb-text-muted: #4b5563;
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    min-height: 2.5rem;
    border-radius: 0.5rem;
    border: 1px solid var(--nd-border-subtle);
    border-left: 4px solid var(--nd-accent);
    background: var(--rb-surface);
    color: var(--rb-text);
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
    font-family: var(--bs-font-monospace, monospace);
    font-size: 0.9rem;
    box-shadow: 0 0.125rem 0.5rem rgba(0,0,0,.06);
    transition: border-left-color 0.2s ease, box-shadow 0.2s ease;
}
/* Dunkler Kasten + helle Schrift (theme-dark und data-bs-theme müssen gleich laufen) */
body.theme-dark .app-content .result-box,
body[data-bs-theme="dark"] .app-content .result-box {
    --rb-surface: var(--nd-bg-elevated);
    --rb-text: #e5e7eb;
    --rb-text-muted: #9ca3af;
    background: var(--rb-surface);
    color: var(--rb-text);
    border-color: var(--nd-border-strong);
    box-shadow: 0 0.125rem 0.5rem rgba(0,0,0,0.35);
}
.app-content .result-box.success {
    border-left-color: var(--bs-success, #198754);
}
body.theme-dark .app-content .result-box.success,
body[data-bs-theme="dark"] .app-content .result-box.success {
    border-left-color: #22c55e;
}
.app-content .result-box.error {
    border-left-color: var(--bs-danger, #dc3545);
}
.app-content .result-box.loading {
    border-left-color: var(--bs-warning, #ffc107);
}

/* Unterblöcke in Result-Boxen (Ping, PDF-Merge, …) – Text aus --rb-* (Kontrast sicher) */
.app-content .result-box .query-info {
    color: var(--rb-text);
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--nd-border-subtle);
    border-left: 4px solid var(--nd-accent);
    border-radius: 0.5rem;
    padding: 0.65rem 0.85rem;
    margin-bottom: 0.75rem;
}
body.theme-dark .app-content .result-box .query-info,
body[data-bs-theme="dark"] .app-content .result-box .query-info {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--nd-border-strong);
}
.app-content .result-box .query-info span {
    color: inherit;
}
.app-content .result-box .ping-stats {
    color: var(--rb-text);
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid var(--nd-border-subtle);
    border-left: 4px solid var(--bs-success, #198754);
    border-radius: 0.5rem;
    padding: 0.85rem 1rem;
    margin-top: 0.5rem;
    white-space: pre-wrap;
    line-height: 1.65;
}
body.theme-dark .app-content .result-box .ping-stats,
body[data-bs-theme="dark"] .app-content .result-box .ping-stats {
    background: rgba(0, 0, 0, 0.25);
    border-color: var(--nd-border-strong);
    border-left-color: #22c55e;
}
.app-content .result-box .stat-line {
    color: var(--rb-text);
}
.app-content .result-box .stat-label {
    color: var(--rb-text-muted);
    font-weight: 600;
}
.app-content .result-box .stat-value {
    color: var(--rb-text);
    font-weight: 500;
}
.app-content .result-box .status-success {
    color: #166534;
    font-weight: 600;
}
body.theme-dark .app-content .result-box .status-success,
body[data-bs-theme="dark"] .app-content .result-box .status-success {
    color: #4ade80;
}
.app-content .result-box .status-warning {
    color: #9a3412;
    font-weight: 600;
}
body.theme-dark .app-content .result-box .status-warning,
body[data-bs-theme="dark"] .app-content .result-box .status-warning {
    color: #fbbf24;
}
.app-content .result-box .status-info {
    color: #075985;
    font-weight: 500;
}
body.theme-dark .app-content .result-box .status-info,
body[data-bs-theme="dark"] .app-content .result-box .status-info {
    color: #38bdf8;
}
.app-content .result-box .status-error {
    color: #b91c1c;
    font-weight: 600;
}
body.theme-dark .app-content .result-box .status-error,
body[data-bs-theme="dark"] .app-content .result-box .status-error {
    color: #fca5a5;
}

/* PDF-Merge: Download-Panel (kein zusätzliches Schwarz im Dark-Mode) */
.app-content .result-box .pdfmerge-download-panel {
    text-align: center;
    margin: 1.25rem 0;
    padding: 1.25rem;
    background: var(--nd-accent-soft);
    border: 1px solid var(--nd-border-subtle);
    border-radius: 0.625rem;
}
body.theme-dark .app-content .result-box .pdfmerge-download-panel,
body[data-bs-theme="dark"] .app-content .result-box .pdfmerge-download-panel {
    background: rgba(249, 115, 22, 0.14);
    border-color: var(--nd-border-strong);
}
.app-content .result-box .pdfmerge-expiry-notice {
    margin-top: 15px;
    padding: 12px;
    border-radius: 8px;
    background: rgba(250, 204, 21, 0.22);
    border: 1px solid rgba(180, 83, 9, 0.45);
    color: #422006;
    line-height: 1.5;
}
body.theme-dark .app-content .result-box .pdfmerge-expiry-notice,
body[data-bs-theme="dark"] .app-content .result-box .pdfmerge-expiry-notice {
    background: rgba(234, 179, 8, 0.15);
    border-color: rgba(250, 204, 21, 0.45);
    color: #fef9c3;
}
.app-content .result-box .pdfmerge-expiry-notice strong {
    color: inherit;
}
.app-content .result-box .pdfmerge-hint {
    margin-top: 10px;
    color: var(--rb-text-muted);
    line-height: 1.5;
}
body.theme-dark .app-content .result-box .pdfmerge-hint,
body[data-bs-theme="dark"] .app-content .result-box .pdfmerge-hint {
    color: #cbd5e1;
}

/* HTML-WYSIWYG: Toolbar & Bearbeitungsfläche */
.htmleditor-toolbar .btn-group-sm > .btn {
    padding: 0.2rem 0.45rem;
}
.htmleditor-toolbar .form-control-color.htmleditor-color {
    width: 2.25rem;
    height: 2rem;
    padding: 0.1rem;
    cursor: pointer;
}
.htmleditor-pro summary {
    cursor: pointer;
    list-style-position: outside;
}
.htmleditor-pro summary::-webkit-details-marker,
.htmleditor-pro summary::marker {
    color: var(--bs-secondary-color, #6c757d);
}
.htmleditor-pro .htmleditor-proaction:focus-visible {
    outline: 2px solid var(--nd-accent);
    outline-offset: 1px;
}

.htmleditor-surface {
    min-height: 280px;
    max-height: min(70vh, 520px);
    overflow-y: auto;
    line-height: 1.55;
    text-align: start;
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
}
.htmleditor-surface:focus {
    outline: 2px solid var(--nd-accent);
    outline-offset: 1px;
}
.htmleditor-surface blockquote {
    margin: 0.5rem 0;
    padding: 0.35rem 0.75rem;
    border-left: 4px solid var(--nd-accent);
    background: rgba(0, 0, 0, 0.04);
}
body.theme-dark .htmleditor-surface blockquote,
body[data-bs-theme="dark"] .htmleditor-surface blockquote {
    background: rgba(255, 255, 255, 0.06);
}
.htmleditor-surface pre {
    padding: 0.5rem 0.75rem;
    border-radius: 0.35rem;
    background: rgba(0, 0, 0, 0.06);
    overflow-x: auto;
    font-size: 0.9em;
}
body.theme-dark .htmleditor-surface pre,
body[data-bs-theme="dark"] .htmleditor-surface pre {
    background: rgba(0, 0, 0, 0.35);
}
.htmleditor-surface table td {
    min-width: 2rem;
}

/* SSH-Key Assistent: lesbare Codeblöcke */
.sshkey-code-block {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid var(--nd-border-subtle);
    padding: 0.85rem 1rem;
    border-radius: 0.375rem;
}
body.theme-dark .sshkey-code-block,
body[data-bs-theme="dark"] .sshkey-code-block {
    background: rgba(0, 0, 0, 0.35);
    border-color: var(--nd-border-strong);
}
.sshkey-steps-intro li {
    line-height: 1.5;
}
.sshkey-steps-intro kbd {
    padding: 0.1rem 0.35rem;
    font-size: 0.8em;
    border-radius: 0.25rem;
    border: 1px solid var(--nd-border-subtle);
    background: var(--nd-bg-elevated);
}

/* Traceroute: Terminal/Konsole (Rohausgabe wie im CLI) */
.app-content .result-box .traceroute-console {
    margin: 0;
    padding: 0.75rem 1rem;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.8125rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    color: var(--rb-text);
    background: rgba(15, 23, 42, 0.06);
    border: 1px solid var(--nd-border-subtle);
    border-radius: 0.375rem;
    overflow-x: auto;
    tab-size: 4;
    -webkit-font-smoothing: antialiased;
}
body.theme-dark .app-content .result-box .traceroute-console,
body[data-bs-theme="dark"] .app-content .result-box .traceroute-console {
    background: rgba(0, 0, 0, 0.42);
    border-color: var(--nd-border-strong);
    color: var(--rb-text);
}
.app-content .result-box .traceroute-console--loading {
    opacity: 0.92;
}
.app-content .result-box .traceroute-console-warn {
    color: #b45309;
    font-weight: 700;
}
body.theme-dark .app-content .result-box .traceroute-console-warn,
body[data-bs-theme="dark"] .app-content .result-box .traceroute-console-warn {
    color: #fbbf24;
}
.app-content .result-box .traceroute-console-err {
    color: #b91c1c;
    font-weight: 700;
}
body.theme-dark .app-content .result-box .traceroute-console-err,
body[data-bs-theme="dark"] .app-content .result-box .traceroute-console-err {
    color: #f87171;
}
.app-content .tab-content {
    display: none;
}
.app-content .tab-content.active {
    display: block;
    animation: tabFadeIn 0.2s ease;
}
@keyframes tabFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Breadcrumb */
.app-content-header .breadcrumb-item a {
    text-decoration: none;
    color: var(--bs-secondary);
}
.app-content-header .breadcrumb-item a:hover {
    color: var(--bs-primary);
}

/* ---------- Footer ---------- */
.app-footer {
    margin-top: 1.5rem;
    padding: 0.9rem 1.25rem;
    border-top: 1px solid var(--nd-border-subtle);
    background: linear-gradient(90deg, #fdfdfd, var(--nd-bg-elevated));
    font-size: 0.8125rem;
    color: var(--nd-text-muted);
}
body.theme-dark .app-footer {
    background: linear-gradient(90deg, #0b0d14, var(--nd-bg-main));
    border-top-color: var(--nd-border-subtle);
}
.app-footer-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem 1.5rem;
    max-width: 100%;
}
.app-footer .footer-left {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.app-footer .footer-meta {
    color: var(--nd-text-muted);
}
.app-footer .footer-right {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
}
.app-footer .footer-right a {
    color: var(--nd-accent);
    text-decoration: none;
}
.app-footer .footer-right a:hover {
    text-decoration: underline;
    color: var(--nd-accent);
}
.app-footer .footer-meta {
    font-size: inherit;
}
.app-footer .footer-dot {
    color: var(--nd-text-muted);
    opacity: 0.7;
    user-select: none;
}
body.theme-dark .app-footer .footer-right a:hover {
    color: var(--nd-accent);
}

/* ---------- Fokus (Tastatur-Navigation) ---------- */
.app-sidebar .nav-link:focus-visible,
.app-content .btn:focus-visible,
.app-content .form-control:focus-visible,
.app-content .form-select:focus-visible,
.app-header .nav-link:focus-visible,
.app-header .form-control:focus-visible,
.scroll-to-top:focus-visible {
    outline: 2px solid var(--nd-accent);
    outline-offset: 2px;
    outline-style: solid;
}
/* Stärkere Sichtbarkeit bei Tastaturnavigation im Dark-Mode */
body.theme-dark .app-content .btn:focus-visible,
body.theme-dark .app-content .form-control:focus-visible,
body.theme-dark .app-content .form-select:focus-visible {
    box-shadow: 0 0 0 3px var(--nd-accent-soft);
}

/* Bugreport-Modal: Dateiauswahl zuverlässig (Overlay / manche Browser) */
#modal-bugreport .modal-body {
    overflow: visible;
}
#modal-bugreport input[type="file"].form-control {
    cursor: pointer;
    position: relative;
    z-index: 2;
    min-height: 2.75rem;
}

/* Copy-Button in Result-Box */
.app-content .result-box .copy-btn {
    margin-top: 0.5rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 0.375rem;
}

/* Lange Code-Ausgaben: scrollbar statt Layout-Sprengring */
.app-content .result-box pre.code-block {
    max-height: min(62vh, 560px);
    overflow: auto;
    margin-bottom: 0.25rem;
    padding: 0.65rem 0.85rem;
    border-radius: 0.375rem;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid var(--nd-border-subtle);
    font-size: 0.8125rem;
    line-height: 1.45;
    tab-size: 4;
}
body.theme-dark .app-content .result-box pre.code-block,
body[data-bs-theme="dark"] .app-content .result-box pre.code-block {
    background: rgba(0, 0, 0, 0.35);
    border-color: var(--nd-border-strong);
}

/* Submit während API/Client-Verarbeitung */
.app-content form.tool-form button[type="submit"].loading {
    pointer-events: none;
    opacity: 0.78;
    cursor: wait;
}

/* ---------- Scroll-to-Top Button ---------- */
.scroll-to-top {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    background: #dc2626;
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(1.5rem) scale(0.85);
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34,1.56,0.64,1), visibility 0.25s ease, box-shadow 0.2s ease;
    z-index: 1030;
    box-shadow: 0 0.25rem 0.75rem rgba(185,28,28,0.4);
}
body.theme-dark .scroll-to-top {
    background: #c02020;
    box-shadow: 0 0.25rem 0.75rem rgba(248,113,113,0.3);
}
.scroll-to-top::before {
    content: '↑';
    line-height: 1;
    font-weight: 700;
}
.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}
.scroll-to-top:hover {
    background: #b91c1c;
    box-shadow: 0 0.4rem 1rem rgba(185,28,28,0.55);
    transform: translateY(-2px) scale(1.05);
}
body.theme-dark .scroll-to-top:hover {
    background: #991b1b;
    box-shadow: 0 0.4rem 1rem rgba(248,113,113,0.4);
}
.scroll-to-top:focus-visible {
    outline: 2px solid var(--nd-accent);
    outline-offset: 2px;
}
.scroll-to-top:active {
    transform: translateY(0) scale(0.95);
    box-shadow: 0 0.15rem 0.4rem rgba(185,28,28,0.35);
}

/* Animation für Result-Box (von script.js IntersectionObserver) */
@keyframes resultSlideIn {
    from {
        opacity: 0;
        transform: translateY(0.5rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Polishing & Dark-Mode-Verfeinerungen
   ============================================ */

/* Sidebar: Trennlinie zwischen Kategorien */
.app-sidebar .nav-item.nav-dropdown + .nav-item.nav-dropdown {
    border-top: 1px solid rgba(255,255,255,0.06);
    margin-top: 0.25rem;
    padding-top: 0.25rem;
}

/* Sidebar: Icon im aktiven Item leuchtet */
.app-sidebar .nav-treeview .nav-link.active .nav-icon {
    color: var(--nd-accent);
    opacity: 1;
}

/* Sidebar: Hover-Icon aufhellen */
.app-sidebar .nav-treeview .nav-link:hover .nav-icon {
    opacity: 1;
}

/* Badge in Sidebar Brand: schärfer */
.sidebar-brand .badge {
    font-size: 0.6rem;
    padding: 0.25em 0.55em;
    letter-spacing: 0.04em;
}

/* Dark-Mode: Tiefes Nachtblau als Basis */
body.theme-dark {
    background-color: var(--nd-bg-main);
}
body.theme-dark .app-wrapper {
    background-color: var(--nd-bg-main);
}

/* Dark-Mode: app-main leicht aufgehellt (Schichtenhierarchie) */
body.theme-dark .app-main {
    background-color: #0f1219;
}

/* Navbar Link Transitions */
.app-header .nav-link {
    transition: color 0.15s ease, opacity 0.15s ease;
}
.app-header .nav-link:hover {
    opacity: 0.8;
}

/* Form Submit Button Loading-State: kleiner Spinner */
.app-content form.tool-form button[type="submit"].loading {
    position: relative;
    pointer-events: none;
    opacity: 0.82;
    cursor: wait;
}

/* Card body: etwas Atemraum in Dark Mode */
body.theme-dark .app-content .card-body {
    color: var(--nd-text-main);
}

/* Result-Box success/error/loading: Farbübergang animiert */
.app-content .result-box.success {
    animation: resultSlideIn 0.22s ease forwards;
}
.app-content .result-box.error {
    animation: resultSlideIn 0.22s ease forwards;
}

/* Code-Block: sanfterer Hintergrund im Light-Mode */
.app-content .result-box pre.code-block {
    background: rgba(0,0,0,0.03);
}

/* Link-Farbe im Content passend zu Akzent */
.app-content a:not(.btn):not(.nav-link):not(.dropdown-item) {
    color: var(--nd-accent);
    text-decoration: none;
    transition: opacity 0.15s ease;
}
.app-content a:not(.btn):not(.nav-link):not(.dropdown-item):hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* ============================================
   Responsive Design – Mobile First
   ============================================ */

/* md: Tablets ≤ 991px */
@media (max-width: 991px) {
    .app-content-header .row {
        row-gap: 0.4rem;
    }
    .app-content-header .breadcrumb {
        float: none !important;
        margin-top: 0.15rem;
    }
    #tool-category-stats .small-box .inner h3 {
        font-size: 1.75rem;
    }
    .app-content .card {
        margin-bottom: 1.25rem;
    }
}

/* sm: große Smartphones & kleine Tablets ≤ 767px */
@media (max-width: 767px) {
    /* Content-Header */
    .app-content-header {
        padding: 0.5rem 0 0.65rem;
        margin-bottom: 0.875rem;
    }
    .app-content-header h3 {
        font-size: 1.1rem;
    }
    .app-content-header .breadcrumb {
        font-size: 0.8125rem;
    }

    /* Karten */
    .app-content .card {
        margin-bottom: 0.875rem;
    }
    .app-content .card-body {
        padding: 0.875rem 0.75rem;
    }

    /* Formulare */
    .app-content .form-group {
        margin-bottom: 0.75rem;
    }
    .app-content .form-control,
    .app-content .form-select {
        font-size: 1rem; /* Verhindert iOS Zoom-In bei < 16px */
    }

    /* Result-Box */
    .app-content .result-box {
        padding: 0.75rem 0.875rem;
        font-size: 0.8125rem;
    }

    /* Scroll-to-Top: kleiner und näher am Rand */
    .scroll-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 2.4rem;
        height: 2.4rem;
        font-size: 1rem;
    }

    /* Stats-Boxen */
    #tool-category-stats {
        margin-bottom: 0.75rem !important;
    }
    #tool-category-stats .small-box {
        margin-bottom: 0.75rem;
    }

    /* Suchfeld: kompakter auf Smartphones */
    .nd-search-input {
        width: 120px;
    }
    .nd-search-input:focus {
        width: 155px;
    }

    /* Footer: kompakter */
    .app-footer {
        padding: 0.7rem 1rem;
    }
}

/* xs: kleine Smartphones ≤ 575px */
@media (max-width: 575px) {
    /* Karten */
    .app-content .card-body {
        padding: 0.75rem 0.625rem;
    }
    .app-content .card-title {
        font-size: 0.95rem;
    }

    /* Result-Box */
    .app-content .result-box {
        padding: 0.625rem 0.75rem;
        font-size: 0.8rem;
    }

    /* Primär-Buttons: volle Breite für bessere Touch-Ziele */
    .app-content form.tool-form .btn-primary {
        width: 100%;
        text-align: center;
    }

    /* Suchfeld: sehr klein auf kleinen Geräten */
    .nd-search-input {
        width: 90px;
        font-size: 0.8rem;
    }
    .nd-search-input:focus {
        width: 115px;
    }

    /* Footer: vertikal stapeln */
    .app-footer-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }
    .app-footer .footer-right {
        gap: 0.35rem 0.75rem;
    }

    /* Content-Header noch kompakter */
    .app-content-header {
        padding: 0.4rem 0 0.5rem;
        margin-bottom: 0.75rem;
    }
    .app-content-header h3 {
        font-size: 1rem;
    }

    /* Code-Block: horizontales Scrollen auf kleinen Screens */
    .app-content .result-box pre.code-block {
        max-height: min(50vh, 400px);
        font-size: 0.75rem;
    }
    .app-content .result-box .traceroute-console {
        font-size: 0.75rem;
    }
}

/* Barrierefreiheit: Bewegung reduzieren */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .scroll-to-top {
        transition: opacity 0.1s ease !important;
    }
    .app-sidebar .nav-treeview .nav-link {
        transition: none !important;
    }
    .app-content .card {
        transition: none !important;
    }
}
