:root {
  --blue: #1A3A8F;
  --blue2: #2249B3;
  --blue-pale: #E8EFFE;
  --sky: #29ABE2;
  --orange: #F5720A;
  --orange2: #FF8C2A;
  --orange-pale: #FEF0E6;
  --dark: #0D1B3E;
  --text: #1E293B;
  --muted: #64748B;
  --border: #E2E8F0;
  --bg: #F1F5FB;
  --white: #ffffff;
  --success: #10B981;
  --warn: #F59E0B;
  --danger: #EF4444;
  --purple: #7C3AED;
  --sidebar-w: 260px;
  --r: 12px;
  --r-sm: 8px;
  --shadow: 0 2px 16px rgba(26, 58, 143, 0.08);
  --shadow-md: 0 6px 28px rgba(26, 58, 143, 0.14);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; line-height: 1.5; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; color: var(--text); }
svg { stroke: currentColor; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* ─── LOGIN ─────────────────────────────────────────── */
.login-bg {
  min-height: 100vh;
  background: linear-gradient(145deg, #0A1530 0%, #162E7A 55%, #0D2060 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; position: relative; overflow: hidden;
}
.login-bg::before {
  content: ''; position: absolute;
  width: 520px; height: 520px; border-radius: 50%;
  background: radial-gradient(circle, rgba(41,171,226,.14), transparent 70%);
  top: -130px; right: -130px; pointer-events: none;
}
.login-bg::after {
  content: ''; position: absolute;
  width: 400px; height: 400px; border-radius: 50%;
  background: radial-gradient(circle, rgba(245,114,10,.10), transparent 70%);
  bottom: -100px; left: -100px; pointer-events: none;
}
.login-card {
  background: var(--white); border-radius: 20px; padding: 40px 36px;
  width: 100%; max-width: 440px;
  box-shadow: 0 28px 72px rgba(0,0,0,.3);
  position: relative; z-index: 1;
}
.login-logo { display: flex; align-items: center; justify-content: center; margin-bottom: 8px; min-height: 130px; }
.login-logo img { max-height: 130px; max-width: 250px; object-fit: contain; }
.logo-inline { display: flex; align-items: center; gap: 10px; }
.logo-inline.sm { gap: 7px; }
.logo-txt { font-size: 24px; font-weight: 800; letter-spacing: -.5px; }
.logo-txt.sm { font-size: 17px; }
.c-blue { color: var(--blue); }
.c-orange { color: var(--orange); }
.login-tagline { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 28px; line-height: 1.6; }
.login-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.chk-label { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.btn-link { background: none; border: none; color: var(--orange); font-size: 13px; font-weight: 500; padding: 0; }
.btn-link:hover { text-decoration: underline; }
.login-foot { text-align: center; font-size: 12px; color: var(--muted); margin-top: 24px; }

/* ─── FORM ELEMENTS ──────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--r-sm); font-size: 14px; background: var(--white);
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26,58,143,.09);
}
.form-group textarea { resize: vertical; min-height: 82px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 42px; }
.pw-eye {
  position: absolute; right: 11px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted); padding: 3px;
  display: flex; align-items: center; transition: color .15s;
}
.pw-eye:hover { color: var(--text); }
.field-err { font-size: 12px; color: var(--danger); margin-top: 4px; display: block; min-height: 16px; }
.form-row { display: flex; gap: 16px; }
.form-row > .form-group { flex: 1; }
.alert-err {
  background: #FEF2F2; border: 1px solid #FCA5A5;
  border-radius: var(--r-sm); padding: 10px 14px;
  font-size: 13px; color: var(--danger); margin-top: 12px;
}
.admin-only  { display: none; }
.manager-only { display: none; }
/* Global search topbar button */
#global-search-btn:hover {
  border-color: var(--orange) !important;
  color: var(--text) !important;
}
 
/* Notification badge */
#notif-badge {
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  padding: 0 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}
 
/* Onboarding widget animation */
#onboarding-widget {
  animation: slideInRight .3s ease;
}
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
 
/* Bulk action bar */
#bulk-action-bar button:hover {
  opacity: .85;
}

/* ─── BUTTONS ────────────────────────────────────────── */
.btn-primary {
  background: linear-gradient(135deg, var(--blue2), var(--blue));
  color: var(--white); border: none; padding: 11px 22px;
  border-radius: var(--r-sm); font-size: 14px; font-weight: 600;
  transition: opacity .15s, transform .1s;
}
.btn-primary:hover { opacity: .9; transform: translateY(-1px); }
.btn-primary.w100 { width: 100%; padding: 13px; margin-top: 4px; }
.btn-orange {
  background: linear-gradient(135deg, var(--orange2), var(--orange));
  color: var(--white); border: none; padding: 11px 22px;
  border-radius: var(--r-sm); font-size: 14px; font-weight: 600;
  transition: opacity .15s, transform .1s;
}
.btn-orange:hover { opacity: .9; transform: translateY(-1px); }
.btn-orange.w100 { width: 100%; }
.btn-outline {
  background: transparent; color: var(--blue); border: 1.5px solid var(--blue);
  padding: 8px 16px; border-radius: var(--r-sm); font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; transition: background .15s;
}
.btn-outline:hover { background: var(--blue-pale); }
.btn-outline-o {
  background: transparent; color: var(--orange); border: 1.5px solid var(--orange);
  padding: 8px 16px; border-radius: var(--r-sm); font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; transition: background .15s;
}
.btn-outline-o:hover { background: var(--orange-pale); }
.btn-ghost {
  background: var(--bg); color: var(--text); border: 1.5px solid var(--border);
  padding: 8px 16px; border-radius: var(--r-sm); font-size: 13px; font-weight: 500;
  transition: border-color .15s;
}
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); }
.btn-danger-sm {
  background: var(--danger); color: var(--white); border: none;
  padding: 5px 10px; border-radius: 6px; font-size: 12px; cursor: pointer;
}

/* ─── SIDEBAR ────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); background: var(--dark); color: var(--white);
  height: 100vh; position: fixed; left: 0; top: 0;
  display: flex; flex-direction: column; z-index: 100;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.sb-top { padding: 18px 20px 14px; border-bottom: 1px solid rgba(255,255,255,.07); }
.sb-logo-img { max-height: 90px; max-width: 300px; object-fit: contain; }
.sb-user {
  padding: 14px 18px; display: flex; align-items: center; gap: 11px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--orange), var(--orange2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: var(--white); flex-shrink: 0; user-select: none;
}
.avatar.sm { width: 32px; height: 32px; font-size: 11px; }
.sb-uname { font-size: 13px; font-weight: 600; color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-role { font-size: 11px; color: rgba(255,255,255,.45); text-transform: uppercase; letter-spacing: .5px; margin-top: 1px; }
.nav-list { list-style: none; padding: 10px 0; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; font-size: 13.5px; font-weight: 500;
  color: rgba(255,255,255,.6); transition: all .18s;
  border-left: 3px solid transparent; white-space: nowrap;
}
.nav-item:hover { color: var(--white); background: rgba(255,255,255,.05); }
.nav-item.active { color: var(--white); background: rgba(41,171,226,.10); border-left-color: var(--orange); }
.ni { width: 17px; height: 17px; flex-shrink: 0; stroke-width: 1.7; }
.sb-foot { padding: 10px 0; border-top: 1px solid rgba(255,255,255,.07); }
.sb-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.42); z-index: 99; }

/* ─── TOPBAR & LAYOUT ────────────────────────────────── */
.main { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
#page-app { display: flex; min-height: 100vh; }
.topbar {
  background: var(--white); padding: 12px 22px;
  display: flex; align-items: center; gap: 14px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.ham-btn { display: none; background: none; border: none; color: var(--muted); padding: 4px; align-items: center; }
.page-title { font-size: 16px; font-weight: 700; flex: 1; }
.tb-right { display: flex; align-items: center; gap: 14px; }
.tb-date { font-size: 12px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.view { padding: 22px; flex: 1; }

/* ─── CARDS ──────────────────────────────────────────── */
.card { background: var(--white); border-radius: var(--r); padding: 22px; box-shadow: var(--shadow); }

/* ─── KPI GRID ───────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi {
  background: var(--white); border-radius: var(--r); padding: 18px 20px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
  transition: transform .18s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi::after { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.kpi.kblue::after   { background: linear-gradient(90deg, var(--blue), var(--sky)); }
.kpi.korange::after { background: linear-gradient(90deg, var(--orange), var(--orange2)); }
.kpi.kgreen::after  { background: linear-gradient(90deg, var(--success), #34D399); }
.kpi.kwarn::after   { background: linear-gradient(90deg, var(--warn), #FCD34D); }
.kpi.kpurple::after { background: linear-gradient(90deg, var(--purple), #A78BFA); }
.kpi-lbl { font-size: 11.5px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 7px; }
.kpi-val { font-size: 28px; font-weight: 800; line-height: 1; }
.kpi-sub { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.kpi-ico { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; font-size: 15px; }
.ib  { background: var(--blue-pale); }
.io  { background: var(--orange-pale); }
.ig  { background: #ECFDF5; }
.ip  { background: #F3F0FF; }

/* ─── TABLE ──────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { background: var(--bg); color: var(--muted); font-weight: 600; padding: 11px 13px; text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 13px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg); }

/* ─── BADGES ─────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.bb { background: var(--blue-pale); color: var(--blue); }
.bo { background: var(--orange-pale); color: var(--orange); }
.bg { background: #ECFDF5; color: var(--success); }
.br { background: #FEF2F2; color: var(--danger); }
.bp { background: #F3F0FF; color: var(--purple); }

/* ─── SECTION HEADERS ────────────────────────────────── */
.sh { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.st { font-size: 15px; font-weight: 700; }
.ss { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
hr.div { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

/* ─── TWO-COL GRID ───────────────────────────────────── */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* ─── FILTER BAR ─────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  background: var(--white); padding: 12px 14px;
  border-radius: var(--r); box-shadow: var(--shadow); margin-bottom: 18px;
}
.filter-bar input, .filter-bar select {
  padding: 7px 11px; border: 1.5px solid var(--border);
  border-radius: var(--r-sm); font-size: 13px;
}
.filter-bar input:focus, .filter-bar select:focus { outline: none; border-color: var(--blue); }

/* ─── CHART BARS ─────────────────────────────────────── */
.cbars { display: flex; flex-direction: column; gap: 11px; }
.cbar { display: flex; align-items: center; gap: 10px; }
.cbar-lbl { font-size: 12px; color: var(--muted); width: 88px; text-align: right; flex-shrink: 0; }
.cbar-track { flex: 1; background: var(--border); border-radius: 99px; height: 9px; overflow: hidden; }
.cbar-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--blue), var(--sky)); transition: width .6s cubic-bezier(.4,0,.2,1); }
.cbar-val { font-size: 12px; font-weight: 700; width: 36px; flex-shrink: 0; }

/* ─── STREAK BANNER ──────────────────────────────────── */
.streak {
  background: linear-gradient(135deg, var(--dark), #1A3A8F);
  border-radius: var(--r); padding: 18px 22px; color: var(--white);
  display: flex; align-items: center; gap: 18px; margin-bottom: 18px; flex-wrap: wrap;
}
.streak-ico { font-size: 34px; flex-shrink: 0; }
.streak-txt { flex: 1; }
.streak-txt h3 { font-size: 19px; font-weight: 800; margin-bottom: 2px; }
.streak-txt p { font-size: 12.5px; opacity: .7; }
.streak-act { margin-left: auto; }

/* ─── EMPTY STATE ────────────────────────────────────── */
.empty { text-align: center; padding: 48px 20px; }
.empty-ico { font-size: 44px; margin-bottom: 14px; opacity: .35; }
.empty h3 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.empty p { font-size: 13px; color: var(--muted); line-height: 1.5; }

/* ─── FORM SECTION BANNERS ───────────────────────────── */
.fsb { border-radius: var(--r-sm); padding: 11px 14px; margin-bottom: 18px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.fsb-blue   { background: var(--blue-pale); color: var(--blue); }
.fsb-orange { background: var(--orange-pale); color: var(--orange); }
.fsb-green  { background: #ECFDF5; color: var(--success); }
.fsb-red    { background: #FEF2F2; color: var(--danger); }
.fsb-purple { background: #F3F0FF; color: var(--purple); }

/* ─── RATING BUTTONS ─────────────────────────────────── */
.rating-row { display: flex; gap: 8px; flex-wrap: wrap; }
.rbt {
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--r-sm); padding: 7px 12px; font-size: 14px;
  transition: all .15s;
}
.rbt.sel { background: var(--blue-pale); border-color: var(--blue); }

/* ─── MODAL ──────────────────────────────────────────── */
.modal-bg {
  position: fixed; inset: 0; background: rgba(13,27,62,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 14px; backdrop-filter: blur(3px);
}
.modal-box {
  background: var(--white); border-radius: 16px;
  width: 100%; max-width: 780px; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,.25);
}
.modal-hd {
  padding: 18px 22px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.modal-hd h2 { font-size: 17px; font-weight: 700; }
.modal-x {
  background: none; border: none; color: var(--muted); padding: 5px;
  border-radius: 6px; display: flex; align-items: center; transition: background .15s;
}
.modal-x:hover { background: var(--bg); }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-ft {
  padding: 14px 22px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end; flex-shrink: 0; flex-wrap: wrap;
}

/* ─── REPORT SECTIONS ────────────────────────────────── */
.rs { margin-bottom: 22px; }
.rs-title {
  font-size: 12.5px; font-weight: 700; color: var(--blue);
  text-transform: uppercase; letter-spacing: .5px;
  margin-bottom: 10px; padding-bottom: 5px;
  border-bottom: 2px solid var(--blue-pale);
}
.rg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.ri { background: var(--bg); border-radius: var(--r-sm); padding: 10px 13px; }
.ri-lbl { font-size: 11px; color: var(--muted); font-weight: 500; text-transform: uppercase; margin-bottom: 3px; }
.ri-val { font-size: 15px; font-weight: 700; }
.ri-val.big { font-size: 21px; color: var(--blue); }
.ri-val.ora { color: var(--orange); }
.rtxt { font-size: 13.5px; line-height: 1.6; background: var(--bg); border-radius: var(--r-sm); padding: 11px 13px; white-space: pre-wrap; }
.rtxt.dng { border-left: 3px solid var(--danger); background: #FEF2F2; }
.rtxt.prp { border-left: 3px solid var(--purple); background: #F3F0FF; }

/* ─── TOAST ──────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 22px; right: 22px;
  background: var(--dark); color: var(--white);
  padding: 11px 18px; border-radius: 10px;
  font-size: 13.5px; font-weight: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  z-index: 999; transform: translateY(80px); opacity: 0;
  transition: all .28s; max-width: 300px; pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.ok  { background: #065F46; }
.toast.err { background: #991B1B; }

/* ─── LEADERBOARD ────────────────────────────────────── */
.medal { font-size: 18px; }

/* ─── SUMMARY MINI CARDS ─────────────────────────────── */
.mini-cards { display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.mini-card { background: var(--white); border-radius: var(--r); padding: 16px 18px; flex: 1; min-width: 130px; box-shadow: var(--shadow); }
.mini-lbl { font-size: 11.5px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .3px; margin-bottom: 5px; }
.mini-val { font-size: 22px; font-weight: 800; }

/* ─── RESPONSIVE ─────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sb-overlay.active { display: block; }
  .main { margin-left: 0; }
  .ham-btn { display: flex; }
  .g2 { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; gap: 0; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .view { padding: 14px; }
  .rg { grid-template-columns: 1fr; }
  .streak { flex-direction: column; text-align: center; }
  .streak-act { margin-left: 0; }
}
@media (max-width: 440px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .modal-ft { flex-direction: column; }
  .modal-ft button { width: 100%; }
  .mini-cards { flex-direction: column; }
}

.headerimg {
     margin: 0 0 18px 0;
  padding-bottom: 10px;
  border-bottom: 3px solid #F5720A;
  font-family: Calibri, Arial, sans-serif;
  font-size: 28pt;
  font-weight: 700;
  letter-spacing: -1px;
}

.brand-blue {
  color: #1746A2;
}

.brand-orange {
  color: #F5720A;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .6; transform: scale(1.15); }
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* =========================================================
   SALESENTRA CHAT — FIXED UI
   Replace the entire chat CSS block in your stylesheet
========================================================= */

#crm-chat {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 999999;
  font-family: Inter, sans-serif;
}

/* FLOAT BUTTON */
#chat-toggle {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(37,99,235,.35), 0 4px 10px rgba(0,0,0,.12);
  transition: .25s;
  position: relative;
}
#chat-toggle:hover { transform: translateY(-3px) scale(1.03); }

/* MAIN WINDOW */
#chat-window {
  position: absolute;
  right: 0;
  bottom: 80px;
  width: 980px;
  height: 720px;
  background: #fff;
  border-radius: 24px;
  overflow: hidden;
  display: none;
  box-shadow: 0 40px 90px rgba(15,23,42,.20), 0 10px 30px rgba(0,0,0,.08);
}
#chat-window.open { display: flex; }

/* SIDEBAR */
#chat-sidebar {
  width: 320px;
  background: #fff;
  border-right: 1px solid #eef2f7;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

/* TOP BAR */
#chat-topbar {
  padding: 22px 20px 16px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.chat-title { font-size: 18px; font-weight: 700; color: #0f172a; }
.chat-sub   { font-size: 12px; color: #64748b; margin-top: 2px; }
#chat-close {
  border: none;
  background: #f1f5f9;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  transition: .2s;
  flex-shrink: 0;
}
#chat-close:hover { background: #e2e8f0; }

/* SEARCH */
.chat-search-wrap {
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
}
#chat-search {
  width: 100%;
  border: none;
  background: #f8fafc;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 14px;
  outline: none;
  transition: .2s;
}
#chat-search:focus {
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* USER LIST */
#chat-users { flex: 1; overflow-y: auto; }
.chat-user {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  cursor: pointer;
  transition: .18s;
  border-bottom: 1px solid #f8fafc;
}
.chat-user:hover  { background: #f8fafc; }
.chat-user.active { background: #eff6ff; }

/* AVATAR */
.chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}
.chat-avatar.sm { width: 42px; height: 42px; font-size: 15px; }
.online-dot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 12px;
  height: 12px;
  background: #10b981;
  border-radius: 50%;
  border: 2px solid #fff;
}

/* USER INFO */
.chat-user-info { flex: 1; min-width: 0; }
.chat-user-name { font-size: 14px; font-weight: 600; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-user-role { font-size: 12px; color: #64748b; margin-top: 3px; }

/* UNREAD BADGE */
.chat-unread {
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #2563eb;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── MAIN AREA ──────────────────────────────────────── */
#chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f8fafc;
  min-width: 0;
  overflow: hidden;
}

/* EMPTY */
#chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
}
.chat-empty-icon { font-size: 58px; margin-bottom: 14px; }

/* CONVERSATION CONTAINER — key fix: flex column fills remaining height */
#chat-conversation {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* CHAT HEADER */
#chat-header {
  height: 78px;
  min-height: 78px;
  background: #fff;
  border-bottom: 1px solid #eef2f7;
  display: flex;
  align-items: center;
  padding: 0 22px;
  flex-shrink: 0;
}
.chat-head-user { display: flex; align-items: center; gap: 14px; }
.chat-head-name   { font-size: 15px; font-weight: 700; color: #0f172a; }
.chat-head-status { font-size: 12px; color: #10b981; margin-top: 3px; }

/* MESSAGES — scrollable middle area */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

/* TYPING INDICATOR — sits just above input, never floats off screen */
#typing-indicator {
  flex-shrink: 0;
  min-height: 24px;
  padding: 0 24px 4px;
  font-size: 12px;
  color: #64748b;
  font-style: italic;
  background: #f8fafc;
}

/* INPUT AREA — always pinned to bottom */
#chat-input-wrap {
  flex-shrink: 0;
  background: #fff;
  border-top: 1px solid #eef2f7;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;   /* emoji picker anchors here */
}

/* INPUT FIELD */
#chat-input {
  flex: 1;
  border: none;
  background: #f1f5f9;
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 14px;
  outline: none;
  min-width: 0;
  font-family: Inter, sans-serif;
  transition: .2s;
}
#chat-input:focus {
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* ACTION BUTTONS */
#chat-send,
#emoji-btn,
#attach-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: .2s;
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1;
  padding: 0;
}
#chat-send {
  background: #2563eb;
  color: #fff;
}
#chat-send:hover {
  transform: scale(1.05);
  background: #1d4ed8;
}
#emoji-btn,
#attach-btn {
  background: #f1f5f9;
}
#emoji-btn:hover,
#attach-btn:hover { background: #e2e8f0; }

/* EMOJI PICKER — anchored inside #chat-input-wrap */
.emoji-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 18px;
  background: #fff;
  border-radius: 18px;
  padding: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  width: 260px;
  box-shadow: 0 20px 50px rgba(0,0,0,.16);
  z-index: 10;
}
.emoji-item { font-size: 24px; cursor: pointer; transition: .15s; }
.emoji-item:hover { transform: scale(1.2); }

/* MESSAGE ROW */
.msg-row { display: flex; }
.msg-row.mine { justify-content: flex-end; }

.msg-bubble {
  max-width: 72%;
  padding: 12px 14px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.04);
  animation: msgIn .18s ease;
}
.msg-row.mine .msg-bubble {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
}
.msg-text { font-size: 14px; line-height: 1.5; word-break: break-word; }
.msg-meta { font-size: 11px; opacity: .7; margin-top: 6px; text-align: right; }

@keyframes msgIn {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}


/* Group header — clickable label row */
.nav-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px 4px;
  cursor: pointer;
  list-style: none;
  margin-top: 6px;
  border-radius: var(--r-sm);
  transition: background .12s;
}
.nav-group-header:hover {
  background: rgba(255,255,255,.05);
}
 
/* Group label text */
.nav-group-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
}
 
/* Collapse arrow */
.nav-group-arrow {
  color: rgba(255,255,255,.3);
  transition: transform .2s;
  flex-shrink: 0;
}
.nav-group-arrow.collapsed {
  transform: rotate(-90deg);
}
 
/* Group items container */
.nav-group-items {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  transition: max-height .25s ease;
}
.nav-group-items.collapsed {
  max-height: 0 !important;
}
 
/* Manager-only items (hidden by default, shown for non-admins) */
.manager-only {
  display: none;
}

/* UNREAD BADGE ON TOGGLE */
#chat-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

/* MOBILE */
@media (max-width: 1000px) {
  #chat-window {
    width: 100vw;
    height: 100dvh;
    right: -24px;
    bottom: -24px;
    border-radius: 0;
  }
  #chat-sidebar { width: 260px; }
}
@media (max-width: 600px) {
  #chat-sidebar { display: none; }
  #chat-window { width: 100vw; }
}
