/* ============ GART Reporting - globalni stilovi ============
   Paleta i header kao GartAdmin (tamni #1e2a38 + akcent #BF3343),
   raspored kao PHP verzija (sidebar + kartice), responsive - klijenti gledaju sa telefona. */

:root {
    --accent: #BF3343;
    --accent-dark: #9e2836;
    --header-bg: #1e2a38;
    --header-bg-2: #2c3e50;
    --page-bg: #eef1f5;
    --surface: #ffffff;
    --border: #d7dce3;
    --text: #22303e;
    --text-2: #52514e;
    --text-muted: #7a8794;
    --grid: #e1e0d9;
    --good: #1e7e45;
    --bad: #c0392b;
    --sidebar-ink: #c8d2dc;
    --sidebar-active: rgba(255, 255, 255, .10);
    --radius: 10px;
    --shadow: 0 1px 3px rgba(20, 35, 50, .12);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 14.5px;
    color: var(--text);
    background: var(--page-bg);
}

a { color: var(--accent); }

.app-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    color: var(--text-muted);
    font-size: 16px;
}

/* ============ Raspored: sidebar + main ============ */

.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    flex: 0 0 250px;
    background: linear-gradient(180deg, var(--header-bg-2), var(--header-bg) 30%);
    color: var(--sidebar-ink);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand-logo { height: 20px; display: block; }

.brand-sub {
    font-weight: 600;
    font-size: 16px;
    color: #e6ecf2;
}

.nav { flex: 1; padding: 12px 8px; overflow-y: auto; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin: 2px 0;
    border-radius: 8px;
    color: var(--sidebar-ink);
    text-decoration: none;
    font-size: 14px;
    line-height: 1.3;
    transition: background .15s, color .15s;
}

.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }

.nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--accent);
}

.nav-ico {
    width: 20px;
    text-align: center;
    opacity: .85;
    font-size: 15px;
}

.sidebar-foot {
    padding: 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #e6ecf2;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.user-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #2ecc71;
    flex-shrink: 0;
}

.logout {
    appearance: none;
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .25);
    color: #e6ecf2;
    font: inherit;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
}

.logout:hover { background: rgba(255, 255, 255, .2); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-right {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.menu-btn {
    display: none;
    appearance: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 20px;
    line-height: 1;
    padding: 6px 10px;
    cursor: pointer;
    color: var(--text);
}

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(11, 11, 11, .45);
    z-index: 15;
}

.content { padding: 20px 24px 40px; }

/* ============ Kartice i mreže ============ */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    min-width: 0;
}

.card h2 {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.card h2.sto-naslov { font-size: 16px; }

.card .sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 14px;
    line-height: 1.5;
}

.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid > .card { margin-bottom: 0; }
.grid.kpi4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.kpi .kpi-label {
    font-size: 12.5px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.kpi .kpi-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.kpi .kpi-value.small { font-size: 16px; font-weight: 600; line-height: 1.6; }

.kpi .kpi-extra { font-size: 13px; color: var(--text-2); margin-top: 6px; }

.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    margin-right: 7px;
    vertical-align: middle;
}

/* ============ Filteri ============ */

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
}

.field { display: flex; flex-direction: column; gap: 5px; min-width: 150px; }

.field label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-2);
}

.field input, .field select {
    font: inherit;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    min-width: 150px;
    max-width: 100%;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.field select { max-width: 360px; }

.field input:focus, .field select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(191, 51, 67, .15);
}

.btn {
    font: inherit;
    font-weight: 600;
    padding: 9px 20px;
    border-radius: 8px;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    transition: background .15s;
    height: 38px;
}

.btn:hover:not(:disabled) { background: var(--accent-dark); }
.btn:disabled { opacity: .7; cursor: default; }

/* ============ Tabele ============ */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    font-variant-numeric: tabular-nums;
}

table.data th, table.data td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

table.data th, table.data td.num, table.data td:first-child { white-space: nowrap; }
table.data td.text { white-space: normal; }

table.data th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .3px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 2px solid var(--border);
}

table.data .num { text-align: right; }
table.data tr:hover td { background: #f6f8fa; }
table.data tr.total td { font-weight: 700; border-top: 2px solid var(--text-2); border-bottom: none; background: #f9fafb; }
table.data tr.subrow td { color: var(--text-2); padding-left: 26px; font-size: 13px; }
table.data tr.subrow td:first-child::before { content: "↳ "; color: var(--text-muted); }

.pct { font-size: 12px; color: var(--text-muted); }
.bad { color: var(--bad); }

.empty {
    padding: 28px 10px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.empty.loading::after { content: ""; animation: tacke 1.2s steps(4, end) infinite; }
@keyframes tacke { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

.err {
    background: #fdecea;
    border: 1px solid #f5c6c0;
    color: #a3261a;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13.5px;
}

/* ============ Grafikoni ============ */

.chart-wrap { position: relative; height: 280px; width: 100%; }
.chart-wrap.tall { height: 340px; }

/* ============ Login ============ */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 16px;
    background: linear-gradient(160deg, var(--header-bg-2) 0%, var(--header-bg) 60%);
}

.login-card {
    background: #fff;
    border-radius: 14px;
    padding: 36px 40px;
    width: 380px;
    max-width: 100%;
    box-shadow: 0 12px 40px rgba(10, 20, 35, .35);
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.login-logo img { height: 30px; display: block; }

.login-logo-sub { font-size: 24px; font-weight: 600; color: #1a1a1a; }

.login-sub { text-align: center; color: var(--text-muted); margin: 6px 0 24px; }

.form-field { margin-bottom: 16px; }

.form-field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}

.form-field input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

#klijentid { letter-spacing: 2px; font-weight: 600; text-transform: uppercase; }

.form-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(191, 51, 67, .15);
}

.login-error {
    background: #fdecea;
    border: 1px solid #f5c6c0;
    color: #a3261a;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 16px;
}

.btn-primary {
    width: 100%;
    padding: 11px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}

.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-primary:disabled { opacity: .7; cursor: default; }

.login-note {
    margin-top: 18px;
    font-size: 12.5px;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.6;
}

/* ============ Blazor error UI ============ */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #fff8e1;
    border-top: 1px solid #f0c36d;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, .15);
    padding: 12px 40px 12px 16px;
    font-size: 14px;
}

#blazor-error-ui .reload { margin-left: 10px; font-weight: 600; }

#blazor-error-ui .dismiss {
    position: absolute;
    right: 14px;
    top: 10px;
    cursor: pointer;
}

/* ============ Responsive ============ */

@media (max-width: 1200px) {
    .grid.kpi4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid.cols3 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: 4px 0 20px rgba(0, 0, 0, .3);
    }
    .sidebar.open { transform: translateX(0); }
    .overlay.show { display: block; }
    .menu-btn { display: inline-block; }
    .topbar { padding: 12px 16px; }
    .topbar h1 { font-size: 17px; }
    .content { padding: 14px 14px 30px; }
    .card { padding: 14px 14px; }
}

@media (max-width: 700px) {
    .grid.kpi4, .grid.cols2 { grid-template-columns: 1fr; }
    .kpi .kpi-value { font-size: 21px; }
    .filters .field { min-width: 100%; }
    .filters .field input, .filters .field select { width: 100%; max-width: none; }
    .btn { width: 100%; }
    .topbar-right { display: none; }
    .chart-wrap { height: 240px; }
    .chart-wrap.tall { height: 280px; }
    .login-card { padding: 28px 22px; }
}
