/* ============================================================
   ODOO × CHATWOOT × WHATSAPP — Unified Workspace
   Design language: "Odoo meets WhatsApp"
   - Brand spine: modernized Odoo plum / aubergine
   - Channel warmth: WhatsApp green + per-channel tints
   - AI: a dedicated cool indigo→violet "intelligence" gradient,
     never reused for brand chrome, so AI always reads as AI.
   ============================================================ */

:root {
  /* ---- Brand: modernized Odoo plum ---- */
  --brand-50:  #F7EEF5;
  --brand-100: #EEDCEA;
  --brand-200: #DCBBD5;
  --brand-300: #C492BB;
  --brand-400: #A86A9D;
  --brand-500: #884E80;  /* primary */
  --brand-600: #6F3F69;
  --brand-700: #573252;
  --brand-800: #3F273D;
  --brand-900: #2B1B2A;

  /* ---- WhatsApp / channel greens ---- */
  --wa-500: #25D366;
  --wa-600: #1FAE5A;
  --wa-700: #0E7C66;
  --wa-bubble: #E4FBD0;
  --wa-bubble-ink: #14361f;

  /* ---- AI intelligence accent (cool, distinct from brand) ---- */
  --ai-50:  #EEF1FF;
  --ai-100: #E0E5FF;
  --ai-300: #B5BEFF;
  --ai-500: #5B68FF;
  --ai-600: #4450E6;
  --ai-700: #333DBF;
  --ai-grad: linear-gradient(122deg, #6E83FF 0%, #9A66FF 55%, #C56BFF 100%);
  --ai-grad-soft: linear-gradient(122deg, #EEF1FF, #F4EDFF);

  /* ---- Channel hues ---- */
  --ch-whatsapp: #25D366;
  --ch-whatsapp-ink: #0E7C66;
  --ch-email: #2F6FED;
  --ch-email-ink: #1B4FBF;
  --ch-livechat: #14A8E0;
  --ch-livechat-ink: #0B7BAB;
  --ch-instagram: #E1306C;
  --ch-instagram-ink: #B11E55;
  --ch-sms: #F59E0B;
  --ch-sms-ink: #B97307;
  --ch-messenger: #0A7CFF;

  /* ---- Semantic neutrals (warm plum-tinted) ---- */
  --bg:          #F4F1F7;
  --surface:     #FFFFFF;
  --surface-2:   #FAF8FC;
  --surface-3:   #F2EEF6;
  --border:      #E8E3EE;
  --border-strong:#D7CFE0;
  --text:        #211A26;
  --text-muted:  #6B6175;
  --text-subtle: #968CA1;
  --inverse:     #FFFFFF;

  /* ---- Status ---- */
  --ok:    #1FAE5A;
  --ok-bg: #E4F8EC;
  --warn:  #E0890B;
  --warn-bg:#FCF0DC;
  --danger:#DC3B4B;
  --danger-bg:#FBE6E8;
  --info:  #2F6FED;

  /* ---- Shape & depth ---- */
  --r-xs: 7px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 26px;
  --r-pill: 999px;
  --sh-1: 0 1px 2px rgba(43,27,42,.06), 0 1px 1px rgba(43,27,42,.04);
  --sh-2: 0 2px 8px rgba(43,27,42,.07), 0 1px 2px rgba(43,27,42,.05);
  --sh-3: 0 10px 30px rgba(43,27,42,.12), 0 3px 8px rgba(43,27,42,.07);
  --sh-4: 0 24px 60px rgba(43,27,42,.20), 0 8px 18px rgba(43,27,42,.10);
  --ring: 0 0 0 3px var(--brand-100);

  /* ---- Density (overridden by [data-density]) ---- */
  --gap: 16px;
  --pad: 16px;
  --row-h: 64px;
  --control-h: 38px;
  --fs: 14px;

  /* ---- Type ---- */
  --font-ui: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "Geist Mono", "JetBrains Mono", ui-monospace, monospace;
}

/* Density variants */
[data-density="compact"] {
  --gap: 11px; --pad: 11px; --row-h: 52px; --control-h: 33px; --fs: 13px;
}
[data-density="comfy"] {
  --gap: 20px; --pad: 21px; --row-h: 74px; --control-h: 42px; --fs: 15px;
}

/* ---- Dark mode ---- */
[data-theme="dark"] {
  --bg:        #141017;
  --surface:   #1D1722;
  --surface-2: #241D2A;
  --surface-3: #2C2433;
  --border:    #322A39;
  --border-strong:#403649;
  --text:      #F2ECF6;
  --text-muted:#AEA3B8;
  --text-subtle:#7E7388;
  --brand-50:  #2A1E2C;
  --brand-100: #3A2A3C;
  --brand-500: #C68FBE;
  --brand-600: #B179A8;
  --wa-bubble: #0C3B2E;
  --wa-bubble-ink: #D6F5DD;
  --ai-50:  #1E2140;
  --ai-100: #262a52;
  --ai-grad-soft: linear-gradient(122deg, #21244a, #2a2350);
  --ok-bg: #15351f; --warn-bg:#3a2a10; --danger-bg:#3a1c20;
  --sh-1: 0 1px 2px rgba(0,0,0,.4);
  --sh-2: 0 2px 10px rgba(0,0,0,.45);
  --sh-3: 0 12px 34px rgba(0,0,0,.5);
  --sh-4: 0 26px 64px rgba(0,0,0,.6);
  --ring: 0 0 0 3px rgba(198,143,190,.25);
}

/* ============================================================ */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-ui);
  font-size: var(--fs);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.45;
}
#root { height: 100%; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
::selection { background: var(--brand-200); }

/* scrollbars */
.scroll { overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.scroll::-webkit-scrollbar { width: 9px; height: 9px; }
.scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
.scroll::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); background-clip: content-box; }
.scroll::-webkit-scrollbar-track { background: transparent; }

/* utility */
.mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; letter-spacing: -.01em; }
.tnum { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* focus */
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

/* ---- shared component classes ---- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 9px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
  background: var(--surface-3); color: var(--text-muted);
  border: 1px solid var(--border);
}
.chip svg { width: 13px; height: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: var(--control-h); padding: 0 15px; border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 600; border: 1px solid transparent;
  background: var(--surface-3); color: var(--text); transition: all .14s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--border); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--brand-500); color: #fff; box-shadow: var(--sh-1); }
.btn-primary:hover { background: var(--brand-600); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-outline { background: var(--surface); border-color: var(--border-strong); }
.btn-outline:hover { background: var(--surface-3); }
.btn-wa { background: var(--wa-500); color: #06351f; }
.btn-wa:hover { background: var(--wa-600); color:#fff; }
.btn-ai {
  background: var(--ai-grad); color: #fff; border: none;
  box-shadow: 0 2px 10px rgba(120,90,255,.35);
}
.btn-ai:hover { filter: brightness(1.06); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--control-h); height: var(--control-h); border-radius: var(--r-sm);
  background: transparent; border: 1px solid transparent; color: var(--text-muted);
  transition: all .14s ease;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--sh-1);
}

/* AI surfaces */
.ai-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  padding: 2px 8px 2px 6px; border-radius: var(--r-pill);
  background: var(--ai-50); color: var(--ai-600);
  border: 1px solid var(--ai-100);
}
[data-theme="dark"] .ai-tag { color: var(--ai-300); }
.ai-tag .spark { width: 12px; height: 12px; }
.ai-surface {
  border: 1px solid var(--ai-100);
  background: var(--ai-grad-soft);
  border-radius: var(--r-md);
  position: relative;
}
.ai-bar { /* gradient left rail for AI suggestion blocks */
  position: relative;
}
.ai-bar::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  border-radius: 99px; background: var(--ai-grad);
}

/* avatar */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; color: #fff; font-weight: 700; flex: none;
  background: var(--brand-400); font-size: 13px; overflow: hidden;
}

/* presence dot */
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* divider */
.hr { height: 1px; background: var(--border); border: 0; margin: 0; }

/* animations */
@keyframes fadeUp { from { transform: translateY(9px); } to { transform: none; } }
@keyframes fadeIn { from { transform: translateY(5px); } to { transform: none; } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
@keyframes typing { 0%,60%,100% { transform: translateY(0); opacity:.4;} 30% { transform: translateY(-4px); opacity:1;} }
@keyframes sheen { 0%{ transform: translateX(-120%);} 100%{ transform: translateX(220%);} }
.fade-up { animation: fadeUp .32s cubic-bezier(.2,.7,.3,1) both; }
.fade-in { animation: fadeIn .3s ease both; }

/* empty state */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty .empty-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--surface-3); color: var(--text-subtle); display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.empty h4 { margin: 0 0 4px; font-size: 15px; font-weight: 700; color: var(--text); }
.empty p { margin: 0 0 16px; font-size: 13px; max-width: 280px; line-height: 1.5; }

/* skeleton row */
.sk-row { height: 14px; border-radius: 7px; }

/* ---- Responsive: tablet / phone ---- */
@media (max-width: 980px) {
  .hide-narrow { display: none !important; }
  .stack-narrow { grid-template-columns: 1fr 1fr !important; }
}
@media (max-width: 720px) {
  :root { --row-h: 56px; --pad: 13px; --gap: 12px; }
  .hide-narrow { display: none !important; }
  .stack-narrow { grid-template-columns: 1fr !important; }
  /* slim the left nav to an icon rail */
  .navrail { width: 60px !important; }
  .navrail .nav-label { display: none !important; }
  .navrail .brandwordmark { display: none !important; }
  /* compress the top bar */
  .topbar-search { max-width: none !important; }
  .role-pill .role-label { display: none !important; }
  .hide-phone { display: none !important; }
  /* any 3/4-col grid collapses */
  .grid-resp { grid-template-columns: 1fr !important; }
}
@media (max-width: 480px) {
  .navrail { width: 52px !important; }
}

.ai-thinking span {
  display:inline-block; width:6px; height:6px; border-radius:50%;
  background: var(--ai-500); margin: 0 1.5px; animation: typing 1.1s infinite;
}
.ai-thinking span:nth-child(2){ animation-delay:.15s; }
.ai-thinking span:nth-child(3){ animation-delay:.3s; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--border) 37%, var(--surface-3) 63%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite;
}

/* glow ring for AI compose */
.ai-glow { position: relative; }
.ai-glow::after {
  content:""; position:absolute; inset:-1px; border-radius: inherit; padding:1px;
  background: var(--ai-grad); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; pointer-events:none; opacity:.9;
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
