/* ========================================================= */
/* Sanad-AI Design System                                     */
/* Overlay scrollbars · soft surfaces · ambient bg · halos    */
/* ========================================================= */

:root {
  color-scheme: light;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --line: rgba(148, 163, 184, 0.18);
  --line-strong: rgba(148, 163, 184, 0.28);
  --text: #0f172a;
  --text-mute: #64748b;
  --brand: #14b8a6;
  --brand-dark: #0d9488;
  --brand-soft: rgba(20, 184, 166, 0.12);
  --brand-halo: rgba(20, 184, 166, 0.28);
  --ok: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 1px 2px rgba(15, 23, 42, .04), 0 2px 6px rgba(15, 23, 42, .04);
  --shadow-lg: 0 4px 6px -2px rgba(15, 23, 42, .05), 0 12px 24px -8px rgba(15, 23, 42, .1);
  --shadow-xl: 0 12px 24px -12px rgba(15, 23, 42, .2), 0 24px 48px -24px rgba(15, 23, 42, .25);
}

html.dark {
  color-scheme: dark;
  --surface: #0f172a;
  --surface-2: #0b1220;
  --surface-3: #020617;
  --line: rgba(100, 116, 139, 0.18);
  --line-strong: rgba(100, 116, 139, 0.32);
  --text: #f1f5f9;
  --text-mute: #94a3b8;
  --brand-soft: rgba(20, 184, 166, 0.16);
  --brand-halo: rgba(20, 184, 166, 0.32);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .2);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, .15), 0 4px 8px rgba(0, 0, 0, .2);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, .2), 0 16px 32px -8px rgba(0, 0, 0, .35);
  --shadow-xl: 0 16px 32px -12px rgba(0, 0, 0, .4), 0 32px 56px -20px rgba(0, 0, 0, .5);
}

/* Ambient page background — subtle, living */
body {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(20, 184, 166, .05) 0%, transparent 55%),
    radial-gradient(1000px 600px at 110% 100%, rgba(99, 102, 241, .04) 0%, transparent 55%),
    var(--surface-2);
  color: var(--text);
  font-feature-settings: 'cv11','ss01','ss03','calt';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
html.dark body {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(20, 184, 166, .08) 0%, transparent 55%),
    radial-gradient(1000px 600px at 110% 100%, rgba(99, 102, 241, .05) 0%, transparent 55%),
    var(--surface-2);
}

/* ─── Overlay scrollbars (macOS-style, thin, hover-reveal) ─── */
.scroll,
.scroll-y,
.scroll-x { scrollbar-width: thin; scrollbar-color: transparent transparent; transition: scrollbar-color .2s; }
.scroll:hover,
.scroll-y:hover,
.scroll-x:hover { scrollbar-color: rgba(148, 163, 184, .45) transparent; }
.scroll::-webkit-scrollbar,
.scroll-y::-webkit-scrollbar,
.scroll-x::-webkit-scrollbar { width: 10px; height: 10px; }
.scroll::-webkit-scrollbar-track,
.scroll-y::-webkit-scrollbar-track,
.scroll-x::-webkit-scrollbar-track { background: transparent; }
.scroll::-webkit-scrollbar-thumb,
.scroll-y::-webkit-scrollbar-thumb,
.scroll-x::-webkit-scrollbar-thumb {
  background-color: transparent;
  background-clip: content-box;
  border: 2px solid transparent;
  border-radius: 999px;
  min-height: 40px;
  transition: background-color .2s;
}
.scroll:hover::-webkit-scrollbar-thumb,
.scroll-y:hover::-webkit-scrollbar-thumb,
.scroll-x:hover::-webkit-scrollbar-thumb { background-color: rgba(148, 163, 184, .45); }
.scroll::-webkit-scrollbar-thumb:hover,
.scroll-y::-webkit-scrollbar-thumb:hover,
.scroll-x::-webkit-scrollbar-thumb:hover { background-color: rgba(100, 116, 139, .7); }
html.dark .scroll:hover::-webkit-scrollbar-thumb,
html.dark .scroll-y:hover::-webkit-scrollbar-thumb,
html.dark .scroll-x:hover::-webkit-scrollbar-thumb { background-color: rgba(148, 163, 184, .35); }

/* Smooth scroll */
html, .scroll, .scroll-y { scroll-behavior: smooth; }

/* ─── Surface system (replaces hard boxes) ─── */
.surface {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.surface-raised {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
}
.surface-pop {
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
}
.surface-hover {
  transition: box-shadow .2s ease-out, transform .15s ease-out;
}
.surface-hover:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

/* Soft divider — use instead of borders between sections */
.divider-soft { height: 1px; background: var(--line); margin: 0; border: 0; }
.divide-soft > * + * { border-top: 1px solid var(--line); }

/* ─── Inputs — soft fill instead of hard border ─── */
.input {
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--surface-3);
  border: 1px solid transparent;
  color: var(--text);
  font-size: 13px;
  transition: all .15s ease-out;
  width: 100%;
}
.input:focus {
  background: var(--surface);
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-halo);
  outline: none;
}
.input::placeholder { color: var(--text-mute); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: 10px;
  font-weight: 600; font-size: 12.5px; border: 1px solid transparent;
  transition: all .15s ease-out; cursor: pointer; white-space: nowrap;
  user-select: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  box-shadow: 0 1px 2px rgba(20, 184, 166, .3), 0 4px 12px -4px rgba(20, 184, 166, .35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px -2px rgba(20, 184, 166, .45); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
  background: var(--surface-3);
  color: var(--text);
}
.btn-secondary:hover { background: var(--surface); box-shadow: var(--shadow-sm); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--surface-3); }

/* Icon-only button */
.icon-btn {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; background: transparent; color: var(--text-mute); transition: all .15s;
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* ─── Chips ─── */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.01em;
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--line);
  transition: all .15s;
}
.chip-sm { padding: 1px 7px; font-size: 10px; }
.chip-solid { border: 0; }

/* Semantic chip colors (soft backgrounds) */
.chip-ok { background: rgba(16, 185, 129, .12); color: rgb(5, 120, 87); border-color: rgba(16, 185, 129, .2); }
.chip-warn { background: rgba(245, 158, 11, .13); color: rgb(146, 64, 14); border-color: rgba(245, 158, 11, .22); }
.chip-bad { background: rgba(239, 68, 68, .12); color: rgb(153, 27, 27); border-color: rgba(239, 68, 68, .22); }
.chip-brand { background: var(--brand-soft); color: var(--brand-dark); border-color: rgba(20, 184, 166, .2); }
.chip-indigo { background: rgba(99, 102, 241, .12); color: rgb(67, 56, 202); border-color: rgba(99, 102, 241, .2); }
.chip-rose { background: rgba(244, 63, 94, .12); color: rgb(159, 18, 57); border-color: rgba(244, 63, 94, .2); }
.chip-cyan { background: rgba(6, 182, 212, .12); color: rgb(14, 116, 144); border-color: rgba(6, 182, 212, .2); }
.chip-amber { background: rgba(245, 158, 11, .13); color: rgb(146, 64, 14); border-color: rgba(245, 158, 11, .22); }
.chip-violet { background: rgba(139, 92, 246, .12); color: rgb(91, 33, 182); border-color: rgba(139, 92, 246, .2); }

html.dark .chip-ok { color: rgb(110, 231, 183); background: rgba(16, 185, 129, .15); }
html.dark .chip-warn { color: rgb(252, 211, 77); background: rgba(245, 158, 11, .15); }
html.dark .chip-bad { color: rgb(252, 165, 165); background: rgba(239, 68, 68, .15); }
html.dark .chip-brand { color: rgb(94, 234, 212); }
html.dark .chip-indigo { color: rgb(165, 180, 252); }
html.dark .chip-rose { color: rgb(253, 164, 175); }
html.dark .chip-cyan { color: rgb(103, 232, 249); }
html.dark .chip-amber { color: rgb(252, 211, 77); }
html.dark .chip-violet { color: rgb(196, 181, 253); }

/* ─── KBD ─── */
.kbd {
  font-family: inherit;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 5px;
  font-size: 10.5px;
  background: var(--surface);
  color: var(--text-mute);
  font-weight: 500;
  display: inline-block;
  min-width: 18px;
  text-align: center;
  letter-spacing: 0;
}

/* ─── Progress bar (for SLA) ─── */
.bar { height: 3px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; transition: width .5s ease-out; background: linear-gradient(90deg, var(--brand), var(--brand-dark)); }
.bar-fill.warn { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.bar-fill.bad  { background: linear-gradient(90deg, #f87171, #ef4444); }

/* ─── Avatar ─── */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
  color: white;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  position: relative;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .12);
}
.avatar.with-presence::after {
  content: '';
  position: absolute;
  right: -1px; bottom: -1px;
  width: 30%; height: 30%;
  background: var(--ok);
  border-radius: 999px;
  border: 2px solid var(--surface);
}
.avatar-sm { width: 28px; height: 28px; font-size: 10px; }
.avatar-md { width: 36px; height: 36px; font-size: 12px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }

/* ─── Focus halo (applied by Tailwind .focus:ring-brand via focus-visible) ─── */
:where(button, a, input, select, textarea):focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--brand-halo);
  border-radius: 10px;
  transition: box-shadow .15s;
}

/* ─── Skeletons ─── */
.skeleton {
  background: linear-gradient(90deg,
    rgba(148, 163, 184, .08) 0%,
    rgba(148, 163, 184, .18) 50%,
    rgba(148, 163, 184, .08) 100%);
  background-size: 200% 100%;
  animation: skel 1.4s ease-in-out infinite;
  border-radius: 8px;
}
@keyframes skel { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ─── Animations ─── */
.fade-in { animation: fade-in .2s ease-out both; }
.scale-in { animation: scale-in .12s ease-out both; }
.slide-up { animation: slide-up .22s ease-out both; }
.slide-right { animation: slide-right .22s ease-out both; }
@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }
@keyframes scale-in { from { opacity: 0; transform: scale(.96) } to { opacity: 1; transform: scale(1) } }
@keyframes slide-up { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }
@keyframes slide-right { from { opacity: 0; transform: translateX(-8px) } to { opacity: 1; transform: none } }

.pulse-dot { animation: pulse-dot 2.2s ease-in-out infinite; }
@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--brand-halo) }
  50% { opacity: .75; box-shadow: 0 0 0 6px transparent }
}

/* ─── Shadow inset at scroll edges (hint of more content) ─── */
.scroll-fade-y {
  mask-image: linear-gradient(to bottom, transparent 0, black 16px, black calc(100% - 16px), transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, black 16px, black calc(100% - 16px), transparent 100%);
}

/* ─── Ambient outline on selected items ─── */
.selected-soft {
  background: var(--brand-soft);
  border-radius: 12px;
  box-shadow: inset 3px 0 0 var(--brand);
}

/* ─── Tooltip (simple) ─── */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  padding: 4px 8px; border-radius: 6px;
  background: var(--text); color: var(--surface);
  font-size: 10.5px; font-weight: 500; white-space: nowrap;
  pointer-events: none; z-index: 100;
  box-shadow: var(--shadow-md);
  opacity: 0; animation: fade-in .15s ease-out .3s forwards;
}

/* ─── Chat bubbles ─── */
.bubble {
  max-width: 86%; padding: 8px 13px; border-radius: 16px;
  font-size: 13.5px; line-height: 1.5;
  white-space: pre-wrap; word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  transition: opacity .2s;
}
.bubble-in { background: var(--surface); align-self: flex-start; border-bottom-left-radius: 5px; }
.bubble-out { background: #dcf8c6; align-self: flex-end; border-bottom-right-radius: 5px; color: #0f172a; }
html.dark .bubble-out { background: rgba(6, 78, 59, .65); color: rgb(220, 252, 231); }
.bubble-bot { background: rgba(236, 254, 255, .9); align-self: flex-start; border-bottom-left-radius: 5px; border: 1px solid rgba(165, 243, 252, .6); }
html.dark .bubble-bot { background: rgba(8, 47, 73, .5); border-color: rgba(34, 211, 238, .25); color: rgb(207, 250, 254); }
.bubble-officer { background: rgba(224, 231, 255, .9); align-self: flex-end; border-bottom-right-radius: 5px; border: 1px solid rgba(199, 210, 254, .6); }
html.dark .bubble-officer { background: rgba(30, 27, 75, .6); border-color: rgba(129, 140, 248, .3); color: rgb(224, 231, 255); }
.bubble-sys { align-self: center; background: rgba(254, 243, 199, .95); border: 1px dashed rgba(251, 191, 36, .6); color: rgb(120, 53, 15); font-size: 11px; padding: 3px 12px; border-radius: 999px; }
html.dark .bubble-sys { background: rgba(120, 53, 15, .3); color: rgb(252, 211, 77); border-color: rgba(245, 158, 11, .4); }

[dir="rtl"] .bubble-in, [dir="rtl"] .bubble-bot { align-self: flex-start; }
[dir="rtl"] .bubble-out, [dir="rtl"] .bubble-officer { align-self: flex-end; }

/* Chat backdrop (whatsapp-ish but softer) */
.chat-bg {
  background:
    radial-gradient(circle at 30% 20%, rgba(20, 184, 166, .03) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(99, 102, 241, .03) 0%, transparent 50%),
    var(--surface-2);
}

/* ─── Empty state illustrations ─── */
.empty {
  display: flex; flex-direction: column; align-items: center;
  padding: 48px 24px; color: var(--text-mute); text-align: center;
}
.empty-icon {
  width: 64px; height: 64px; border-radius: 18px;
  background: linear-gradient(135deg, var(--surface-3), var(--surface-2));
  display: grid; place-items: center;
  font-size: 28px; margin-bottom: 12px;
  box-shadow: inset 0 0 0 1px var(--line);
}
.empty-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.empty-desc { font-size: 12px; color: var(--text-mute); max-width: 260px; }

/* ─── Overlay (modals / cmdk) ─── */
.overlay {
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(10px) saturate(150%);
  -webkit-backdrop-filter: blur(10px) saturate(150%);
}

/* ─── Transitions for tab bodies ─── */
[data-tab-panel][hidden] { display: none; }
[data-tab-panel] { animation: fade-in .18s ease-out both; }

/* ─── Gradient text accent ─── */
.wordmark {
  background: linear-gradient(135deg, var(--brand), #6366f1);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Remove underline from avatar links etc */
.no-underline, a.no-underline { text-decoration: none; }

/* Better details/summary (for collapsible sections) */
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary .chev { transform: rotate(90deg); }
.chev { transition: transform .15s; }
