/* =========================================================
   Gart POS Web Reporting - stilovi
   ========================================================= */
:root {
    --page:           #f9f9f7;
    --surface:        #fcfcfb;
    --ink:            #0b0b0b;
    --ink-2:          #52514e;
    --ink-muted:      #898781;
    --grid:           #e1e0d9;
    --baseline:       #c3c2b7;
    --border:         rgba(11, 11, 11, 0.10);
    --accent:         #2a78d6;
    --accent-dark:    #1c5cab;
    --good:           #006300;
    --bad:            #d03b3b;
    --sidebar-bg:     #14202e;
    --sidebar-ink:    #c9d4e0;
    --sidebar-active: #1e3a52;
    --radius:         10px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--page);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 15px;
}

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

/* ---------- Sidebar ---------- */
.sidebar {
    width: 250px;
    flex: 0 0 250px;
    background: var(--sidebar-bg);
    color: var(--sidebar-ink);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

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

.brand-logo {
    width: 38px; height: 38px;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 20px;
    display: flex; align-items: center; justify-content: center;
}

.brand-name { font-weight: 600; color: #fff; }
.brand-sub  { font-size: 12px; color: var(--sidebar-ink); opacity: .8; }

.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.25;
}

.nav-link:hover  { background: rgba(255,255,255,0.07); color: #fff; }
.nav-link.active { background: var(--accent); color: #fff; }
.nav-ico { width: 18px; text-align: center; opacity: .85; flex: 0 0 18px; }

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

.user-chip {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; color: #fff;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #1baf7a; flex: 0 0 8px;
}
.logout {
    color: var(--sidebar-ink);
    font-size: 13px;
    text-decoration: none;
    border: 1px solid rgba(255,255,255,0.18);
    padding: 5px 10px;
    border-radius: 7px;
}
.logout:hover { background: rgba(255,255,255,0.08); color: #fff; }

/* Hamburger dugme - vidljivo samo na mobilnom */
.menu-btn {
    display: none;
    background: var(--surface);
    border: 1px solid var(--baseline);
    border-radius: 8px;
    width: 38px;
    height: 38px;
    font-size: 19px;
    line-height: 1;
    color: var(--ink);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex: 0 0 38px;
}

/* Overlay iza otvorenog mobilnog menija */
.overlay {
    display: none;
}

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

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 26px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 19px; font-weight: 650; }
.topbar-right { color: var(--ink-muted); font-size: 13px; }

.content { padding: 22px 26px 40px; }

/* ---------- Kartice / sekcije ---------- */
.grid { display: grid; gap: 16px; }
.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)); }

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

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 16px;
}
.grid .card { margin-bottom: 0; }

.card h2 {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-2);
}
.card .sub { font-size: 12px; color: var(--ink-muted); margin-bottom: 10px; }

/* KPI pločice */
.kpi .kpi-value {
    font-size: 26px;
    font-weight: 700;
    margin-top: 6px;
    line-height: 1.15;
}
.kpi .kpi-label { font-size: 13px; color: var(--ink-2); }
.kpi .kpi-extra { font-size: 12px; color: var(--ink-muted); margin-top: 6px; }
.kpi .kpi-extra b { color: var(--ink-2); font-weight: 600; }

/* ---------- Forme / filteri ---------- */
.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px;
}
.filters .field { display: flex; flex-direction: column; gap: 5px; }
.filters label { font-size: 12px; color: var(--ink-2); font-weight: 600; }

input[type="date"], select, input[type="text"], input[type="password"], input[type="number"] {
    font: inherit;
    padding: 8px 10px;
    border: 1px solid var(--baseline);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    min-width: 150px;
}
select { max-width: 340px; }

.btn {
    font: inherit;
    font-weight: 600;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 18px;
    cursor: pointer;
}
.btn:hover { background: var(--accent-dark); }

.hint { font-size: 12px; color: var(--ink-muted); }

/* ---------- Grafikon ---------- */
.chart-wrap { position: relative; height: 340px; }
.chart-wrap.tall { height: 420px; }
.chart-wrap.small { height: 260px; }

/* ---------- Tabele ---------- */
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
table.data th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--ink-muted);
    font-weight: 600;
    padding: 8px 10px;
    border-bottom: 2px solid var(--grid);
    white-space: nowrap;
}
table.data td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--grid);
    vertical-align: top;
}
table.data tr:hover td { background: #f4f4f0; }
/* pod-red: kategorije unutar "Ostalo" grupe */
table.data tr.subrow td { color: var(--ink-muted); font-size: 12.5px; }
table.data tr.subrow td:first-child { padding-left: 27px; }
table.data td.num, table.data th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
table.data tr.total td {
    font-weight: 700;
    border-top: 2px solid var(--baseline);
    background: #f7f7f3;
}
.pct { color: var(--ink-muted); font-size: 12px; }

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

/* legenda tacka uz naziv */
.dot {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 3px;
    margin-right: 7px;
    vertical-align: baseline;
}

/* ---------- Login ---------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #14202e 0%, #1d314e 60%, #14202e 100%);
    padding: 20px;
}
.login-box {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border-radius: 14px;
    padding: 30px 28px;
    box-shadow: 0 18px 50px rgba(0,0,0,.35);
}
.login-box .brand { border: none; padding: 0 0 18px; }
.login-box .brand-name { color: var(--ink); font-size: 17px; }
.login-box .brand-sub  { color: var(--ink-muted); }
.login-box .field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.login-box label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.login-box input { width: 100%; min-width: 0; }
.login-box .btn { width: 100%; margin-top: 6px; }
.login-err {
    background: #fdecec;
    border: 1px solid #f3b8b8;
    color: #8c1d1d;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 14px;
}
.login-note { margin-top: 16px; font-size: 12px; color: var(--ink-muted); text-align: center; }

/* =========================================================
   RESPONSIVE - tableti i telefoni
   ========================================================= */

@media (max-width: 900px) {

    /* Sidebar postaje off-canvas fioka */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        height: 100dvh;
        width: 272px;
        flex: none;
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 60;
        box-shadow: 0 0 40px rgba(0,0,0,.35);
    }
    .sidebar.open { transform: translateX(0); }

    .overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease;
        z-index: 50;
    }
    .overlay.show { opacity: 1; pointer-events: auto; }

    .menu-btn { display: inline-flex; }

    .topbar {
        position: sticky;
        top: 0;
        z-index: 40;
        gap: 10px;
        padding: 10px 14px;
    }
    .topbar h1 { font-size: 16px; flex: 1; min-width: 0; }
    .topbar-right { display: none; }

    .content { padding: 14px 12px 32px; }

    /* Nesto vece dodirne povrsine u navigaciji */
    .nav-link { padding: 12px; font-size: 15px; }
}

@media (max-width: 700px) {

    body { font-size: 14px; }

    /* Sve kartice u jednoj koloni */
    .grid.kpi4, .grid.cols2 { grid-template-columns: 1fr; }

    .card { padding: 13px 14px; }
    .kpi .kpi-value { font-size: 22px; }

    /* Filteri: polja preko cele sirine, dugme ispod */
    .filters { gap: 10px; }
    .filters .field { width: 100%; }
    .filters input[type="date"],
    .filters input[type="text"],
    .filters input[type="number"],
    .filters select {
        width: 100%;
        min-width: 0;
        max-width: none;
    }
    .filters .btn { width: 100%; padding: 12px; }

    /* Grafikoni nesto nizi da stanu na ekran */
    .chart-wrap       { height: 250px; }
    .chart-wrap.tall  { height: 300px; }
    .chart-wrap.small { height: 220px; }

    /* Tabele: horizontalni scroll umesto lomljenja */
    table.data {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    table.data th,
    table.data td { white-space: nowrap; }

    /* Login */
    .login-box { padding: 24px 20px; }
}
