@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root {
  /* Surface & Background Colors */
  --bg-app: #fcfcfc;              /* Soft off-white for main background */
  --bg-sidebar: #0b0f19;          /* Dark slate blue for sidebar */
  --bg-surface: #ffffff;          /* Crisp white for cards/containers */
  --bg-surface-hover: #f4f4f5;    /* Neutral hover state */
  --bg-surface-active: rgba(249, 115, 22, 0.1);   /* Soft orange tint active state */
  
  --border-subtle: #e4e4e7;       /* Delicate 1px borders */
  --border-medium: #d4d4d8;       /* Medium border line */
  --border-active: #f97316;       /* Orange active border */
  
  --text-primary: #09090b;        /* Almost black for sharp legibility */
  --text-secondary: #52525b;      /* Muted slate for subtext/labels */
  --text-muted: #a1a1aa;          /* Disabled/placeholder text */
  
  /* Accent Brand Colors (Orange) */
  --accent-blue: #f97316;         /* Primary brand Orange mapped to existing accent blue */
  --accent-blue-hover: #ea580c;   /* Darker orange hover mapped to blue hover */
  --accent-purple: #f97316;       /* Secondary brand orange mapped to purple */
  --accent-purple-hover: #ea580c;
  --accent-glow: rgba(249, 115, 22, 0.1) !important; /* Orange shadow glow */
  
  /* Semantic Alert Colors */
  --status-success: #047857;
  --status-success-bg: #ecfdf5;
  --status-success-border: #a7f3d0;
  
  --status-warning: #b45309;
  --status-warning-bg: #fffbeb;
  --status-warning-border: #fde68a;
  
  --status-danger: #dc2626;
  --status-danger-bg: #fef2f2;
  --status-danger-border: #fecaca;

  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 16px;
  
  --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.04), 0 1px 2px -1px rgba(0, 0, 0, 0.02);
  --shadow-dropdown: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-primary);
  letter-spacing: -0.019em;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-app);
}
::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Glassmorphism & Cards */
.card, .glass-card {
  background-color: var(--bg-surface) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-card) !important;
  transition: border-color 0.15s ease, transform 0.15s ease;
  overflow: hidden;
}

.card:hover, .glass-card:hover {
  border-color: var(--border-medium) !important;
  transform: translateY(-1px);
}

/* Sidebar styling */
#sidebar {
  width: 260px;
  background-color: var(--bg-sidebar) !important;
  border-right: 1px solid var(--border-subtle) !important;
  z-index: 100;
}

.sidebar-logo {
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary) !important;
}

.nav-section-title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  padding: 0.75rem 0.75rem 0.25rem;
}

.sidebar .nav-link {
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary) !important;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.sidebar .nav-link i {
  font-size: 1rem;
}

.sidebar .nav-link:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary) !important;
}

.sidebar .nav-link.active {
  color: var(--accent-blue) !important;
  background-color: var(--bg-surface-active) !important;
  font-weight: 600;
  border-left: 3px solid var(--accent-blue);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Collapsible transition chevron icons */
.sidebar .collapsed .transition-icon {
  transform: rotate(0deg);
}
.sidebar .nav-link:not(.collapsed) .transition-icon {
  transform: rotate(180deg);
}
.sidebar .transition-icon {
  transition: transform 0.2s ease;
}
.sidebar .sub-link {
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem 0.35rem 1.65rem;
  font-weight: 500;
  opacity: 0.85;
  border-left: 2px solid transparent;
}
.sidebar .sub-link:hover, .sidebar .sub-link.active {
  opacity: 1;
}
.sidebar .sub-link.active {
  border-left-color: var(--accent-blue);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Sidebar profile & badges */
.sidebar-account-panel {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.03), rgba(234, 88, 12, 0.03));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

/* Topbar */
.topbar {
  background-color: rgba(252, 252, 252, 0.8) !important;
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle) !important;
  z-index: 99;
}

/* Search Bar */
.search-wrapper {
  position: relative;
  max-width: 320px;
  width: 100%;
}

.search-wrapper input {
  padding-left: 2.25rem;
  padding-right: 2.25rem;
  background-color: var(--bg-surface-hover) !important;
}

.search-wrapper i.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.search-wrapper kbd {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.65rem;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
}

/* KPI Cards */
.kpi-card {
  position: relative;
  overflow: hidden;
  padding: 1.5rem;
}

.kpi-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-blue-hover), transparent);
  opacity: 0.5;
}

.kpi-value {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 0.5rem 0;
}

.kpi-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.kpi-trend {
  font-size: 0.75rem;
  font-weight: 500;
}

/* Status Badges */
.badge-status-enabled, .badge-status-active, .badge-status-success {
  background-color: var(--status-success-bg) !important;
  color: var(--status-success) !important;
  border: 1px solid var(--status-success-border) !important;
}

.badge-status-paused, .badge-status-secondary {
  background-color: var(--bg-surface-hover) !important;
  color: var(--text-secondary) !important;
  border: 1px solid var(--border-subtle) !important;
}

.badge-status-warning {
  background-color: var(--status-warning-bg) !important;
  color: var(--status-warning) !important;
  border: 1px solid var(--status-warning-border) !important;
}

.badge-status-removed, .badge-status-danger {
  background-color: var(--status-danger-bg) !important;
  color: var(--status-danger) !important;
  border: 1px solid var(--status-danger-border) !important;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3em 0.6em;
  border-radius: var(--radius-sm);
}

/* Tables */
.table-custom {
  background: transparent;
  color: var(--text-primary);
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

.table-custom th {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  background-color: var(--bg-subtle, #f8f8f8);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.85rem 1rem;
}

.table-custom td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.875rem;
}

.table-custom tbody tr {
  transition: background-color 0.15s ease;
}

.table-custom tbody tr:hover {
  background-color: var(--bg-surface-hover) !important;
}

.table-container {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

/* Forms */
.form-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
}

.form-control, .form-select, .form-check-input {
  background-color: var(--bg-surface) !important;
  border: 1px solid var(--border-subtle) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-sm) !important;
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}

.form-control:focus, .form-select:focus {
  border-color: var(--border-active) !important;
  box-shadow: 0 0 0 3px var(--accent-glow) !important;
  outline: none;
}

.form-control::placeholder {
  color: var(--text-muted);
}

/* Custom switch toggle */
.form-check-input:checked {
  background-color: var(--accent-blue) !important;
  border-color: var(--accent-blue) !important;
}

/* Buttons */
.btn {
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-primary {
  background-color: var(--accent-blue) !important;
  border: 1px solid var(--accent-blue) !important;
  color: #fff !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-primary:hover {
  background-color: var(--accent-blue-hover) !important;
  border-color: var(--accent-blue-hover) !important;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.2) !important;
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-outline-secondary {
  background-color: var(--bg-surface) !important;
  border: 1px solid var(--border-subtle) !important;
  color: var(--text-primary) !important;
}

.btn-outline-secondary:hover {
  background-color: var(--bg-surface-hover) !important;
  border-color: var(--border-medium) !important;
}

/* Breadcrumbs */
.breadcrumb {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.breadcrumb-item a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease;
}

.breadcrumb-item a:hover {
  color: var(--text-primary);
}

.breadcrumb-item.active {
  color: var(--text-primary);
}

.breadcrumb-item + .breadcrumb-item::before {
  content: "›";
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 0.8;
}

/* Pulse animation for live connection indicator */
.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: #047857;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(4, 120, 87, 0.7);
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(4, 120, 87, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(4, 120, 87, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(4, 120, 87, 0);
  }
}

/* Campaign Creation Progress Indicator */
.steps-nav {
  display: flex;
  gap: 1rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 1rem;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.step-item.active {
  color: var(--accent-blue);
  font-weight: 600;
  background: var(--bg-surface-hover);
}

.step-item.completed {
  color: var(--status-success);
}

.step-number {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  border: 1px solid var(--border-subtle);
}

.step-item.active .step-number {
  border-color: var(--accent-blue);
  background: var(--accent-blue);
  color: #fff;
}

.step-item.completed .step-number {
  border-color: var(--status-success);
  background: var(--status-success);
  color: #fff;
}

/* Skeletons */
.skeleton {
  background: linear-gradient(90deg, var(--bg-surface-hover) 25%, var(--border-subtle) 50%, var(--bg-surface-hover) 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   COMPREHENSIVE LIGHT-MODE OVERRIDE SYSTEM
   Remaps all dark-mode Bootstrap classes to the light SaaS palette
   Scope: #main-area only — sidebar and modals are excluded
   ══════════════════════════════════════════════════════════════════════════ */

/* Text color overrides */
#main-area .text-white,
#main-area h1.text-white, #main-area h2.text-white,
#main-area h3.text-white, #main-area h4.text-white,
#main-area h5.text-white, #main-area h6.text-white,
#main-area .fw-bold.text-white, #main-area .fw-semibold.text-white {
  color: var(--text-primary) !important;
}
#main-area .text-light {
  color: var(--text-secondary) !important;
}
#main-area code.text-white {
  color: #f97316 !important;
}

/* Preserve white text inside buttons and badges */
#main-area .btn .text-white,
#main-area .badge.text-white,
#main-area .btn-primary, #main-area .btn-primary *,
#main-area .btn-danger, #main-area .btn-danger *,
#main-area .btn-success, #main-area .btn-success *,
#main-area .btn-warning, #main-area .btn-warning * {
  color: #fff !important;
}

/* Background overrides — bg-dark cards become clean white surfaces */
#main-area .bg-dark,
#main-area .bg-dark.bg-opacity-60,
#main-area .bg-dark.bg-opacity-40,
#main-area .bg-dark.bg-opacity-80,
#main-area .bg-black {
  background-color: var(--bg-surface) !important;
  color: var(--text-primary) !important;
}

/* Keep dark bg inside code blocks (executive report terminal style) */
#main-area pre.bg-dark, #main-area pre.bg-black {
  background-color: #1e1e1e !important;
  color: #e4e4e7 !important;
}

/* Border overrides */
#main-area .border-secondary {
  border-color: var(--border-subtle) !important;
}
#main-area .border-secondary.border-opacity-10,
#main-area .border-secondary.border-opacity-20,
#main-area .border-secondary.border-opacity-30 {
  border-color: var(--border-subtle) !important;
}

/* Form controls inside main-area */
#main-area .form-control.bg-dark,
#main-area .form-select.bg-dark,
#main-area .form-control.text-white,
#main-area .form-select.text-white {
  background-color: var(--bg-surface) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-subtle) !important;
}
#main-area .input-group-text.bg-dark {
  background-color: var(--bg-surface-hover) !important;
  border-color: var(--border-subtle) !important;
  color: var(--text-secondary) !important;
}

/* Dropdown menus */
#main-area .dropdown-menu.bg-dark {
  background-color: var(--bg-surface) !important;
  border: 1px solid var(--border-subtle) !important;
  box-shadow: var(--shadow-dropdown) !important;
}
#main-area .dropdown-menu.bg-dark .dropdown-item {
  color: var(--text-primary) !important;
}
#main-area .dropdown-menu.bg-dark .dropdown-item:hover {
  background-color: var(--bg-surface-hover) !important;
}
#main-area .dropdown-menu.bg-dark .dropdown-divider {
  border-color: var(--border-subtle) !important;
}

/* card-header that uses text-white */
#main-area .card-header.text-white,
#main-area .card-header .text-white {
  color: var(--text-primary) !important;
}

/* Rounded-xl cards with bg-dark */
#main-area .rounded-xl.bg-dark {
  background-color: var(--bg-surface) !important;
  border: 1px solid var(--border-subtle) !important;
}

/* Heading color fixes */
#main-area h1, #main-area h2, #main-area h3,
#main-area h4, #main-area h5, #main-area h6 {
  color: var(--text-primary);
}

/* Table override */
#main-area .table-custom td,
#main-area .table-custom th {
  color: var(--text-primary);
}
#main-area .font-monospace.text-white {
  color: var(--text-primary) !important;
  font-weight: 600;
}

.border-primary {
  border-color: var(--accent-blue) !important;
}
.text-primary {
  color: var(--accent-blue) !important;
}
.bg-primary {
  background-color: var(--accent-blue) !important;
}
.bg-primary.bg-opacity-10 {
  background-color: var(--bg-surface-active) !important;
}

/* Login Page Specific Premium Styling */
.login-card {
  background: rgba(255, 255, 255, 0.75) !important;
  backdrop-filter: blur(20px) !important;
  border: 1px solid rgba(249, 115, 22, 0.15) !important;
  box-shadow: 0 25px 60px -15px rgba(249, 115, 22, 0.08), 0 0 80px -20px rgba(249, 115, 22, 0.04) !important;
}
.btn-login {
  color: #ffffff !important;
}
.btn-login:hover {
  transform: translateY(-1.5px);
  box-shadow: 0 8px 22px rgba(249, 115, 22, 0.3) !important;
}

/* Sidebar Active State Specificity Override (Matches FigureOut Reference Dashboard) */
#sidebar .nav-pills .nav-link.active,
.sidebar .nav-link.active {
  color: #ffffff !important;
  background-color: #f97316 !important; /* Solid Orange Active Tab */
  font-weight: 600 !important;
  border-left: none !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.25) !important;
}
#sidebar .nav-pills .nav-link.active i {
  color: #ffffff !important;
}

/* Sidebar Text and Link Colors (Dark Sidebar Aesthetic) */
.sidebar .nav-link {
  color: #94a3b8 !important; /* Muted slate color */
}
.sidebar .nav-link:hover {
  background-color: rgba(255, 255, 255, 0.05) !important;
  color: #ffffff !important;
}
.nav-section-title {
  color: #64748b !important;
}

/* ── Bootstrap bg-dark & border-secondary overrides for SaaS Light Theme ── */
.bg-dark:not(#sidebar *):not(.offcanvas *) {
  background-color: var(--bg-surface) !important;
}
.bg-dark.bg-opacity-60:not(#sidebar *):not(.offcanvas *),
.bg-dark.bg-opacity-40:not(#sidebar *):not(.offcanvas *),
.bg-dark.bg-opacity-80:not(#sidebar *):not(.offcanvas *) {
  background-color: var(--bg-surface) !important;
}
.border-secondary {
  border-color: var(--border-subtle) !important;
}
.border-secondary.border-opacity-10,
.border-secondary.border-opacity-20,
.border-secondary.border-opacity-30 {
  border-color: var(--border-subtle) !important;
}
.dropdown-menu.bg-dark {
  background-color: var(--bg-surface) !important;
  border: 1px solid var(--border-subtle) !important;
  box-shadow: var(--shadow-dropdown) !important;
}
.dropdown-menu.bg-dark .dropdown-item {
  color: var(--text-primary) !important;
}
.dropdown-menu.bg-dark .dropdown-item:hover {
  background-color: var(--bg-surface-hover) !important;
  color: var(--text-primary) !important;
}
.dropdown-menu.bg-dark .dropdown-divider {
  border-color: var(--border-subtle) !important;
}
.input-group-text.bg-dark {
  background-color: var(--bg-surface-hover) !important;
  border: 1px solid var(--border-subtle) !important;
  color: var(--text-secondary) !important;
}
.btn-outline-secondary {
  color: var(--text-primary) !important;
  border-color: var(--border-subtle) !important;
}
.btn-outline-secondary:hover {
  background-color: var(--bg-surface-hover) !important;
  color: var(--text-primary) !important;
}

/* Login Page Specific Wrapper Background */
.login-page-wrapper {
  background-color: #f8fafc !important;
  background-image: 
    radial-gradient(at 0% 0%, rgba(249, 115, 22, 0.05) 0px, transparent 50%), 
    radial-gradient(at 100% 0%, rgba(245, 158, 11, 0.04) 0px, transparent 50%), 
    radial-gradient(at 50% 100%, rgba(249, 115, 22, 0.03) 0px, transparent 50%) !important;
  background-size: 100% 100%;
}

/* Rounded Helper Classes */
.rounded-lg {
  border-radius: 0.75rem !important;
}
.rounded-xl {
  border-radius: 1rem !important;
}
.rounded-2xl {
  border-radius: 1.25rem !important;
}

/* ── Fractional Spacing Utilities (Tailwind-compatible, fills Bootstrap gaps) */
.gap-0\.5  { gap: 0.125rem !important; }
.gap-1\.5  { gap: 0.375rem !important; }
.gap-2\.5  { gap: 0.625rem !important; }
.gap-3\.5  { gap: 0.875rem !important; }

.p-0\.5    { padding: 0.125rem !important; }
.p-1\.5    { padding: 0.375rem !important; }
.p-2\.5    { padding: 0.625rem !important; }
.p-3\.5    { padding: 0.875rem !important; }

.px-0\.5   { padding-left: 0.125rem !important; padding-right: 0.125rem !important; }
.px-1\.5   { padding-left: 0.375rem !important; padding-right: 0.375rem !important; }
.px-2\.5   { padding-left: 0.625rem !important; padding-right: 0.625rem !important; }
.px-3\.5   { padding-left: 0.875rem !important; padding-right: 0.875rem !important; }

.py-0\.5   { padding-top: 0.125rem !important; padding-bottom: 0.125rem !important; }
.py-1\.5   { padding-top: 0.375rem !important; padding-bottom: 0.375rem !important; }
.py-2\.5   { padding-top: 0.625rem !important; padding-bottom: 0.625rem !important; }
.py-3\.5   { padding-top: 0.875rem !important; padding-bottom: 0.875rem !important; }

.pt-2\.5   { padding-top: 0.625rem !important; }
.pb-2\.5   { padding-bottom: 0.625rem !important; }

.mb-0\.5   { margin-bottom: 0.125rem !important; }
.mb-1\.5   { margin-bottom: 0.375rem !important; }
.mb-2\.5   { margin-bottom: 0.625rem !important; }
.mb-3\.5   { margin-bottom: 0.875rem !important; }
.mb-4\.5   { margin-bottom: 1.125rem !important; }

.mt-0\.5   { margin-top: 0.125rem !important; }
.mt-1\.5   { margin-top: 0.375rem !important; }
.mt-2\.5   { margin-top: 0.625rem !important; }

/* Pill shape utility */
.rounded-full { border-radius: 9999px !important; }
