/* ═══════════════════════════════════════════════════════════════
   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%;
}
