/* ============================================================
   Karlix QMS — profil, tenant, impersonacija
   Dopuna uz qms.css i qms-case.css.
   ============================================================ */

/* pomoćne klase (umjesto inline stilova — CLAUDE.md) */
.qms-profile-wrap { max-width: 760px; }
.qms-profile-idcol { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.qms-profile-permlink { font-size: 12px; margin-left: 8px; }
.qms-savebar--flush { border: 0; border-top: 1px solid var(--line); border-radius: 0; }

/* ------------------------------------------------------------
   1. ZAGLAVLJE PROFILA
   ------------------------------------------------------------ */

.qms-profile-head {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}
.qms-profile-avatar {
    flex: 0 0 auto;
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--accent); color: var(--accent-ink);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 600;
}
.qms-profile-name { font-size: 15px; font-weight: 600; color: var(--ink-strong); }
.qms-profile-meta { font-size: 12.5px; color: var(--ink-3); }

/* identitet se ne uređuje u QMS-u */
.qms-profile-note {
    display: flex; align-items: flex-start; gap: 9px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
    font-size: 12px; line-height: 1.55; color: var(--ink-2);
}
.qms-profile-note i { flex: 0 0 auto; font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }

.qms-profile-row {
    display: flex; align-items: baseline; gap: 12px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--line-soft);
}
.qms-profile-row:last-child { border-bottom: 0; }
.qms-profile-label { flex: 0 0 150px; font-size: 11.5px; color: var(--ink-3); }
.qms-profile-value { min-width: 0; font-size: 13px; color: var(--ink); }
.qms-profile-value--good { color: var(--good-text); }
.qms-profile-value--muted { color: var(--ink-2); }

/* ------------------------------------------------------------
   2. POSTAVKE RADA
   ------------------------------------------------------------ */

.qms-prefrow {
    display: flex; align-items: center; gap: 14px;
    padding: 13px 20px;
    border-bottom: 1px solid var(--line-soft);
}
.qms-prefrow-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.qms-prefrow-label { font-size: 13.5px; color: var(--ink-strong); }
.qms-prefrow-note { font-size: 12px; color: var(--ink-3); text-wrap: pretty; }
.qms-prefrow select { flex: 0 0 auto; width: auto; min-height: 34px; }

/* ------------------------------------------------------------
   3. POPIS TENANATA
   ------------------------------------------------------------ */

/* pomoćne klase (umjesto inline stilova — CLAUDE.md) */
.qms-tenantsearch {
    padding: 0 20px; height: 44px; display: flex; align-items: center;
    border-bottom: 1px solid var(--line-soft); background: var(--surface-2);
}
.qms-tenantsearch input { border: 0; background: transparent; padding-left: 0; }
.qms-tenantcol { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.qms-tenant-switchbtn { width: auto; padding: 0 11px; gap: 6px; font-size: 12px; }
.qms-tenantfoot { padding: 12px 20px; font-size: 12px; line-height: 1.55; color: var(--ink-3); }

.qms-tenantrow {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--line-soft);
    color: inherit; text-decoration: none;
}
.qms-tenantrow:hover { background: var(--surface-2); text-decoration: none; color: inherit; }
.qms-tenantrow.is-current { background: var(--accent-soft); }
.qms-tenantrow.is-current:hover { background: var(--accent-soft); }

.qms-tenantmark {
    flex: 0 0 auto;
    width: 26px; height: 26px;
    border-radius: 7px;
    background: var(--neutral-soft); color: var(--ink-2);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700;
}
.is-current .qms-tenantmark { background: var(--accent); color: var(--accent-ink); }

.qms-tenantname { font-size: 13.5px; color: var(--ink-strong); }
.is-current .qms-tenantname { font-weight: 600; }
.qms-tenantmeta { font-size: 11.5px; color: var(--ink-3); }

.qms-tenantcurrent {
    flex: 0 0 auto;
    padding: 2px 8px; border-radius: 20px;
    background: var(--accent-soft); color: var(--accent-text);
    font-size: 11px; font-weight: 600;
}

/* ------------------------------------------------------------
   4. PREGLED KAO KORISNIK
   Nije prijava kao ta osoba — crvena je namjerna.
   ------------------------------------------------------------ */

.qms-impersonate {
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 3px solid var(--bad);
    border-radius: var(--r);
    overflow: hidden;
}
.qms-impersonate-head {
    display: flex; align-items: center; gap: 11px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
}
.qms-impersonate-head > i { font-size: 13.5px; color: var(--bad-text); }
.qms-impersonate-title { font-size: 14px; font-weight: 600; color: var(--ink-strong); }
.qms-readonly-tag {
    margin-left: auto;
    padding: 2px 8px; border-radius: 5px;
    background: var(--bad-soft); color: var(--bad-text);
    font-size: 11px;
}

.qms-impersonate-warn {
    display: flex; align-items: flex-start; gap: 9px;
    padding: 13px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
    font-size: 12px; line-height: 1.6; color: var(--ink-2);
}
.qms-impersonate-warn i { flex: 0 0 auto; font-size: 12.5px; color: var(--bad-text); margin-top: 2px; }

.qms-impersonate-field {
    display: flex; flex-direction: column; gap: 6px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line-soft);
}
.qms-impersonate-hint { font-size: 11.5px; color: var(--ink-3); }

.qms-impersonate-foot {
    display: flex; align-items: center; gap: 10px;
    padding: 13px 20px;
    background: var(--surface-2);
}
.qms-impersonate-foot span { font-size: 12px; color: var(--ink-3); }

.qms-btn-danger {
    margin-left: auto;
    display: inline-flex; align-items: center; gap: 7px;
    height: 32px; padding: 0 14px;
    border: 1px solid color-mix(in oklch, var(--bad) 45%, transparent);
    border-radius: var(--r-sm);
    background: var(--bad-soft);
    color: var(--bad-text);
    font: inherit; font-size: 12.5px; font-weight: 600;
    cursor: pointer; text-decoration: none;
}
.qms-btn-danger:hover { border-color: var(--bad); color: var(--bad-text); text-decoration: none; }

/* ------------------------------------------------------------
   5. TRAKA AKTIVNOG PREGLEDA
   Stoji na SVAKOM ekranu; bez nje administrator zaboravi da je
   u pregledu i tumači ekran kao svoj.
   ------------------------------------------------------------ */

.qms-impbar {
    position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; gap: 12px;
    padding: 11px 18px;
    background: var(--impbar-bg);
    color: var(--impbar-fg);
    font-size: 13px;
}
.qms-theme, .qms-theme-dark { --impbar-bg: oklch(0.68 0.16 25); --impbar-fg: #1a0705; --impbar-btn-bg: #1a0705; --impbar-btn-fg: oklch(0.86 0.1 25); }
/* na svijetloj podlozi jantar-crvena nema kontrast za nešto što se ne smije propustiti */
.qms-theme-light { --impbar-bg: oklch(0.5 0.18 25); --impbar-fg: #ffffff; --impbar-btn-bg: #ffffff; --impbar-btn-fg: oklch(0.46 0.18 25); }

.qms-impbar-name { font-weight: 600; }
.qms-impbar-meta { opacity: .9; font-size: 12.5px; }
.qms-impbar-exit {
    margin-left: auto;
    display: inline-flex; align-items: center; gap: 7px;
    height: 28px; padding: 0 12px;
    border: 0; border-radius: 7px;
    background: var(--impbar-btn-bg);
    color: var(--impbar-btn-fg);
    font: inherit; font-size: 12px; font-weight: 600;
    cursor: pointer; text-decoration: none;
}
.qms-impbar-exit:hover { color: var(--impbar-btn-fg); text-decoration: none; }

/* u pregledu se ne sprema ništa — ali gumb za IZLAZAK iz pregleda mora raditi */
body.is-impersonating .btn-primary:not(.qms-impbar-exit),
body.is-impersonating button[type="submit"]:not(.qms-impbar-exit) {
    opacity: 1;
    background: var(--surface-3) !important;
    border-color: var(--line-strong) !important;
    color: var(--ink-disabled) !important;
    pointer-events: none;
}

@media (max-width: 640px) {
    .qms-impbar { flex-wrap: wrap; }
    .qms-impbar-exit { margin-left: 0; width: 100%; justify-content: center; height: 36px; }
    .qms-profile-row { flex-direction: column; gap: 2px; }
    .qms-profile-label { flex: 0 0 auto; }
}

@media print {
    .qms-impbar { position: static; }
}
