/* Globaler Dark Mode */
html {
    color-scheme: light;
}

html.dark-mode {
    color-scheme: dark;
}

body {
    transition:
        background-color 0.25s ease,
        color 0.25s ease;
}

html.dark-mode body {
    background-color: #121826 !important;
    color: #edf2f7 !important;
}

html.dark-mode header {
    background-color: #1f2937 !important;
    border-color: transparent !important;
    border-width: 0 !important;
    color: #f8fafc !important;
}

html.dark-mode main,
html.dark-mode footer,
html.dark-mode #content2,
html.dark-mode #content3,
html.dark-mode #content4,
html.dark-mode #content6 {
    color: #edf2f7 !important;
}

html.dark-mode h1,
html.dark-mode h2,
html.dark-mode h3,
html.dark-mode #content2,
html.dark-mode #content3,
html.dark-mode #content4,
html.dark-mode #content6 {
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

html.dark-mode .tile,
html.dark-mode .post,
html.dark-mode #post,
html.dark-mode .accordion,
html.dark-mode #chartContainer,
html.dark-mode #mapContainer,
html.dark-mode #tableContainer,
html.dark-mode table,
html.dark-mode .chart-box {
    background-color: #1f2937 !important;
    color: #edf2f7 !important;
}

html.dark-mode table,
html.dark-mode input,
html.dark-mode textarea,
html.dark-mode select {
    border-color: #334155 !important;
}

html.dark-mode input,
html.dark-mode textarea,
html.dark-mode select {
    background-color: #111827 !important;
    color: #f8fafc !important;
    border-color: #334155 !important;
}

html.dark-mode a {
    color: #93c5fd;
}

html.dark-mode hr {
    border-color: #334155 !important;
}

html.dark-mode img.wetterbild,
html.dark-mode .post img,
html.dark-mode #DWD img,
html.dark-mode #content5 img {
    filter: brightness(0.88) contrast(1.05);
}

html.dark-mode .leaflet-container {
    background: #111827 !important;
}

html.dark-mode .highcharts-background,
html.dark-mode .highcharts-plot-background {
    fill: #1f2937 !important;
    background: #1f2937 !important;
}

html.dark-mode .highcharts-title,
html.dark-mode .highcharts-subtitle,
html.dark-mode .highcharts-axis-title,
html.dark-mode .highcharts-axis-labels text,
html.dark-mode .highcharts-legend-item text,
html.dark-mode .highcharts-caption,
html.dark-mode .highcharts-credits {
    color: #f8fafc !important;
    fill: #f8fafc !important;
}

html.dark-mode .highcharts-grid-line {
    stroke: #334155 !important;
}

html.dark-mode .highcharts-axis-line,
html.dark-mode .highcharts-tick {
    stroke: #64748b !important;
}

html.dark-mode .leaflet-popup-content-wrapper,
html.dark-mode .leaflet-popup-tip {
    background: #1f2937;
    color: #f8fafc;
}

html.dark-mode .accordion summary {
    background: #1f2937 !important;
    color: #f8fafc !important;
}

html.dark-mode .accordion summary:hover {
    background: #334155 !important;
}

html.dark-mode .accordion-content {
    background: #1f2937 !important;
    color: #e5e7eb !important;
}

html.dark-mode .accordion-content p,
html.dark-mode .accordion-content li {
    color: #d1d5db !important;
}

html.dark-mode .accordion-content a {
    color: #93c5fd !important;
}

.dark-mode-toggle {
    position: absolute;
    top: 74px;
    right: 20px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 88px;
    padding: 6px 9px;
    border: 1px solid #334155;
    border-radius: 999px;
    background: #f8fafc;
    color: #111827;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    line-height: 1;
    z-index: 20;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
}

.dark-mode-toggle:hover {
    background: #e2e8f0;
}

.dark-mode-toggle__track {
    position: relative;
    flex: 0 0 auto;
    width: 30px;
    height: 16px;
    border-radius: 999px;
    background: #cbd5e1;
}

.dark-mode-toggle__thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #0f172a;
    transition: transform 0.2s ease;
}

html.dark-mode .dark-mode-toggle {
    background: #0f172a;
    color: #f8fafc;
    border-color: #64748b;
}

html.dark-mode .dark-mode-toggle:hover {
    background: #1e293b;
}

html.dark-mode .dark-mode-toggle__track {
    background: #2563eb;
}

html.dark-mode .dark-mode-toggle__thumb {
    background: #f8fafc;
    transform: translateX(14px);
}

@media (max-width: 600px) {
    html.dark-mode body {
        padding: 10px !important;
        overflow-x: hidden;
    }

    html.dark-mode header {
        width: 100%;
        box-sizing: border-box;
        gap: 8px;
        padding: 10px !important;
        border-radius: 8px;
    }

    html.dark-mode main,
    html.dark-mode footer,
    html.dark-mode #content2,
    html.dark-mode #content3,
    html.dark-mode #content4,
    html.dark-mode #content6 {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    html.dark-mode h1 {
        font-size: clamp(28px, 9vw, 42px);
        line-height: 1.12;
        margin: 18px 0 14px;
        overflow-wrap: anywhere;
    }

    html.dark-mode h2 {
        font-size: clamp(20px, 7vw, 30px);
        line-height: 1.18;
        overflow-wrap: anywhere;
    }

    html.dark-mode #content3,
    html.dark-mode #content4,
    html.dark-mode #content6 {
        font-size: 16px;
        line-height: 1.45;
        padding-inline: 4px;
    }

    html.dark-mode .tile,
    html.dark-mode .post,
    html.dark-mode #post,
    html.dark-mode .accordion,
    html.dark-mode #chartContainer,
    html.dark-mode #mapContainer,
    html.dark-mode #tableContainer,
    html.dark-mode .chart-box {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        margin-left: 0;
        margin-right: 0;
        padding: 12px;
        border-radius: 8px;
    }

    html.dark-mode .grid {
        width: 100%;
        box-sizing: border-box;
        padding: 8px 0;
        gap: 12px;
    }

    html.dark-mode .highcharts-container,
    html.dark-mode .highcharts-root {
        width: 100% !important;
        max-width: 100% !important;
    }

    html.dark-mode .sourceControls {
        position: relative;
        top: auto;
        right: auto;
        justify-content: center;
        flex-wrap: wrap;
        width: 100%;
        margin-bottom: 8px;
    }

    html.dark-mode .sourceControls button {
        min-height: 32px;
        padding: 6px 10px;
        font-size: 12px;
    }

    html.dark-mode table {
        display: block;
        width: 100%;
        overflow-x: auto;
        box-sizing: border-box;
    }

    html.dark-mode img,
    html.dark-mode iframe {
        max-width: 100%;
        height: auto;
    }

    .dark-mode-toggle {
        position: static !important;
        order: 99;
        width: auto !important;
        max-width: 120px;
        justify-content: center;
        padding: 6px 8px;
        font-size: 11px;
        margin: 2px auto 0;
        flex: 0 0 auto;
    }

    .dark-mode-toggle__track {
        width: 28px;
        height: 15px;
    }

    .dark-mode-toggle__thumb {
        width: 11px;
        height: 11px;
    }

    html.dark-mode .dark-mode-toggle__thumb {
        transform: translateX(13px);
    }
}
