/**
 * Klima-SEITE CSS - Wetterstation Schladming
 * Ausgelagert aus klima.php
 * Nutzt globale Variablen aus style.css
 */

body {
    background: var(--bg-page);
    min-height: 100vh;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1.5rem var(--space-lg) 2rem;
}

.section-header {
    text-align: center;
    margin-bottom: 0.75rem;
    padding: 1rem 1.5rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--blue-a25);
    border-radius: var(--radius-lg);
}

.section-header h2 {
    color: var(--blue-light);
    font-size: var(--fs-hero);
    margin-bottom: 0.5rem;
}

.section-header .subtitle {
    color: var(--text-secondary);
    font-size: var(--fs-md);
    margin: 0;
}

.live-tag {
    display: inline-block; margin-left: 0.6rem; padding: 0.2rem 0.6rem;
    background: var(--blue-a25); border: 1px solid var(--blue);
    border-radius: var(--radius-md); font-size: var(--fs-base); font-weight: 400; color: var(--text-primary);
    vertical-align: middle;
}
.live-tag strong { font-weight: 700; color: var(--text-primary); }
.daten-hinweis {
    display: inline-block; margin-left: 0.4rem; padding: 0.15rem 0.5rem;
    background: rgba(100, 116, 139, 0.15); border: 1px solid rgba(100, 116, 139, 0.25);
    border-radius: var(--radius-sm); font-size: var(--fs-sm); font-weight: 400; color: var(--text-muted);
    vertical-align: middle; font-style: italic;
}
.live-tag .lh-ja { color: var(--text-primary); font-weight: 700; }
.live-tag .lh-nein { color: var(--text-primary); font-weight: 700; }

.table-responsive {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.table-responsive::-webkit-scrollbar { display: none; }

.heatmap-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 1.5px;
    margin: 0.4rem 0 0;
    font-size: var(--fs-base);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.heatmap-table th,
.heatmap-table td {
    padding: 0.3rem 0.2rem;
    text-align: center;
    border: none;
}
.heatmap-table th:last-child,
.heatmap-table td:last-child { border-right: none; }
.heatmap-table tbody tr:last-child td { border-bottom: none; }

/* ===== Monats-Header + Jahresspalte: eigener Hintergrund ===== */
.heatmap-table thead th {
    background: #131a2e;
    color: var(--blue-light);
    font-weight: 700;
    font-size: var(--fs-sm);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 0.4rem 0.2rem;
    border-bottom: 2px solid var(--blue-a25);
    position: sticky;
    top: 0;
    z-index: 10;
}
:root.light .heatmap-table thead th {
    background: #dce4ef;
    color: #1e3a5f;
}

.heatmap-table th.jahr-col {
    background: #131a2e;
    color: var(--blue-light);
    font-weight: 700;
    min-width: 50px;
    position: sticky;
    left: 0;
    z-index: 11;
    border-right: 2px solid var(--blue-a25);
}
:root.light .heatmap-table th.jahr-col {
    background: #dce4ef;
    color: #1e3a5f;
}
.heatmap-table thead th.jahr-col {
    z-index: 12;
}

.heatmap-table td {
    font-weight: 600;
    font-size: var(--fs-sm);
}

/* Leere Zellen (Zukunft) und 0-Wert-Zellen */
.heatmap-table td.cell-empty {
    background: transparent;
    color: var(--text-muted);
}
.heatmap-table td.cell-zero {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
}
:root.light .heatmap-table td.cell-zero {
    background: rgba(0, 0, 0, 0.03);
}
:root.light .heatmap-table td.cell-empty {
    background: rgba(0, 0, 0, 0.02);
}

.heatmap-table tbody tr:hover td {
    filter: brightness(1.1);
    transition: filter 0.15s ease;
}

/* ===== Ø-Zeile + Σ-Spalte: anderer Hintergrund als Header ===== */
.heatmap-table td.avg-col,
.heatmap-table tbody tr:last-child td {
    background: #0c1220 !important;
    color: var(--text-primary) !important;
    font-weight: 600;
}
:root.light .heatmap-table td.avg-col,
:root.light .heatmap-table tbody tr:last-child td {
    background: #c4cfe3 !important;
    color: #1a1a2e !important;
}
.heatmap-table td.avg-col       { border-left: 2px solid var(--blue-a25) }
.heatmap-table tbody tr:last-child td { border-top: 2px solid var(--blue-a25) }
.heatmap-table tbody tr:last-child th { border-top: 2px solid var(--blue-a25) }
.heatmap-table thead th:last-child    { border-left: 2px solid var(--blue-a25) }

/* Höchster/Niedrigster Wert in Ø/Σ hervorheben */
.heatmap-table tbody tr td.avg-hi,
.heatmap-table tbody tr:last-child td.avg-hi {
    color: #e65100 !important;
}
:root.light .heatmap-table tbody tr td.avg-hi,
:root.light .heatmap-table tbody tr:last-child td.avg-hi {
    color: #d84315 !important;
}

/* ===== DESKTOP ICON-BAR ===== */
.klima-iconbar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: 1rem;
    padding: 0.6rem;
    background: var(--bg-card);
    border: 1px solid var(--blue-a25);
    border-radius: var(--radius-lg);
    align-items: flex-end;
}

/* Gruppen-Trenner */
.ib-sep {
    width: 1px;
    align-self: stretch;
    background: var(--blue-a40);
    margin: 0.1rem 0.25rem;
}

/* ===== GRUPPEN-NAVIGATION – Vorhersage-Stil ===== */
#klima-gruppen {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: var(--space-sm);
    margin-bottom: 0.5rem;
    padding: 0;
    background: none;
    border: none;
    border-radius: 0;
}
.ib-grp {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 0.5rem;
    border-radius: var(--radius-lg);
    cursor: pointer;
    border: 1px solid var(--blue-a25);
    border-left-width: 3px;  /* Farbe kommt aus den Gruppen-Definitionen */
    background: var(--bg-card);
    transition: all 0.2s;
    user-select: none;
    white-space: nowrap;
    height: 68px;
}
.ib-grp:hover {
    border-color: var(--blue-a40);
    background: var(--bg-card-hover);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.ib-grp.active {
    background: var(--bg-card);
    box-shadow: 0 0 16px var(--blue-a25);
    /* border-color wird NICHT überschrieben → Gruppen-Farbe bleibt erhalten */
}
.ib-grp .ib-icon {
    font-size: var(--fs-base);
    line-height: 1;
    transition: transform 0.2s;
}
.ib-grp:hover .ib-icon {
    transform: scale(1.15);
}
.ib-grp .ib-label {
    font-size: var(--fs-sm);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* Individuelle Farben pro Gruppe (gilt Desktop + Mobile, gleiche Farben wie Vorhersage) */
.ib-grp[data-group="temperatur"]    { border-left-color: var(--blue-light); color: var(--blue-light); }
.ib-grp[data-group="temperatur"] .ib-label { color: var(--blue-light); }
.ib-grp[data-group="temperatur"].active   { border-left-color: var(--blue-light); }

.ib-grp[data-group="niederschlag"]  { border-left-color: var(--green-muted); color: var(--green-muted); }
.ib-grp[data-group="niederschlag"] .ib-label { color: var(--green-muted); }
.ib-grp[data-group="niederschlag"].active { border-left-color: var(--green-muted); }

.ib-grp[data-group="kenntage"]      { border-left-color: var(--orange-light); color: var(--orange-light); }
.ib-grp[data-group="kenntage"] .ib-label { color: var(--orange-light); }
.ib-grp[data-group="kenntage"].active     { border-left-color: var(--orange-light); }

.ib-grp[data-group="wind"]          { border-left-color: var(--purple); color: var(--purple); }
.ib-grp[data-group="wind"] .ib-label { color: var(--purple); }
.ib-grp[data-group="wind"].active         { border-left-color: var(--purple); }

.ib-grp[data-group="sonne"]         { border-left-color: var(--yellow); color: var(--yellow); }
.ib-grp[data-group="sonne"] .ib-label { color: var(--yellow); }
.ib-grp[data-group="sonne"].active        { border-left-color: var(--yellow); }

.ib-grp[data-group="schnee"]        { border-left-color: var(--cyan); color: var(--cyan); }
.ib-grp[data-group="schnee"] .ib-label { color: var(--cyan); }
.ib-grp[data-group="schnee"].active       { border-left-color: var(--cyan); }

.ib-grp[data-group="boden"]         { border-left-color: var(--green); color: var(--green); }
.ib-grp[data-group="boden"] .ib-label { color: var(--green); }
.ib-grp[data-group="boden"].active        { border-left-color: var(--green); }

/* Light-Mode override nicht mehr nötig - Variablen wechseln automatisch */

/* Sub-Iconbar (Detail-Icons) – ohne Box, linksbündig */
.klima-iconbar.klima-sub {
    margin-bottom: 0.75rem;
    margin-top: -0.15rem;
    justify-content: flex-start;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scrollbar-width: none;
    background: none;
    border: none;
    padding: 0.3rem 0;
    gap: var(--space-xs);
}
.klima-iconbar.klima-sub::-webkit-scrollbar { display: none; }

/* Mobile */
@media (max-width: 600px) {
    #klima-gruppen {
        display: grid;
        grid-template-columns: repeat(7, 1fr);
        gap: 0.4rem;
        position: sticky;
        top: 0;
        z-index: 50;
        background: var(--bg-page);
        padding: 0.4rem 0.2rem;
        margin: 0;
        width: 100%;
        box-sizing: border-box;
        overflow: visible;
    }
    .ib-grp {
        padding: 0.5rem 0;
        height: 68px;
        gap: 0.2rem;
        min-width: 0;
        flex-direction: column;
        white-space: nowrap;
        border: 1px solid var(--blue-a25);
        border-left-width: 1px !important;
        background: var(--bg-card);
        border-radius: var(--radius-md);
        text-align: center;
        cursor: pointer;
        transition: all 0.2s;
        overflow: hidden;
    }
    .ib-grp .ib-icon { width: 20px; height: 20px; font-size: 1rem; color: inherit; display: flex; align-items: center; justify-content: center; }
    .ib-grp .ib-icon svg { width: 20px; height: 20px; }
    .ib-grp .ib-label {
        font-size: var(--fs-xs);
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: inherit;
    }
    /* Kurzlabels auf Mobile via data-mobile-Attribut */
    .ib-grp .ib-label[data-mobile] {
        font-size: 0;
    }
    .ib-grp .ib-label[data-mobile]::before {
        content: attr(data-mobile);
        font-size: var(--fs-xs);
    }
    /* Mobile: Border pro Gruppe gedämpft (analog Vorhersage: keine volle Sättigung) */
    .ib-grp[data-group="temperatur"]    { border-color: var(--blue-a40) !important; }
    .ib-grp[data-group="niederschlag"]  { border-color: var(--green-a35) !important; }
    .ib-grp[data-group="kenntage"]      { border-color: var(--orange-a35) !important; }
    .ib-grp[data-group="wind"]          { border-color: var(--purple-a30) !important; }
    .ib-grp[data-group="sonne"]         { border-color: var(--yellow-a35) !important; }
    .ib-grp[data-group="schnee"]        { border-color: rgba(56,189,248,0.35) !important; }
    .ib-grp[data-group="boden"]         { border-color: rgba(74,222,128,0.35) !important; }

    /* Mobile Light-Mode: kräftigere Borders entfallen - currentColor regelt das automatisch */
    /* Active: Background + Glow in Gruppen-Farbe + kräftigere Border */
    .ib-grp[data-group="temperatur"].active   { background: rgba(96,165,250,0.18);  box-shadow: 0 0 12px rgba(96,165,250,0.25); border-color: var(--blue-light) !important; }
    .ib-grp[data-group="niederschlag"].active { background: rgba(52,211,153,0.18);  box-shadow: 0 0 12px rgba(52,211,153,0.25); border-color: var(--green-muted) !important; }
    .ib-grp[data-group="kenntage"].active     { background: rgba(251,146,60,0.18);  box-shadow: 0 0 12px rgba(251,146,60,0.25); border-color: var(--orange-light) !important; }
    .ib-grp[data-group="wind"].active         { background: rgba(167,139,250,0.18); box-shadow: 0 0 12px rgba(167,139,250,0.25); border-color: var(--purple) !important; }
    .ib-grp[data-group="sonne"].active        { background: rgba(251,191,36,0.18);  box-shadow: 0 0 12px rgba(251,191,36,0.25); border-color: var(--yellow) !important; }
    .ib-grp[data-group="schnee"].active       { background: rgba(56,189,248,0.18);  box-shadow: 0 0 12px rgba(56,189,248,0.25); border-color: var(--cyan) !important; }
    .ib-grp[data-group="boden"].active        { background: rgba(74,222,128,0.18);  box-shadow: 0 0 12px rgba(74,222,128,0.25); border-color: var(--green) !important; }
    /* SVG-Icons übernehmen Container-Farbe via currentColor */
    .ib-grp .ib-icon svg path,
    .ib-grp .ib-icon svg line,
    .ib-grp .ib-icon svg circle,
    .ib-grp .ib-icon svg rect,
    .ib-grp .ib-icon svg polyline {
        stroke: currentColor !important;
    }
    .ib-grp .ib-icon svg [fill]:not([fill="none"]) {
        fill: currentColor !important;
        fill-opacity: 0.15;
    }
    .klima-sub {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        position: sticky;
        top: 48px;
        z-index: 49;
        background: var(--bg-page);
        border: none;
        padding: 0.3rem 0;
        margin-top: 0.3rem;
        margin-bottom: 0.5rem;
        justify-content: flex-start;
        gap: var(--space-sm);
    }
    .klima-sub::-webkit-scrollbar { display: none; }
    .ib-btn { flex-shrink: 0; width: 56px; }
}

/* Integrierter Titel */
.ib-title {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-right: 0.4rem;
    white-space: nowrap;
}
.ib-title-main {
    color: var(--blue-light);
    font-size: var(--fs-base);
    font-weight: 700;
    line-height: 1.2;
}
.ib-title-sub {
    color: var(--text-muted);
    font-size: var(--fs-xs);
}

/* Icon-Kachel */
.ib-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 48px;
    padding: 0.25rem 0.1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    border: 1px solid transparent;
    background: transparent;
    transition: all 0.15s;
    user-select: none;
    flex-shrink: 0;
}
.ib-btn:hover {
    background: var(--glass-hover);
    border-color: rgba(52, 152, 219, 0.25);
}
.ib-btn.active {
    background: var(--blue-a25);
    border-color: rgba(59, 130, 246, 0.5);
}
.ib-btn.active .ib-label {
    color: var(--blue-light);
}
.ib-icon {
    font-size: var(--fs-lg);
    line-height: 1;
    margin-bottom: 0.15rem;
}
.ib-label {
    font-size: var(--fs-xs);
    color: var(--db-label);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    text-align: center;
    line-height: 1.1;
    white-space: nowrap;
}

/* Heatmap-Wrapper: Desktop hidden by default */
.hm-wrap { display: none; }
.hm-wrap.hm-visible { display: block; }

/* Mobile: Icon-Bar als sticky scrollbares Grid */
@media (max-width: 600px) {
    .klima-iconbar {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        position: sticky;
        top: 0;
        z-index: 50;
        background: var(--bg-card);
        border: 1px solid var(--blue-a25);
        border-radius: var(--radius-lg);
        padding: 0.4rem 0.3rem;
        margin: 0 0 0.75rem;
        gap: var(--space-xs);
    }
    .klima-iconbar::-webkit-scrollbar { display: none; }
    .ib-title { display: none; }
    .ib-sep { display: block; flex-shrink: 0; }
    .ib-btn { width: 56px; height: 44px; flex-shrink: 0; }
    .hm-wrap { display: none; }
    .hm-wrap.hm-visible { display: block; }
}


/* Legacy klima-gruppe */
.klima-gruppe { margin: 0; }
.klima-gruppe-header { display: none; }

.heatmap-section {
    background: var(--bg-card);
    border: 1px solid var(--blue-a25);
    border-radius: var(--radius-lg);
    padding: 0.5rem 0.4rem;
    margin: 0.75rem 0;
    overflow: hidden;
}

/* Grid-Hintergrund: border-spacing zeigt diesen BG als Gitterlinien */
.heatmap-table {
    background: rgba(0, 0, 0, 0.3);
}
:root.light .heatmap-table {
    background: rgba(0, 0, 0, 0.08);
}

/* Vertikalen Scrollbar überall in Klimatabellen verstecken */
.hm-wrap, .heatmap-section, .table-responsive, .heatmap-table {
    scrollbar-width: none;
}
.hm-wrap::-webkit-scrollbar, .heatmap-section::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar, .heatmap-table::-webkit-scrollbar {
    display: none;
}

.heatmap-section h3 {
    color: var(--blue-light);
    margin-bottom: 0.2rem;
    font-size: var(--fs-lg);
    font-weight: 700;
}

.heatmap-section p {
    display: none;
}

/* Temperatur-Farbklassen → jetzt in heatmap-colors.css (.hm-temp-*) */

/* RESPONSIVE DESIGN FÜR MOBILE */
/* Mobile: heatmap-section sichtbar wenn hm-wrap aktiv */
@media (max-width: 600px) {
    .hm-wrap.hm-visible .heatmap-section { display: block; }
}

@media (max-width: 768px) {
    .container {
        padding: 0.5rem 1rem;
    }
    
    .section-header {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .section-header h2 {
        font-size: var(--fs-lg);
    }
    
    .section-header .subtitle {
        font-size: var(--fs-base);
    }
    
    .heatmap-section {
        margin: 0.4rem 0;
        padding: 0.5rem;
    }
    
    .heatmap-section h3 {
        font-size: var(--fs-base);
        margin-bottom: 0.2rem;
    }

    .live-tag {
        font-size: var(--fs-xs); padding: 0.1rem 0.35rem; margin-left: 0.3rem;
    }
    .daten-hinweis {
        font-size: var(--fs-xs); padding: 0.1rem 0.3rem; margin-left: 0.2rem;
    }
    
    .table-responsive {
        margin: 0 -0.5rem;
        padding: 0 0.5rem;
        border-radius: var(--radius-md);
    }
    
    .heatmap-table {
        font-size: 0.55rem;
        min-width: 420px;
    }
    
    .heatmap-table th,
    .heatmap-table td {
        padding: 0.25rem 0.1rem;
        min-width: 26px;
    }
    
    .heatmap-table th.jahr-col {
        min-width: 32px;
        font-size: 0.5rem;
    }
    
}

/* EXTRA KLEINE GERÄTE */
@media (max-width: 480px) {
    .heatmap-table {
        font-size: 0.5rem;
        min-width: 380px;
    }
    
    .heatmap-table th,
    .heatmap-table td {
        padding: 0.2rem 0.05rem;
        min-width: 24px;
    }
    
    .heatmap-table th.jahr-col {
        min-width: 28px;
        font-size: 0.45rem;
    }
    
    .heatmap-section h3 {
        font-size: var(--fs-base);
    }

    .jahres-abw-badge {
        display: none !important;
    }
}
/* Klima-Chart Container */
.klima-chart-box {
    position: relative;
    height: 380px;
    margin: 0.5rem 0;
}
@media (max-width: 600px) {
    .klima-chart-box {
        height: 320px;
    }
}

/* Jahr-Auswahl Buttons für Charts */
.chart-jahr-select {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    justify-content: center;
    margin: 0.5rem 0;
}
.cj-btn {
    padding: 0.25rem 0.65rem;
    font-size: var(--fs-sm);
    font-weight: 600;
    background: none;
    border: 1px solid var(--glass-medium);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    line-height: 1.4;
}
.cj-btn:hover {
    color: var(--text-primary);
    border-color: var(--blue-a25);
}
.cj-btn.active {
    background: var(--blue-a25);
    border-color: var(--blue);
    color: var(--blue-light);
}

/* Info-Button und Modal */
.info-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border-radius: var(--radius-full);
    background: var(--blue-a10);
    border: 1.5px solid var(--blue-a40);
    color: var(--blue-light); font-size: var(--fs-xs); cursor: pointer;
    vertical-align: middle; margin-left: 8px;
    transition: all 0.2s; font-weight: 600;
    font-family: Georgia, serif; font-style: italic;
    line-height: 1; padding-bottom: 1px;
}
.info-btn:hover {
    background: var(--blue-a25);
    border-color: var(--blue-light);
    transform: scale(1.1);
}
.info-overlay {
    display: none; position: fixed; inset: 0; z-index: 9999;
    background: var(--overlay-heavy); backdrop-filter: blur(4px);
    align-items: center; justify-content: center; padding: 1.2rem;
}
.info-modal {
    background: var(--bg-tooltip);
    border: 1.5px solid var(--glass-medium); border-radius: var(--radius-lg);
    max-width: 460px; width: 100%; max-height: 85vh; overflow-y: auto;
    padding: 1.4rem 1.5rem 1.25rem; position: relative;
    color: var(--text-secondary); font-size: var(--fs-base); line-height: 1.6;
    box-shadow: var(--shadow-lg);
}
.info-modal h4 { color: var(--text-primary); margin: 0 0 1rem; font-size: var(--fs-md); font-weight: 700; padding-right: 2rem; }
.info-modal .close-btn {
    position: sticky; float: right; top: 0; right: 0;
    background: none; border: none;
    color: var(--text-muted); font-size: var(--fs-xl);
    cursor: pointer; width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    z-index: 10; transition: all 0.2s;
    border-radius: var(--radius-sm);
}
.info-modal .close-btn:hover { color: var(--text-primary); background: var(--glass-medium); }
.info-modal .info-row { display: flex; gap: var(--space-sm); margin-bottom: 0.5rem; }
.info-modal .info-label { color: var(--text-secondary); min-width: 130px; flex-shrink: 0; }
.info-modal .info-val { color: var(--text-primary); }
.info-modal .info-divider { border: none; border-top: 1px solid var(--blue-a10); margin: 0.8rem 0; }
.info-modal .info-formula {
    background: var(--glass-hover); border-radius: var(--radius-md); padding: 0.6rem 0.8rem;
    font-family: 'Courier New', monospace; font-size: var(--fs-sm); color: var(--blue-light);
    margin: 0.5rem 0;
}

.klima-attribution {
    text-align: right;
    font-size: var(--fs-sm);
    color: var(--text-muted);
    padding: 4px 8px 6px;
    font-style: italic;
}
.klima-chart-copyright {
    text-align: right;
    font-size: var(--fs-sm);
    color: var(--db-chart-copyright);
    margin-top: 0.15rem;
}
