/* ─── Podešavanja i izbornik modela ──────────────────────────────────────────
   Zaseban fajl jer je components.css na 543 od 600 linija. Ide IZNAD
   responsive.css u index.html — sva @media pravila su tamo i računaju na to da
   gaze sve pre sebe (DESIGN_SYSTEM.md §1).

   Sve boje idu kroz tokene iz tokens.css; nijedna hardkodovana vrednost, da
   obe teme rade bez posebnog bloka. */

.settings-layout {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    align-items: start;
    gap: var(--s-5);
}

.settings-sidebar {
    padding: var(--s-4);
    position: sticky;
    top: 96px;
}

.settings-menu-title {
    margin: var(--s-1) var(--s-2) var(--s-4);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.7px;
}

.settings-nav {
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    width: 100%;
    min-height: 44px;
    padding: var(--s-3) var(--s-2);
    border: 1px solid transparent;
    border-radius: var(--r-md);
    background: transparent;
    color: var(--ink-2);
    text-align: left;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.settings-nav-item span {
    flex: 1;
}

.settings-nav-item:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.settings-nav-item.active {
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-weight: 600;
}

.settings-nav-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.settings-nav-item .ico:last-child {
    font-size: 14px;
    visibility: hidden;
}

.settings-nav-item.active .ico:last-child {
    visibility: visible;
}

.settings-menu-hint {
    margin: var(--s-4) var(--s-2) var(--s-1);
    padding-top: var(--s-4);
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.settings-content {
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
    min-width: 0;
}

.settings-content > .error-text {
    margin: 0;
}

/* Polje sa dugmetom „Izaberi" — model se ne kuca, bira se iz spiska, pa je
   input readonly i služi samo prikazu. */
.setting-pick {
    display: flex;
    gap: var(--s-2);
    align-items: center;
}

.setting-pick input {
    flex: 1;
    min-width: 0;
}

.setting-pick input[readonly] {
    cursor: default;
    color: var(--muted);
}

.setting-pick input[readonly]:not(:placeholder-shown) {
    color: var(--ink);
}

/* Spisak kolekcija u koje AI sme da piše. */
.setting-checks {
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
    padding: var(--s-2);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface-2);
    max-height: 190px;
    overflow-y: auto;
}

.check-inline {
    display: flex;
    gap: var(--s-2);
    align-items: center;
    font-size: 0.875rem;
    color: var(--ink);
    cursor: pointer;
}

.check-inline input {
    width: auto;
    margin: 0;
    cursor: pointer;
}

/* Prompt: labela i „Vrati na podrazumevano" u istom redu iznad textarea. */
.setting-prompt + .setting-prompt {
    margin-top: var(--s-4);
}

.setting-prompt-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--s-2);
}

.setting-prompt textarea {
    width: 100%;
    resize: vertical;
    font-family: var(--mono);
    font-size: 0.8125rem;
    line-height: 1.5;
}

/* ─── Izbornik modela ──────────────────────────────────────────────────────── */

.modal-card.modal-wide {
    max-width: 720px;
    width: 100%;
}

.model-filter {
    display: flex;
    gap: var(--s-2);
    align-items: center;
    margin-bottom: var(--s-2);
}

.model-filter input[type="search"] {
    flex: 1;
    min-width: 0;
    margin: 0;
}

/* Spisak je visok i skroluje se sam: 396 modela ne sme da razvuče modal preko
   ekrana. Visina je fiksna da se ne trza dok se filtrira. */
.model-list {
    height: 46vh;
    min-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface-2);
}

.model-row {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    width: 100%;
    padding: var(--s-2) var(--s-3);
    border: 0;
    border-bottom: 1px solid var(--line);
    background: transparent;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
}

.model-row:last-child {
    border-bottom: 0;
}

.model-row:hover,
.model-row:focus-visible {
    background: var(--surface-3);
}

.model-row.is-active {
    background: var(--accent-soft);
}

.model-row-main {
    flex: 1;
    min-width: 0;
}

.model-row-name {
    display: block;
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-row-id {
    display: block;
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-row-meta {
    flex: 0 0 auto;
    text-align: right;
    font-size: 0.75rem;
    color: var(--muted);
    white-space: nowrap;
}

.model-row-price {
    display: block;
    font-family: var(--mono);
}

/* Model bez podrške za alate — Korektor ga ne može koristiti. */
.model-row-notools {
    color: var(--muted);
}

.model-empty {
    padding: var(--s-4);
    text-align: center;
    color: var(--muted);
    font-size: 0.875rem;
}

/* Tri roka retencije u redu dok ima mesta — isto pravilo kao stat pločice na
   dashboard-u, pa se ispod ~640px slažu jedan pod drugi bez media upita. */
.settings-trio {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: var(--s-4);
}

/* Zauzeće i dugme za pražnjenje, jedno pored drugog dok ima mesta. Dugme se
   ne skuplja — natpis mu je jedina oznaka šta radi. */
.settings-images {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    margin-top: var(--s-5);
    padding-top: var(--s-4);
    border-top: 1px solid var(--line);
}

.settings-images .field-label {
    margin: 0;
}

.settings-images .hint {
    margin: var(--s-1) 0 0;
}

.settings-images .ghost-btn {
    flex-shrink: 0;
    width: auto;
}

/* ─── Kartica „Baza" ─────────────────────────────────────────────────────────
   Samo prikaz stanja SQLite baze (js/settings_db.js). Pločice su iste kao na
   dashboard-u; ispod njih spisak tabela sa trakom udela i detalji. */

/* Pločice idu u dva para. Spoljni grid stavlja parove jedan pored drugog kad
   svaki dobije bar 400px, unutrašnji deli par na dve pločice od bar 180px —
   pa je raspored 4, 2 × 2 ili 1 u koloni, a nikad 3 + 1. Bez media upita,
   jer širina kartice ne prati širinu prozora (DESIGN_SYSTEM.md, .card-duo). */
.db-stats {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
}

.db-stat-pair {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
    gap: var(--s-4);
}

.db-tile-detail {
    margin: var(--s-2) 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
    font-variant-numeric: tabular-nums;
}

.db-section-title {
    margin: var(--s-6) 0 var(--s-2);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.db-tables {
    display: flex;
    flex-direction: column;
}

.db-empty {
    margin: 0;
    padding: var(--s-4) 0;
    color: var(--muted);
    font-size: 13px;
}

/* Ikonica · ime · brojevi u jednom redu, traka ispod imena i brojeva. Brojevi
   su jedan uz drugi u koloni, pa red ostaje čitljiv i na 375px bez media upita. */
.db-table-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    column-gap: var(--s-3);
    row-gap: var(--s-2);
    padding: var(--s-3) 0;
    border-bottom: 1px solid var(--line);
}

.db-table-row:last-child {
    border-bottom: 0;
}

.db-table-icon {
    width: 28px;
    height: 28px;
}

.db-table-icon .ico {
    font-size: 24px;
}

.db-table-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.db-table-label {
    color: var(--ink);
    font-size: 13.5px;
    font-weight: 600;
}

.db-table-name {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11.5px;
    overflow-wrap: anywhere;
}

.db-table-nums {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.db-table-rows {
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 600;
}

.db-table-size {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11.5px;
}

.db-table-bar {
    grid-column: 2 / -1;
    height: 4px;
    background: var(--surface-3);
    border-radius: var(--r-pill);
    overflow: hidden;
}

.db-table-fill {
    display: block;
    height: 100%;
    border-radius: var(--r-pill);
    background: var(--ink-2);
    transition: width 0.5s var(--ease);
}

.db-table-fill.tone-accent { background: var(--accent); }
.db-table-fill.tone-violet { background: var(--violet); }
.db-table-fill.tone-emerald { background: var(--emerald); }
.db-table-fill.tone-cyan { background: var(--cyan); }
.db-table-fill.tone-slate { background: var(--muted); }

.db-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--s-3);
}

/* Ikonica levo, labela iznad vrednosti. */
.db-meta-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: var(--s-3);
    align-items: center;
    padding: var(--s-3);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
}

.db-meta-item .ico {
    grid-row: 1 / span 2;
    font-size: 22px;
    color: var(--muted);
}

.db-meta-label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.db-meta-value {
    color: var(--ink);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.db-meta-value.mono {
    font-family: var(--mono);
    font-size: 12px;
}

#dbRefresh:disabled .ico {
    animation: busySpin 0.9s linear infinite;
}
