/* =============================================================================
   TECSON Heizölpreise Manager — Frontend Chart Styles
   ============================================================================= */

/* Chart wrapper */
.topm-chart-wrapper, .topm-rohoel-chart-wrapper {
    width: 100%;
    font-family: inherit;
}

/* Average filter bar (standalone box) */
.topm-avg-box, .topm-rohoel-avg-box {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    padding: 8px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}

.topm-avg-label, .topm-rohoel-avg-label {
    font-size: 13px;
    color: #475569;
    margin-right: 4px;
}

/* Filter buttons — TECSON brand: rectangular, navy active */
.topm-avg-btn, .topm-rohoel-avg-btn {
    padding: 6px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #fff;
    color: #334155;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease-in-out;
    outline: none;
    font-family: inherit;
}

.topm-avg-btn, .topm-rohoel-avg-btn:hover {
    border-color: #1e3a8a;
    background: #f8fafc;
    color: #1e3a8a;
}

.topm-avg-btn, .topm-rohoel-avg-btn.active {
    background: #1e3a8a;
    border-color: #1e3a8a;
    color: #fff;
}

/* Highcharts container */
.topm-chart-plot-area, .topm-rohoel-chart-plot-area {
    width: 100%;
    min-height: 400px;
}
.topm-chart-container, .topm-rohoel-chart-container {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

/* Info Box (Absolute positioning over chart) */
.topm-infobox, .topm-rohoel-infobox {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    z-index: 5;
    pointer-events: none; /* Let clicks pass through to chart */
}

.topm-infobox-top-left, .topm-rohoel-infobox-top-left     { top: 12px; left: 12px; }
.topm-infobox-top-right, .topm-rohoel-infobox-top-right    { top: 12px; right: 12px; }
.topm-infobox-bottom-left, .topm-rohoel-infobox-bottom-left  { bottom: 40px; left: 12px; }
.topm-infobox-bottom-right, .topm-rohoel-infobox-bottom-right { bottom: 40px; right: 12px; }

/* Secondary Legends (Ø-Linie and Year list) */
.topm-secondary-legend, .topm-rohoel-secondary-legend, .topm-year-legend, .topm-rohoel-year-legend {
    position: absolute;
    right: 12px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    z-index: 9999;
    min-width: 140px;
}
.topm-secondary-legend, .topm-rohoel-secondary-legend {
    top: 12px;
}
.topm-year-legend, .topm-rohoel-year-legend {
    top: 180px; /* Positions it below the secondary legend */
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}
.topm-year-legend, .topm-rohoel-year-legend::-webkit-scrollbar {
    width: 6px;
}
.topm-year-legend, .topm-rohoel-year-legend::-webkit-scrollbar-track {
    background: transparent;
}
.topm-year-legend, .topm-rohoel-year-legend::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 10px;
}

.topm-sec-legend-item, .topm-rohoel-sec-legend-item, .topm-year-legend-item, .topm-rohoel-year-legend-item {
    margin-bottom: 2px;
}
.topm-sec-legend-item, .topm-rohoel-sec-legend-item:hover, .topm-year-legend-item, .topm-rohoel-year-legend-item:hover {
    background: rgba(241, 245, 249, 0.8);
    border-radius: 6px;
}

.topm-infobox-label, .topm-rohoel-infobox-label {
    font-weight: 700;
    color: #1e3a8a;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 12px;
}

.topm-infobox-date, .topm-rohoel-infobox-date {
    color: #64748b;
    font-size: 13px;
}

.topm-infobox-price, .topm-rohoel-infobox-price {
    font-size: 20px;
    font-weight: 700;
    color: #c0392b;
}

.topm-infobox-unit, .topm-rohoel-infobox-unit {
    font-size: 12px;
    color: #94a3b8;
}

/* Responsive */
@media (min-width: 769px) {
    .topm-mobile-topbar,
    .topm-mobile-filter-panel {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .topm-chart-card, .topm-rohoel-chart-card {
        margin-top: 0 !important;
    }

    .topm-chart-body, .topm-rohoel-chart-body {
        position: relative;
        padding: 4px !important;
    }

    .topm-mobile-topbar {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        padding: 6px 10px;
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        margin-bottom: 8px;
    }

    .topm-mobile-topbar-left {
        display: flex;
        flex-direction: column;
        gap: 2px;
        font-size: 10px;
        color: #475569;
    }
    .topm-mobile-topbar-left strong {
        color: #1e293b;
    }

    .topm-mobile-filter-trigger {
        display: inline-flex !important;
        align-items: center;
        gap: 6px;
        padding: 6px 12px;
        font-size: 11px;
        font-weight: 700;
        border-radius: 6px;
        background: #1e3a8a;
        color: #ffffff;
        border: none;
        box-shadow: 0 2px 6px rgba(30, 58, 138, 0.25);
        cursor: pointer;
        flex-shrink: 0;
        z-index: 25;
        transition: transform 0.15s ease, background-color 0.15s ease;
    }

    .topm-mobile-filter-trigger:active {
        transform: scale(0.95);
        background: #1d4ed8;
    }

    /* Hide desktop block rows when mobile overlay is active */
    .topm-avg-box, .topm-rohoel-avg-box,
    .topm-year-legend, .topm-rohoel-year-legend,
    .topm-secondary-legend, .topm-rohoel-secondary-legend {
        display: none !important;
    }

    .topm-mobile-filter-panel {
        position: absolute;
        top: 48px;
        left: 4px;
        right: 4px;
        width: auto;
        max-width: none;
        background: #ffffff !important;
        border: 1px solid #cbd5e1;
        border-radius: 10px;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
        z-index: 50;
        padding: 12px;
        display: none;
        animation: topmFadeIn 0.18s ease-out;
    }

    .topm-mobile-filter-panel.open {
        display: block !important;
    }

    .topm-mobile-filter-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 6px;
        padding-bottom: 4px;
        border-bottom: 1px solid #e2e8f0;
    }

    .topm-mobile-filter-title {
        font-size: 10px;
        font-weight: 700;
        color: #1e293b;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    .topm-mobile-filter-close {
        background: none;
        border: none;
        font-size: 16px;
        line-height: 1;
        color: #64748b;
        cursor: pointer;
        padding: 0 2px;
    }

    .topm-mobile-section-title {
        font-size: 9px;
        font-weight: 700;
        color: #64748b;
        text-transform: uppercase;
        margin-bottom: 4px;
    }

    .topm-mobile-avg-section {
        margin-bottom: 8px;
    }

    .topm-mobile-avg-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4px;
    }

    .topm-mobile-avg-chip {
        padding: 4px 6px;
        font-size: 10px;
        font-weight: 600;
        text-align: center;
        border-radius: 4px;
        border: 1px solid #cbd5e1;
        background: #ffffff;
        color: #334155;
        cursor: pointer;
        min-height: 26px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.15s ease;
    }

    .topm-mobile-avg-chip.active {
        background: #1e3a8a;
        color: #ffffff;
        border-color: #1e3a8a;
        font-weight: 700;
    }

    .topm-mobile-year-chips {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    .topm-mobile-year-chip {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 3px 8px;
        font-size: 10px;
        font-weight: 600;
        border-radius: 14px;
        border: 1px solid #cbd5e1;
        background: #f8fafc;
        color: #1e293b;
        cursor: pointer;
        min-height: 24px;
        transition: opacity 0.18s ease;
    }

    .topm-color-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        display: inline-block;
        flex-shrink: 0;
    }

    .topm-chart-card, .topm-rohoel-chart-card {
        margin-top: 0 !important;
        padding: 0 !important;
    }
    .topm-chart-plot-area, .topm-rohoel-chart-plot-area {
        min-height: auto !important;
        height: auto !important;
    }
    .topm-chart-container, .topm-rohoel-chart-container {
        height: auto !important;
        min-height: 300px;
    }
}

@keyframes topmFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 600px) {
    .topm-chart-header {
        padding: 12px 14px !important;
    }
    .topm-chart-body {
        padding: 12px 10px !important;
    }
    .topm-infobox, .topm-rohoel-infobox {
        flex-direction: column;
        align-items: flex-start;
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        margin-bottom: 12px !important;
        width: 100% !important;
    }
    .topm-infobox-price, .topm-rohoel-infobox-price {
        font-size: 18px;
    }
}

@media (max-width: 375px) {
    .topm-chart-container, .topm-rohoel-chart-container {
        border-radius: 4px;
        min-height: 280px;
    }
    .topm-avg-btn, .topm-rohoel-avg-btn {
        padding: 6px 10px;
        font-size: 11px;
        min-height: 38px;
    }
    .topm-infobox, .topm-rohoel-infobox {
        padding: 10px 12px;
        gap: 6px;
    }
}

/* Draggable Year Badges */
.topm-year-badge, .topm-rohoel-year-badge {
    position: absolute;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    cursor: grab;
    user-select: none;
    transform: translate(-50%, -50%);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    z-index: 10;
    pointer-events: auto;
}
.topm-year-badge, .topm-rohoel-year-badge:active {
    cursor: grabbing;
}

/* Highcharts Plot Line Label & Tooltip Overlap Prevention */
.highcharts-plot-line-label {
    pointer-events: none !important;
    user-select: none !important;
}
.highcharts-tooltip-container, .highcharts-tooltip {
    z-index: 9999 !important;
}

