/* ─────────────────────────────────────────────────────────────
 * AdBridge Design System — ported from visual-canvas styles.css
 * Fresh Blue aesthetic — bright, friendly, premium SaaS.
 * ───────────────────────────────────────────────────────────── */

:root {
  /* Surfaces */
  --background: #ffffff;
  --surface: #f7f9fc;
  --surface-muted: #f2f5fb;
  --foreground: #1e293b;
  --card: #ffffff;
  --card-foreground: #1e293b;

  /* Brand — the primary is BLUE, not indigo/purple */
  --primary: #4f7cff;
  --primary-foreground: #ffffff;
  --primary-strong: #3d63e8;
  --primary-soft: #eef2ff;
  --accent-grad-from: #4f7cff;
  --accent-grad-to: #6e5bff;

  /* Neutrals */
  --secondary: #f2f5fb;
  --secondary-foreground: #1e293b;
  --muted: #f2f5fb;
  --muted-foreground: #64748b;
  --subtle: #94a3b8;
  --accent: #f0f2f8;
  --accent-foreground: #1e293b;

  /* Status */
  --destructive: #dc2626;
  --destructive-foreground: #ffffff;
  --success: #16a34a;
  --success-foreground: #ffffff;
  --warning: #f59e0b;
  --warning-foreground: #1e293b;

  /* Lines */
  --border: #eaecf2;
  --border-strong: #dbe1ea;
  --input: #eaecf2;
  --ring: #4f7cff;

  /* Channels */
  --channel-google: #ea4335;
  --channel-meta: #4267b2;
  --channel-tiktok: #111827;

  /* Rainbow CTA (Magic UI–inspired) */
  --rainbow-1: hsl(0 100% 63%);
  --rainbow-2: hsl(270 100% 63%);
  --rainbow-3: hsl(210 100% 63%);
  --rainbow-4: hsl(195 100% 63%);
  --rainbow-5: hsl(90 100% 63%);

  /* Shared corner radius for buttons, cards, inputs, and sidebar */
  --control-radius: 0.625rem;
}

/* ── Base ────────────────────────────────────────────────── */

* {
  border-color: var(--border);
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
}

h1,
h2,
h3,
h4 {
  letter-spacing: -0.02em;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

summary::-webkit-details-marker {
  display: none;
}

/* ── Brand utilities ─────────────────────────────────────── */

.bg-brand-gradient {
  background-image: linear-gradient(135deg, var(--accent-grad-from), var(--accent-grad-to));
}

.text-brand-gradient {
  background-image: linear-gradient(135deg, var(--accent-grad-from), var(--accent-grad-to));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ── Shadows (identical to prototype) ────────────────────── */

.shadow-soft {
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.04), 0 1px 3px rgb(15 23 42 / 0.04);
}

.shadow-card {
  box-shadow: 0 4px 14px rgb(15 23 42 / 0.06);
}

.shadow-elevated {
  box-shadow: 0 10px 30px -10px rgb(15 23 42 / 0.12);
}

.shadow-glow {
  box-shadow: 0 8px 30px rgb(79 124 255 / 0.25);
}

/* ── Backgrounds ─────────────────────────────────────────── */

.bg-grid {
  background-image:
    linear-gradient(to right, rgb(234 236 242 / 0.6) 1px, transparent 1px),
    linear-gradient(to bottom, rgb(234 236 242 / 0.6) 1px, transparent 1px);
  background-size: 40px 40px;
}

.bg-radial-fade {
  background: radial-gradient(ellipse at top, rgb(79 124 255 / 0.14), transparent 60%);
}

/* ── Semantic color utilities (match prototype tokens) ───── */

.bg-background {
  background-color: var(--background);
}

.bg-surface {
  background-color: var(--surface);
}

.bg-surface-muted {
  background-color: var(--surface-muted);
}

.bg-card {
  background-color: var(--card);
}

.bg-primary {
  background-color: var(--primary);
}

.bg-primary-strong {
  background-color: var(--primary-strong);
}

.bg-primary-soft {
  background-color: var(--primary-soft);
}

.bg-muted {
  background-color: var(--muted);
}

.bg-accent {
  background-color: var(--accent);
}

.bg-destructive {
  background-color: var(--destructive);
}

.bg-success {
  background-color: var(--success);
}

.text-foreground {
  color: var(--foreground);
}

.text-card-foreground {
  color: var(--card-foreground);
}

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

.text-primary-strong {
  color: var(--primary-strong);
}

.text-primary-foreground {
  color: var(--primary-foreground);
}

.text-muted-foreground {
  color: var(--muted-foreground);
}

.text-subtle {
  color: var(--subtle);
}

.text-success {
  color: var(--success);
}

.text-warning {
  color: var(--warning);
}

.text-destructive {
  color: var(--destructive);
}

.border-border {
  border-color: var(--border);
}

.border-border-strong {
  border-color: var(--border-strong);
}

.border-input {
  border-color: var(--input);
}

.hover\:bg-surface:hover {
  background-color: var(--surface);
}

.hover\:bg-primary-strong:hover {
  background-color: var(--primary-strong);
}

.hover\:text-foreground:hover {
  color: var(--foreground);
}

/* ── Metric cards ────────────────────────────────────────── */

.metric-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--control-radius);
  background: var(--card);
  padding: 1.25rem;
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.04), 0 1px 3px rgb(15 23 42 / 0.04);
  transition: box-shadow 180ms ease;
}

.metric-card:hover {
  box-shadow: 0 4px 14px rgb(15 23 42 / 0.06);
}

.metric-label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
}

/* ── Delta pills ─────────────────────────────────────────── */

.delta-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border-radius: 9999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.delta-pill.up {
  background: rgb(22 163 74 / 0.1);
  color: var(--success);
}

.delta-pill.down {
  background: rgb(220 38 38 / 0.1);
  color: var(--destructive);
}

.delta-pill.flat {
  background: rgb(100 116 139 / 0.1);
  color: var(--muted-foreground);
}

/* ── Creative wizard compatibility badges ───────────────── */

.compat-badge {
  display: inline-block;
  margin-top: 0.5rem;
  border-radius: 9999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.35;
  border: 1px solid transparent;
}

.compat-badge--ok {
  background: #f0fdf4;
  color: #166534;
  border-color: #86efac;
}

.compat-badge--warn {
  background: #fffbeb;
  color: #92400e;
  border-color: #fcd34d;
}

.compat-badge--block {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fca5a5;
}

.delta-tooltip {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  min-width: max-content;
  border-radius: 8px;
  background: var(--foreground);
  color: var(--background);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
  padding: 6px 8px;
  box-shadow: 0 8px 20px rgb(15 23 42 / 0.2);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.group:hover .delta-tooltip {
  opacity: 1;
  transform: translateY(0);
}

/* ── Sparklines ──────────────────────────────────────────── */

.sparkline {
  overflow: visible;
}

.sparkline polyline {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sparkline polygon {
  opacity: 1;
}

.sparkline.up polyline {
  stroke: var(--success);
}

.sparkline.up polygon {
  fill: url(#spark-grad-up);
}

.sparkline.down polyline {
  stroke: var(--destructive);
}

.sparkline.down polygon {
  fill: url(#spark-grad-down);
}

.sparkline.flat polyline {
  stroke: var(--subtle);
}

.sparkline.flat polygon {
  fill: none;
}

/* ── Channel badge dots ──────────────────────────────────── */

.channel-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 700;
  color: white;
}

.channel-dot-sm {
  width: 14px;
  height: 14px;
}

.channel-dot-md {
  width: 16px;
  height: 16px;
}

/* ── Feature icon box ────────────────────────────────────── */

.feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--control-radius);
  background: var(--primary-soft);
  color: var(--primary-strong);
}

/* ── FAQ rotate animation ────────────────────────────────── */

.faq-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: 14px;
  transition: transform 200ms ease;
  flex-shrink: 0;
}

details[open] .faq-toggle {
  transform: rotate(45deg);
}

/* ── Control radius (buttons, cards, inputs, sidebar) ── */

button:not(.rounded-full):not(.rounded-none),
input[type="submit"]:not(.rounded-full):not(.rounded-none),
input[type="button"]:not(.rounded-full):not(.rounded-none),
input[type="reset"]:not(.rounded-full):not(.rounded-none),
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="range"]):not([type="file"]):not([type="color"]),
select,
textarea,
.btn-rainbow {
  border-radius: var(--control-radius);
}

.rounded-btn {
  border-radius: var(--control-radius);
}

/* ── Rainbow milestone CTA (inspired by Magic UI rainbow-button) ── */

@keyframes rainbow-shift {
  0% {
    background-position: 0% 50%;
  }

  100% {
    background-position: 200% 50%;
  }
}

.btn-rainbow {
  position: relative;
  z-index: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border: 2px solid transparent;
  border-radius: var(--control-radius);
  --btn-rainbow-fill: var(--primary);
  background-image:
    linear-gradient(var(--btn-rainbow-fill), var(--btn-rainbow-fill)),
    linear-gradient(var(--btn-rainbow-fill) 50%, rgb(255 255 255 / 0.12) 80%, rgb(255 255 255 / 0)),
    linear-gradient(
      90deg,
      var(--rainbow-1),
      var(--rainbow-5),
      var(--rainbow-3),
      var(--rainbow-4),
      var(--rainbow-2)
    );
  background-size: 100% 100%, 100% 100%, 200% 100%;
  background-origin: border-box;
  background-clip: padding-box, padding-box, border-box;
  animation: rainbow-shift 2.5s linear infinite;
  color: var(--primary-foreground);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25rem;
  white-space: nowrap;
  box-shadow: 0 8px 30px rgb(79 124 255 / 0.25);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.btn-rainbow::before {
  content: "";
  position: absolute;
  bottom: -14%;
  left: 50%;
  z-index: -1;
  width: 68%;
  height: 22%;
  transform: translateX(-50%);
  border-radius: 9999px;
  background-image: linear-gradient(
    90deg,
    var(--rainbow-1),
    var(--rainbow-5),
    var(--rainbow-3),
    var(--rainbow-4),
    var(--rainbow-2)
  );
  background-size: 200% 100%;
  animation: rainbow-shift 2.5s linear infinite;
  filter: blur(0.5rem);
  opacity: 0.65;
  pointer-events: none;
}

.btn-rainbow:hover {
  transform: translateY(-1px) scale(1.02);
  --btn-rainbow-fill: var(--primary-strong);
  box-shadow: 0 12px 36px rgb(79 124 255 / 0.35);
}

.btn-rainbow:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px rgb(79 124 255 / 0.35),
    0 12px 36px rgb(79 124 255 / 0.35);
}

@media (prefers-reduced-motion: reduce) {

  .btn-rainbow,
  .btn-rainbow::before {
    animation: none;
  }

  .btn-rainbow:hover {
    transform: none;
  }
}