/* ==============================================================================
   KRAFT AI STUDIO — ENTERPRISE THEME SYSTEM
   Supports: System Default | Light Mode | Dark Dark Mode (Midnight)
   ============================================================================== */

:root {
  --kraft-bg: #f8fafc;
  --kraft-card: #ffffff;
  --kraft-card-subtle: #f1f5f9;
  --kraft-border: #e2e8f0;
  --kraft-border-subtle: #cbd5e1;
  --kraft-text-primary: #0f172a;
  --kraft-text-secondary: #475569;
  --kraft-text-muted: #64748b;
  --kraft-input-bg: #f8fafc;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Dark Dark Mode (Deep Midnight Theme) */
html.dark {
  --kraft-bg: #06080e;
  --kraft-card: #0d121c;
  --kraft-card-subtle: #121824;
  --kraft-border: #1a2233;
  --kraft-border-subtle: #242f45;
  --kraft-text-primary: #f8fafc;
  --kraft-text-secondary: #cbd5e1;
  --kraft-text-muted: #94a3b8;
  --kraft-input-bg: #090d15;
  color-scheme: dark;
}

html.dark body {
  background-color: var(--kraft-bg) !important;
  color: var(--kraft-text-primary) !important;
}

/* Surfaces & Cards in Dark Mode */
html.dark .bg-white {
  background-color: var(--kraft-card) !important;
  border-color: var(--kraft-border) !important;
  color: var(--kraft-text-primary) !important;
}

html.dark .hero-glow-banner {
  background: linear-gradient(135deg, #0d121c 0%, #111827 50%, #151d2f 100%) !important;
  border-color: #1a2233 !important;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5) !important;
}

html.dark .bg-slate-50 {
  background-color: #090d16 !important;
  border-color: var(--kraft-border) !important;
}

html.dark .bg-slate-100 {
  background-color: var(--kraft-card-subtle) !important;
  border-color: var(--kraft-border) !important;
}

html.dark .bg-slate-200 {
  background-color: #1a2233 !important;
}

/* Header & Sidebar in Dark Mode */
html.dark header {
  background-color: rgba(9, 13, 22, 0.9) !important;
  border-color: var(--kraft-border) !important;
}

html.dark aside {
  background-color: #070a11 !important;
  border-color: var(--kraft-border) !important;
}

/* Borders in Dark Mode */
html.dark .border-slate-200,
html.dark .border-slate-200\/80,
html.dark .border-slate-200\/90,
html.dark .border-slate-100 {
  border-color: var(--kraft-border) !important;
}

html.dark .border-slate-300 {
  border-color: var(--kraft-border-subtle) !important;
}

/* Typography in Dark Mode */
html.dark .text-slate-900 {
  color: #f8fafc !important;
}

html.dark .text-slate-800 {
  color: #f1f5f9 !important;
}

html.dark .text-slate-700 {
  color: #e2e8f0 !important;
}

html.dark .text-slate-600 {
  color: #cbd5e1 !important;
}

html.dark .text-slate-500 {
  color: #94a3b8 !important;
}

html.dark .text-slate-400 {
  color: #64748b !important;
}

/* Form Inputs, Selects & Textareas */
html.dark input,
html.dark textarea,
html.dark select {
  background-color: var(--kraft-input-bg) !important;
  border-color: var(--kraft-border-subtle) !important;
  color: #f8fafc !important;
}

html.dark input::placeholder,
html.dark textarea::placeholder {
  color: #64748b !important;
}

/* Hover States & Active Nav in Dark Mode */
html.dark .hover\:bg-slate-100:hover {
  background-color: #141b2a !important;
}

html.dark .hover\:bg-slate-50:hover {
  background-color: #0e1422 !important;
}

html.dark .hover\:text-slate-800:hover,
html.dark .hover\:text-slate-900:hover {
  color: #ffffff !important;
}

html.dark .nav-tab-btn.active {
  background-color: rgba(124, 58, 237, 0.18) !important;
  color: #c084fc !important;
}

/* Brand Cards & Badges in Dark Mode */
html.dark .bg-purple-50 {
  background-color: rgba(147, 51, 234, 0.14) !important;
  border-color: rgba(147, 51, 234, 0.3) !important;
}

html.dark .bg-amber-50 {
  background-color: rgba(245, 158, 11, 0.14) !important;
  border-color: rgba(245, 158, 11, 0.3) !important;
}

html.dark .bg-emerald-50 {
  background-color: rgba(16, 185, 129, 0.14) !important;
  border-color: rgba(16, 185, 129, 0.3) !important;
}

html.dark .bg-rose-50 {
  background-color: rgba(244, 63, 94, 0.14) !important;
  border-color: rgba(244, 63, 94, 0.3) !important;
}

html.dark .bg-indigo-50 {
  background-color: rgba(99, 102, 241, 0.14) !important;
  border-color: rgba(99, 102, 241, 0.3) !important;
}

/* Dropdown Menus & Modals in Dark Mode */
html.dark #authModal > div,
html.dark #themeDropdown,
html.dark #userDropdownMenu {
  background-color: #0e1422 !important;
  border-color: var(--kraft-border-subtle) !important;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.7) !important;
}

/* Scrollbars */
html.dark ::-webkit-scrollbar-track {
  background: #07090e;
}
html.dark ::-webkit-scrollbar-thumb {
  background: #1e2638;
  border-radius: 8px;
}
html.dark ::-webkit-scrollbar-thumb:hover {
  background: #2a364e;
}

/* ==============================================================================
   INTERCOM-STYLE INTERACTIVE ONBOARDING POPOVER & SPOTLIGHT
   ============================================================================== */
#onboardingOverlay {
  position: fixed;
  inset: 0;
  z-index: 9990;
  background-color: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(2px);
  transition: opacity 0.25s ease;
}

#tourSpotlight {
  position: fixed;
  z-index: 9992;
  pointer-events: none;
  border-radius: 14px;
  box-shadow: 0 0 0 3px #6366f1, 0 0 25px rgba(99, 102, 241, 0.5);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  animation: tourSpotlightPulse 2s infinite ease-in-out;
}

@keyframes tourSpotlightPulse {
  0%, 100% {
    box-shadow: 0 0 0 3px #6366f1, 0 0 20px rgba(99, 102, 241, 0.4);
  }
  50% {
    box-shadow: 0 0 0 4px #818cf8, 0 0 30px rgba(129, 140, 248, 0.65);
  }
}

#tourPopover {
  position: fixed;
  z-index: 9995;
  width: 340px;
  max-width: calc(100vw - 32px);
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 16px;
  box-shadow: 0 20px 25px -5px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.04);
  padding: 18px 20px;
  transition: top 0.25s cubic-bezier(0.16, 1, 0.3, 1), left 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}

/* Pointer Arrow */
.tour-arrow {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  transform: rotate(45deg);
  z-index: 10;
}

.tour-arrow-left {
  left: -7px;
  top: 32px;
  border-right: none !important;
  border-top: none !important;
}

.tour-arrow-top {
  top: -7px;
  left: 36px;
  border-right: none !important;
  border-bottom: none !important;
}

.tour-arrow-right {
  right: -7px;
  top: 32px;
  border-left: none !important;
  border-bottom: none !important;
}

.tour-arrow-bottom {
  bottom: -7px;
  left: 36px;
  border-left: none !important;
  border-top: none !important;
}

/* Intercom Popover Text Protection (Pure White Card with Crisp Dark Text in all modes) */
#tourPopover,
#tourPopover * {
  color-scheme: light !important;
}

#tourPopover #tourPopoverTitle,
#tourPopover h4,
#tourPopover .text-slate-900,
html.dark #tourPopover #tourPopoverTitle,
html.dark #tourPopover h4,
html.dark #tourPopover .text-slate-900 {
  color: #0f172a !important;
}

#tourPopover #tourPopoverBody,
#tourPopover .text-slate-600,
#tourPopover .text-slate-700,
html.dark #tourPopover #tourPopoverBody,
html.dark #tourPopover .text-slate-600,
html.dark #tourPopover .text-slate-700 {
  color: #334155 !important;
}

#tourPopover #tourPopoverCounter,
#tourPopover .text-slate-400,
#tourPopover .text-slate-500,
html.dark #tourPopover #tourPopoverCounter,
html.dark #tourPopover .text-slate-400,
html.dark #tourPopover .text-slate-500 {
  color: #64748b !important;
}

#tourPopover .border-slate-100,
html.dark #tourPopover .border-slate-100 {
  border-color: #f1f5f9 !important;
}

#tourPopover button#btnTourNext,
html.dark #tourPopover button#btnTourNext {
  background-color: #0f172a !important;
  color: #ffffff !important;
}

#tourPopover button#btnTourNext:hover,
html.dark #tourPopover button#btnTourNext:hover {
  background-color: #1e293b !important;
}

#tourPopover button#btnTourNext span,
#tourPopover button#btnTourNext i,
html.dark #tourPopover button#btnTourNext span,
html.dark #tourPopover button#btnTourNext i {
  color: #ffffff !important;
}

#tourPopover button#btnTourPrev,
html.dark #tourPopover button#btnTourPrev {
  color: #64748b !important;
}

#tourPopover button#btnTourPrev:hover,
html.dark #tourPopover button#btnTourPrev:hover {
  color: #0f172a !important;
}

html.dark .hero-glow-banner .bg-white\/90 {
  background-color: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  color: #e2e8f0 !important;
}
