/**
 * Summary stránka — [agf-shipping-summary] shortcode renderer.
 * Bez zaoblených rohov (web nemá radius).
 *
 * Cenová matrix: jeden semantický markup, dva zobrazenia.
 * Desktop = transposed grid (riadky = labels, stĺpce = sadzby).
 * Mobile  = lineárne dvojice (každá sadzba = pair "label + value").
 * Pivot je čisto cez CSS Grid + grid-auto-flow column + custom property `--cols`.
 */

.agf-summary { margin: 24px 0; }

.agf-summary-section-title {
    font-size: 22px;
    font-weight: 700;
    color: #2c3e50;
    margin: 24px 0 14px;
}

.agf-summary-empty {
    padding: 18px;
    text-align: center;
    color: #6c757d;
    background: #f8f9fa;
    margin-bottom: 16px;
}

.agf-summary-list {
    list-style: none;
    padding: 0;
    margin: 0 0 18px;
}

.agf-summary-item {
    background: #fff;
    border: 1px solid #e3e8ee;
    margin-bottom: 8px;
    overflow: hidden;
    transition: box-shadow 0.15s ease;
}
.agf-summary-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,.04); }

.agf-summary-row {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding: 14px 18px;
    background: transparent;
    border: 0;
    cursor: pointer;
    text-align: left;
    outline: none;
    transition: background 0.15s ease;
}
.agf-summary-row:focus { outline: none; }
.agf-summary-row:hover { background: #fafcfe; }
.agf-summary-row.is-static { cursor: default; }
.agf-summary-row.is-static:hover { background: transparent; }

.agf-summary-icon {
    flex-shrink: 0;
    width: 80px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5cb85c;
    font-size: 22px;
}
.agf-summary-icon img {
    max-width: 80px;
    max-height: 50px;
    width: auto;
    height: auto;
    object-fit: contain;
}
.agf-summary-icon--payment {
    /* Parent box je transparent — bg drží inner .agf-summary-icon-box (80×50 fixed).
       Tým sa bg pri mobile (parent flex:0 0 100%) nerozleje cez celý riadok. */
    background: transparent;
    color: #fff;
    font-size: 18px;
}
.agf-summary-icon--payment .agf-summary-icon-box {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 50px;
    background: #5cb85c;
    color: #fff;
    padding: 4px;
    box-sizing: border-box;
}
.agf-summary-icon--payment .agf-summary-icon-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.agf-summary-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.agf-summary-name {
    font-size: 16px;
    font-weight: 700;
    color: #2c3e50;
}
.agf-summary-price {
    margin-top: 4px;
    font-size: 13px;
    color: #6c757d;
}
.agf-summary-price strong {
    color: #2c3e50;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.agf-summary-free {
    font-weight: 700;
    color: #5cb85c;
}
/* Pravidlo "doprava zdarma od X Kč" v hlavičke karty pod cenou (variant A).
   V popisovom bloku (variant C) sa vyrenderuje ako <p> ktoré dedí chevron z generic .agf-summary-desc p::before. */
.agf-summary-free-rule {
    display: inline-block;
    margin-top: 3px;
    font-size: 12px;
    font-weight: 600;
    color: #5cb85c;
}
.agf-summary-free-rule .fa { margin-right: 4px; }

/* Více / Méně toggle */
.agf-summary-toggle {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #6c757d;
    font-size: 13px;
    transition: color 0.15s ease;
}
.agf-summary-toggle .fa {
    font-size: 11px;
    transition: transform 0.18s ease;
}
.agf-summary-item.is-expanded .agf-summary-toggle { color: #5cb85c; }
.agf-summary-item.is-expanded .agf-summary-toggle .fa { transform: rotate(180deg); }

.agf-summary-detail {
    display: none;
    padding: 0 18px 16px;
    border-top: 1px solid #f0f3f7;
    /* Container query root — rates tabuľky sa stackujú podľa šírky tohto kontajnera
       (nie viewportu), takže každá metóda reaguje nezávisle. Threshold závisí od
       počtu stĺpcov tabuľky (viď container queries nižšie). */
    container-type: inline-size;
}
/* `display` je riadený jQuery slideToggle (inline style) — žiadne CSS override
   pre .is-expanded, inak by sa CSS prepol instantly a zlomil animáciu. */

.agf-summary-desc {
    padding-top: 12px;
    color: #495057;
    font-size: 14px;
    line-height: 1.5;
}
.agf-summary-desc p {
    font-size: 14px;
    position: relative;
    padding-left: 18px;
}
.agf-summary-desc p + p { margin-top: 0; }
.agf-summary-desc p:last-child { margin-bottom: 0; }
.agf-summary-desc p::before {
    content: "\f054"; /* fa-chevron-right */
    font-family: "Font Awesome 5 Pro";
    font-weight: 900;
    position: absolute;
    left: 0;
    top: 0;
    color: #5cb85c;
    font-size: 11px;
}
/* `<a>` v paragraphe popisu má dedi farbu/váhu (link sa nevizuálne odlišuje od textu) */
.agf-summary-desc p a {
    font-weight: inherit;
    color: inherit;
}
.agf-summary-desc a { color: #5cb85c; }
/* Resetujeme parent .agf-summary-list nastavenia (list-style:none, padding:0)
   — Summernote ukladá <ul><li>...</li></ul>, ktoré chceme renderovať s bullets. */
.agf-summary-desc ul,
.agf-summary-desc ol {
    list-style: revert;
    padding-left: 22px;
    margin: 0 0 8px;
}
.agf-summary-desc ul { list-style: disc; }
.agf-summary-desc ol { list-style: decimal; }
.agf-summary-desc li { margin-bottom: 4px; }
.agf-summary-desc li:last-child { margin-bottom: 0; }

/* Sekciový nadpis "Kolik zaplatím za dopravu?" / "Cena dobírky" */
.agf-summary-pricing-title {
    font-size: 15px;
    font-weight: 700;
    color: #2c3e50;
    margin: 18px 0 10px;
}

/* === CENOVÁ MATRIX (desktop transposed view via Grid) =====================
 *  HTML: <div .agf-summary-rates style="--cols: N;">
 *          <span .label--w>Hmotnost obj.</span>
 *          <span .label--p>Cena dopravy</span>
 *          [opakuje sa N×]
 *          <span .cell--w data-label>do 2 kg</span>
 *          <span .cell--p data-label>120 Kč</span>
 *        </div>
 *  Grid plnenie: column-flow → 1. stĺpec = labels, ďalšie N stĺpcov = páry (w/p).
 */
.agf-summary-rates {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(var(--rows, 2), 1fr);
    grid-template-columns: minmax(160px, auto) repeat(var(--cols, 1), minmax(80px, 1fr));
    background: #f8f9fa;
    font-size: 13px;
    overflow-x: auto;
}
.agf-summary-rates > * {
    padding: 10px 14px;
    text-align: center;
    line-height: 1.3;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333745;
    background: #f8f9fa;
    border: 2px solid #FFFFFF;
}
.agf-summary-rates-label {
    text-align: left !important;
    justify-content: flex-start !important;
    font-weight: bold;
    color: #333745;
}
.agf-summary-rates-cell {
    font-variant-numeric: tabular-nums;
}

/* Dobírka (flat) — prirodzený paragraph v rámci desc. Margin dedíme z generického
   `.agf-summary-desc p` (resp. browser default) — explicitný override sa nehodí,
   lebo by sa nerovnal gapu medzi ostatnými p tagmi (free-rule-bullet, no-pytle).
   Posledný p už zneutralizuje `.agf-summary-desc p:last-child { margin-bottom: 0 }`. */

/* === MOBILE — viewport-level non-rates UI tweaks ==========================
 *  Title sizes, paddings, icon flex — tieto reagujú na viewport (mobile UX),
 *  nie na container width. Stack-mode pre rates tabuľky je nižšie cez
 *  container queries (per metóda + per počet stĺpcov).
 */
@media (max-width: 767px) {
    .agf-summary-section-title { font-size: 18px; }
    .agf-summary-row {
        padding: 12px 14px;
        gap: 8px;
        flex-wrap: wrap;
    }
    /* Ikona/obrázok dopravy na samostatnom riadku — texty (name/price/free rule) pod ňou */
    .agf-summary-icon {
        flex: 0 0 100%;
        justify-content: flex-start;
        height: auto;
        font-size: 18px;
    }
    .agf-summary-name { font-size: 15px; }
    .agf-summary-detail { padding: 0 14px 14px; }
    .agf-summary-toggle-text { display: none; }
}

/* === CONTAINER QUERIES — stack mode per # stĺpcov ==========================
 *  Každá tabuľka má svoj `--cols: N;` v inline style. Threshold pre stack mode
 *  závisí od N — tabuľka s viac stĺpcami potrebuje viac priestoru, takže
 *  stack-uje skôr (pri väčšom container width):
 *
 *    2-3 cols → stack ak je `.agf-summary-detail` ≤ 500px (úzka tabuľka)
 *    4-5 cols → stack ak ≤ 700px (stredná)
 *    6+ cols → stack ak ≤ 900px (široká)
 *
 *  Pri mobile viewporte (~360px) sa všetky container queries aktivujú —
 *  všetky tabuľky stackujú. Pri desktope, len úzke layouty (sidebar widget,
 *  narrow column) trigger-ujú stack.
 */

/* Aliased selector helper — `:is()` agguruje rovnaké rules pre rôzne cols ranges.
   Pozor: trailing `;` v `[style*="--cols: N;"]` zabraňuje že N=1 matchne aj 10, 11... */

@container (max-width: 500px) {
    .agf-summary-rates:is([style*="--cols: 1;"], [style*="--cols: 2;"], [style*="--cols: 3;"]) {
        display: block;
        border: 0;
        overflow: visible;
        background: transparent;
    }
    .agf-summary-rates:is([style*="--cols: 1;"], [style*="--cols: 2;"], [style*="--cols: 3;"]) .agf-summary-rates-label { display: none; }
    .agf-summary-rates:is([style*="--cols: 1;"], [style*="--cols: 2;"], [style*="--cols: 3;"]) .agf-summary-rates-cell {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0;
        padding-right: 10px;
        min-height: 36px;
        border: 0;
        border-bottom: 2px solid #FFFFFF;
        text-align: left;
        white-space: normal;
    }
    .agf-summary-rates:is([style*="--cols: 1;"], [style*="--cols: 2;"], [style*="--cols: 3;"]) .agf-summary-rates-cell:last-child { border-bottom: 0; }
    .agf-summary-rates:is([style*="--cols: 1;"], [style*="--cols: 2;"], [style*="--cols: 3;"]) .agf-summary-rates-cell::before {
        content: attr(data-label);
        display: flex;
        align-items: center;
        align-self: stretch;
        width: 50%;
        margin-right: 10px;
        padding: 6px 10px;
        border-right: 2px solid #FFFFFF;
        box-sizing: border-box;
        flex-shrink: 0;
        font-size: 13px;
        font-weight: 600;
    }
    .agf-summary-rates:is([style*="--cols: 1;"], [style*="--cols: 2;"], [style*="--cols: 3;"]) .agf-summary-rates-cell--pr { color: #333745; }
    .agf-summary-rates:is([style*="--cols: 1;"], [style*="--cols: 2;"], [style*="--cols: 3;"]) .agf-summary-rates-cell--p {
        position: relative;
        color: #333745;
        margin-bottom: 20px;
        border-bottom: 0;
    }
    .agf-summary-rates:is([style*="--cols: 1;"], [style*="--cols: 2;"], [style*="--cols: 3;"]) .agf-summary-rates-cell--p::after {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        bottom: -10px;
        height: 1px;
        background: #d0d4da;
    }
    .agf-summary-rates:is([style*="--cols: 1;"], [style*="--cols: 2;"], [style*="--cols: 3;"]) .agf-summary-rates-cell--p:last-child { margin-bottom: 0; }
    .agf-summary-rates:is([style*="--cols: 1;"], [style*="--cols: 2;"], [style*="--cols: 3;"]) .agf-summary-rates-cell--p:last-child::after { display: none; }
}

@container (max-width: 700px) {
    .agf-summary-rates:is([style*="--cols: 4;"], [style*="--cols: 5;"]) {
        display: block;
        border: 0;
        overflow: visible;
        background: transparent;
    }
    .agf-summary-rates:is([style*="--cols: 4;"], [style*="--cols: 5;"]) .agf-summary-rates-label { display: none; }
    .agf-summary-rates:is([style*="--cols: 4;"], [style*="--cols: 5;"]) .agf-summary-rates-cell {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0;
        padding-right: 10px;
        min-height: 36px;
        border: 0;
        border-bottom: 2px solid #FFFFFF;
        text-align: left;
        white-space: normal;
    }
    .agf-summary-rates:is([style*="--cols: 4;"], [style*="--cols: 5;"]) .agf-summary-rates-cell:last-child { border-bottom: 0; }
    .agf-summary-rates:is([style*="--cols: 4;"], [style*="--cols: 5;"]) .agf-summary-rates-cell::before {
        content: attr(data-label);
        display: flex;
        align-items: center;
        align-self: stretch;
        width: 50%;
        margin-right: 10px;
        padding: 6px 10px;
        border-right: 2px solid #FFFFFF;
        box-sizing: border-box;
        flex-shrink: 0;
        font-size: 13px;
        font-weight: 600;
    }
    .agf-summary-rates:is([style*="--cols: 4;"], [style*="--cols: 5;"]) .agf-summary-rates-cell--pr { color: #333745; }
    .agf-summary-rates:is([style*="--cols: 4;"], [style*="--cols: 5;"]) .agf-summary-rates-cell--p {
        position: relative;
        color: #333745;
        margin-bottom: 20px;
        border-bottom: 0;
    }
    .agf-summary-rates:is([style*="--cols: 4;"], [style*="--cols: 5;"]) .agf-summary-rates-cell--p::after {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        bottom: -10px;
        height: 1px;
        background: #d0d4da;
    }
    .agf-summary-rates:is([style*="--cols: 4;"], [style*="--cols: 5;"]) .agf-summary-rates-cell--p:last-child { margin-bottom: 0; }
    .agf-summary-rates:is([style*="--cols: 4;"], [style*="--cols: 5;"]) .agf-summary-rates-cell--p:last-child::after { display: none; }
}

@container (max-width: 900px) {
    .agf-summary-rates:is([style*="--cols: 6;"], [style*="--cols: 7;"], [style*="--cols: 8;"], [style*="--cols: 9;"]) {
        display: block;
        border: 0;
        overflow: visible;
        background: transparent;
    }
    .agf-summary-rates:is([style*="--cols: 6;"], [style*="--cols: 7;"], [style*="--cols: 8;"], [style*="--cols: 9;"]) .agf-summary-rates-label { display: none; }
    .agf-summary-rates:is([style*="--cols: 6;"], [style*="--cols: 7;"], [style*="--cols: 8;"], [style*="--cols: 9;"]) .agf-summary-rates-cell {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0;
        padding-right: 10px;
        min-height: 36px;
        border: 0;
        border-bottom: 2px solid #FFFFFF;
        text-align: left;
        white-space: normal;
    }
    .agf-summary-rates:is([style*="--cols: 6;"], [style*="--cols: 7;"], [style*="--cols: 8;"], [style*="--cols: 9;"]) .agf-summary-rates-cell:last-child { border-bottom: 0; }
    .agf-summary-rates:is([style*="--cols: 6;"], [style*="--cols: 7;"], [style*="--cols: 8;"], [style*="--cols: 9;"]) .agf-summary-rates-cell::before {
        content: attr(data-label);
        display: flex;
        align-items: center;
        align-self: stretch;
        width: 50%;
        margin-right: 10px;
        padding: 6px 10px;
        border-right: 2px solid #FFFFFF;
        box-sizing: border-box;
        flex-shrink: 0;
        font-size: 13px;
        font-weight: 600;
    }
    .agf-summary-rates:is([style*="--cols: 6;"], [style*="--cols: 7;"], [style*="--cols: 8;"], [style*="--cols: 9;"]) .agf-summary-rates-cell--pr { color: #333745; }
    .agf-summary-rates:is([style*="--cols: 6;"], [style*="--cols: 7;"], [style*="--cols: 8;"], [style*="--cols: 9;"]) .agf-summary-rates-cell--p {
        position: relative;
        color: #333745;
        margin-bottom: 20px;
        border-bottom: 0;
    }
    .agf-summary-rates:is([style*="--cols: 6;"], [style*="--cols: 7;"], [style*="--cols: 8;"], [style*="--cols: 9;"]) .agf-summary-rates-cell--p::after {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        bottom: -10px;
        height: 1px;
        background: #d0d4da;
    }
    .agf-summary-rates:is([style*="--cols: 6;"], [style*="--cols: 7;"], [style*="--cols: 8;"], [style*="--cols: 9;"]) .agf-summary-rates-cell--p:last-child { margin-bottom: 0; }
    .agf-summary-rates:is([style*="--cols: 6;"], [style*="--cols: 7;"], [style*="--cols: 8;"], [style*="--cols: 9;"]) .agf-summary-rates-cell--p:last-child::after { display: none; }
}

/* === Rule engine — auto-generated text bloky v summary desc =================
   Každý typ akcie má vlastnú farebnú signalizáciu:
     allows     — neutrálny popisný text (default čierna, bez prefix ikony)
     set_free   — zelená "doprava zdarma"
     surcharges — oranžová "príplatok"
     blocks     — sivá/červená "nedostupné"
*/
.agf-summary-rule-allows {
    color: #495057;
}
.agf-summary-rule-free {
    color: #3c763d;
    font-weight: 600;
}
.agf-summary-rule-surcharge {
    color: #8a6d3b;
}
.agf-summary-rule-block {
    color: #a94442;
}
