/* Grundlayout aller Seiten (base.html). Branding-Farben (--primary-color ...) setzt base.html inline. */

.navbar-brand, .btn-primary, .bg-primary, .navbar.bg-primary {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

.btn-primary:hover {
    background-color: color-mix(in srgb, var(--primary-color) 85%, black) !important;
    border-color: color-mix(in srgb, var(--primary-color) 85%, black) !important;
}

.text-primary {
    color: var(--primary-color) !important;
}

.border-primary {
    border-color: var(--primary-color) !important;
}

/* Apple Dark Mode Support - auto-detect (unless manually set to light) */
@media (prefers-color-scheme: dark) {
    html:not([data-bs-theme="light"]) :root {
        --bs-body-bg: #1a1a1a;
        --bs-body-color: #e9ecef;
        --bs-dark: #343a40;
        --bs-light: #2d3035;
        --bs-gray-100: #2d3035;
        --bs-gray-200: #3a3e44;
        --bs-gray-300: #4a5059;
        --bs-border-color: #495057;
    }

    html:not([data-bs-theme="light"]) body {
        background-color: #1a1a1a !important;
        color: #e9ecef !important;
    }

    html:not([data-bs-theme="light"]) .bg-light {
        background-color: #2d3035 !important;
    }

    html:not([data-bs-theme="light"]) .bg-white {
        background-color: #343a40 !important;
        color: #e9ecef !important;
    }

    html:not([data-bs-theme="light"]) .card {
        background-color: #343a40 !important;
        color: #e9ecef !important;
        border: 1px solid #495057 !important;
    }

    html:not([data-bs-theme="light"]) .card-header {
        background-color: #495057 !important;
        color: #e9ecef !important;
        border-bottom: 1px solid #495057 !important;
    }

    html:not([data-bs-theme="light"]) .card-header.bg-transparent {
        background-color: transparent !important;
        border-bottom: 1px solid #495057 !important;
    }

    html:not([data-bs-theme="light"]) .table {
        color: #e9ecef !important;
    }

    html:not([data-bs-theme="light"]) .table-striped > tbody > tr:nth-of-type(odd) > td {
        background-color: #2d3035 !important;
    }

    html:not([data-bs-theme="light"]) .form-control,
    html:not([data-bs-theme="light"]) .form-select {
        background-color: #495057 !important;
        color: #e9ecef !important;
        border: 1px solid #6c757d !important;
    }

    html:not([data-bs-theme="light"]) .form-control:focus,
    html:not([data-bs-theme="light"]) .form-select:focus {
        background-color: #495057 !important;
        color: #e9ecef !important;
        border-color: var(--primary-color) !important;
        box-shadow: 0 0 0 0.2rem rgba(var(--primary-color), 0.25) !important;
    }

    html:not([data-bs-theme="light"]) .text-muted {
        color: #adb5bd !important;
    }

    html:not([data-bs-theme="light"]) .text-dark {
        color: #e9ecef !important;
    }

    html:not([data-bs-theme="light"]) .border {
        border-color: #495057 !important;
    }

    html:not([data-bs-theme="light"]) .dropdown-menu {
        background-color: #343a40 !important;
        border: 1px solid #495057 !important;
    }

    html:not([data-bs-theme="light"]) .dropdown-item {
        color: #e9ecef !important;
    }

    html:not([data-bs-theme="light"]) .dropdown-item:hover,
    html:not([data-bs-theme="light"]) .dropdown-item:focus {
        background-color: #495057 !important;
        color: #e9ecef !important;
    }

    html:not([data-bs-theme="light"]) .nav-link {
        color: rgba(255, 255, 255, 0.85) !important;
    }

    html:not([data-bs-theme="light"]) .nav-link:hover {
        color: rgba(255, 255, 255, 1) !important;
    }

    html:not([data-bs-theme="light"]) .btn-outline-secondary {
        color: #adb5bd !important;
        border-color: #6c757d !important;
    }

    html:not([data-bs-theme="light"]) .btn-outline-secondary:hover {
        background-color: #6c757d !important;
        color: #fff !important;
    }

    html:not([data-bs-theme="light"]) .btn-outline-primary:hover {
        background-color: var(--primary-color) !important;
        color: #fff !important;
    }

    html:not([data-bs-theme="light"]) .btn-outline-success:hover {
        background-color: var(--success-color) !important;
        color: #fff !important;
    }

    html:not([data-bs-theme="light"]) .btn-outline-danger:hover {
        background-color: var(--danger-color) !important;
        color: #fff !important;
    }

    html:not([data-bs-theme="light"]) .btn-outline-info:hover {
        background-color: var(--info-color) !important;
        color: #fff !important;
    }

    html:not([data-bs-theme="light"]) .btn-outline-warning:hover {
        background-color: var(--warning-color) !important;
        color: #000 !important;
    }

    html:not([data-bs-theme="light"]) .alert-light {
        background-color: #495057 !important;
        color: #e9ecef !important;
        border-color: #6c757d !important;
    }

    html:not([data-bs-theme="light"]) .modal-content {
        background-color: #343a40 !important;
        color: #e9ecef !important;
    }

    html:not([data-bs-theme="light"]) .modal-header {
        border-bottom: 1px solid #495057 !important;
    }

    html:not([data-bs-theme="light"]) .modal-footer {
        border-top: 1px solid #495057 !important;
    }

    html:not([data-bs-theme="light"]) .list-group-item {
        background-color: #343a40 !important;
        color: #e9ecef !important;
        border: 1px solid #495057 !important;
    }

    html:not([data-bs-theme="light"]) .list-group-item:hover {
        background-color: #495057 !important;
    }

    html:not([data-bs-theme="light"]) .progress {
        background-color: #495057 !important;
    }

    html:not([data-bs-theme="light"]) canvas {
        filter: brightness(0.9) contrast(1.1);
    }

    html:not([data-bs-theme="light"]) .text-white {
        color: #e9ecef !important;
    }

    html:not([data-bs-theme="light"]) .badge.bg-light {
        background-color: #495057 !important;
        color: #e9ecef !important;
    }

    html:not([data-bs-theme="light"]) .badge.bg-secondary {
        background-color: #6c757d !important;
        color: #e9ecef !important;
    }

    html:not([data-bs-theme="light"]) small,
    html:not([data-bs-theme="light"]) .small {
        color: #adb5bd !important;
    }

    html:not([data-bs-theme="light"]) code {
        background-color: #495057 !important;
        color: #f8f9fa !important;
    }

    html:not([data-bs-theme="light"]) .input-group-text {
        background-color: #495057 !important;
        color: #e9ecef !important;
        border: 1px solid #6c757d !important;
    }

    html:not([data-bs-theme="light"]) .toast {
        background-color: #343a40 !important;
        color: #e9ecef !important;
    }

    html:not([data-bs-theme="light"]) .toast-header {
        background-color: #495057 !important;
        color: #e9ecef !important;
    }

    html:not([data-bs-theme="light"]) .chart-wrapper {
        background-color: #343a40 !important;
        border-radius: 0.375rem;
        padding: 1rem;
    }

    html:not([data-bs-theme="light"]) .card-header.bg-primary {
        background-color: var(--primary-color) !important;
        color: #fff !important;
    }

    html:not([data-bs-theme="light"]) .card-header.bg-success {
        background-color: var(--success-color) !important;
        color: #fff !important;
    }

    html:not([data-bs-theme="light"]) .card-header.bg-warning {
        background-color: var(--warning-color) !important;
        color: #000 !important;
    }

    html:not([data-bs-theme="light"]) .card-header.bg-info {
        background-color: var(--info-color) !important;
        color: #fff !important;
    }

    html:not([data-bs-theme="light"]) .card-header.bg-danger {
        background-color: var(--danger-color) !important;
        color: #fff !important;
    }

    html:not([data-bs-theme="light"]) .timeline-item {
        border-left: 2px solid #495057 !important;
    }

    html:not([data-bs-theme="light"]) .loading {
        color: #adb5bd !important;
    }

    html:not([data-bs-theme="light"]) .bi,
    html:not([data-bs-theme="light"]) .fas,
    html:not([data-bs-theme="light"]) .far,
    html:not([data-bs-theme="light"]) .fab {
        opacity: 0.9;
    }

    html:not([data-bs-theme="light"]) .text-secondary {
        color: #adb5bd !important;
    }

    html:not([data-bs-theme="light"]) .bg-secondary {
        background-color: #6c757d !important;
        color: #fff !important;
    }

    html:not([data-bs-theme="light"]) .card-body .text-center .fw-bold {
        color: #f8f9fa !important;
    }

    html:not([data-bs-theme="light"]) .footer {
        background-color: #343a40 !important;
        color: #e9ecef !important;
        border-top: 1px solid #495057 !important;
    }

    html:not([data-bs-theme="light"]) .table-responsive {
        background-color: #343a40 !important;
    }

    html:not([data-bs-theme="light"]) .page-link {
        background-color: #343a40 !important;
        color: #e9ecef !important;
        border: 1px solid #495057 !important;
    }

    html:not([data-bs-theme="light"]) .page-link:hover {
        background-color: #495057 !important;
        color: #e9ecef !important;
    }

    html:not([data-bs-theme="light"]) .page-item.active .page-link {
        background-color: var(--primary-color) !important;
        border-color: var(--primary-color) !important;
    }
}

/* Manual dark mode toggle support */
html[data-bs-theme="dark"] {
    --bs-body-bg: #1a1a1a;
    --bs-body-color: #e9ecef;
    --bs-dark: #343a40;
    --bs-light: #2d3035;
    --bs-gray-100: #2d3035;
    --bs-gray-200: #3a3e44;
    --bs-gray-300: #4a5059;
    --bs-border-color: #495057;
}

html[data-bs-theme="dark"] body {
    background-color: #1a1a1a !important;
    color: #e9ecef !important;
}

html[data-bs-theme="dark"] .bg-light {
    background-color: #2d3035 !important;
}

html[data-bs-theme="dark"] .bg-white {
    background-color: #343a40 !important;
    color: #e9ecef !important;
}

html[data-bs-theme="dark"] .card {
    background-color: #343a40 !important;
    color: #e9ecef !important;
    border: 1px solid #495057 !important;
}

html[data-bs-theme="dark"] .card-header {
    background-color: #495057 !important;
    color: #e9ecef !important;
    border-bottom: 1px solid #495057 !important;
}

html[data-bs-theme="dark"] .card-header.bg-transparent {
    background-color: transparent !important;
    border-bottom: 1px solid #495057 !important;
}

html[data-bs-theme="dark"] .table {
    color: #e9ecef !important;
}

html[data-bs-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > td {
    background-color: #2d3035 !important;
}

html[data-bs-theme="dark"] .form-control,
html[data-bs-theme="dark"] .form-select {
    background-color: #495057 !important;
    color: #e9ecef !important;
    border: 1px solid #6c757d !important;
}

html[data-bs-theme="dark"] .form-control:focus,
html[data-bs-theme="dark"] .form-select:focus {
    background-color: #495057 !important;
    color: #e9ecef !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 0.2rem rgba(var(--primary-color), 0.25) !important;
}

html[data-bs-theme="dark"] .text-muted {
    color: #adb5bd !important;
}

html[data-bs-theme="dark"] .text-dark {
    color: #e9ecef !important;
}

html[data-bs-theme="dark"] .border {
    border-color: #495057 !important;
}

html[data-bs-theme="dark"] .dropdown-menu {
    background-color: #343a40 !important;
    border: 1px solid #495057 !important;
}

html[data-bs-theme="dark"] .dropdown-item {
    color: #e9ecef !important;
}

html[data-bs-theme="dark"] .dropdown-item:hover,
html[data-bs-theme="dark"] .dropdown-item:focus {
    background-color: #495057 !important;
    color: #e9ecef !important;
}

html[data-bs-theme="dark"] .nav-link {
    color: rgba(255, 255, 255, 0.85) !important;
}

html[data-bs-theme="dark"] .nav-link:hover {
    color: rgba(255, 255, 255, 1) !important;
}

html[data-bs-theme="dark"] .btn-outline-secondary {
    color: #adb5bd !important;
    border-color: #6c757d !important;
}

html[data-bs-theme="dark"] .btn-outline-secondary:hover {
    background-color: #6c757d !important;
    color: #fff !important;
}

html[data-bs-theme="dark"] .btn-outline-primary:hover {
    background-color: var(--primary-color) !important;
    color: #fff !important;
}

html[data-bs-theme="dark"] .btn-outline-success:hover {
    background-color: var(--success-color) !important;
    color: #fff !important;
}

html[data-bs-theme="dark"] .btn-outline-danger:hover {
    background-color: var(--danger-color) !important;
    color: #fff !important;
}

html[data-bs-theme="dark"] .btn-outline-info:hover {
    background-color: var(--info-color) !important;
    color: #fff !important;
}

html[data-bs-theme="dark"] .btn-outline-warning:hover {
    background-color: var(--warning-color) !important;
    color: #000 !important;
}

html[data-bs-theme="dark"] .alert-light {
    background-color: #495057 !important;
    color: #e9ecef !important;
    border-color: #6c757d !important;
}

html[data-bs-theme="dark"] .modal-content {
    background-color: #343a40 !important;
    color: #e9ecef !important;
}

html[data-bs-theme="dark"] .modal-header {
    border-bottom: 1px solid #495057 !important;
}

html[data-bs-theme="dark"] .modal-footer {
    border-top: 1px solid #495057 !important;
}

html[data-bs-theme="dark"] .list-group-item {
    background-color: #343a40 !important;
    color: #e9ecef !important;
    border: 1px solid #495057 !important;
}

html[data-bs-theme="dark"] .list-group-item:hover {
    background-color: #495057 !important;
}

html[data-bs-theme="dark"] .progress {
    background-color: #495057 !important;
}

html[data-bs-theme="dark"] canvas {
    filter: brightness(0.9) contrast(1.1);
}

html[data-bs-theme="dark"] .text-white {
    color: #e9ecef !important;
}

html[data-bs-theme="dark"] .badge.bg-light {
    background-color: #495057 !important;
    color: #e9ecef !important;
}

html[data-bs-theme="dark"] .badge.bg-secondary {
    background-color: #6c757d !important;
    color: #e9ecef !important;
}

html[data-bs-theme="dark"] small,
html[data-bs-theme="dark"] .small {
    color: #adb5bd !important;
}

html[data-bs-theme="dark"] code {
    background-color: #495057 !important;
    color: #f8f9fa !important;
}

html[data-bs-theme="dark"] .input-group-text {
    background-color: #495057 !important;
    color: #e9ecef !important;
    border: 1px solid #6c757d !important;
}

html[data-bs-theme="dark"] .toast {
    background-color: #343a40 !important;
    color: #e9ecef !important;
}

html[data-bs-theme="dark"] .toast-header {
    background-color: #495057 !important;
    color: #e9ecef !important;
}

html[data-bs-theme="dark"] .chart-wrapper {
    background-color: #343a40 !important;
    border-radius: 0.375rem;
    padding: 1rem;
}

html[data-bs-theme="dark"] .card-header.bg-primary {
    background-color: var(--primary-color) !important;
    color: #fff !important;
}

html[data-bs-theme="dark"] .card-header.bg-success {
    background-color: var(--success-color) !important;
    color: #fff !important;
}

html[data-bs-theme="dark"] .card-header.bg-warning {
    background-color: var(--warning-color) !important;
    color: #000 !important;
}

html[data-bs-theme="dark"] .card-header.bg-info {
    background-color: var(--info-color) !important;
    color: #fff !important;
}

html[data-bs-theme="dark"] .card-header.bg-danger {
    background-color: var(--danger-color) !important;
    color: #fff !important;
}

html[data-bs-theme="dark"] .timeline-item {
    border-left: 2px solid #495057 !important;
}

html[data-bs-theme="dark"] .loading {
    color: #adb5bd !important;
}

html[data-bs-theme="dark"] .bi,
html[data-bs-theme="dark"] .fas,
html[data-bs-theme="dark"] .far,
html[data-bs-theme="dark"] .fab {
    opacity: 0.9;
}

html[data-bs-theme="dark"] .text-secondary {
    color: #adb5bd !important;
}

html[data-bs-theme="dark"] .bg-secondary {
    background-color: #6c757d !important;
    color: #fff !important;
}

html[data-bs-theme="dark"] .card-body .text-center .fw-bold {
    color: #f8f9fa !important;
}

html[data-bs-theme="dark"] .footer {
    background-color: #343a40 !important;
    color: #e9ecef !important;
    border-top: 1px solid #495057 !important;
}

html[data-bs-theme="dark"] .table-responsive {
    background-color: #343a40 !important;
}

html[data-bs-theme="dark"] .page-link {
    background-color: #343a40 !important;
    color: #e9ecef !important;
    border: 1px solid #495057 !important;
}

html[data-bs-theme="dark"] .page-link:hover {
    background-color: #495057 !important;
    color: #e9ecef !important;
}

html[data-bs-theme="dark"] .page-item.active .page-link {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

/* Blinking indicator for active alarms and new news */
@keyframes blink-red {
    0%, 50%, 100% { color: #dc3545; opacity: 1; }
    25%, 75% { color: #dc3545; opacity: 0.4; }
}

@keyframes blink-blue {
    0%, 50%, 100% { color: #0d6efd; opacity: 1; }
    25%, 75% { color: #0d6efd; opacity: 0.4; }
}

.alarm-indicator-active {
    animation: blink-red 2s ease-in-out infinite;
}

.news-indicator-active {
    animation: blink-blue 2s ease-in-out infinite;
}

/* Badge styling for counters */
.indicator-badge {
    font-size: 0.65rem;
    padding: 0.2em 0.4em;
    margin-left: 0.3rem;
    vertical-align: top;
}
