/* ============================================================
   XO — tema u stilu Minimax (plavi sidebar, svetla radna površina)
   Brend = plava; zelena/crvena samo za priliv/odliv (računovodstvena semantika).
   ============================================================ */
:root {
    --brand-900: #0b2a4a;
    --brand-800: #103a63;
    --brand-700: #16497c;
    --brand-600: #1d5d9b;   /* primarni akcenat */
    --brand-500: #2671b8;
    --brand-400: #4a90d0;
    --brand-300: #93bfe2;

    --ink: #1f2a37;
    --muted: #6b7785;
    --line: #e4e9ef;
    --canvas: #eef1f5;
    --panel: #ffffff;

    --ok: #1f9d57;          /* priliv / aktivan */
    --ok-700: #157a43;
    --red: #d64545;
    --amber: #d99020;

    --radius: 12px;
    --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 14px rgba(16,24,40,.06);
    --sidebar-w: 232px;
}

* { box-sizing: border-box; }

html { font-size: 15px; }

body {
    margin: 0;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--ink);
    background: var(--canvas);
    -webkit-font-smoothing: antialiased;
}

/* ---------- App skelet ---------- */
.app { display: flex; min-height: 100vh; }
.nav-toggle-cb { display: none; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: linear-gradient(180deg, var(--brand-800), var(--brand-900));
    color: #dbe9f6;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-brand {
    display: flex; align-items: center; gap: .65rem;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-mark {
    width: 34px; height: 34px; border-radius: 9px;
    background: var(--brand-400);
    color: #06243f; font-weight: 800; font-size: .95rem;
    display: grid; place-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.brand-text { font-weight: 700; font-size: 1.05rem; line-height: 1; color: #fff; }
.brand-text small { display: block; font-weight: 500; font-size: .72rem; color: var(--brand-300); margin-top: 2px; }

.sidebar-nav { padding: .75rem .6rem; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: .7rem;
    padding: .62rem .7rem;
    border-radius: 9px;
    color: #c5dcf0;
    font-weight: 500; font-size: .94rem;
    text-decoration: none;
    transition: background .12s, color .12s;
}
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav .nav-link.active { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 3px 0 0 var(--brand-400); }
.sidebar-nav .ic { width: 19px; height: 19px; fill: currentColor; opacity: .9; flex: 0 0 auto; }
.sidebar-nav .nav-section {
    padding: .85rem .8rem .3rem;
    font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
    color: var(--brand-300); opacity: .65;
}
.sidebar-nav .nav-section:first-child { padding-top: .35rem; }
.sidebar-foot { padding: .9rem 1.25rem; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-foot .muted { color: var(--brand-300); font-size: .75rem; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 1rem;
    height: 60px; padding: 0 1.5rem;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-size: 1.05rem; font-weight: 600; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: .9rem; }
.user-name { font-size: .9rem; color: var(--muted); font-weight: 500; }
.btn-logout {
    border: 1px solid var(--line); background: #fff; color: var(--ink);
    padding: .35rem .8rem; border-radius: 8px; font-size: .85rem; font-weight: 500; cursor: pointer;
}
.btn-logout:hover { background: #f6f8fa; border-color: #d6dde5; }
.nav-burger { display: none; cursor: pointer; }
.nav-burger svg { width: 24px; height: 24px; fill: var(--ink); }

.content { padding: 1.6rem 1.75rem; max-width: 1320px; width: 100%; }

/* ---------- Tipografija ---------- */
h1, .h1, h2, .h2, h3, .h3 { color: var(--ink); font-weight: 700; letter-spacing: -.01em; }
.page-sub { color: var(--muted); margin-top: -.25rem; }

/* ---------- Kartice / paneli ---------- */
.card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    background: var(--panel);
}
.card-header { background: #fff; border-bottom: 1px solid var(--line); font-weight: 600; border-radius: var(--radius) var(--radius) 0 0 !important; }

/* KPI kartice */
.kpi { border-radius: var(--radius); padding: 1.1rem 1.25rem; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
.kpi .kpi-label { text-transform: uppercase; letter-spacing: .04em; font-size: .72rem; color: var(--muted); font-weight: 600; }
.kpi .kpi-value { font-size: 1.5rem; font-weight: 700; margin-top: .25rem; font-variant-numeric: tabular-nums; }
.kpi .kpi-sub { font-size: .8rem; color: var(--muted); }
.kpi-primary {
    background: linear-gradient(135deg, var(--brand-600), var(--brand-800));
    border: none; color: #eaf3fb;
}
.kpi-primary .kpi-label { color: #c2dcf2; }
.kpi-primary .kpi-value { color: #fff; font-size: 1.9rem; }
.kpi-primary .kpi-sub { color: #c2dcf2; }

/* ---------- Tabele ---------- */
.table { color: var(--ink); margin: 0; }
.table > thead th {
    background: #f7f9fb; color: var(--muted);
    text-transform: uppercase; font-size: .72rem; letter-spacing: .03em; font-weight: 600;
    border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table > tbody td { border-color: #eef1f4; vertical-align: middle; }
.table-hover > tbody > tr:hover > * { background: #f3f8fc; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.pos { color: var(--ok-700); }
.neg { color: var(--red); }

/* ---------- Bedževi ---------- */
.badge-status { display: inline-flex; align-items: center; gap: .4rem; font-size: .76rem; font-weight: 600; padding: .25rem .6rem; border-radius: 999px; }
.badge-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.badge-active { background: #e6f6ed; color: var(--ok-700); }
.badge-active::before { background: var(--ok); }
.badge-idle { background: #f0f2f5; color: var(--muted); }
.badge-idle::before { background: #b7c0cc; }
.badge-ai { background: #ede4fb; color: #6b35c9; }
.badge-ai::before { background: #8a4fe0; }
.badge-review { background: #fff3e0; color: #b46e00; }
.badge-review::before { background: #e0911f; }

/* ---------- Mini-bar (breakdown) ---------- */
.bar-track { background: #eef1f4; border-radius: 6px; height: 8px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; }
.bar-out { background: var(--red); }
.bar-in  { background: var(--ok); }
.dot { display:inline-block; width:9px; height:9px; border-radius:50%; margin-right:.4rem; }

/* ---------- Dugmad / forme (Bootstrap override) ---------- */
.btn-primary { --bs-btn-bg: var(--brand-600); --bs-btn-border-color: var(--brand-600); --bs-btn-hover-bg: var(--brand-700); --bs-btn-hover-border-color: var(--brand-700); --bs-btn-active-bg: var(--brand-800); --bs-btn-focus-shadow-rgb: 29,93,155; }
.btn-success { --bs-btn-bg: var(--ok); --bs-btn-border-color: var(--ok); --bs-btn-hover-bg: var(--ok-700); --bs-btn-hover-border-color: var(--ok-700); }
.btn-outline-secondary { --bs-btn-color: var(--ink); --bs-btn-border-color: var(--line); --bs-btn-hover-bg: #f6f8fa; --bs-btn-hover-border-color: #d6dde5; --bs-btn-hover-color: var(--ink); }
.btn { border-radius: 9px; font-weight: 500; }
.form-control, .form-select { border-color: #d8dee6; border-radius: 9px; }
.form-control:focus, .form-select:focus { border-color: var(--brand-400); box-shadow: 0 0 0 .2rem rgba(29,93,155,.18); }
.form-label { font-size: .85rem; font-weight: 500; color: #44505e; }
.form-switch .form-check-input:checked { background-color: var(--brand-600); border-color: var(--brand-600); }
.nav-pills .nav-link.active { background: var(--brand-600); }
.nav-pills .nav-link { color: var(--brand-700); }
a { color: var(--brand-700); }
a:hover { color: var(--brand-800); }

/* ---------- Auth (login) ---------- */
.auth-shell {
    min-height: 100vh; display: grid; place-items: center;
    background: radial-gradient(1200px 600px at 50% -10%, #21557f 0%, var(--brand-900) 55%, #061a2e 100%);
    padding: 1rem;
}
.auth-card {
    width: 100%; max-width: 380px; background: #fff; border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0,0,0,.3); padding: 2rem 1.9rem;
}
.auth-logo { width: 52px; height: 52px; border-radius: 14px; background: var(--brand-500); color: #fff;
    font-weight: 800; display: grid; place-items: center; margin: 0 auto 1rem; font-size: 1.2rem; }

/* ---------- Dashboard switcher (Pregled · Analiza · AI Analiza) ---------- */
.dash-switcher {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .75rem;
    margin-bottom: 1.5rem;
}

.dash-item {
    display: flex;
    align-items: flex-start;
    gap: .85rem;
    padding: 1rem 1.15rem;
    background: var(--panel);
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--ink);
    transition: border-color .14s, box-shadow .14s, background .14s;
}

.dash-item:hover {
    border-color: var(--brand-400);
    background: #f5f9ff;
    box-shadow: 0 2px 10px rgba(29,93,155,.1);
    color: var(--ink);
    text-decoration: none;
}

.dash-item.dash-active {
    border-color: var(--brand-600);
    border-width: 2px;
    background: #edf4fc;
    box-shadow: 0 0 0 1px var(--brand-600), var(--shadow);
    cursor: default;
    color: var(--ink);
    text-decoration: none;
}

.dash-icon {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #e5edf8;
    color: var(--brand-600);
}

.dash-item.dash-active .dash-icon {
    background: var(--brand-600);
    color: #fff;
}

.dash-icon svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.dash-body {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    min-width: 0;
}

.dash-title {
    font-size: .94rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.2;
}

.dash-item.dash-active .dash-title { color: var(--brand-700); }

.dash-sub {
    font-size: .75rem;
    color: var(--muted);
    line-height: 1.4;
}

@media (max-width: 768px) {
    .dash-switcher {
        grid-template-columns: 1fr;
        gap: .5rem;
    }
}

/* ---------- Responsive ---------- */
.nav-backdrop { display: none; }

@media (max-width: 820px) {
    .sidebar { position: fixed; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
    .nav-toggle-cb:checked ~ .sidebar { transform: translateX(0); }
    .nav-burger { display: inline-flex; }
    .content { padding: 1.1rem; }

    /* Zatamnjena pozadina ispod izvučenog menija — dodir zatvara meni */
    .nav-toggle-cb:checked ~ .nav-backdrop {
        display: block; position: fixed; inset: 0;
        background: rgba(6,26,46,.45); z-index: 35;
    }
}

/* ---------- Telefon ---------- */
@media (max-width: 560px) {
    html { font-size: 14px; }
    .content { padding: .8rem; }
    .topbar { padding: 0 .9rem; gap: .6rem; }
    .topbar-title { font-size: .98rem; }
    .user-name { display: none; }            /* skrati topbar na uskim ekranima */
    .kpi { padding: .85rem .95rem; }
    .kpi .kpi-value { font-size: 1.3rem; }
    .kpi-primary .kpi-value { font-size: 1.6rem; }

    /* Tabela → kartice: svaki red postaje kartica sa labelama */
    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
    .table-cards tr {
        border: 1px solid var(--line); border-radius: 10px;
        background: var(--panel); box-shadow: var(--shadow);
        padding: .55rem .75rem; margin-bottom: .6rem;
    }
    .table-cards td {
        border: none !important; padding: .22rem 0;
        display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
        text-align: right; white-space: normal;
    }
    .table-cards td::before {
        content: attr(data-label);
        font-weight: 600; color: var(--muted);
        text-align: left; flex: 0 0 auto;
    }
    /* Ćelije bez labele (čekboks, akcije) — bez prefiksa, puna širina */
    .table-cards td[data-label=""] { justify-content: space-between; }
    .table-cards td[data-label=""]::before { content: none; }
    .table-cards td.num { text-align: right; }
}
