/* ========================================================================
   Page: Legal list (/propisi) — pretraga + tabela rezultata propisa.
   ------------------------------------------------------------------------
   Header (pb-page-head), panel (pb-panel), tabela (pb-table), pager
   (_Pager), čipovi (pb-chip), prazno stanje (pb-empty) i status pill
   (pb-pill) dolaze iz STAMP-a. Ovde ostaju samo leg-* selektori specifični
   za /propisi: FTS search red, grupni dropdown filter, breadcrumbs,
   tabela rezultata i in-row citati. Ranija „tree + shell" varijanta je
   uklonjena (cshtml je čista search-first tabela).
   ======================================================================== */

/* ================= FTS search panel ================= */
/* z-index: pb-panel ima backdrop-filter (stacking kontekst); bez ovoga donji
   panel (kasniji sibling) prekriva otvoreni „Zakon ▾" dropdown koji je zarobljen
   u kontekstu ovog panela. Podizanjem panela ceo njegov sadržaj ide iznad. */
.leg-fts-panel { margin: 16px 0 18px; padding: 18px 20px; z-index: 5; }
.leg-fts-panel .pb-panel__head { padding-bottom: 12px; border-bottom: 1px solid var(--c-border-subtle); margin-bottom: 14px; }
.leg-fts-form { display: flex; flex-direction: column; gap: 10px; }
.leg-fts-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Search input — fokus prsten iz STAMP-a (--c-focus-ring), bez sopstvene plave. */
.leg-fts-input { position: relative; flex: 1 1 320px; min-width: 240px; }
.leg-fts-input-ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--c-text-secondary); }
.leg-fts-input input {
    width: 100%; padding: 10px 12px 10px 34px;
    border: 1px solid var(--c-border-subtle); border-radius: 8px;
    font-size: var(--fs-base); background: var(--c-surface-card); color: var(--c-text-primary);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.leg-fts-input input:focus {
    outline: none;
    border-color: var(--c-focus-ring-border);
    box-shadow: 0 0 0 3px var(--c-focus-ring);
}

/* === Group filter dropdown pill (unutar search reda) ===
   Korisnik vidi jedan kompaktan pill ("Zakon" / "Podzakonski akti" / "Svi") koji
   na klik otvara checklist sa tri opcije. Implementirano <details>/<summary>
   pa radi i bez JS-a (forma se sama submit-uje na change). */
.leg-fts-group-pill { position: relative; flex: 0 0 auto; }
.leg-fts-group-pill[open] > .leg-fts-group-pill__btn .leg-fts-group-pill__caret { transform: rotate(180deg); }
.leg-fts-group-pill__btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 12px; border-radius: var(--p-radius-pill);
    border: 1px solid var(--c-border-subtle);
    background: var(--c-surface-card);
    color: var(--c-text-primary);
    font-size: var(--fs-sm); font-weight: 600; line-height: 1.1;
    cursor: pointer; user-select: none; white-space: nowrap;
    transition: border-color .12s ease, box-shadow .12s ease, background-color .12s ease;
    list-style: none;
}
.leg-fts-group-pill__btn::-webkit-details-marker { display: none; }
.leg-fts-group-pill__btn::marker { content: ""; }
.leg-fts-group-pill__btn:hover { border-color: var(--c-brand); }
.leg-fts-group-pill[open] > .leg-fts-group-pill__btn {
    border-color: var(--c-brand);
    box-shadow: 0 0 0 3px var(--c-focus-ring);
}
.leg-fts-group-pill__label { color: var(--c-text-primary); }
.leg-fts-group-pill__caret { color: var(--c-text-secondary); transition: transform .15s ease; }

.leg-fts-group-pill__menu {
    position: absolute; top: calc(100% + 6px); left: 0;
    min-width: 280px; max-width: 360px;
    padding: 6px;
    background: var(--c-surface-card);
    border: 1px solid var(--c-border-subtle);
    border-radius: 12px;
    box-shadow: var(--p-shadow-glass);
    z-index: 30;
    display: flex; flex-direction: column; gap: 2px;
}
.leg-fts-group-opt {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 8px 10px; border-radius: 8px; cursor: pointer;
    transition: background-color .12s ease;
}
.leg-fts-group-opt:hover { background: var(--c-surface-page-soft); }
.leg-fts-group-opt input[type="checkbox"] {
    margin: 3px 0 0; flex: 0 0 auto;
    accent-color: var(--c-brand);
}
.leg-fts-group-opt__txt { display: flex; flex-direction: column; gap: 2px; line-height: 1.25; }
.leg-fts-group-opt__txt strong { font-size: var(--fs-sm); font-weight: 600; color: var(--c-text-primary); }
.leg-fts-group-opt__txt em { font-style: normal; font-size: var(--fs-2xs); color: var(--c-text-secondary); }

/* === Sugestije ispod pretrage ("Probajte: …") — čipovi su STAMP `.pb-chip --sm`,
   ovde samo raspored reda i labela. === */
.leg-fts-hints {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
}
.leg-fts-hint-label { font-size: var(--fs-2xs); color: var(--c-text-secondary); margin-right: 2px; }

/* Suptilan summary chip iznad tabele kad je pretraga aktivna */
.leg-fts-summary { font-size: var(--fs-sm); color: var(--c-text-secondary); margin-bottom: 10px; }
.leg-fts-summary em { color: var(--c-text-primary); font-style: normal; font-weight: 600; }
.leg-fts-summary--inline {
    margin-top: 14px;
    padding: 10px 14px;
    background: var(--c-brand-tint);
    border: 1px solid var(--c-border-brand);
    border-radius: 10px;
}

/* Sticky search panel — ostaje gore pri skrolu (paritet sa /sudska-praksa). */
#lawFtsPanel { position: sticky; top: 0; z-index: 5; }

/* ================= Rezultati ================= */
.leg-results { display: flex; flex-direction: column; }
.leg-results-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 0;
    gap: 12px;
    position: sticky; top: 0; z-index: 4;
    background: var(--c-surface-page);
}
.leg-breadcrumbs { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--c-text-secondary); flex-wrap: wrap; min-width: 0; flex: 1 1 auto; overflow: hidden; }
.leg-breadcrumbs .crumb {
    font-family: var(--p-font-text);
    font-weight: 600; padding: 2px 6px; border-radius: 6px;
    color: var(--c-text-secondary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.leg-breadcrumbs .crumb.is-last { color: var(--c-brand-strong); background: var(--c-brand-surface); font-weight: 650; min-width: 0; }
.leg-breadcrumbs .crumb-sep { color: var(--c-text-faint); display: inline-flex; }
.leg-results-meta { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.leg-results-count strong { color: var(--c-text-strong); font-weight: 650; }

/* ---------- Tabela rezultata (osnova: STAMP .pb-table) ---------- */
.leg-table-wrap { overflow: auto; }
.leg-table { width: 100%; font-size: var(--fs-sm); }
.leg-table .col-tip { width: 88px; }
.leg-table .col-jur { width: 80px; }
.leg-table .col-glas { width: 220px; }
.leg-table .col-date { width: 130px; }
.leg-table .col-status { width: 110px; }
.leg-table .col-actions { width: 110px; text-align: right; }

.leg-soft { color: var(--c-text-secondary); }
.leg-subtitle { font-size: var(--fs-2xs); color: var(--c-text-subtle); margin-top: 3px; }
.leg-flag-pill { margin-left: 6px; }

.leg-title-cell a {
    color: var(--c-brand-strong); font-weight: 700; text-decoration: none;
    transition: color .15s ease;
}
.leg-title-cell a:hover { color: var(--c-brand-deep); text-decoration: underline; }

.leg-actions-cell { text-align: right; }
.leg-open-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 12px;
    border-radius: var(--p-radius-pill);
    background: var(--c-brand-surface);
    border: 1px solid var(--c-border-brand);
    color: var(--c-brand);
    font-size: var(--fs-xs); font-weight: 600;
    text-decoration: none;
    transition: background .15s ease, transform .12s ease;
}
.leg-open-btn:hover { background: var(--c-brand-tint); transform: translateX(1px); }

/* ---------- In-row citati (Azure Search) ---------- */
.leg-row-snippet {
    margin-top: 6px;
    font-size: var(--fs-xs);
    line-height: 1.45;
    color: var(--c-text-secondary);
    max-width: 720px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.leg-row-snippet mark { background: var(--c-state-warn-soft); color: inherit; padding: 0 2px; border-radius: 2px; }

/* Top-pogođeni član sa naslovom (iz splitter-a v2 / ArticleTitle iz indeksa). */
.leg-row-top-article {
    margin-top: 4px;
    display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline;
    font-size: var(--fs-xs); color: var(--c-text-secondary);
}
.leg-row-top-article__num { font-weight: 600; color: var(--c-text-primary); }
.leg-row-top-article__title { font-style: italic; }

/* Pill-ovi za dubinske linkove ka članovima, ispod citata */
.leg-row-articles { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.leg-article-pill {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px;
    font-size: var(--fs-2xs); font-weight: 600; line-height: 1;
    color: var(--c-brand-strong);
    background: var(--c-brand-tint);
    border: 1px solid var(--c-border-brand);
    border-radius: var(--p-radius-pill);
    text-decoration: none;
    transition: background .12s, border-color .12s, color .12s;
}
.leg-article-pill:hover { background: var(--c-brand-surface); border-color: var(--c-brand); color: var(--c-brand-deep); text-decoration: none; }
.leg-article-pill svg { opacity: .85; }

/* Predefinisani upiti u empty box-u — čipovi su STAMP `.pb-chip --sm`; ovde samo
   raspored. Vidljivo samo na mobilnom (desktop ima gornji „Probajte" red). */
.leg-empty-tries { display: none; }

/* ====================================================================
   MOBILNI (kanonski breakpoint-i: 720 glavni, 560 uski telefon)
   ==================================================================== */
@media (max-width: 720px) {
    /* Sticky paneli prave preklapanja na uskom ekranu — vraćamo u tok. */
    #lawFtsPanel { position: static; }
    .leg-results-head { position: static; }

    /* Search panel — kompaktniji header, sklanja dugačak subtitle. */
    .leg-fts-panel { padding: 14px 14px; margin: 10px 0 12px; }
    .leg-fts-panel .pb-panel__head { padding-bottom: 8px; margin-bottom: 10px; }
    .leg-fts-panel .pb-panel__title { font-size: var(--fs-base); }
    .leg-fts-panel .pb-panel__sub { display: none; }

    /* „Probajte" red iz vrha se sklanja; predlozi se prikazuju u empty box-u. */
    .leg-fts-hints { display: none; }
    .leg-empty-tries {
        display: flex; flex-wrap: wrap; justify-content: center;
        gap: 8px; margin-top: 16px;
    }
    .pb-empty { padding: 26px 16px 28px; }
    .pb-empty__ico { margin-bottom: 12px; }

    /* Page header — manji vertikalni hod. */
    .pb-page-head { margin-bottom: 8px; }
    .pb-page-head__subtitle { font-size: var(--fs-sm); line-height: 1.45; }

    /* Results head je redundantan na mobilnom (tabela sledi odmah ispod). */
    .leg-results-head { display: none; }

    /* Sakrij sekundarne kolone — naslov je primarni cilj. */
    .leg-table .col-glas,
    .leg-table .col-date,
    .leg-table .col-status,
    .leg-table .col-actions,
    .leg-table tbody td:nth-child(4),
    .leg-table tbody td:nth-child(5),
    .leg-table tbody td:nth-child(6),
    .leg-table tbody td:nth-child(7) { display: none; }
    .leg-table .col-tip { width: 72px; }
    .leg-table .col-jur { width: 58px; }
}

/* ---------- Uski telefon: rezultati kao kartice ----------
   Svaki red postaje kompaktna kartica koja ZADRŽAVA datum + status:
   Tip pill → naslov → meta (datum + status). */
@media (max-width: 560px) {
    .leg-table-wrap { overflow: visible; }
    .leg-table, .leg-table tbody, .leg-table tr, .leg-table td { display: block; width: auto; }
    .leg-table thead { display: none; }

    .leg-table tbody tr {
        border: 1px solid var(--c-border-hairline);
        border-radius: 12px;
        background: var(--c-surface-card);
        padding: 11px 13px;
        margin-bottom: 10px;
    }
    .leg-table tbody tr:last-child { margin-bottom: 0; }
    .leg-table tbody td { border: 0; padding: 0; }

    /* Sakriveno: Nivo(2), Sl. glasilo(4), Akcije(7). */
    .leg-table tbody td:nth-child(2),
    .leg-table tbody td:nth-child(4),
    .leg-table tbody td:nth-child(7) { display: none; }

    /* Tip pill — svoj red na vrhu kartice. */
    .leg-table tbody td:nth-child(1) { display: inline-block; width: auto; margin-bottom: 8px; }

    /* Naslov — primarni, pun red. */
    .leg-table tbody td.leg-title-cell { display: block; padding-right: 0; margin-bottom: 8px; }
    .leg-title-cell a { display: block; font-size: var(--fs-base); }

    /* Meta red: datum (sa labelom) + status pill. */
    .leg-table tbody td:nth-child(5),
    .leg-table tbody td:nth-child(6) { display: inline-block; vertical-align: middle; }
    .leg-table tbody td:nth-child(5) { font-size: var(--fs-xs); color: var(--c-text-subtle); margin-right: 10px; }
    .leg-table tbody td:nth-child(5)::before { content: "Na snazi: "; opacity: .7; }
}
