/* ==========================================================================
   SIK CRM — app.css
   Aesthetika: grafitni sidebar + svijetli sadržaj, emerald/teal akcent,
   amber sekundar. Tipografija: Sora (naslovi) + Figtree (tijelo).
   ========================================================================== */

:root {
    --bg:        #f4f6f8;
    --surface:   #ffffff;
    --surface-2: #f8fafc;
    --line:      #e6eaef;
    --ink:       #0f1720;
    --ink-soft:  #475569;
    --ink-mute:  #8a97a6;

    --brand:     #0ea5a4;   /* teal */
    --brand-dk:  #0c8d8c;
    --brand-soft:#e2f6f5;
    --accent:    #f59e0b;   /* amber */
    --accent-soft:#fef3e2;

    --sidebar:   #11161d;
    --sidebar-2: #161d27;
    --sidebar-ink: #aeb9c6;

    --ok:#16a34a; --warn:#d97706; --bad:#dc2626; --info:#0284c7;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(15,23,32,.06), 0 1px 3px rgba(15,23,32,.05);
    --shadow:    0 4px 16px rgba(15,23,32,.07), 0 2px 6px rgba(15,23,32,.04);
    --sidebar-w: 248px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Figtree', system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .page-title, .topbar-title, .brand-text, .card-title, .kpi-value {
    font-family: 'Sora', system-ui, sans-serif;
    letter-spacing: -.01em;
}

a { color: var(--brand-dk); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar);
    color: var(--sidebar-ink);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    border-right: 1px solid rgba(255,255,255,.04);
}

.sidebar-brand {
    display: flex; align-items: center; gap: 11px;
    padding: 20px 22px;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-mark {
    width: 34px; height: 34px; border-radius: 9px;
    background: linear-gradient(135deg, var(--brand), #14b8a6);
    display: grid; place-items: center;
    font-family: 'Sora'; font-weight: 700; color: #042f2e; font-size: 18px;
    box-shadow: 0 4px 12px rgba(14,165,164,.4);
}
.brand-text { font-weight: 700; font-size: 17px; }

.sidebar-nav { flex: 1; padding: 14px 12px; overflow-y: auto; scrollbar-width: none; }
.sidebar-nav::-webkit-scrollbar { display: none; }
.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 13px; margin-bottom: 3px;
    border-radius: 10px;
    color: var(--sidebar-ink);
    font-weight: 500; font-size: 14.5px;
    transition: background .15s, color .15s;
}
.sidebar-nav .nav-link i { font-size: 17px; width: 20px; text-align: center; }
.sidebar-nav .nav-link:hover { background: var(--sidebar-2); color: #fff; text-decoration: none; }
.sidebar-nav .nav-link.active {
    background: linear-gradient(90deg, rgba(14,165,164,.18), rgba(14,165,164,.04));
    color: #fff;
    box-shadow: inset 3px 0 0 var(--brand);
}

.sidebar-foot {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-user { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.su-meta { min-width: 0; }
.su-meta strong { display: block; color: #fff; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.su-meta small { color: var(--ink-mute); font-size: 11.5px; }
.logout { color: var(--sidebar-ink); font-size: 18px; padding: 6px; border-radius: 8px; }
.logout:hover { background: var(--sidebar-2); color: #fff; text-decoration: none; }

.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, var(--brand), #14b8a6);
    color: #042f2e; font-weight: 700; font-size: 13px;
    display: grid; place-items: center; flex-shrink: 0;
    font-family: 'Sora';
}
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }

.sidebar-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(8,12,18,.5); z-index: 1035;
}

.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex; flex-direction: column;
    min-width: 0;
}

/* --- Topbar ----------------------------------------------------------- */
.topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; gap: 16px;
    padding: 0 26px; height: 64px;
    background: rgba(255,255,255,.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.topbar-title { font-size: 18px; font-weight: 600; margin: 0; flex-shrink: 0; }
.hamburger {
    display: none; border: 0; background: transparent;
    font-size: 24px; color: var(--ink); cursor: pointer; padding: 4px;
}
.topbar-search {
    margin-left: auto; position: relative; max-width: 320px; width: 100%;
}
.topbar-search i {
    position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
    color: var(--ink-mute); font-size: 15px;
}
.topbar-search input {
    width: 100%; padding: 9px 14px 9px 38px;
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--surface-2); font-size: 14px; color: var(--ink);
    transition: border .15s, box-shadow .15s;
}
.topbar-search input:focus {
    outline: none; border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft); background: #fff;
}

/* --- Content ---------------------------------------------------------- */
.content { padding: 26px; max-width: 1400px; width: 100%; }

.page-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-title { font-size: 24px; font-weight: 700; margin: 0; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* --- Cards ------------------------------------------------------------- */
.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px 22px; }
.card-title { font-size: 16px; font-weight: 600; margin: 0 0 2px; }
.card-sub { color: var(--ink-mute); font-size: 13px; margin: 0; }
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 17px 22px; border-bottom: 1px solid var(--line); gap: 12px;
}

/* --- KPI grid --------------------------------------------------------- */
.kpi-grid {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 18px; margin-bottom: 22px;
}
.kpi {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 18px 20px;
    box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi-ico {
    width: 42px; height: 42px; border-radius: 11px;
    display: grid; place-items: center; font-size: 20px; margin-bottom: 14px;
}
.kpi-label { color: var(--ink-mute); font-size: 13px; font-weight: 500; }
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1.1; margin-top: 2px; }
.kpi-delta { font-size: 12.5px; margin-top: 6px; font-weight: 500; }
.kpi-delta.up { color: var(--ok); }
.kpi-delta.down { color: var(--bad); }

/* --- Grids ------------------------------------------------------------ */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }
.mt { margin-top: 18px; }
.mb { margin-bottom: 18px; }

/* --- Tables ----------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th {
    text-align: left; padding: 12px 16px;
    color: var(--ink-mute); font-weight: 600; font-size: 12px;
    text-transform: uppercase; letter-spacing: .03em;
    border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.tbl td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tbody tr { transition: background .12s; }
table.tbl tbody tr:hover { background: var(--surface-2); }
.t-strong { font-weight: 600; color: var(--ink); }
.t-mute { color: var(--ink-mute); font-size: 13px; }

/* --- Badges ----------------------------------------------------------- */
.badge-pill {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; border-radius: 100px;
    font-size: 12px; font-weight: 600; line-height: 1;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-secondary { background: #eef1f4; color: #475569; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #e0f2fe; color: #0369a1; }
.badge-primary { background: var(--brand-soft); color: var(--brand-dk); }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-dark { background: #e2e8f0; color: #334155; }

.tag {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 7px; font-size: 12px; font-weight: 500;
    background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-soft);
    margin: 2px;
}
.tag .dot { width: 7px; height: 7px; border-radius: 50%; }

/* --- Buttons ---------------------------------------------------------- */
.btn {
    border-radius: 10px; font-weight: 600; font-size: 14px;
    padding: 9px 16px; border: 1px solid transparent; display: inline-flex;
    align-items: center; gap: 7px; transition: all .15s; cursor: pointer; line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dk); border-color: var(--brand-dk); color: #fff; box-shadow: 0 4px 12px rgba(14,165,164,.3); }
.btn-light { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-light:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--bad); }
.btn-danger:hover { background: #fef2f2; color: var(--bad); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); padding: 6px 9px; }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-block { width: 100%; justify-content: center; }

.icon-btn {
    width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line);
    background: var(--surface); color: var(--ink-soft); display: inline-grid; place-items: center;
    transition: all .12s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.icon-btn.danger:hover { background: #fef2f2; color: var(--bad); border-color: #fecaca; }

/* --- Forms ------------------------------------------------------------ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--ink-mute); margin-top: 5px; }
.input, .select, .textarea, select.input {
    width: 100%; padding: 10px 13px; border: 1px solid var(--line);
    border-radius: 10px; font-size: 14px; font-family: inherit;
    background: var(--surface); color: var(--ink); transition: border .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus, select.input:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.textarea { min-height: 96px; resize: vertical; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check-pill {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 7px 12px; border: 1px solid var(--line); border-radius: 9px;
    cursor: pointer; font-size: 13.5px; user-select: none; background: var(--surface);
}
.check-pill input { accent-color: var(--brand); }
.check-pill:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dk); font-weight: 600; }
/* dugme-čip varijanta (bez inputa) za brzo trajanje */
button.check-pill { font-family: inherit; }
button.check-pill.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dk); font-weight: 600; }

/* --- Štoperica (timer) ----------------------------------------------- */
.timer { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); }
.timer-display { font-family: 'Sora', sans-serif; font-size: 26px; font-weight: 700; letter-spacing: .5px; color: var(--ink); min-width: 86px; }

/* --- Tabs ------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a {
    padding: 11px 16px; color: var(--ink-soft); font-weight: 600; font-size: 14px;
    border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--brand-dk); border-bottom-color: var(--brand); }

/* --- Timeline (aktivnosti) -------------------------------------------- */
.timeline { position: relative; padding-left: 8px; }
.tl-item { display: flex; gap: 14px; padding-bottom: 18px; position: relative; }
.tl-item:not(:last-child)::before {
    content: ''; position: absolute; left: 17px; top: 36px; bottom: -2px;
    width: 2px; background: var(--line);
}
.tl-ico {
    width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
    display: grid; place-items: center; color: #fff; font-size: 15px; z-index: 1;
}
.tl-body { flex: 1; min-width: 0; padding-top: 1px; }
.tl-body .tl-top { display: flex; justify-content: space-between; gap: 10px; }
.tl-title { font-weight: 600; font-size: 14px; }
.tl-time { color: var(--ink-mute); font-size: 12.5px; white-space: nowrap; }
.tl-note { color: var(--ink-soft); font-size: 13.5px; margin-top: 3px; }
.tl-meta { color: var(--ink-mute); font-size: 12.5px; margin-top: 4px; display: flex; gap: 12px; flex-wrap: wrap; }

/* --- Kanban (leadovi) ------------------------------------------------- */
.kanban { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 8px; }
.kan-col { flex: 0 0 280px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); }
.kan-head { padding: 13px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.kan-head strong { font-size: 13.5px; }
.kan-count { background: var(--surface); border: 1px solid var(--line); border-radius: 100px; padding: 1px 9px; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.kan-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 60px; }
.kan-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px; box-shadow: var(--shadow-sm); transition: box-shadow .15s, transform .1s; }
.kan-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kan-card .kc-name { font-weight: 600; font-size: 14px; }
.kan-card .kc-meta { font-size: 12.5px; color: var(--ink-mute); margin-top: 5px; display: flex; justify-content: space-between; align-items: center; }
.kan-val { color: var(--brand-dk); font-weight: 600; }
.kan-col-sum { padding: 0 16px 12px; font-size: 12px; color: var(--ink-mute); }

/* --- Detail layout ---------------------------------------------------- */
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 18px; }
.info-list { display: grid; gap: 0; }
.info-row { display: flex; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.info-row:last-child { border-bottom: 0; }
.info-row .k { color: var(--ink-mute); }
.info-row .v { font-weight: 500; text-align: right; }

/* --- Empty state ------------------------------------------------------ */
.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-mute); }
.empty-state i { font-size: 48px; opacity: .4; }
.empty-state h3 { margin: 14px 0 6px; color: var(--ink-soft); font-size: 18px; }
.empty-state p { margin: 0 0 18px; }

/* --- Mini bar/progress ------------------------------------------------ */
.mini-bar { height: 7px; background: var(--surface-2); border-radius: 100px; overflow: hidden; }
.mini-bar > span { display: block; height: 100%; background: var(--brand); border-radius: 100px; }

/* --- Stat row in reports ---------------------------------------------- */
.stat-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.stat-row:last-child { border-bottom: 0; }
.stat-row .sr-label { flex: 0 0 160px; font-size: 14px; }
.stat-row .sr-bar { flex: 1; }
.stat-row .sr-val { flex: 0 0 70px; text-align: right; font-weight: 600; font-size: 14px; }

/* --- Login ------------------------------------------------------------ */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
    background: radial-gradient(1200px 600px at 70% -10%, #0e2a2a 0%, #0b1016 55%); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0,0,0,.4); padding: 34px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.login-brand .brand-mark { width: 40px; height: 40px; font-size: 21px; }
.login-brand h1 { font-size: 20px; margin: 0; }
.login-brand small { color: var(--ink-mute); display: block; font-size: 12.5px; }

/* --- Utilities -------------------------------------------------------- */
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.muted { color: var(--ink-mute); }
.soft { color: var(--ink-soft); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.gap-sm { gap: 6px; }
.w-100 { width: 100%; }
.hide { display: none; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* --- Responsive ------------------------------------------------------- */
@media (max-width: 1100px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2, .grid-3, .grid-2-1, .detail-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
}
/* Horizontalni scroll za filter dugmad na mobilnom */
.btn-scroll-row { display:flex; gap:6px; overflow-x:auto; flex-wrap:nowrap; -webkit-overflow-scrolling:touch; scrollbar-width:none; padding-bottom:2px; }
.btn-scroll-row::-webkit-scrollbar { display:none; }
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
    .app.nav-open .sidebar { transform: translateX(0); }
    .app.nav-open .sidebar-backdrop { display: block; }
    .main { margin-left: 0; }
    .hamburger { display: inline-block; }
    .topbar { padding: 0 16px; }
    .topbar-title { font-size: 16px; }
    .topbar-search { max-width: none; }
    .content { padding: 18px 16px; }
    .page-title { font-size: 20px; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .kpi-value { font-size: 23px; }
}
@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .topbar-search { display: none; }
}

/* --- Notifikacije (zvono) -------------------------------------------- */
.notif-bell { position: relative; display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 10px; color: var(--ink-soft); font-size: 19px;
    border: 1px solid var(--line); background: var(--surface); flex: 0 0 auto; text-decoration: none; }
.notif-bell:hover { color: var(--brand-dk); border-color: var(--brand); }
.notif-badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 100px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center; line-height: 1; }

/* --- Pretraživi select (searchable) ---------------------------------- */
.ss-wrap { position: relative; }
.ss-hidden { position: absolute; opacity: 0; pointer-events: none; height: 0; width: 0; }
.ss-input { cursor: text; }
.ss-list { display: none; position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px);
    max-height: 240px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line);
    border-radius: 10px; box-shadow: 0 12px 30px rgba(15,23,32,.12); padding: 5px; }
.ss-wrap.open .ss-list { display: block; }
.ss-item { padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 14px; }
.ss-item:hover { background: var(--surface-2); }
.ss-item.active { background: var(--brand-soft); color: var(--brand-dk); font-weight: 600; }

/* --- Custom polja ----------------------------------------------------- */
.cf-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; margin: 0 2px; }

/* --- Recency filter chips -------------------------------------------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
@media (max-width: 768px) {
    .filter-bar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
    .filter-bar::-webkit-scrollbar { display: none; }
}

/* --- Napredni panel (filteri + kolone) ------------------------------- */
.adv-panel { margin-top: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); }
.adv-panel > summary { cursor: pointer; padding: 11px 14px; font-size: 13.5px; font-weight: 600; color: var(--ink-soft);
    list-style: none; display: flex; align-items: center; gap: 8px; user-select: none; }
.adv-panel > summary::-webkit-details-marker { display: none; }
.adv-panel > summary::before { content: "\F285"; font-family: "bootstrap-icons"; font-weight: normal; transition: transform .15s; }
.adv-panel[open] > summary::before { transform: rotate(90deg); }
.adv-form { padding: 4px 14px 16px; }
.adv-block { padding: 10px 0; border-top: 1px dashed var(--line); }
.adv-head { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-mute); margin-bottom: 8px; }

/* ====================================================================== */
/*  MOBILNI UI/UX + BOTTOM NAV + PWA                                      */
/* ====================================================================== */

/* Donja navigacija (samo mobilni) */
.bottom-nav { display: none; }
.bn-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; padding: 7px 0 calc(7px + env(safe-area-inset-bottom, 0px)); background: none; border: 0;
    color: var(--ink-mute); font-size: 10.5px; font-weight: 600; text-decoration: none; cursor: pointer;
    font-family: inherit; transition: color .12s;
}
.bn-item i { font-size: 20px; line-height: 1; }
.bn-item.active { color: var(--brand-dk); }
.bn-item:active { transform: scale(.94); }

@media (max-width: 767px) {
    .bottom-nav {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
        background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
        border-top: 1px solid var(--line); box-shadow: 0 -4px 18px rgba(15,23,32,.06);
    }
    .content { padding-bottom: 78px !important; }       /* prostor za donju traku */

    /* Veći razmak/čitljivost na malim ekranima */
    .content { padding-left: 14px; padding-right: 14px; }
    .page-head { flex-wrap: wrap; gap: 10px; }
    .page-actions { width: 100%; flex-wrap: wrap; }
    .page-actions .btn { flex: 1; justify-content: center; }

    /* KPI kartice u 2 stupca umjesto 1 */
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .kpi-value { font-size: 20px !important; }

    /* Sve dvostupčane mreže idu u jedan stupac */
    .grid-2, .grid-2-1, .grid-3, .detail-grid { grid-template-columns: 1fr !important; }

    /* Veći tap-targeti */
    .btn { min-height: 40px; }
    .icon-btn { width: 38px; height: 38px; }
    .input, .textarea, select.input { font-size: 16px; }   /* sprječava zoom na iOS-u */

    /* Tablica: zalijepljeno zaglavlje pri skrolu unutar table-wrap */
    .table-wrap { -webkit-overflow-scrolling: touch; }
    .tbl thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }

    /* Topbar: skrati pretragu */
    .topbar-title { font-size: 16px; }
    .topbar-search { max-width: 40vw; }

    /* Kanban kolone čitljivije (vodoravni scroll) */
    .kanban { grid-auto-columns: 80vw; }
}

@media (max-width: 480px) {
    .topbar-search { display: none; }   /* pretraga preko "Više" → meni */
    .kpi-grid { grid-template-columns: 1fr 1fr; }
}

/* PWA standalone: malo zraka ispod gornje trake zbog statusne trake na iOS-u */
@media (display-mode: standalone) {
    .topbar { padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
}

/* --- Pločice pregleda po vrsti (dnevnik) ------------------------------ */
.cf-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.cf-tile { display: flex; align-items: center; gap: 10px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.cf-tile-ic { width: 36px; height: 36px; border-radius: 9px; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 16px; flex: 0 0 auto; }
.cf-tile-lbl { font-size: 12px; color: var(--ink-mute); }
.cf-tile-val { font-size: 15px; font-weight: 700; color: var(--ink); }
@media (max-width: 767px){ .cf-tiles { grid-template-columns: 1fr 1fr; } }

/* ==========================================================================
   SIK CRM — UI/UX Unapređenja v2
   ========================================================================== */

/* --- Dark mode ----------------------------------------------------------- */
[data-theme="dark"] {
    --bg:         #0c1118;
    --surface:    #151d28;
    --surface-2:  #1a2436;
    --line:       #232f3e;
    --ink:        #e2e8f0;
    --ink-soft:   #94a3b8;
    --ink-mute:   #4a5568;
    --brand-soft: #0a2e2e;
    --accent-soft:#2d1f00;
}
[data-theme="dark"] .topbar { background: rgba(21,29,40,.92); }
[data-theme="dark"] .bottom-nav { background: rgba(21,29,40,.96); }
[data-theme="dark"] .topbar-search input { background: var(--surface-2); color: var(--ink); }
[data-theme="dark"] .login-wrap { background: radial-gradient(1200px 600px at 70% -10%, #0e2a2a 0%, #060b10 55%); }
[data-theme="dark"] .adv-panel { background: var(--surface-2); }
[data-theme="dark"] .check-pill { background: var(--surface); }
[data-theme="dark"] .can-card, [data-theme="dark"] .kan-card { background: var(--surface); }
[data-theme="dark"] .ss-list { background: var(--surface); }
[data-theme="dark"] .input, [data-theme="dark"] .textarea, [data-theme="dark"] select.input {
    background: var(--surface); color: var(--ink);
}

/* --- Sidebar section labels --------------------------------------------- */
.sidebar-section {
    padding: 14px 14px 4px;
    font-size: 10px;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: #2e3c4f;
    font-weight: 700;
    font-family: 'Figtree', system-ui, sans-serif;
}

/* --- KPI colored top border variant ------------------------------------ */
.kpi-accent { border-top-width: 3px !important; border-top-style: solid !important; }
.kpi-teal   { border-top-color: var(--brand) !important; }
.kpi-blue   { border-top-color: #0284c7 !important; }
.kpi-amber  { border-top-color: #f59e0b !important; }
.kpi-purple { border-top-color: #6d28d9 !important; }
.kpi-green  { border-top-color: #16a34a !important; }
.kpi-red    { border-top-color: #dc2626 !important; }

/* KPI trend text */
.kpi-trend {
    font-size: 12px; margin-top: 4px;
    display: flex; align-items: center; gap: 4px; font-weight: 500;
}
.kpi-trend.up   { color: var(--ok); }
.kpi-trend.down { color: var(--bad); }
.kpi-trend.flat { color: var(--ink-mute); }

/* Sparkline */
.kpi-sparkline {
    display: flex; align-items: flex-end; gap: 2px;
    height: 22px; margin-top: 6px;
}
.kpi-sparkline b {
    flex: 1; border-radius: 2px 2px 0 0;
    background: currentColor; opacity: .28; min-height: 2px;
}

/* --- Toast container & items ------------------------------------------- */
.toast-container {
    position: fixed; bottom: 24px; right: 24px; z-index: 9100;
    display: flex; flex-direction: column-reverse; gap: 8px;
    pointer-events: none; max-width: 380px;
}
@media (max-width: 767px) {
    .toast-container {
        bottom: calc(68px + env(safe-area-inset-bottom, 0px));
        right: 12px; left: 12px; max-width: none;
    }
}
.toast-item {
    background: #1e2d3d; color: #e2e8f0;
    padding: 12px 14px; border-radius: 12px;
    font-size: 13.5px; font-weight: 500;
    display: flex; align-items: center; gap: 10px;
    box-shadow: 0 8px 28px rgba(0,0,0,.35);
    pointer-events: all; position: relative; overflow: hidden;
    animation: toastIn .22s cubic-bezier(.22,1,.36,1);
    border-left: 4px solid transparent;
}
.toast-item.toast-success { border-left-color: #4ade80; }
.toast-item.toast-error   { border-left-color: #f87171; background: #2a1010; }
.toast-item.toast-warning { border-left-color: #fbbf24; }
.toast-item.toast-info    { border-left-color: #60a5fa; }
.toast-ico { font-size: 15px; flex-shrink: 0; }
.toast-msg { flex: 1; line-height: 1.4; }
.toast-x {
    font-size: 18px; cursor: pointer; opacity: .5; line-height: 1;
    background: none; border: none; color: inherit; padding: 0 2px; flex-shrink: 0;
}
.toast-x:hover { opacity: 1; }
.toast-bar {
    position: absolute; bottom: 0; left: 0; height: 2px;
    background: rgba(255,255,255,.2);
    animation: toastBar var(--td, 4s) linear forwards;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(14px) scale(.96); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
    from { opacity: 1; max-height: 80px; padding: 12px 14px; margin-bottom: 0; }
    to   { opacity: 0; max-height: 0; padding: 0; margin-bottom: -8px; }
}
@keyframes toastBar {
    from { width: 100%; }
    to   { width: 0%; }
}
.toast-item.removing { animation: toastOut .2s ease forwards; pointer-events: none; }

/* --- FAB (mobilni floating action button) ------------------------------ */
.fab-wrap {
    position: fixed; bottom: 24px; right: 20px; z-index: 500;
    display: none;
}
@media (max-width: 767px) {
    .fab-wrap { display: block; bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
}
.fab {
    width: 52px; height: 52px; border-radius: 50%;
    background: var(--brand); color: #fff; border: none;
    cursor: pointer; font-size: 24px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 20px rgba(14,165,164,.5);
    transition: transform .22s cubic-bezier(.34,1.56,.64,1), box-shadow .2s, background .15s;
    position: relative; z-index: 2;
}
.fab-wrap.open .fab { transform: rotate(45deg); background: var(--brand-dk); }
.fab-menu {
    position: absolute; bottom: 60px; right: 2px;
    display: flex; flex-direction: column; gap: 8px;
    pointer-events: none; opacity: 0;
    transform: translateY(10px) scale(.95);
    transition: opacity .18s, transform .18s cubic-bezier(.22,1,.36,1);
}
.fab-wrap.open .fab-menu { pointer-events: all; opacity: 1; transform: translateY(0) scale(1); }
.fab-item {
    display: flex; align-items: center; gap: 10px;
    background: #1e2d3d; color: #e2e8f0;
    padding: 10px 14px 10px 12px; border-radius: 10px;
    font-size: 13.5px; font-weight: 600; white-space: nowrap;
    text-decoration: none; box-shadow: 0 4px 14px rgba(0,0,0,.25);
    justify-content: flex-end;
    transition: background .12s, color .12s;
}
.fab-item:hover { background: var(--brand); color: #fff; text-decoration: none; }
.fab-item i { font-size: 16px; order: 2; }
.fab-item span { order: 1; }
.fab-backdrop {
    display: none; position: fixed; inset: 0; z-index: 499;
}
.fab-wrap.open ~ .fab-backdrop { display: block; }

/* --- Mobilna pretraga — toggle i overlay -------------------------------- */
.search-toggle {
    width: 38px; height: 38px; border-radius: 10px;
    background: var(--surface-2); border: 1px solid var(--line);
    display: none; align-items: center; justify-content: center;
    color: var(--ink-soft); font-size: 17px; cursor: pointer; flex-shrink: 0;
}
.search-toggle:hover { background: var(--line); color: var(--ink); }
.search-overlay {
    display: none; position: fixed; inset: 0; z-index: 1200;
    background: rgba(8,12,18,.5); align-items: flex-start;
}
.search-overlay.open { display: flex; }
.search-overlay-inner {
    width: 100%; background: var(--surface);
    padding: 14px; border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.search-overlay-inner input {
    flex: 1; padding: 10px 14px; border: 1px solid var(--line);
    border-radius: 10px; font-size: 16px; background: var(--surface-2);
    color: var(--ink); outline: none; font-family: inherit;
}
.search-overlay-inner input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.search-cancel {
    font-size: 14px; font-weight: 600; color: var(--brand-dk);
    background: none; border: none; cursor: pointer; padding: 6px; white-space: nowrap;
}
@media (max-width: 480px) {
    .topbar-search { display: none !important; }
    .search-toggle { display: inline-flex; }
}

/* --- Topbar title: desktop = app name, mobile = page title ------------- */
.topbar-title .t-app  { display: block; }
.topbar-title .t-page { display: none; }
@media (max-width: 768px) {
    .topbar-title .t-app  { display: none; }
    .topbar-title .t-page { display: block; }
}

/* --- Breadcrumbs ------------------------------------------------------- */
.breadcrumb {
    display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
    font-size: 12.5px; color: var(--ink-mute); margin-bottom: 10px;
    list-style: none; padding: 0;
}
.breadcrumb a { color: var(--ink-mute); text-decoration: none; }
.breadcrumb a:hover { color: var(--brand-dk); text-decoration: underline; }
.breadcrumb .bc-sep { opacity: .4; font-size: 10px; }

/* --- Dark mode toggle -------------------------------------------------- */
.dm-toggle {
    width: 30px; height: 30px; border-radius: 8px;
    background: transparent; border: none;
    color: var(--sidebar-ink); cursor: pointer; font-size: 15px;
    display: flex; align-items: center; justify-content: center;
    transition: background .12s, color .12s; flex-shrink: 0;
}
.dm-toggle:hover { background: var(--sidebar-2); color: #fff; }

/* --- Avatar boje (hash po ID-u korisnika) ----------------------------- */
.av-0 { background: linear-gradient(135deg, #0ea5a4, #14b8a6) !important; color: #042f2e !important; }
.av-1 { background: linear-gradient(135deg, #6366f1, #8b5cf6) !important; color: #fff !important; }
.av-2 { background: linear-gradient(135deg, #f59e0b, #f97316) !important; color: #431407 !important; }
.av-3 { background: linear-gradient(135deg, #0284c7, #38bdf8) !important; color: #fff !important; }
.av-4 { background: linear-gradient(135deg, #dc2626, #ef4444) !important; color: #fff !important; }
.av-5 { background: linear-gradient(135deg, #16a34a, #22c55e) !important; color: #fff !important; }
.av-6 { background: linear-gradient(135deg, #7c3aed, #c084fc) !important; color: #fff !important; }
.av-7 { background: linear-gradient(135deg, #db2777, #f472b6) !important; color: #fff !important; }

/* --- Klikabilni redci tablice ------------------------------------------ */
.tbl tbody tr[data-href] { cursor: pointer; }
.tbl tbody tr[data-href]:hover { background: var(--surface-2); }

/* --- Tipkovni prečaci overlay ----------------------------------------- */
.kb-overlay {
    position: fixed; inset: 0; z-index: 9200;
    background: rgba(8,12,18,.72); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity .18s;
}
.kb-overlay.open { opacity: 1; pointer-events: all; }
.kb-modal {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 16px; padding: 26px 30px;
    box-shadow: 0 24px 60px rgba(0,0,0,.4); max-width: 520px; width: 92%;
}
.kb-modal h3 { font-size: 17px; margin: 0 0 18px; display: flex; align-items: center; gap: 8px; }
.kb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.kb-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px;
}
.kb-row:last-child { border-bottom: 0; }
.kb-desc { color: var(--ink-soft); }
.kb-keys { display: flex; gap: 4px; flex-shrink: 0; }
.kb-key {
    padding: 3px 8px; background: var(--surface-2); border: 1px solid var(--line);
    border-radius: 5px; font-size: 11.5px; font-weight: 600; color: var(--ink-soft);
    font-family: 'Sora', monospace; white-space: nowrap;
}

/* --- Row highlight animacija za novo dodane redove -------------------- */
@keyframes rowHighlight {
    0%   { background-color: rgba(14,165,164,.15); }
    100% { background-color: transparent; }
}
.row-new { animation: rowHighlight 1.8s ease forwards; }

/* --- Print stilovi ----------------------------------------------------- */
@media print {
    .sidebar, .topbar, .bottom-nav, .fab-wrap, .fab-backdrop,
    .toast-container, .kb-overlay, .search-overlay, .search-toggle,
    .page-actions, form[data-confirm], .adv-panel, .icon-btn,
    .btn-danger, .notif-bell { display: none !important; }
    .main  { margin-left: 0 !important; }
    .content { padding: 0 !important; max-width: none !important; }
    body   { font-size: 12px; background: #fff !important; }
    .card  { box-shadow: none !important; border: 1px solid #dde !important; page-break-inside: avoid; }
    .kpi-grid { page-break-inside: avoid; }
    a[href]::after { content: none !important; }
}

/* --- Pagination info --------------------------------------------------- */
.tbl-info {
    padding: 10px 16px 12px;
    font-size: 13px; color: var(--ink-mute);
    border-top: 1px solid var(--line);
}
