* { box-sizing: border-box; }

:root {
  --font-ui: 'Inter', system-ui, -apple-system, BlinkMacSystemFont,
             'Segoe UI', Roboto, Arial, sans-serif;

  /* brand */
  --tb-navy: #0F1530;
  --tb-blue: #3B82F6;
  --tb-border: rgba(255,255,255,0.10);
  --tb-link: rgba(255,255,255,0.88);
  --tb-link-muted: rgba(255,255,255,0.74);
  --tb-hover-bg: rgba(59,130,246,0.14);
  --tb-active-bg: rgba(59,130,246,0.22);
  --tb-active-border: rgba(59,130,246,0.95);
}

html, body { height: 100%; }
body {
  background: #f5f7fa;
  margin:0;
  font-family: var(--font-ui);
}

body.auth-body {
  height: 100vh;     /* fallback */
  height: 100dvh;
  overflow: hidden;
}

.app-shell {
  height: 100vh;     /* fallback */
  height: 100dvh;
  overflow: hidden;
  min-height: 0;
}

/* ✅ BRAND NAVY SIDEBAR + dorade linkova */
.sidebar {
  width: 260px;
  background: var(--tb-navy);
  color: #fff;

  /* ✅ FIX SIDEBAR SHRINK (desktop) */
  flex: 0 0 260px;
  min-width: 260px;
  max-width: 260px;

  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar a { color: var(--tb-link); text-decoration: none; }
.sidebar a:hover { color: #fff; }

/* ✅ FIX: nav-link da se NIKAD ne reže (wrap-safe) */
.sidebar .nav-link{
  border-radius: 12px;
  padding: 10px 12px;
  transition: background 0.12s ease, transform 0.12s ease, color 0.12s ease;

  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.2;
  white-space: normal;
  min-height: 44px;
}
.sidebar .nav-link:hover{
  background: var(--tb-hover-bg);
  color: #fff;
}
.sidebar .nav-link.active{
  background: var(--tb-active-bg);
  border-radius: 12px;
  position: relative;
  color: #fff;
}
.sidebar .nav-link.active::before{
  content:"";
  position:absolute;
  left: 6px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: var(--tb-active-border);
}

/* icon u sidebaru: fiksna širina + ne skuplja se u flexu */
.nav-link i {
  width: 18px;
  flex: 0 0 18px;
  display: inline-block;
  margin-right: 0;
  margin-top: 1px;
}

/* ✅ bitno za flex: da se tekst ne "čudno" reže na mobitelu */
.sidebar .nav-link span{
  flex: 1 1 auto;
  min-width: 0;
}

.topbar { background: #fff; border-bottom: 1px solid #e5e7eb; }
.card { border: 1px solid #e5e7eb; border-radius: 14px; }
.table { background:#fff; }
.badge-status { font-weight: 600; }

/* =========================================================
   ✅ KLJUČNI FIX: sidebar NE scrolla; scrolla samo NAV dio
   ========================================================= */
#sidebar{
  height: 100%;
  min-height: 0;

  /* više ne scrolla cijeli sidebar (da footer ne upada u meni) */
  overflow: hidden;
}
.sidebar-nav{
  flex: 1 1 auto;
        /*
   * Safari/Chromium flex overflow edge-case:
   * bez eksplicitne visine child ponekad ne ulazi u scroll state.
   */
  height: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;

  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;

  /* ✅ FIX: NIKAD ne dopuštaj “stupce”/wrap u sidebar navu */
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap !important;
  align-content: flex-start;

  /* ✅ Scrollbar (taman, ne iskače) */
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: rgba(255,255,255,0.18) rgba(15,21,48,0.0);
}
/* ✅ dodatni safety: svaki link zauzima cijelu širinu */
.sidebar-nav > .nav-link{
  width: 100%;
}

/* Chromium (Chrome/Edge/Android) + Safari */
.sidebar-nav::-webkit-scrollbar{
  width: 10px;
}
.sidebar-nav::-webkit-scrollbar-track{
  background: rgba(15,21,48,0.0);
}
.sidebar-nav::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,0.16);
  border-radius: 999px;
  border: 3px solid rgba(15,21,48,0.85);
}
.sidebar-nav::-webkit-scrollbar-thumb:hover{
  background: rgba(255,255,255,0.24);
}

.sidebar-footer{
  flex: 0 0 auto;
}

main.flex-grow-1{
  display:flex;
  flex-direction:column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.page-content{
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  background: transparent;
}

/* ✅ BITNO: bez height:100% (rezalo chat) */
.page-content > .container-fluid{
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.container-fluid{ min-height: 0; }

.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(0,0,0,0.12);
  background: #fff;
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 1000;
}

@media (max-width: 991.98px) {
  .sidebar-toggle { display: inline-flex; }

  #sidebar {
    position: fixed;
    top: 0;
    left: 0;

    /* ✅ bolja širina na mobitelu (izbjegava "ikone + prvo slovo") */
    width: 86vw;
    max-width: 280px;

    height: 100vh;
    height: 100dvh;

    transform: translateX(-110%);
    transition: transform 0.22s ease;
    z-index: 1001;
    box-shadow: 0 10px 30px rgba(0,0,0,0.22);
  }
  #sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
}

/* ✅ BRAND: sidebar logo (u boji) */
.sidebar-logo {
  display: flex;              /* ⬅ centriraj */
  align-items: center;
  justify-content: center;    /* ⬅ centriraj */
  text-decoration: none;
  width: 100%;
}
.sidebar-logo img{
  height: 42px;               /* ⬅ veći logo */
  width: auto;
  display: block;
  filter: drop-shadow(0 1px 10px rgba(0,0,0,0.35));
}

/* ✅ Divider ispod loga */
.sidebar-divider{
  height: 1px;
  background: var(--tb-border);
  margin: 12px 0 10px;
}

/* ✅ BRAND: login logo (koristi login.html) */
.login-logo {
  display: flex;
  justify-content: center;
}
.login-logo img {
  width: 320px;
  max-width: 90%;
  height: auto;
  display: block;
}

.sidebar .opacity-75 { opacity: .78 !important; }

.sidebar .badge.text-bg-warning{
  border: 1px solid rgba(255,255,255,0.22);
}

.telechat-widget{
  --telechat-bottom: 18px;
  --telechat-lift: 0px;
  position: fixed;
  right: 18px;
  bottom: calc(var(--telechat-bottom) + var(--telechat-lift));
  z-index: 1400;
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  gap:10px;
}
.telechat-launcher{
  width: 58px;
  height: 58px;
  border-radius:999px;
  border:none;
  background:#0f1530;
  color:#fff;
  box-shadow:0 10px 24px rgba(2,6,23,.35);
  display:flex;
  align-items:center;
  justify-content:center;
  position:relative;
}
.telechat-launcher:hover{ background:#1b2455; }
.telechat-launcher .badge{
  position:absolute;
  top:-6px;
  right:-6px;
  min-width:24px;
}
.telechat-box{
  width: min(380px, calc(100vw - 20px));
  height: min(560px, calc(100dvh - 100px));
  background:#fff;
  border:1px solid rgba(15,23,42,.10);
  border-radius:16px;
  box-shadow:0 18px 36px rgba(2,6,23,.22);
  overflow:hidden;
  display:none;
  flex-direction:column;
}
.telechat-box.open{ display:flex; }
.telechat-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px 12px;
  background:#f4f7fb;
  border-bottom:1px solid rgba(15,23,42,.10);
  flex:0 0 auto;
}
.telechat-head-actions{
  display:flex;
  align-items:center;
  gap:6px;
}
.telechat-lift-controls{
  display:flex;
  align-items:center;
  gap:4px;
}
.telechat-lift-btn{
  width:28px;
  height:28px;
  border:1px solid rgba(15,23,42,.16);
  border-radius:8px;
  background:#fff;
  color:#1e293b;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size:14px;
  line-height:1;
}
.telechat-lift-btn:hover{ background:#f8fafc; }
.telechat-body{
  flex:1 1 auto;
  min-height:0;
  display:flex;
  flex-direction:column;
}
.telechat-search-wrap{ padding:10px; border-bottom:1px solid rgba(15,23,42,.08); }
.telechat-picker{
  border-bottom:1px solid rgba(15,23,42,.08);
  background:#fff;
}
.telechat-picker-summary{
  list-style:none;
  cursor:pointer;
  padding:10px 12px;
  font-weight:600;
  font-size:13px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  color:#0f172a;
  border-bottom:1px solid rgba(15,23,42,.08);
}
.telechat-picker-summary::-webkit-details-marker{ display:none; }
.telechat-picker-summary i{ transition:transform .18s ease; }
.telechat-picker[open] .telechat-picker-summary i{ transform:rotate(180deg); }
.telechat-search{
  width:100%;
  border:1px solid rgba(15,23,42,.12);
  border-radius:12px;
  padding:8px 10px;
  outline:none;
}
.telechat-people{ max-height:180px; overflow:auto; padding:6px; }
.telechat-person{
  border:none; background:transparent; width:100%; text-align:left;
  display:flex; align-items:center; justify-content:space-between; gap:8px;
  padding:8px 10px; border-radius:10px;
}
.telechat-person:hover{ background:rgba(2,6,23,.05); }
.telechat-person.active{ background:rgba(37,99,235,.10); }
.telechat-presence{ font-size:11px; color:rgba(15,23,42,.62); }
.telechat-chat{
  flex:1 1 auto; min-height:0; display:flex; flex-direction:column;
}
.telechat-messages{ flex:1 1 auto; min-height:0; overflow:auto; padding:10px; background:#fafbfe; }
.telechat-msg{ margin-bottom:8px; display:flex; }
.telechat-msg .bubble{
  max-width:80%; padding:8px 10px; border-radius:12px; border:1px solid rgba(15,23,42,.10); background:#f1f5f9;
  font-size:13px;
}
.telechat-msg.me{ justify-content:flex-end; }
.telechat-msg.me .bubble{ background:#e6f0ff; }
.telechat-compose{ padding:10px; border-top:1px solid rgba(15,23,42,.08); display:flex; gap:8px; }
.telechat-compose input{ flex:1; min-width:0; border:1px solid rgba(15,23,42,.12); border-radius:10px; padding:8px 10px; }

@media (max-width: 991.98px) {
  .telechat-widget{ --telechat-bottom: 10px; right:10px; }
  .telechat-box{
    width: calc(100vw - 10px);
    height: min(72dvh, 620px);
  }
}
  
