/* ===========================================
   AdIntel Pro — Premium Design System
   =========================================== */

* { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

html, body { height: 100%; }

body {
  background:
    radial-gradient(ellipse 80% 60% at 20% 0%, rgba(63,93,255,0.12), transparent 60%),
    radial-gradient(ellipse 70% 50% at 100% 30%, rgba(139,92,246,0.10), transparent 60%),
    radial-gradient(ellipse 60% 50% at 50% 100%, rgba(34,197,94,0.06), transparent 60%),
    #0f1220;
  background-attachment: fixed;
}

/* ========== Scrollbars ========== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(139, 149, 179, 0.25);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(139, 149, 179, 0.45); background-clip: padding-box; }

/* ========== Glass cards ========== */
.glass {
  background: rgba(28, 32, 51, 0.55);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 10px 30px -12px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.04);
}

.glass-strong {
  background: rgba(22, 26, 43, 0.8);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.glass-hover { transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1); }
.glass-hover:hover {
  background: rgba(34, 40, 62, 0.65);
  border-color: rgba(139, 149, 255, 0.25);
  transform: translateY(-2px);
  box-shadow: 0 20px 40px -18px rgba(63, 93, 255, 0.35);
}

/* ========== Gradient text ========== */
.text-gradient {
  background: linear-gradient(135deg, #93b0ff 0%, #c4b5fd 50%, #f0abfc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text-gradient-brand {
  background: linear-gradient(135deg, #3f5dff 0%, #8b5cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ========== Glowing buttons ========== */
.btn-primary {
  background: linear-gradient(135deg, #3f5dff 0%, #6366f1 50%, #8b5cf6 100%);
  background-size: 200% 200%;
  color: white;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: 10px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 14px 0 rgba(63, 93, 255, 0.3);
  border: 1px solid rgba(255,255,255,0.1);
  position: relative;
  overflow: hidden;
}
.btn-primary:hover {
  background-position: 100% 100%;
  box-shadow: 0 8px 24px 0 rgba(63, 93, 255, 0.5);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: rgba(255,255,255,0.05);
  color: #d9dde8;
  font-weight: 500;
  padding: 0.6rem 1.15rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  transition: all 0.2s ease;
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); }

.btn-ghost {
  color: #b6bdd0;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  transition: all 0.2s;
}
.btn-ghost:hover { background: rgba(255,255,255,0.06); color: #eef0f5; }

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  font-weight: 600;
  padding: 0.6rem 1.15rem;
  border-radius: 10px;
  transition: all 0.2s ease;
}
.btn-danger:hover { box-shadow: 0 8px 20px -4px rgba(239, 68, 68, 0.4); }

/* ========== Inputs ========== */
.input {
  width: 100%;
  background: rgba(15, 18, 32, 0.6);
  border: 1px solid rgba(255,255,255,0.08);
  color: #eef0f5;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.input:focus {
  outline: none;
  border-color: #6485ff;
  background: rgba(15, 18, 32, 0.9);
  box-shadow: 0 0 0 3px rgba(63, 93, 255, 0.15);
}
.input::placeholder { color: #6a7597; }

.label { font-size: 0.8rem; font-weight: 500; color: #b6bdd0; margin-bottom: 0.35rem; display: block; }
.label-required::after { content: ' *'; color: #ef4444; }

/* ========== Sidebar ========== */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  color: #8b95b3;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.2s;
  position: relative;
  cursor: pointer;
}
.sidebar-link:hover { background: rgba(255,255,255,0.04); color: #eef0f5; }
.sidebar-link.active {
  background: linear-gradient(135deg, rgba(63,93,255,0.18), rgba(139,92,246,0.12));
  color: #ffffff;
  border: 1px solid rgba(99, 102, 241, 0.25);
}
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: -1px; top: 20%; bottom: 20%;
  width: 3px; border-radius: 2px;
  background: linear-gradient(180deg, #6485ff, #8b5cf6);
}
.sidebar-link i { width: 18px; text-align: center; }

/* ========== Badges ========== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.badge-success { background: rgba(34, 197, 94, 0.15); color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.3); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.badge-info { background: rgba(63, 93, 255, 0.15); color: #93b0ff; border: 1px solid rgba(63,93,255,0.3); }
.badge-purple { background: rgba(139, 92, 246, 0.15); color: #c4b5fd; border: 1px solid rgba(139,92,246,0.3); }
.badge-gray { background: rgba(139, 149, 179, 0.1); color: #b6bdd0; border: 1px solid rgba(139,149,179,0.2); }

/* ========== KPI cards ========== */
.kpi-card {
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: -50%; right: -20%;
  width: 200px; height: 200px;
  background: radial-gradient(circle, var(--kpi-glow, rgba(63,93,255,0.15)), transparent 70%);
  pointer-events: none;
}

/* ========== Tables ========== */
.table-premium { width: 100%; border-collapse: separate; border-spacing: 0; }
.table-premium th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8b95b3;
  padding: 0.75rem 1rem;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.table-premium td {
  padding: 0.85rem 1rem;
  font-size: 0.88rem;
  color: #d9dde8;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.table-premium tr:hover td { background: rgba(255,255,255,0.02); }
.table-premium tr:last-child td { border-bottom: none; }

/* ========== Loading spinner ========== */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: #6485ff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.spinner-lg { width: 36px; height: 36px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== Pulsing dot ========== */
.pulse-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #4ade80;
  position: relative;
}
.pulse-dot::after {
  content: '';
  position: absolute; inset: -3px;
  border-radius: 50%;
  background: #4ade80;
  opacity: 0.5;
  animation: pulse 1.5s ease-out infinite;
}
@keyframes pulse {
  0% { transform: scale(0.8); opacity: 0.7; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* ========== Toast ========== */
.toast {
  min-width: 280px;
  max-width: 400px;
  padding: 0.9rem 1.1rem;
  border-radius: 12px;
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.1);
  animation: slideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: start;
  gap: 0.7rem;
  box-shadow: 0 15px 40px -12px rgba(0,0,0,0.5);
}
.toast-success { background: rgba(34,197,94,0.15); border-color: rgba(34,197,94,0.4); color: #bbf7d0; }
.toast-error { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.4); color: #fecaca; }
.toast-info { background: rgba(63,93,255,0.15); border-color: rgba(63,93,255,0.4); color: #c7d2fe; }
@keyframes slideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOut { to { opacity: 0; transform: translateX(40px); } }
.toast.hiding { animation: slideOut 0.25s ease forwards; }

/* ========== Markdown content ========== */
.md-content { line-height: 1.7; color: #d9dde8; }
.md-content h1, .md-content h2, .md-content h3 { color: #eef0f5; font-weight: 700; margin: 1.2em 0 0.5em; }
.md-content h1 { font-size: 1.5rem; }
.md-content h2 { font-size: 1.25rem; border-bottom: 1px solid rgba(255,255,255,0.08); padding-bottom: 0.3em; }
.md-content h3 { font-size: 1.05rem; color: #c4b5fd; }
.md-content p { margin: 0.6em 0; }
.md-content ul, .md-content ol { margin: 0.6em 0; padding-left: 1.4em; }
.md-content li { margin: 0.3em 0; }
.md-content ul li::marker { color: #6485ff; }
.md-content strong { color: #eef0f5; font-weight: 700; }
.md-content code {
  background: rgba(0,0,0,0.35);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
  color: #f0abfc;
}
.md-content pre {
  background: rgba(0,0,0,0.4);
  padding: 1em;
  border-radius: 8px;
  overflow-x: auto;
  border: 1px solid rgba(255,255,255,0.06);
  margin: 0.8em 0;
}
.md-content pre code { background: transparent; padding: 0; color: #d9dde8; }
.md-content blockquote {
  border-left: 3px solid #6485ff;
  padding-left: 1em;
  color: #b6bdd0;
  margin: 0.8em 0;
}
.md-content table {
  border-collapse: collapse;
  margin: 0.8em 0;
  font-size: 0.88em;
}
.md-content th, .md-content td {
  border: 1px solid rgba(255,255,255,0.08);
  padding: 0.4em 0.8em;
}
.md-content th { background: rgba(255,255,255,0.03); font-weight: 600; }

/* ========== Animations ========== */
.fade-in { animation: fadeIn 0.35s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.stagger > * { animation: fadeIn 0.4s ease-out backwards; }
.stagger > *:nth-child(1) { animation-delay: 0.02s; }
.stagger > *:nth-child(2) { animation-delay: 0.06s; }
.stagger > *:nth-child(3) { animation-delay: 0.10s; }
.stagger > *:nth-child(4) { animation-delay: 0.14s; }
.stagger > *:nth-child(5) { animation-delay: 0.18s; }
.stagger > *:nth-child(6) { animation-delay: 0.22s; }
.stagger > *:nth-child(7) { animation-delay: 0.26s; }
.stagger > *:nth-child(8) { animation-delay: 0.30s; }

/* ========== Drop zone ========== */
.drop-zone {
  border: 2px dashed rgba(139, 149, 179, 0.3);
  border-radius: 14px;
  padding: 2.5rem;
  text-align: center;
  transition: all 0.25s;
  cursor: pointer;
  background: rgba(15, 18, 32, 0.3);
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: #6485ff;
  background: rgba(63, 93, 255, 0.08);
  transform: scale(1.01);
}

/* ========== Chat bubbles ========== */
.chat-bubble-user {
  background: linear-gradient(135deg, rgba(63,93,255,0.2), rgba(139,92,246,0.15));
  border: 1px solid rgba(99,102,241,0.3);
  padding: 0.85rem 1.1rem;
  border-radius: 16px 16px 4px 16px;
  max-width: 80%;
  margin-left: auto;
  color: #eef0f5;
}
.chat-bubble-ai {
  background: rgba(22, 26, 43, 0.7);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 0.85rem 1.1rem;
  border-radius: 16px 16px 16px 4px;
  max-width: 85%;
  color: #d9dde8;
}

/* ========== Typing dots ========== */
.typing-dots { display: inline-flex; gap: 4px; align-items: center; padding: 4px 0; }
.typing-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #8b95b3;
  animation: bounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; } 40% { transform: scale(1); opacity: 1; } }

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .sidebar-mobile { position: fixed; left: -100%; top: 0; bottom: 0; z-index: 50; transition: left 0.3s; }
  .sidebar-mobile.open { left: 0; }
}

/* ========== Light Theme Overrides ==========
   Activated by html[data-theme="light"]
   Keeps the brand gradients but inverts the surfaces for a clean light mode
*/
html[data-theme="light"] body {
  background:
    radial-gradient(ellipse 80% 60% at 20% 0%, rgba(63,93,255,0.08), transparent 60%),
    radial-gradient(ellipse 70% 50% at 100% 30%, rgba(139,92,246,0.06), transparent 60%),
    #f7f8fb;
  color: #1f2333;
}

html[data-theme="light"] .bg-ink-950 { background: #f7f8fb !important; }
html[data-theme="light"] .bg-ink-900 { background: #eef0f5 !important; }

/* Text color inversions */
html[data-theme="light"] .text-white { color: #1f2333 !important; }
html[data-theme="light"] .text-ink-100 { color: #1f2333 !important; }
html[data-theme="light"] .text-ink-200 { color: #393f53 !important; }
html[data-theme="light"] .text-ink-300 { color: #525d7c !important; }
html[data-theme="light"] .text-ink-400 { color: #6a7597 !important; }
html[data-theme="light"] .text-ink-500 { color: #8b95b3 !important; }

/* Glass cards: white surface with subtle border */
html[data-theme="light"] .glass {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(15, 18, 32, 0.06);
  box-shadow: 0 4px 16px -6px rgba(15, 18, 32, 0.08), inset 0 1px 0 rgba(255,255,255,0.6);
}

html[data-theme="light"] .glass-strong {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(15, 18, 32, 0.08);
}

html[data-theme="light"] .glass-hover:hover {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(63, 93, 255, 0.25);
  box-shadow: 0 12px 28px -10px rgba(63, 93, 255, 0.18);
}

/* Inputs, borders, dividers */
html[data-theme="light"] .input {
  background: #ffffff;
  border: 1px solid rgba(15, 18, 32, 0.1);
  color: #1f2333;
}
html[data-theme="light"] .input:focus {
  background: #ffffff;
  border-color: #3f5dff;
}
html[data-theme="light"] .input::placeholder { color: #8b95b3; }

html[data-theme="light"] .border-white\/5 { border-color: rgba(15, 18, 32, 0.06) !important; }
html[data-theme="light"] .border-white\/10 { border-color: rgba(15, 18, 32, 0.08) !important; }
html[data-theme="light"] .bg-white\/5 { background: rgba(15, 18, 32, 0.03) !important; }
html[data-theme="light"] .bg-white\/10 { background: rgba(15, 18, 32, 0.05) !important; }
html[data-theme="light"] .hover\:bg-white\/5:hover { background: rgba(15, 18, 32, 0.04) !important; }

/* Sidebar links */
html[data-theme="light"] .sidebar-link { color: #525d7c; }
html[data-theme="light"] .sidebar-link:hover { background: rgba(63, 93, 255, 0.08); color: #1f2333; }
html[data-theme="light"] .sidebar-link.active {
  background: linear-gradient(135deg, rgba(63, 93, 255, 0.1), rgba(139, 92, 246, 0.08));
  color: #3f5dff;
}

/* Tables */
html[data-theme="light"] .table-premium thead { background: rgba(15, 18, 32, 0.02); }
html[data-theme="light"] .table-premium th { color: #6a7597; border-color: rgba(15, 18, 32, 0.06); }
html[data-theme="light"] .table-premium tbody tr { border-color: rgba(15, 18, 32, 0.04); }
html[data-theme="light"] .table-premium tbody tr:hover { background: rgba(15, 18, 32, 0.02); }
html[data-theme="light"] .table-premium td { color: #1f2333; }

/* Badges keep their color but become more solid */
html[data-theme="light"] .badge-gray { background: rgba(15, 18, 32, 0.06); color: #525d7c; }

/* Buttons */
html[data-theme="light"] .btn-secondary {
  background: rgba(15, 18, 32, 0.05);
  color: #1f2333;
  border: 1px solid rgba(15, 18, 32, 0.08);
}
html[data-theme="light"] .btn-secondary:hover { background: rgba(15, 18, 32, 0.08); }

/* Scrollbar */
html[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(15, 18, 32, 0.2); background-clip: padding-box; }
html[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: rgba(15, 18, 32, 0.35); background-clip: padding-box; }

/* Theme toggle switch */
.theme-toggle {
  width: 40px; height: 22px; border-radius: 11px;
  background: rgba(255, 255, 255, 0.08);
  position: relative; cursor: pointer;
  transition: background 0.2s;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
html[data-theme="light"] .theme-toggle {
  background: rgba(63, 93, 255, 0.15);
  border-color: rgba(63, 93, 255, 0.2);
}
.theme-toggle::after {
  content: ''; position: absolute;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff;
  top: 2px; left: 2px;
  transition: transform 0.2s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
html[data-theme="light"] .theme-toggle::after {
  transform: translateX(18px);
  background: #3f5dff;
}

/* ============ Small button variant + sidebar-link ============ */
.btn-sm { padding: 4px 12px !important; font-size: 12px !important; }
.btn-ghost.btn-sm { padding: 4px 8px !important; }

/* ============ Sidebar navigation link ============ */
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 10px;
  font-size: 13px; font-weight: 500;
  color: #b6bdd0; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.sidebar-link:hover { background: rgba(255,255,255,0.04); color: #eef0f5; }
.sidebar-link.active {
  background: linear-gradient(135deg, rgba(63,93,255,0.18), rgba(139,92,246,0.12));
  color: white;
  box-shadow: 0 0 0 1px rgba(63,93,255,0.25);
}
.sidebar-link i { width: 16px; text-align: center; font-size: 13px; }

/* Light theme sidebar */
html[data-theme="light"] .sidebar-link { color: #525d7c; }
html[data-theme="light"] .sidebar-link:hover { background: rgba(15,18,32,0.04); color: #141a54; }
html[data-theme="light"] .sidebar-link.active { color: #141a54; background: rgba(63,93,255,0.1); }

/* ============ Platform brand colors ============ */
.platform-google { background: linear-gradient(135deg, #4285F4, #34A853); }
.platform-meta   { background: linear-gradient(135deg, #1877F2, #42B6F5); }
.platform-ga4    { background: linear-gradient(135deg, #E37400, #FF9800); }
