/* ===============================================================
   SentientCX — AI Customer Experience Command Center
   Enterprise SaaS Design System
   =============================================================== */

:root {
  /* Light theme */
  --bg-app: #f4f6fb;
  --bg-surface: #ffffff;
  --bg-surface-2: #f8fafc;
  --bg-elevated: #ffffff;
  --bg-sidebar: #0f1729;
  --bg-sidebar-hover: #1c2741;
  --bg-input: #ffffff;
  --border: #e4e8f0;
  --border-strong: #d2d9e6;
  --text-primary: #0f1729;
  --text-secondary: #5a6679;
  --text-muted: #8a93a6;
  --text-on-dark: #c7d0e0;
  --text-on-dark-muted: #7e8aa3;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;

  --pos: #16a34a;
  --pos-soft: #e7f6ec;
  --neu: #d97706;
  --neu-soft: #fdf3e3;
  --neg: #dc2626;
  --neg-soft: #fdeaea;

  --crit: #dc2626;
  --high: #ea580c;
  --med: #d97706;
  --low: #0891b2;

  --shadow-sm: 0 1px 2px rgba(15,23,41,.06);
  --shadow: 0 4px 16px rgba(15,23,41,.08);
  --shadow-lg: 0 12px 40px rgba(15,23,41,.14);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 248px;
  --topbar-h: 60px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

[data-theme="dark"] {
  --bg-app: #0a0e1a;
  --bg-surface: #121829;
  --bg-surface-2: #0f1424;
  --bg-elevated: #161d32;
  --bg-sidebar: #0a0e1a;
  --bg-sidebar-hover: #1a2238;
  --bg-input: #1a2138;
  --border: #232c44;
  --border-strong: #2e3a57;
  --text-primary: #e8edf7;
  --text-secondary: #9aa6bf;
  --text-muted: #6b7793;
  --text-on-dark: #c7d0e0;
  --text-on-dark-muted: #7e8aa3;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-soft: #1e2547;
  --pos-soft: #11271a;
  --neu-soft: #2a2310;
  --neg-soft: #2a1414;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow: 0 4px 16px rgba(0,0,0,.35);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-app);
  color: var(--text-primary);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ===================== LAYOUT ===================== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ===================== SIDEBAR ===================== */
.sidebar {
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.04);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  display: grid; place-items: center;
  color: #fff; font-size: 19px;
  box-shadow: 0 4px 14px rgba(99,102,241,.45);
}
.brand-text h1 { font-size: 15px; color: #fff; font-weight: 700; letter-spacing: -.2px; }
.brand-text span { font-size: 10.5px; color: var(--text-on-dark-muted); font-weight: 500; letter-spacing: .3px; text-transform: uppercase; }

.nav-section { padding: 14px 12px 4px; }
.nav-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-on-dark-muted); font-weight: 600;
  padding: 4px 12px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 9px;
  color: var(--text-on-dark); font-size: 13.5px; font-weight: 500;
  cursor: pointer; margin-bottom: 2px; position: relative;
  transition: background .15s, color .15s;
}
.nav-item i { width: 18px; text-align: center; font-size: 15px; }
.nav-item:hover { background: var(--bg-sidebar-hover); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(99,102,241,.25), rgba(99,102,241,.05)); color: #fff; }
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  background: var(--accent); border-radius: 0 3px 3px 0;
}
.nav-badge {
  margin-left: auto; background: var(--neg); color: #fff;
  font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 10px;
}
.nav-badge.amber { background: var(--high); }
.sidebar-footer { margin-top: auto; padding: 14px; border-top: 1px solid rgba(255,255,255,.06); }
.ai-status {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: rgba(99,102,241,.12); border-radius: 9px;
}
.ai-status .pulse-dot { width: 9px; height: 9px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 0 rgba(34,197,94,.6); animation: pulse 2s infinite; }
.ai-status-text { font-size: 11.5px; }
.ai-status-text strong { color: #fff; display: block; font-size: 12px; }
.ai-status-text span { color: var(--text-on-dark-muted); font-size: 10.5px; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34,197,94,.5); }
  70% { box-shadow: 0 0 0 8px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

/* ===================== MAIN ===================== */
.main { display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: var(--topbar-h); flex-shrink: 0;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 22px;
}
.topbar-title h2 { font-size: 17px; font-weight: 700; letter-spacing: -.3px; }
.topbar-title p { font-size: 11.5px; color: var(--text-muted); }
.topbar-search {
  margin-left: 22px; flex: 1; max-width: 420px; position: relative;
}
.topbar-search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 13px; }
.topbar-search input {
  width: 100%; padding: 9px 12px 9px 36px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--bg-input);
  color: var(--text-primary); font-size: 13px; outline: none;
}
.topbar-search input:focus { border-color: var(--accent); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center;
  color: var(--text-secondary); position: relative; transition: background .15s;
}
.icon-btn:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.icon-btn .dot {
  position: absolute; top: 7px; right: 8px; width: 8px; height: 8px;
  background: var(--neg); border-radius: 50%; border: 2px solid var(--bg-surface);
}
.user-chip {
  display: flex; align-items: center; gap: 9px; padding: 5px 5px 5px 12px;
  border-radius: 30px; background: var(--bg-surface-2); border: 1px solid var(--border);
}
.user-chip .uname { font-size: 12.5px; font-weight: 600; }
.user-chip .urole { font-size: 10.5px; color: var(--text-muted); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg,#6366f1,#a855f7); color: #fff; font-size: 12px; font-weight: 700;
}

.content {
  flex: 1; overflow-y: auto; padding: 22px;
}
.view { display: none; animation: fadeIn .25s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ===================== CARDS / KPIs ===================== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; margin-bottom: 20px; }
.kpi {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.kpi-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 16px; }
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.kpi-value { font-size: 27px; font-weight: 800; letter-spacing: -.6px; line-height: 1; }
.kpi-delta { font-size: 11.5px; font-weight: 600; margin-top: 7px; display: inline-flex; align-items: center; gap: 4px; }
.kpi-delta.up { color: var(--pos); }
.kpi-delta.down { color: var(--neg); }
.kpi-delta.warn { color: var(--high); }

.panel {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); margin-bottom: 18px; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px; border-bottom: 1px solid var(--border);
}
.panel-head h3 { font-size: 14.5px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.panel-head h3 i { color: var(--accent); }
.panel-head .sub { font-size: 11.5px; color: var(--text-muted); font-weight: 400; }
.panel-body { padding: 18px; }
.panel-body.flush { padding: 0; }

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 18px; }
@media(max-width: 1100px){ .grid-2,.grid-3 { grid-template-columns: 1fr; } }

/* ===================== BADGES / PILLS ===================== */
.pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 20px; white-space: nowrap;
}
.pill i { font-size: 9px; }
.pill-pos { background: var(--pos-soft); color: var(--pos); }
.pill-neu { background: var(--neu-soft); color: var(--neu); }
.pill-neg { background: var(--neg-soft); color: var(--neg); }
.pill-crit { background: var(--neg-soft); color: var(--crit); }
.pill-high { background: #fdf0e7; color: var(--high); }
.pill-med  { background: var(--neu-soft); color: var(--med); }
.pill-low  { background: #e6f5f9; color: var(--low); }
[data-theme="dark"] .pill-high { background: #2a1c10; }
[data-theme="dark"] .pill-low { background: #0c2730; }
.pill-accent { background: var(--accent-soft); color: var(--accent); }
.pill-gray { background: var(--bg-surface-2); color: var(--text-secondary); border: 1px solid var(--border); }

.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.plat-icon { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; color: #fff; font-size: 12px; flex-shrink: 0; }
.plat-x { background: #000; }
.plat-facebook { background: #1877f2; }
.plat-instagram { background: linear-gradient(45deg,#f09433,#e6683c,#dc2743,#cc2366,#bc1888); }
.plat-linkedin { background: #0a66c2; }
.plat-tiktok { background: #010101; }
.plat-youtube { background: #ff0000; }

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 9px;
  font-size: 12.5px; font-weight: 600; transition: all .15s; border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--bg-surface-2); color: var(--text-secondary); border-color: var(--border); }
.btn-ghost:hover { background: var(--border); color: var(--text-primary); }
.btn-sm { padding: 5px 10px; font-size: 11.5px; }

/* ===================== TABLE ===================== */
.tbl-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th {
  text-align: left; padding: 11px 14px; color: var(--text-muted);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600;
  border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--bg-surface-2);
}
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr { cursor: pointer; transition: background .12s; }
table.data tbody tr:hover { background: var(--bg-surface-2); }
.cell-strong { font-weight: 600; }
.cell-muted { color: var(--text-muted); }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 11.5px; }

/* ===================== INBOX ===================== */
.inbox-layout { display: grid; grid-template-columns: 1fr; gap: 14px; }
.mention-card {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 16px; display: flex; gap: 13px; box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, transform .1s; position: relative;
}
.mention-card:hover { box-shadow: var(--shadow); }
.mention-card.crit-flag { border-left: 3px solid var(--crit); }
.mention-body { flex: 1; min-width: 0; }
.mention-head { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; flex-wrap: wrap; }
.mention-author { font-weight: 700; font-size: 13px; }
.mention-meta { font-size: 11px; color: var(--text-muted); }
.mention-text { font-size: 13px; line-height: 1.55; color: var(--text-primary); margin: 6px 0 10px; }
.mention-tags { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.mention-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.ai-conf { font-size: 10.5px; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.conf-bar { width: 46px; height: 5px; border-radius: 3px; background: var(--border); overflow: hidden; }
.conf-bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.vip-tag { background: linear-gradient(135deg,#f59e0b,#d97706); color:#fff; font-size:9.5px; font-weight:700; padding:2px 7px; border-radius:5px; }

/* ===================== AUTOMATION FLOWS ===================== */
.flow-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(310px,1fr)); gap: 16px; }
.flow-card {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column;
}
.flow-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 19px; color:#fff; margin-bottom: 13px; }
.flow-card h4 { font-size: 14.5px; font-weight: 700; margin-bottom: 5px; }
.flow-card p { font-size: 12px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 13px; flex: 1; }
.flow-stats { display: flex; gap: 16px; padding: 12px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: 13px; }
.flow-stat .num { font-size: 18px; font-weight: 800; }
.flow-stat .lbl { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.flow-foot { display: flex; align-items: center; justify-content: space-between; }

/* Toggle switch */
.switch { position: relative; width: 40px; height: 22px; }
.switch input { display: none; }
.switch-track { position: absolute; inset: 0; background: var(--border-strong); border-radius: 22px; transition: .2s; }
.switch-track::before { content:''; position:absolute; width: 16px; height: 16px; left: 3px; top: 3px; background:#fff; border-radius:50%; transition:.2s; box-shadow: var(--shadow-sm); }
.switch input:checked + .switch-track { background: var(--pos); }
.switch input:checked + .switch-track::before { transform: translateX(18px); }

/* ===================== INSIGHTS ===================== */
.insight-card {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 15px;
  display: flex; gap: 13px; margin-bottom: 12px; background: var(--bg-surface);
}
.insight-card.crit { border-left: 4px solid var(--crit); }
.insight-card.warn { border-left: 4px solid var(--high); }
.insight-card.info { border-left: 4px solid var(--low); }
.insight-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; flex-shrink: 0; }
.insight-card h4 { font-size: 13.5px; font-weight: 700; margin-bottom: 4px; }
.insight-card p { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
.insight-foot { margin-top: 9px; display: flex; gap: 10px; align-items: center; }

.risk-meter { display: flex; align-items: center; gap: 10px; }
.risk-ring { width: 54px; height: 54px; }

/* ===================== CHARTS ===================== */
.chart-box { position: relative; width: 100%; }

/* ===================== HEATMAP ===================== */
.heatmap { display: grid; gap: 3px; }
.heat-cell { aspect-ratio: 1; border-radius: 4px; display:grid; place-items:center; font-size: 9px; color: rgba(255,255,255,.85); }

/* ===================== DRAWER / MODAL ===================== */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(8,12,22,.5); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 80;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: 480px; max-width: 92vw;
  background: var(--bg-surface); box-shadow: var(--shadow-lg); z-index: 90;
  transform: translateX(100%); transition: transform .28s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-head { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; }

.detail-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.detail-row .k { color: var(--text-muted); }
.detail-row .v { font-weight: 600; text-align: right; }

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content:''; position:absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item::before { content:''; position:absolute; left:-20px; top: 3px; width: 11px; height: 11px; border-radius:50%; background: var(--accent); border: 2px solid var(--bg-surface); }
.tl-item .tl-title { font-size: 12.5px; font-weight: 600; }
.tl-item .tl-time { font-size: 10.5px; color: var(--text-muted); }
.tl-item .tl-desc { font-size: 11.5px; color: var(--text-secondary); margin-top: 2px; }

/* ===================== TOASTS ===================== */
.toast-stack { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--bg-elevated); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 10px; padding: 13px 15px; box-shadow: var(--shadow-lg); width: 330px;
  display: flex; gap: 11px; animation: slideIn .3s ease; align-items: flex-start;
}
.toast.crit { border-left-color: var(--crit); }
.toast.warn { border-left-color: var(--high); }
.toast.ok { border-left-color: var(--pos); }
.toast-icon { font-size: 16px; margin-top: 1px; }
.toast h5 { font-size: 12.5px; font-weight: 700; margin-bottom: 2px; }
.toast p { font-size: 11.5px; color: var(--text-secondary); line-height: 1.4; }
.toast .x { margin-left: auto; color: var(--text-muted); cursor: pointer; }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===================== FILTERS ===================== */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.select-wrap { position: relative; }
.fselect {
  appearance: none; padding: 8px 30px 8px 12px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--bg-input); color: var(--text-primary); font-size: 12.5px; font-weight: 500; cursor: pointer; outline: none;
}
.fselect:focus { border-color: var(--accent); }
.select-wrap i { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--text-muted); font-size: 11px; }

.seg { display: inline-flex; background: var(--bg-surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; }
.seg button { padding: 6px 13px; border-radius: 7px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.seg button.active { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-sm); }

/* progress strip */
.prog { height: 7px; border-radius: 5px; background: var(--border); overflow: hidden; }
.prog span { display:block; height:100%; border-radius:5px; }

.empty { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty i { font-size: 36px; margin-bottom: 12px; opacity: .4; }

.mt8{margin-top:8px}.mt12{margin-top:12px}.mt16{margin-top:16px}.mb12{margin-bottom:12px}
.flex{display:flex}.between{justify-content:space-between}.center{align-items:center}.gap8{gap:8px}.gap12{gap:12px}.wrap{flex-wrap:wrap}

@media(max-width: 920px){
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar-search { display: none; }
}
