/* Magnus · BigID Admin look (preview)
 * Active when html[data-ui-look="bigid"]. Customer icon palette stays on
 * --brand-primary / --brand-accent / --brand-accent-soft (set in base.html).
 * Flip off via Settings → “BigID look (preview)” or ?theme=classic.
 *
 * 1.3.31 — soft-adopts BigIDApp (iphone) Theme.swift neutrals + secondary accents
 * (orange / pink / purple) while leaving brand CTAs on --brand-*.
 */

html[data-ui-look="bigid"] {
  /* BigIDApp Theme.swift secondary accents (logo sweep: orange → pink → purple) */
  --iphone-orange: #f78a3b;
  --iphone-pink: #e61a5e;
  --iphone-purple: #6b4fa6;
  --iphone-base: #120f24;
  --iphone-base-light: #241a42;
  --iphone-brand-grad: linear-gradient(
    90deg,
    var(--iphone-orange),
    var(--iphone-pink),
    var(--iphone-purple)
  );

  /* Soft lavender surfaces (light) inspired by purple base, kept airy like Admin */
  --page-bg: #f3f1f8;
  --surface: #ffffff;
  --surface-2: #faf9fc;
  --surface-3: #ffffff;
  --surface-muted: #f5f3fa;
  --border: #e4e0ee;
  --border-strong: #d4cfe0;
  --border-soft: #ebe7f2;
  --border-faint: #f1eef6;
  --text: #1a1626;
  --text-secondary: #3a3550;
  --text-muted: #6b6685;
  --text-faint: #9a95b0;
  --hover: #f5f3fa;
  --hover-row: #f7f5fc;
  --shadow: 0 4px 16px rgba(66, 49, 101, 0.07), 0 1px 3px rgba(18, 15, 36, 0.04);
  --shadow-lg: 0 10px 32px rgba(66, 49, 101, 0.12), 0 2px 8px rgba(230, 26, 94, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --font-sans: "Inter", "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

html[data-ui-look="bigid"].dark {
  /* BigIDApp Theme.swift base + risk-graph deep navy shell */
  --page-bg: #0b0e18;
  --surface: #14102a;
  --surface-2: #100e20;
  --surface-3: #241a42;
  --surface-muted: #100e20;
  --border: #342a52;
  --border-strong: #4a3d6e;
  --border-soft: #2a2244;
  --border-faint: #1e1836;
  --text: #f0ecf8;
  --text-secondary: #cfc6e0;
  --text-muted: #a094b8;
  --text-faint: #7a7090;
  --hover: #241a42;
  --hover-row: #241a42;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.45), 0 0 24px rgba(230, 26, 94, 0.08);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.55), 0 0 32px rgba(247, 138, 59, 0.08);
}

/* Typography — Inter (Google Fonts, free). Accent colors still from brand. */
html[data-ui-look="bigid"] body {
  font-family: var(--font-sans);
  letter-spacing: -0.01em;
}
html[data-ui-look="bigid"] .font-mono,
html[data-ui-look="bigid"] code,
html[data-ui-look="bigid"] pre,
html[data-ui-look="bigid"] .tabular-nums {
  font-family: var(--font-mono);
}

/* —— Shell: light BigID-admin chrome (accent from customer icon) —— */
html[data-ui-look="bigid"] body > header {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-bottom: 1px solid var(--border-soft);
  box-shadow: 0 1px 0 rgba(66, 49, 101, 0.04);
  position: relative;
}
/* iPhone logo sweep as a thin header accent (secondary; brand CTAs untouched) */
html[data-ui-look="bigid"] body > header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--iphone-brand-grad);
  opacity: 0.85;
  pointer-events: none;
}
html[data-ui-look="bigid"] body > header a,
html[data-ui-look="bigid"] body > header button,
html[data-ui-look="bigid"] body > header span,
html[data-ui-look="bigid"] body > header label {
  color: inherit;
}
html[data-ui-look="bigid"] body > header .text-white\/90,
html[data-ui-look="bigid"] body > header .text-white\/80,
html[data-ui-look="bigid"] body > header a.text-white\/90,
html[data-ui-look="bigid"] body > header button {
  color: var(--text-secondary) !important;
}
html[data-ui-look="bigid"] body > header a:hover,
html[data-ui-look="bigid"] body > header button:hover,
html[data-ui-look="bigid"] body > header .hover\:bg-white\/10:hover {
  background: var(--hover) !important;
  color: var(--text) !important;
}
html[data-ui-look="bigid"] body > header .bg-white\/10,
html[data-ui-look="bigid"] body > header a.bg-white\/10 {
  background: var(--brand-accent-soft) !important;
  color: var(--brand-accent) !important;
}
html[data-ui-look="bigid"] body > header .border-white\/15 {
  border-color: var(--border) !important;
}
html[data-ui-look="bigid"] body > header .bg-black\/20 {
  background: var(--surface-muted) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
html[data-ui-look="bigid"] body > header select {
  background: var(--surface-muted) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
  border-radius: var(--radius-sm);
}
html[data-ui-look="bigid"] body > header .h-4.w-px.bg-white\/15 {
  background: var(--border) !important;
}
html[data-ui-look="bigid"] body > header .font-semibold {
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.02em;
}
html[data-ui-look="bigid"] body > header a.text-amber-200 {
  color: #b45309 !important;
}

/* Top tabs */
html[data-ui-look="bigid"] .shell-topnav {
  background: var(--surface);
  border-color: var(--border-soft);
  box-shadow: none;
}
html[data-ui-look="bigid"] .shell-topnav a {
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-weight: 500;
  font-size: 12.5px;
}
html[data-ui-look="bigid"] .shell-topnav a.bigid-tab-active {
  color: var(--brand-accent);
  border-bottom-color: var(--brand-accent);
  font-weight: 600;
}
html[data-ui-look="bigid"] .shell-topnav a:not(.bigid-tab-active):hover {
  background: var(--hover);
  color: var(--text);
}

/* Side nav — icon-pill active like BigID Admin */
html[data-ui-look="bigid"] .shell-sidebar {
  background: var(--surface);
  border-color: var(--border-soft);
  box-shadow: 2px 0 12px rgba(66, 49, 101, 0.05);
}
html[data-ui-look="bigid"] .shell-sidebar a {
  border-radius: var(--radius-sm);
  margin: 1px 4px;
  font-weight: 500;
}
html[data-ui-look="bigid"] .shell-sidebar a.side-active {
  background: var(--brand-accent-soft);
  color: var(--brand-accent);
  font-weight: 600;
}
html[data-ui-look="bigid"] .shell-sidebar a.side-active svg {
  color: var(--brand-accent) !important;
}

/* Main content breathing room */
html[data-ui-look="bigid"] main {
  padding-top: 1.25rem;
}

/* Buttons — primary CTAs stay on brand-accent */
html[data-ui-look="bigid"] .btn-brand {
  border-radius: var(--radius-sm);
  font-weight: 600;
  letter-spacing: -0.01em;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--brand-accent) 35%, transparent);
}
html[data-ui-look="bigid"] button:not([class*="rounded-full"]),
html[data-ui-look="bigid"] .inline-flex.h-7,
html[data-ui-look="bigid"] .inline-flex.h-8,
html[data-ui-look="bigid"] a.inline-flex.h-7,
html[data-ui-look="bigid"] a.inline-flex.h-8 {
  border-radius: var(--radius-sm);
}
html[data-ui-look="bigid"] input:not([type="checkbox"]):not([type="radio"]),
html[data-ui-look="bigid"] select,
html[data-ui-look="bigid"] textarea {
  border-radius: var(--radius-sm);
}

/* Cards / panels — rounded + soft purple-tinted shadow */
html[data-ui-look="bigid"] main .border.bg-white,
html[data-ui-look="bigid"] main .border.border-\[\#d5dbe3\].bg-white,
html[data-ui-look="bigid"] main [class*="border"][class*="bg-white"],
html[data-ui-look="bigid"] #s-out > div,
html[data-ui-look="bigid"] #s-cat-bars,
html[data-ui-look="bigid"] #s-owners,
html[data-ui-look="bigid"] #s-ft-list,
html[data-ui-look="bigid"] #s-donuts > div,
html[data-ui-look="bigid"] section.mb-4.border,
html[data-ui-look="bigid"] #appearance,
html[data-ui-look="bigid"] .border.border-\[\#d5dbe3\] {
  border-radius: var(--radius);
  border-color: var(--border-soft) !important;
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Summary KPI tiles — BigID Data Overview + iPhone StatCard secondary accents */
html[data-ui-look="bigid"] #s-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--brand-accent) 10%, transparent),
    0 8px 28px color-mix(in srgb, var(--iphone-purple) 10%, transparent),
    var(--shadow);
  overflow: hidden;
  position: relative;
}
html[data-ui-look="bigid"] #s-tiles::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: var(--iphone-brand-grad);
  opacity: 0.9;
  pointer-events: none;
  z-index: 1;
}
html[data-ui-look="bigid"] #s-tiles > div {
  border: none !important;
  border-right: 1px solid var(--border-soft) !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  padding: 1.1rem 1.25rem !important;
  text-align: left;
}
html[data-ui-look="bigid"] #s-tiles > div:last-child {
  border-right: none !important;
}
html[data-ui-look="bigid"] #s-tiles > div > div:first-child {
  font-size: 1.65rem !important;
  font-weight: 700 !important;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text) !important;
}
/* Cycle iPhone secondary accents on KPI values (not brand CTAs) */
html[data-ui-look="bigid"] #s-tiles > div:nth-child(3n + 1) > div:first-child {
  color: var(--iphone-orange) !important;
}
html[data-ui-look="bigid"] #s-tiles > div:nth-child(3n + 2) > div:first-child {
  color: var(--iphone-pink) !important;
}
html[data-ui-look="bigid"] #s-tiles > div:nth-child(3n + 3) > div:first-child {
  color: var(--iphone-purple) !important;
}
html[data-ui-look="bigid"] #s-tiles > div > div:nth-child(2) {
  margin-top: 0.35rem;
  font-size: 11px !important;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none !important;
  color: var(--text-muted) !important;
}

/* Page titles */
html[data-ui-look="bigid"] main h1,
html[data-ui-look="bigid"] main h2.ink-primary,
html[data-ui-look="bigid"] .ink-primary {
  letter-spacing: -0.025em;
  font-weight: 700;
}
html[data-ui-look="bigid"].dark .ink-primary {
  color: var(--text);
}

/* Tables */
html[data-ui-look="bigid"] table {
  border-collapse: separate;
  border-spacing: 0;
}
html[data-ui-look="bigid"] thead th {
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  background: var(--surface-muted);
}
html[data-ui-look="bigid"] tbody tr {
  transition: background 0.12s ease;
}
html[data-ui-look="bigid"] tbody tr:hover {
  background: var(--hover-row);
}

/* Chips / tags */
html[data-ui-look="bigid"] .attr-chip,
html[data-ui-look="bigid"] .tag-ok,
html[data-ui-look="bigid"] .tag-none,
html[data-ui-look="bigid"] .tag-unres {
  border-radius: var(--radius-pill);
}

/* Modals / menus */
html[data-ui-look="bigid"] .colmenu,
html[data-ui-look="bigid"] .attr-menu,
html[data-ui-look="bigid"] .cat-drawer {
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

/* Catalog drawer tabs */
html[data-ui-look="bigid"] .cat-drawer-tabs button.active {
  border-radius: var(--radius-sm);
  color: var(--brand-accent);
  border-color: color-mix(in srgb, var(--brand-accent) 35%, var(--border));
  background: var(--brand-accent-soft);
}

/* Soften hard square corners on common panels */
html[data-ui-look="bigid"] #s-msg,
html[data-ui-look="bigid"] #s-err,
html[data-ui-look="bigid"] #s-notes {
  border-radius: var(--radius);
}

/* Focus / links — soft orange tint like BigIDApp .tint(Theme.orange), only as secondary */
html[data-ui-look="bigid"] :focus-visible {
  outline-color: color-mix(in srgb, var(--brand-accent) 70%, var(--iphone-orange));
}

/* Preview badge in footer when look is on */
html[data-ui-look="bigid"] #app-version-footer::after {
  content: " · BigID look (preview)";
  color: var(--brand-accent);
  font-family: var(--font-sans);
  font-weight: 500;
  letter-spacing: 0;
}
