/* ═══════════════════════════════════════════════════════════════════════════
   TiM → Qdrant · Primitivi: brend, kartice, card-icon/tone-*, forme, dugmad, theme toggle.

   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
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── 3. PRIMITIVI ──────────────────────────────────────────────────────── */

/* Brand */
.brand {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    min-width: 0;
}
.logo-tile {
    /* Visina je fiksna, širina prati prirodni odnos tim_logo.webp (123×110)
       da se logo nikad ne izobliči ni ne iseče. */
    display: grid;
    place-items: center;
    height: 38px;
    aspect-ratio: 123 / 110;
    flex-shrink: 0;
    border-radius: var(--r-md);
    overflow: hidden;
    background: var(--ink);
    color: var(--bg);
    box-shadow: var(--sh-md);
}
.logo-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}
.brand-name {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.2px;
    white-space: nowrap;
}
.brand-sub {
    font-size: 11px;
    color: var(--muted);
    letter-spacing: 0.2px;
}

/* Kartice */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    padding: var(--s-6);
    box-shadow: var(--sh-md);
}

.card-head {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    margin-bottom: var(--s-5);
}
.card-head-text {
    flex: 1;
    min-width: 0;
}
.card-title {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.2px;
}
.card-sub {
    font-size: 12.5px;
    color: var(--muted);
    line-height: 1.45;
}

/* Ikona u zaglavlju kartice — bez pozadinskog tile-a; tone-* menja boju ikone. */
.card-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    color: var(--ink-2);
}
.card-icon .ico {
    font-size: 36px;
}
.card-icon.tone-accent {
    color: var(--accent);
}
.card-icon.tone-violet {
    color: var(--violet);
}
.card-icon.tone-emerald {
    color: var(--emerald);
}
.card-icon.tone-cyan {
    color: var(--cyan);
}
.card-icon.tone-rose {
    color: var(--rose);
}
.card-icon.tone-slate {
    color: var(--ink-2);
}
.card-icon.xl {
    width: 52px;
    height: 52px;
    margin: 0 auto var(--s-4);
}
.card-icon.xl .ico {
    font-size: 46px;
}

/* Forme */
.field-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--muted);
    margin: var(--s-5) 0 var(--s-2);
}
.card-head + .field-label,
.modal-head + .field-label,
form > .field-label:first-child {
    margin-top: 0;
}

input,
select,
textarea {
    width: 100%;
    padding: 11px 13px;
    background: var(--input-bg);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 14px;
    outline: none;
    transition:
        border-color 0.16s var(--ease),
        box-shadow 0.16s var(--ease);
}
input:hover:not(:focus),
select:hover:not(:focus),
textarea:hover:not(:focus) {
    border-color: var(--muted);
}
input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
}
input::placeholder,
textarea::placeholder {
    color: var(--faint);
}

select {
    appearance: none;
    padding-right: 38px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237c7a77' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
}
[data-theme="dark"] select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2396969e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

input[type="file"] {
    padding: 8px 12px;
    cursor: pointer;
    color: var(--muted);
    font-size: 13px;
}
input[type="file"]::file-selector-button {
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    color: var(--ink-2);
    border-radius: var(--r-sm);
    padding: 6px 14px;
    margin-right: var(--s-3);
    cursor: pointer;
    font-family: var(--sans);
    font-weight: 500;
    font-size: 13px;
    transition:
        border-color 0.16s var(--ease),
        color 0.16s var(--ease),
        background 0.16s var(--ease);
}
input[type="file"]::file-selector-button:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.hint {
    color: var(--muted);
    font-size: 11.5px;
    font-family: var(--mono);
    margin-top: var(--s-2);
    word-break: break-word;
    line-height: 1.5;
}

.select-wrap {
    display: flex;
    gap: var(--s-2);
}
.select-wrap select {
    flex: 1;
    min-width: 0;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: var(--s-3);
    margin-top: var(--s-5);
    padding: var(--s-3) var(--s-4);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    font-size: 13px;
    color: var(--ink-2);
    cursor: pointer;
    line-height: 1.45;
}
.checkbox-label:hover {
    border-color: var(--line-strong);
}
input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin: 2px 0 0;
    padding: 0;
    accent-color: var(--accent);
    cursor: pointer;
}
.checkbox-label span {
    user-select: none;
}

/* Dugmad */
.primary-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    width: 100%;
    margin-top: var(--s-6);
    padding: 12px 20px;
    background: var(--accent);
    color: var(--on-accent);
    border: none;
    border-radius: var(--r-md);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    transition:
        background 0.16s var(--ease),
        transform 0.08s var(--ease),
        box-shadow 0.16s var(--ease);
}
.primary-btn:hover {
    background: var(--accent-strong);
    box-shadow: 0 4px 14px var(--accent-ring);
}
.primary-btn:active {
    transform: translateY(1px);
}
.primary-btn:disabled {
    background: var(--accent);
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}
.primary-btn.compact {
    width: auto;
    margin-top: 0;
    padding: 9px 18px;
    font-size: 13.5px;
}
.primary-btn.danger {
    background: var(--rose);
}
.primary-btn.danger:hover {
    background: var(--rose);
    filter: brightness(0.92);
    box-shadow: 0 4px 14px var(--rose-soft);
}

.ghost-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    color: var(--ink-2);
    border-radius: var(--r-md);
    padding: 9px 16px;
    font-weight: 500;
    font-size: 13.5px;
    cursor: pointer;
    transition:
        border-color 0.16s var(--ease),
        color 0.16s var(--ease),
        background 0.16s var(--ease);
}
.ghost-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}
/* Bez ovoga ugašeno `.ghost-btn` izgleda potpuno obično: klik ne radi ništa,
   `click` se i ne emituje pa nema ni poruke ni traga u konzoli. Tako je „Pregled"
   u editoru izgledao kao pokvaren. `:disabled` mora da se vidi. */
.ghost-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.ghost-btn:disabled:hover {
    border-color: var(--line-strong);
    color: var(--ink-2);
    background: var(--surface);
}
.ghost-btn.small {
    padding: 6px 12px;
    font-size: 12.5px;
    border-radius: var(--r-sm);
}
/* Destruktivna radnja u tihoj varijanti — miran dok se ne dodirne, pa crven. */
.ghost-btn.danger:hover {
    border-color: var(--rose);
    color: var(--rose);
    background: var(--rose-soft);
}
/* JS postavlja display:block na #loadMoreAuditBtn — zato width preko margine. */
.ghost-btn.block {
    width: 100%;
    margin-top: var(--s-3);
}

.icon-btn {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    color: var(--muted);
    cursor: pointer;
    transition:
        border-color 0.16s var(--ease),
        color 0.16s var(--ease),
        background 0.16s var(--ease);
}
.icon-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}
/* Kompaktna varijanta za redove u listi (korisnici, uređaji). */
.icon-btn.small {
    width: 28px;
    height: 28px;
    border-radius: var(--r-sm);
}
.icon-btn.small .ico {
    font-size: 15px;
}
.icon-btn:disabled,
.art-del-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.icon-btn:disabled:hover {
    border-color: var(--line-strong);
    color: var(--muted);
    background: var(--surface);
}
.art-del-btn:disabled:hover {
    color: var(--faint);
    background: transparent;
}

/* Tooltip — čist CSS, bez JS-a: element sa klasom `.tip` i atributom `data-tip`
   dobija oblačić iznad sebe na hover i na fokus tastaturom. Koristi se kad tekst
   NIJE vidljiv nigde drugde (ikonica bez natpisa, stanje sinhronizacije); kad
   samo ponavlja natpis koji se već vidi, dovoljan je `title`. Isti tekst uvek
   ide i u `aria-label` — oblačić je za oko, `aria-label` za čitač ekrana. */
.tip {
    position: relative;
}
.tip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    z-index: 40;
    width: max-content;
    max-width: 240px;
    padding: 6px 9px;
    background: var(--ink);
    color: var(--surface);
    border-radius: var(--r-sm);
    box-shadow: var(--sh-lg);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.35;
    letter-spacing: normal;
    text-transform: none;
    text-align: center;
    opacity: 0;
    transform: translate(-50%, 4px);
    pointer-events: none;
    transition:
        opacity 0.14s var(--ease),
        transform 0.14s var(--ease);
}
.tip:hover::after,
.tip:focus-visible::after {
    opacity: 1;
    transform: translate(-50%, 0);
}
/* Za kontrolu uz desnu ivicu — centriran oblačić bi izašao iz kartice. */
.tip-end::after {
    left: auto;
    right: 0;
    transform: translate(0, 4px);
}
.tip-end:hover::after,
.tip-end:focus-visible::after {
    transform: translate(0, 0);
}

/* Theme toggle — fiksan, vidljiv i na login i na app ekranu. */
.theme-toggle {
    position: fixed;
    top: var(--s-5);
    right: var(--s-5);
    z-index: 60;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    color: var(--muted);
    cursor: pointer;
    box-shadow: var(--sh-sm);
    transition:
        border-color 0.16s var(--ease),
        color 0.16s var(--ease);
}
.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.theme-toggle .icon-sun {
    display: none;
}
.theme-toggle .icon-moon,
[data-theme="dark"] .theme-toggle .icon-sun {
    display: grid;
}
[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}

.error-text {
    display: flex;
    align-items: flex-start;
    gap: var(--s-2);
    margin-top: var(--s-4);
    padding: 10px 13px;
    background: var(--rose-soft);
    border: 1px solid transparent;
    border-radius: var(--r-md);
    color: var(--rose);
    font-size: 13px;
    line-height: 1.45;
}
