/* ══════════════════════════════════════════════════
   OPI – Oglasy Property Index
   Shared styles for all Price Index blocks
   ══════════════════════════════════════════════════ */

:root {
    --spi-primary: #00a699;
    --spi-primary-light: #e6f7f5;
    --spi-accent: #e8457a;
    --spi-text: #1a1a2e;
    --spi-text-secondary: #6b7280;
    --spi-text-muted: #9ca3af;
    --spi-border: #e5e7eb;
    --spi-bg: #ffffff;
    --spi-bg-light: #f9fafb;
    --spi-radius: 12px;
    --spi-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

/* ── Section headers ── */
.spi-page-title {
    color: var(--spi-text) !important;
}
.spi-section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 20px;
    gap: 12px;
}
.spi-section-header-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.spi-section-title {
    font-family: var(--spi-font);
    font-size: 20px;
    font-weight: 700;
    color: var(--spi-text);
    margin: 0;
    line-height: 1.3;
}
.spi-section-meta {
    font-size: 13px;
    color: var(--spi-text-muted);
}
.spi-section-desc {
    font-size: 14px;
    color: var(--spi-text-secondary);
    line-height: 1.6;
    margin: 6px 0 0;
}

/* ── Toggle buttons (Sale / Rent) ── */
.spi-toggle {
    display: inline-flex;
    background: var(--spi-bg-light);
    border: 1px solid var(--spi-border);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
    flex-shrink: 0;
}
.spi-toggle-btn {
    font-family: var(--spi-font);
    font-size: 13px;
    font-weight: 600;
    padding: 7px 20px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--spi-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}
.spi-toggle-btn:hover {
    color: var(--spi-text);
    background: #fff;
}
.spi-toggle-btn.spi-active {
    background: var(--spi-primary);
    color: #fff;
    box-shadow: 0 1px 3px rgba(0, 166, 153, 0.3);
}

/* ── KPI strip ── */
.spi-kpi-section { text-align: center; }
.spi-kpi-header { margin-bottom: 24px; }
.spi-kpi-subtitle { font-size: 15px; font-weight: 600; color: var(--spi-text); }
.spi-kpi-period { font-size: 13px; color: var(--spi-text-muted); margin-top: 2px; }
.spi-kpi-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--spi-bg);
    border: 1px solid var(--spi-border);
    border-radius: var(--spi-radius);
    padding: 24px 8px;
}
.spi-kpi-item {
    flex: 1 1 0%;
    min-width: 0;
    padding: 0 12px;
    text-align: center;
}
.spi-kpi-item-value {
    font-size: 22px;
    font-weight: 800;
    color: #111827;
    line-height: 1.2;
    letter-spacing: -0.02em;
    white-space: nowrap;
}
.spi-kpi-unit {
    font-size: 13px;
    font-weight: 500;
    color: var(--spi-text-muted);
}
.spi-kpi-sep {
    font-weight: 400;
    color: var(--spi-text-muted);
    margin: 0 2px;
}
.spi-kpi-item-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--spi-text-secondary);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.spi-kpi-divider {
    width: 1px;
    height: 36px;
    background: var(--spi-border);
    flex-shrink: 0;
}

/* ── Tables ── */
.spi-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--spi-radius);
    border: 1px solid var(--spi-border);
}
.spi-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--spi-font);
    background: var(--spi-bg);
    min-width: 400px;
}
.spi-table thead {
    background: var(--spi-bg-light);
}
.spi-table th {
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--spi-text-secondary);
    text-align: left;
    border-bottom: 1px solid var(--spi-border);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.spi-table td {
    padding: 12px 16px;
    font-size: 14px;
    color: var(--spi-text);
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}
.spi-table tbody tr {
    transition: background 0.15s;
}
.spi-table tbody tr:hover {
    background: #fafbfc;
}
.spi-table tbody tr:last-child td {
    border-bottom: none;
}

.spi-th-area { width: 28%; }
.spi-td-area { font-weight: 600; color: var(--spi-text); white-space: nowrap; }
.spi-td-num { font-variant-numeric: tabular-nums; color: #374151; }
.spi-td-current { font-weight: 700; color: var(--spi-text); }

.spi-td-change {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.spi-td-change.spi-up { color: var(--spi-primary); }
.spi-td-change.spi-down { color: #ef4444; }
.spi-change-arrow { margin-right: 2px; }

.spi-td-yield {
    text-align: right;
    font-weight: 700;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

.spi-new-badge {
    display: inline-block;
    background: var(--spi-primary);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: 6px;
    vertical-align: middle;
}

.spi-empty {
    text-align: center;
    color: var(--spi-text-muted);
    padding: 40px 20px !important;
    font-style: italic;
}

/* ── Yield bars ── */
.spi-yield-bar-track {
    height: 10px;
    background: #f3f4f6;
    border-radius: 5px;
    overflow: hidden;
}
.spi-yield-bar-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 1s ease;
}

/* ── Chart section ── */
.spi-chart-wrap {
    background: var(--spi-bg);
    border: 1px solid var(--spi-border);
    border-radius: var(--spi-radius);
    padding: 24px;
    min-height: 300px;
    position: relative;
}
.spi-chart-wrap canvas {
    width: 100% !important;
    max-height: 350px;
}
.spi-chart-source {
    text-align: right;
    font-size: 11px;
    color: var(--spi-text-muted);
    margin-top: 10px;
    font-style: italic;
}

/* ── Map section ── */
.spi-map-wrap {
    background: var(--spi-bg);
    border: 1px solid var(--spi-border);
    border-radius: var(--spi-radius);
    padding: 8px;
    overflow: hidden;
}
.spi-map-wrap .leaflet-container {
    border-radius: 8px;
}

/* ── FAQ section ── */
.spi-faq-list {
    max-width: 800px;
    margin: 0 auto;
}
.spi-faq-item {
    border: 1px solid var(--spi-border);
    border-radius: 10px;
    margin-bottom: 10px;
    overflow: hidden;
    transition: box-shadow 0.2s;
}
.spi-faq-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.spi-faq-question {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 18px 20px;
    border: none;
    background: var(--spi-bg);
    font-family: var(--spi-font);
    font-size: 15px;
    font-weight: 600;
    color: var(--spi-text);
    cursor: pointer;
    text-align: left;
    gap: 12px;
    transition: background 0.15s;
}
.spi-faq-question:hover {
    background: var(--spi-bg-light);
}
.spi-faq-chevron {
    flex-shrink: 0;
    color: var(--spi-text-muted);
    transition: transform 0.25s;
}
.spi-faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease;
    padding: 0 20px;
}
.spi-faq-answer p {
    font-size: 14px;
    line-height: 1.7;
    color: var(--spi-text-secondary);
    margin: 0;
}
.spi-faq-item.spi-open .spi-faq-answer {
    max-height: 500px;
    padding: 0 20px 18px;
}
.spi-faq-item.spi-open .spi-faq-chevron {
    transform: rotate(180deg);
}
.spi-faq-item.spi-open .spi-faq-question {
    color: var(--spi-primary);
}

/* ── Block spacing ── */
.spi-kpi-section,
.spi-table-section,
.spi-chart-section,
.spi-map-section,
.spi-yield-section,
.spi-faq-section {
    font-family: var(--spi-font);
    margin-bottom: 48px;
}

/* ══════════════════════════════════════════════════
   RESPONSIVE – Tablet (max-width: 768px)
   ══════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .spi-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .spi-section-title { font-size: 18px; }
    .spi-section-desc { font-size: 13px; }

    /* KPI: 2-column grid */
    .spi-kpi-strip {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0;
        padding: 0;
    }
    .spi-kpi-item {
        padding: 16px 12px;
        border-bottom: 1px solid var(--spi-border);
    }
    .spi-kpi-item:nth-child(odd) {
        border-right: 1px solid var(--spi-border);
    }
    .spi-kpi-item:nth-last-child(-n+2) {
        border-bottom: none;
    }
    /* single last item spans full width */
    .spi-kpi-item:last-child:nth-child(odd) {
        grid-column: 1 / -1;
        border-right: none;
    }
    .spi-kpi-divider { display: none; }
    .spi-kpi-item-value { font-size: 20px; }
    .spi-kpi-item-label { font-size: 10px; }

    /* Table */
    .spi-table th, .spi-table td { padding: 10px 12px; font-size: 13px; }
    .spi-th-hide-mobile { display: none; }

    /* Chart */
    .spi-chart-wrap { padding: 16px 12px; min-height: 250px; }
    .spi-chart-wrap canvas { max-height: 260px; }

    /* Map */
    .spi-map-container { height: 320px !important; }

    /* FAQ */
    .spi-faq-question { font-size: 14px; padding: 14px 16px; }
    .spi-faq-answer p { font-size: 13px; }

    /* Spacing */
    .spi-kpi-section,
    .spi-table-section,
    .spi-chart-section,
    .spi-map-section,
    .spi-yield-section,
    .spi-faq-section {
        margin-bottom: 36px;
    }
}

/* ══════════════════════════════════════════════════
   RESPONSIVE – Mobile (max-width: 480px)
   ══════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .spi-toggle-btn { padding: 6px 14px; font-size: 12px; }
    .spi-kpi-item-value { font-size: 18px; }
    .spi-kpi-item-label { font-size: 9px; }
    .spi-kpi-unit { font-size: 11px; }

    .spi-section-title { font-size: 16px; }

    .spi-chart-wrap { padding: 12px 8px; min-height: 220px; }
    .spi-chart-wrap canvas { max-height: 220px; }

    .spi-faq-question { font-size: 13px; padding: 12px 14px; gap: 8px; }
    .spi-faq-answer p { font-size: 12px; line-height: 1.6; }
    .spi-faq-item.spi-open .spi-faq-answer { padding: 0 14px 14px; }
}

/* ══════════════════════════════════════════════════
   DARK MODE
   ══════════════════════════════════════════════════ */
[data-theme="dark"] {
    --spi-text: #e5e7eb;
    --spi-text-secondary: #9ca3af;
    --spi-text-muted: #6b7280;
    --spi-border: #2d3444;
    --spi-bg: #1a1d27;
    --spi-bg-light: #242836;
}

[data-theme="dark"] .spi-toggle-btn:hover {
    color: var(--spi-text);
    background: #2d3444;
}

[data-theme="dark"] .spi-kpi-item-value {
    color: var(--spi-text);
}

[data-theme="dark"] .spi-table tbody tr:hover {
    background: var(--spi-bg-light);
}

[data-theme="dark"] .spi-table td {
    border-bottom-color: var(--spi-border);
}

[data-theme="dark"] .spi-td-num {
    color: var(--spi-text-secondary);
}

[data-theme="dark"] .spi-td-change.spi-down {
    color: #f87171;
}

[data-theme="dark"] .spi-yield-bar-track {
    background: var(--spi-border);
}

[data-theme="dark"] .spi-faq-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

[data-theme="dark"] .spi-page-subtitle {
    color: var(--spi-text-secondary) !important;
}