/* ═══════════════════════════════════════════════════════════════════════════
   TiM → Qdrant · Komponente: stat plocice, grid kolekcija, status pill, log, audit, modali.

   Deo je podeljenog design sistema (static/css/). REDOSLED UČITAVANJA JE
   KASKADA i stoji u <head>-u index.html — ne menjaj ga:
     vendor/phosphor → tokens → primitives → layout → components → help
     → views → responsive

   Pravila i uputstvo za dodavanje novih ekrana: docs/DESIGN_SYSTEM.md
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── 5. KOMPONENTE ─────────────────────────────────────────────────────── */

/* Stat tile-ovi (dashboard) */
.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: var(--s-4);
}
.stat-tile {
    padding: var(--s-5);
}
.stat-head {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    margin-bottom: var(--s-4);
}
.stat-label {
    font-size: 13.5px;
    font-weight: 600;
}
.stat-value {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -1px;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.stat-value-sm {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.2px;
    line-height: 1.35;
}
.stat-unit {
    font-size: 15px;
    font-weight: 600;
    color: var(--muted);
    margin-left: 2px;
}

/* Traka napretka u stat tile-u. Selektor je namerno skopiran na .stat-tile —
   log linije nose klasu `progress` kao naziv SSE stanja (.log-line.progress),
   pa ih je nevezani `.progress` pretvarao u traku od 6px bez vidljivog teksta. */
.stat-tile .progress {
    height: 6px;
    margin-top: var(--s-3);
    background: var(--surface-3);
    border-radius: var(--r-pill);
    overflow: hidden;
}
.progress-fill {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: var(--r-pill);
    transition: width 0.5s var(--ease);
}

/* Grid kolekcija */
.collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: var(--s-3);
}
.collection-card {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-4);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    transition:
        border-color 0.16s var(--ease),
        transform 0.16s var(--ease);
}
.collection-card:hover {
    border-color: var(--line-strong);
    transform: translateY(-1px);
}
.collection-card .col-dot {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
    border-radius: var(--r-pill);
    background: var(--accent);
}
.collection-card .col-body {
    flex: 1;
    min-width: 0;
}
.collection-card .col-name {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.collection-card .col-meta {
    font-size: 11.5px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.collection-empty {
    grid-column: 1 / -1;
    padding: var(--s-8);
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

/* Status pill — ui.js postavlja className = "status-pill <state>" */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    padding: 5px 11px;
    border-radius: var(--r-pill);
    background: var(--slate-soft);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10.5px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
.status-pill::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: var(--r-pill);
    background: currentColor;
}
.status-pill.running {
    background: var(--accent-soft);
    color: var(--accent);
    animation: pulse 1.4s ease-in-out infinite;
}
.status-pill.done {
    background: var(--emerald-soft);
    color: var(--emerald);
}
.status-pill.error {
    background: var(--rose-soft);
    color: var(--rose);
}
/* Help članak u pripremi — jedini status koji ERP ne objavljuje na sajtu. */
.status-pill.draft {
    background: var(--warn-soft);
    color: var(--warn);
}
@keyframes pulse {
    50% {
        opacity: 0.55;
    }
}

/* Log */
.log-output {
    /* Fiksna visina, ne flex — log-card ne sme da bude flex kontejner jer bi
       `flex-basis: 0` pregazio height i skupio panel na jedan red. */
    background: var(--log-bg);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: var(--s-4);
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.75;
    height: 420px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.log-placeholder {
    color: var(--faint);
}
.log-line {
    display: block;
}
.log-line .tag {
    color: var(--faint);
}
.log-line.ok .tag {
    color: var(--ok);
}
.log-line.error {
    color: var(--err);
}
.log-line.start .tag,
.log-line.progress .tag {
    color: var(--info);
}
.log-line.done {
    color: var(--ok);
    font-weight: 500;
}

/* Audit lista */
.audit-list {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
}
.audit-row {
    display: flex;
    align-items: flex-start;
    gap: var(--s-3);
    padding: 11px var(--s-4);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    font-size: 13px;
    transition: border-color 0.16s var(--ease);
}
.audit-row:hover {
    border-color: var(--line-strong);
}
.audit-row .dot {
    width: 8px;
    height: 8px;
    margin-top: 7px;
    flex-shrink: 0;
    border-radius: var(--r-pill);
}
.audit-row .dot.done {
    background: var(--ok);
    box-shadow: 0 0 0 3px var(--emerald-soft);
}
.audit-row .dot.error {
    background: var(--err);
    box-shadow: 0 0 0 3px var(--rose-soft);
}
.audit-row .a-main {
    flex: 1;
    min-width: 0;
}
.audit-row .a-title {
    display: flex;
    align-items: center;
    gap: 2px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Ikonica ispred naslova zapisa. Veličina i razmak su ovde, a ne u
   `audit.js` — `_phIcon()` gradi samo `<i class="ico ph-light …">`. */
.audit-row .a-title .ico {
    margin-right: 5px;
    font-size: 15px;
    color: var(--muted);
}
.audit-row .a-meta {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11px;
    line-height: 1.6;
}
.audit-empty {
    padding: var(--s-8);
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}
.copy-ids-btn {
    background: transparent;
    border-color: transparent;
}
.copy-ids-btn .ico {
    font-size: 14px;
}
/* Potvrda kopiranja: `events.js` prebaci ikonicu na `ph-check` i doda ovu
   klasu na 1,5 s. Boja ide kroz token — ranije je bila hardkodovan hex. */
.copy-ids-btn.is-copied {
    color: var(--ok);
}

/* Collapse chevron u „Istorija" zaglavlju */
#auditHead {
    cursor: pointer;
    user-select: none;
}
.chevron {
    font-size: 16px;
    color: var(--muted);
    transition: transform 0.2s var(--ease);
}

/* ─── Modali ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--s-5);
    background: var(--overlay);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.18s var(--ease);
}
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-card {
    width: 100%;
    max-width: 620px;
    max-height: 88vh;
    overflow-y: auto;
    padding: var(--s-6) var(--s-6) var(--s-5);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--sh-xl);
    animation: modalRise 0.22s var(--ease);
}
.modal-card.small {
    max-width: 400px;
    text-align: center;
}
.modal-card.wide {
    max-width: 820px;
}

/* Pregled mape članaka — uvučeno drvce iz /data/sitemap.txt. */
.sitemap-tree {
    background: var(--log-bg);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: var(--s-4);
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.8;
    max-height: 62vh;
    overflow: auto;
}
.sitemap-row {
    display: block;
    white-space: pre;
}
.sitemap-row.level-1 {
    color: var(--ink);
    font-weight: 600;
}
.sitemap-row.level-2 {
    color: var(--ink-2);
}
.sitemap-guide {
    color: var(--faint);
}
.sitemap-id {
    color: var(--muted);
}
.sitemap-empty {
    color: var(--faint);
}
@keyframes modalRise {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.modal-head {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    margin-bottom: var(--s-5);
}
.confirm-message {
    margin-bottom: var(--s-5);
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--ink-2);
}

.modal-actions {
    display: flex;
    gap: var(--s-2);
    margin-top: var(--s-6);
    justify-content: flex-end;
}
.modal-actions.center {
    justify-content: center;
}

/* Lista artikala u delete modalu */
.article-scroll {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
}
.article-item {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: 10px var(--s-4);
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    transition: background 0.12s var(--ease);
}
.article-item:last-child {
    border-bottom: none;
}
.article-item:hover {
    background: var(--surface-2);
}
.article-item .art-title {
    flex: 1;
    min-width: 0;
    font-family: var(--mono);
    font-size: 12.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.article-item .art-count {
    flex-shrink: 0;
    padding: 2px 8px;
    background: var(--surface-3);
    border-radius: var(--r-pill);
    color: var(--muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}
.article-item .art-input {
    flex-shrink: 0;
}
.article-item .art-del-btn {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    background: transparent;
    border: none;
    border-radius: var(--r-sm);
    color: var(--faint);
    cursor: pointer;
    transition:
        color 0.16s var(--ease),
        background 0.16s var(--ease);
}
.article-item .art-del-btn:hover {
    color: var(--rose);
    background: var(--rose-soft);
}
/* Dugme je 28px, pa ikonica ide manja od `.ico` default-a (18px). */
.article-item .art-del-btn .ico {
    font-size: 15px;
}
.article-empty {
    padding: var(--s-6);
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

/* Red korisnika / uređaja — .article-item sa dva reda teksta i grupom akcija. */
.user-item .user-avatar {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: var(--r-sm);
    background: var(--surface-3);
    color: var(--muted);
}
.user-item .user-avatar .ico {
    font-size: 17px;
}
.user-item .user-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}
.user-item .user-main .art-title {
    flex: none;
}
.user-item .art-sub {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-size: 11.5px;
}
.user-item .user-actions {
    display: flex;
    align-items: center;
    gap: var(--s-1);
    flex-shrink: 0;
}
.user-item .art-count.muted {
    color: var(--faint);
}
/* Deaktiviran nalog ostaje čitljiv, ali vizuelno povučen unazad. */
.user-item.inactive .user-avatar {
    color: var(--rose);
    background: var(--rose-soft);
}
.user-item.inactive .art-title {
    color: var(--muted);
    text-decoration: line-through;
}

/* Zaglavlje kartice sa više kontrola (lista Help članaka: pretraga, filter, dva
   ikon-dugmeta i primarna akcija). Bez preloma bi se na užim ekranima naslov i
   podnaslov stisnuli u kolonu od nekoliko redova; ovako kontrole padaju u drugi
   red, a tekst zadržava čitljivu širinu. */
.card-head.wrap {
    flex-wrap: wrap;
}
.card-head.wrap .card-head-text {
    min-width: 220px;
}
