/* ═══════════════════════════════════════════════════════════════
   SHORTCODES — style dla [rcn_ceny], [rcn_top], [rcn_transakcje]
   Plik załadowany przez theme (functions.php) po zam-components.
   Plugin nie generuje już inline CSS.
═══════════════════════════════════════════════════════════════ */

/* ── Wrapper ogólny ── */
.dp-sc-wrap {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden; /* dla border-radius */
    margin: 1.6em 0;
    font-family: inherit;
    display: flex;
    flex-direction: column;
    max-width: 100%;
    min-width: 0; /* nie rozciągaj rodzica w flex/grid */
}
/* Każde bezpośrednie dziecko flex nie może rozciągać wrappera */
.dp-sc-wrap > * { min-width: 0; }
.dp-sc-header {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--dp-sc-header-bg, #f0fdf4);
    padding: 10px 14px;
    border-bottom: 1px solid var(--dp-sc-header-border, #d1fae5);
}
.dp-sc-icon  { font-size: 1.1rem; }
.dp-sc-title { flex: 1; font-size: .88rem; font-weight: 700; color: #111; }
.dp-sc-link  { font-size: .75rem; color: var(--color-primary, #1a6b45); text-decoration: none; font-weight: 600; white-space: nowrap; }
.dp-sc-link:hover { text-decoration: underline; }
.dp-sc-src   { font-size: .62rem; color: #9ca3af; border-top: 1px solid #f3f4f6; margin: 0 !important; padding: 6px 14px 10px !important; }
.dp-sc-empty { color: #9ca3af; font-style: italic; padding: 16px; text-align: center; }
.dp-sc-hi    { color: var(--color-primary, #1a6b45); font-weight: 800; }

/* ── Tabela cen [rcn_ceny] ── */
.dp-sc-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    /* gradient-hint że można scrollować */
    background:
        linear-gradient(to right, #fff 30%, transparent),
        linear-gradient(to left,  #fff 30%, transparent) 100% 0,
        radial-gradient(farthest-side at 0   50%, rgba(0,0,0,.08), transparent),
        radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.08), transparent) 100% 0;
    background-repeat: no-repeat;
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
}
.dp-sc-ceny .dp-sc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
}
.dp-sc-ceny .dp-sc-table th,
.dp-sc-ceny .dp-sc-table td {
    padding: 8px 14px;
    border-bottom: 1px solid #f3f4f6;
    text-align: left;
    white-space: nowrap;
}
.dp-sc-ceny .dp-sc-table th {
    background: #fafafa;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #6b7280;
    font-weight: 700;
}
.dp-sc-ceny .dp-sc-table tr:last-child td,
.dp-sc-ceny .dp-sc-table tbody tr:last-child td { border-bottom: none; }
.dp-sc-ceny .dp-sc-table tr:hover td { background: #f9fafb; }
.dp-sc-msc-cell {
    background: var(--dp-sc-header-bg, #f0fdf4) !important;
    vertical-align: middle;
    border-right: 2px solid var(--dp-sc-header-border, #d1fae5);
    padding: 10px 14px;
    white-space: nowrap;
    font-size: .82rem;
}
.dp-sc-msc-first td { border-top: 2px solid #e5e7eb; }

/* ── Wykres [rcn_wykres] ── */
.dp-sc-wykres canvas { padding: 10px 14px; display: block; }

/* ── Ranking [rcn_top] ── */
.dp-sc-ranking { list-style: none; margin: 0; padding: 8px 0; }
.dp-sc-rank-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 8px 14px;
    border-bottom: 1px solid #f3f4f6;
}
.dp-sc-rank-item:last-child { border-bottom: none; }
.dp-sc-rank-n   { min-width: 22px; font-size: .72rem; font-weight: 800; color: #9ca3af; padding-top: 2px; }
.dp-sc-rank-body { flex: 1; }
.dp-sc-rank-row { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: .82rem; }
.dp-sc-bar      { height: 4px; background: #f3f4f6; border-radius: 2px; overflow: hidden; }
.dp-sc-bar-fill { height: 100%; background: var(--color-primary, #1a6b45); border-radius: 2px; }
.dp-sc-rank-item small { font-size: .65rem; color: #9ca3af; }

/* ── Transakcje [rcn_transakcje] ── */
.dp-sc-tl { list-style: none; margin: 0; padding: 4px 0; }
.dp-sc-tl li { border-bottom: 1px solid #f3f4f6; }
.dp-sc-tl li:last-child { border-bottom: none; }
.dp-sc-ti {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    text-decoration: none;
    color: inherit;
    transition: background .15s;
}
.dp-sc-ti:hover { background: #f9fafb; }
.dp-sc-tic { font-size: 1rem; flex-shrink: 0; }
.dp-sc-tib { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.dp-sc-tib strong { font-size: .82rem; color: #111; }
.dp-sc-tib small  { font-size: .68rem; color: #9ca3af; }
.dp-sc-tip { font-size: .88rem; text-align: right; flex-shrink: 0; }
.dp-sc-tip small { font-size: .65rem; font-weight: 400; color: #6b7280; }

/* ── Stat [rcn_stat] ── */
.dp-sc-stat     { text-align: center; padding: 20px 14px 6px; }
.dp-sc-stat-val { font-size: 2.2rem; font-weight: 900; color: var(--color-primary, #1a6b45); line-height: 1.1; }
.dp-sc-stat-val small { font-size: .9rem; font-weight: 600; color: #6b7280; }
.dp-sc-stat-lbl { font-size: .8rem; color: #6b7280; margin-top: 4px; }

/* ═══════════════════════════════════════════════════════════════
   RANKING GMIN — tabela jako karty na mobile
═══════════════════════════════════════════════════════════════ */
.rg-table-wrap { overflow: visible; }

/* Scroll dla tabeli cen (dużo wierszy) */
.rg-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0 0 12px 12px;
    min-width: 0;
    background:
        linear-gradient(to right, #fff 30%, transparent),
        linear-gradient(to left,  #fff 30%, transparent) 100% 0,
        radial-gradient(farthest-side at 0   50%, rgba(0,0,0,.07), transparent),
        radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.07), transparent) 100% 0;
    background-repeat: no-repeat;
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
}

/* Desktop: normalna tabela */
.rg-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.rg-table th {
    padding: 10px 14px;
    background: #f9fafb;
    border-bottom: 2px solid #e5e7eb;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #9ca3af;
    text-align: left;
}
.rg-table td { padding: 12px 14px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.rg-table tr:last-child td { border-bottom: none; }
.rg-table tr:hover td { background: #f9fafb; }

/* ── Mobile: karty ── */
@media (max-width: 580px) {

    /* Ukryj oryginalną tabelę, pokaż karty */
    .rg-table-scroll { overflow: visible; background: none; }
    .rg-table thead { display: none; }
    .rg-table,
    .rg-table tbody,
    .rg-table tr { display: block; width: 100%; }

    .rg-table tr {
        display: grid;
        grid-template-columns: 36px 1fr 1fr;
        grid-template-rows: auto auto;
        gap: 0 8px;
        padding: 12px 14px;
        border-bottom: 1px solid #f3f4f6;
        align-items: center;
        white-space: normal;
    }
    .rg-table tr:last-child { border-bottom: none; }
    .rg-table tr:hover { background: #f9fafb; }

    /* Kolumna #, Gmina, Cena — widoczne */
    .rg-table td { display: block; padding: 0; border: none; }

    /* td:nth-child(1) = # pozycja */
    .rg-table td:nth-child(1) {
        grid-column: 1;
        grid-row: 1 / 3;
        font-size: 1.2rem;
        text-align: center;
        align-self: center;
    }
    /* td:nth-child(2) = Gmina */
    .rg-table td:nth-child(2) {
        grid-column: 2;
        grid-row: 1;
    }
    /* td:nth-child(3) = Wykres-bar — ukryty na mobile */
    .rg-table td:nth-child(3) { display: none; }

    /* td:nth-child(4) = Śr. cena/m² */
    .rg-table td:nth-child(4) {
        grid-column: 3;
        grid-row: 1;
        text-align: right;
    }
    /* td:nth-child(5) = Min-Max */
    .rg-table td:nth-child(5) {
        grid-column: 2;
        grid-row: 2;
        font-size: .7rem;
        color: #9ca3af;
        margin-top: 2px;
    }
    /* td:nth-child(6) = Trend */
    .rg-table td:nth-child(6) {
        grid-column: 3;
        grid-row: 2;
        text-align: right;
        margin-top: 2px;
    }
    /* td:nth-child(7) = Transakcje — ukryty, mało istotny */
    .rg-table td:nth-child(7) { display: none; }

    /* Rozmiary w kartach */
    .rg-gmina-name { font-size: .88rem; }
    .rg-avg { font-size: .9rem; }
    .rg-minmax { font-size: .68rem; }
    .rg-trend { font-size: .75rem; }
}

/* ═══════════════════════════════════════════════════════════════
   TABELE W ARTYKUŁACH — scroll
═══════════════════════════════════════════════════════════════ */
.art-content .table-responsive-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1.2em 0;
    max-width: 100%;
}
.art-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
    white-space: nowrap; /* wrapper ma overflow-x:auto */
    margin: 0;
    min-width: 0; /* nie wymuszaj min-width */
}
.art-content table th,
.art-content table td { padding: 8px 12px; border-bottom: 1px solid #f3f4f6; }
.art-content table th { background: #f9fafb; font-size: .75rem; font-weight: 700; color: #6b7280; }
.art-content table tr:last-child td { border-bottom: none; }

/* ── Shortcodes wewnątrz artykułu — nie mogą rozciągać rodzica ── */
.art-content .dp-sc-wrap {
    margin-left: 0;
    margin-right: 0;
    max-width: 100%;
}
.art-content .dp-sc-table-wrap,
.art-content .rg-table-scroll {
    max-width: 100%;
}

/* ══════════════════════════════════════════════════════════════════
   Nowe shortcody (2026): udzial / histogram / porownanie / top_trans
   ══════════════════════════════════════════════════════════════════ */

/* [rcn_udzial] — taki sam layout jak ranking, tylko % zamiast ceny */
.dp-sc-udzial-list { list-style: none; margin: 0; padding: 0; }
.dp-sc-udzial-item { display: flex; align-items: flex-start; gap: 10px;
    padding: 10px 0; border-bottom: 1px solid var(--color-border, #f0f0f0); }
.dp-sc-udzial-item:last-child { border-bottom: none; }

/* [rcn_histogram] */
.dp-sc-histogram .dp-sc-chart-wrap { padding: 12px 0; }

/* [rcn_porownanie] */
.dp-sc-por-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 14px 0;
}
@media (max-width: 600px) { .dp-sc-por-grid { grid-template-columns: 1fr; } }

.dp-sc-por-box {
    border-radius: 10px;
    padding: 16px;
    text-align: center;
}
.dp-sc-por-med   { background: #d1fae5; border: 1px solid #6ee7b7; }
.dp-sc-por-avg   { background: #dbeafe; border: 1px solid #93c5fd; }
.dp-sc-por-range { background: #f1f5f9; border: 1px solid #cbd5e1; }

.dp-sc-por-label { font-size: .78rem; font-weight: 700; color: var(--color-text-muted,#64748b);
    text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.dp-sc-por-val   { font-size: 1.35rem; font-weight: 800; color: var(--color-text,#1e293b);
    line-height: 1.2; }
.dp-sc-por-val small { font-size: .75rem; font-weight: 500; color: var(--color-text-muted,#64748b); }
.dp-sc-por-sub   { font-size: .78rem; color: var(--color-text-muted,#64748b); margin-top: 4px; }

.dp-sc-por-insight {
    background: #fffbeb;
    border-left: 4px solid #f59e0b;
    border-radius: 0 8px 8px 0;
    padding: 10px 14px;
    font-size: .86rem;
    color: #92400e;
    margin-top: 4px;
}

/* dark mode */
body.dark-mode .dp-sc-por-med   { background: #064e3b; border-color: #065f46; }
body.dark-mode .dp-sc-por-avg   { background: #1e3a5f; border-color: #1d4ed8; }
body.dark-mode .dp-sc-por-range { background: #1e293b; border-color: #334155; }
body.dark-mode .dp-sc-por-label { color: #94a3b8; }
body.dark-mode .dp-sc-por-val   { color: #f1f5f9; }
body.dark-mode .dp-sc-por-sub   { color: #94a3b8; }
body.dark-mode .dp-sc-por-insight { background: #1c1300; border-color: #b45309; color: #fcd34d; }

/* [rcn_top_transakcja] */
.dp-sc-tt-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    text-decoration: none;
    margin: 12px 0 8px;
    transition: transform .15s ease, box-shadow .15s ease;
}
.dp-sc-tt-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(26,107,69,.12); }

.dp-sc-tt-icon { font-size: 2.2rem; flex-shrink: 0; }

.dp-sc-tt-body { flex: 1; min-width: 0; }
.dp-sc-tt-loc  { font-size: 1.05rem; font-weight: 700; color: #1e293b; }
.dp-sc-tt-meta { font-size: .82rem; color: #64748b; margin-top: 2px; }
.dp-sc-tt-price-total { font-size: .88rem; font-weight: 600; color: #1a6b45; margin-top: 4px; }

.dp-sc-tt-m2 { text-align: right; flex-shrink: 0; }
.dp-sc-tt-m2 .dp-sc-hi { display: block; font-size: 1.6rem; font-weight: 800; color: #1a6b45; }
.dp-sc-tt-m2 small { font-size: .75rem; color: #64748b; }

body.dark-mode .dp-sc-tt-card { background: linear-gradient(135deg,#064e3b,#065f46);
    border-color: #059669; }
body.dark-mode .dp-sc-tt-loc  { color: #f1f5f9; }
body.dark-mode .dp-sc-tt-meta { color: #94a3b8; }
body.dark-mode .dp-sc-tt-price-total { color: #6ee7b7; }
body.dark-mode .dp-sc-tt-m2 .dp-sc-hi { color: #34d399; }
body.dark-mode .dp-sc-tt-m2 small { color: #94a3b8; }
