/* Nocturne — design tokens and component classes for the Template Editor
   and Office Overrides editor screens. Scoped to those two views only;
   the rest of the app keeps its existing Bootstrap theme. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --color-bg: #161826;
  --color-surface: #232532;
  --color-text: #e9e9ed;
  /* Accent ramp is built around EPI's brand mark gradient (#00A8EA -> #005BAB), slotted in at
     the 500 and 700 steps respectively so the app's accent literally matches the logo at two
     points, with the rest of the ramp extrapolated around them. --color-accent uses the
     brighter stop (good contrast on this dark navy bg); the light theme below uses the deeper
     stop instead (better contrast on white) — same relationship as the old accent-600 reuse. */
  --color-accent: #00a8ea;
  --color-accent-2: #33bef0;
  --color-divider: color-mix(in srgb, #e9e9ed 16%, transparent);

  --color-neutral-100: #f3f5fe;
  --color-neutral-200: #e4e7f5;
  --color-neutral-300: #cfd3e5;
  --color-neutral-400: #b2b6ca;
  --color-neutral-500: #9397ab;
  --color-neutral-600: #75798c;
  --color-neutral-700: #595d6c;
  --color-neutral-800: #3f424d;
  --color-neutral-900: #292b31;

  --color-accent-100: #eaf6fd;
  --color-accent-200: #cdeafb;
  --color-accent-300: #9ed8f7;
  --color-accent-400: #5cc0f3;
  --color-accent-500: #00a8ea;
  --color-accent-600: #0089c7;
  --color-accent-700: #005bab;
  --color-accent-800: #003f79;
  --color-accent-900: #002a52;

  /* Semantic status colors — used for success/error banners, delete controls, and the
     approved/pending/suspended status dots. Centralized here (instead of the hardcoded hex
     that used to be copy-pasted across ~15 files) specifically so the light theme below can
     re-tune them for contrast on a white background without touching every consumer.
     Green/red picked to sit alongside the brand blue: a cooler emerald and a clean, slightly
     less orange red than the old Bootstrap-y defaults, both at a similar saturation/vibrancy
     to #00A8EA so nothing reads as muddier than the accent next to it. Pending's amber is
     unrelated to this brand pass and stays as-is. */
  --color-success-bg: color-mix(in srgb, #10b981 16%, transparent);
  --color-success-text: #34d399;
  --color-danger-bg: color-mix(in srgb, #ef4444 16%, transparent);
  --color-danger-text: #f87171;
  --color-delete-text: #f26d6d;
  --color-status-approved: #10b981;
  --color-status-pending: #c89a3f;
  --color-status-suspended: #ef4444;

  --font-heading: "Inter", system-ui, sans-serif;
  --font-heading-weight: 500;
  --font-body: "Inter", system-ui, sans-serif;

  --space-1: 2.8px;
  --space-2: 5.6px;
  --space-3: 8.4px;
  --space-4: 11.2px;
  --space-6: 16.8px;
  --space-8: 22.4px;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;

  --shadow-sm: 0 0 0 1px #3f424d;
  --shadow-md: 0 0 0 1px #595d6c, 0 6px 18px rgba(0,0,0,0.55);
  --shadow-lg: 0 0 0 1px #9397ab, 0 16px 40px rgba(0,0,0,0.65);
}

/* Light theme — same token names, re-tuned values. The --color-neutral-* ramp is
   deliberately *inverted* rather than just re-colored: every consumer uses these on the
   assumption that low numbers are subtle/close-to-background and high numbers are
   strong/far-from-background (e.g. neutral-400 as "muted but readable" secondary text,
   neutral-800/900 as near-invisible scrollbar chrome). Since the background itself flips from
   near-black to near-white, the ramp has to flip too for those same semantics to hold — a
   light gray that reads as "subtle" on a dark page reads as "invisible" on a white one.
   --color-accent-100, -400..900 (the tag/badge tint scale) intentionally do NOT change: those pair
   a background and foreground both drawn from this same scale (e.g. .tag-accent), so they're
   self-contained and correct regardless of the surrounding page background. --color-accent-200/300
   are the exception: across the app they're used as standalone link/label/icon color sitting
   directly on the page or card surface (not paired with an accent-scale background), so — like the
   neutral ramp — they need a darker flip to stay legible once that surface turns white. */
:root[data-bs-theme="light"] {
  /* --color-bg is EPI's brand "solid white" (#F7F7F7) rather than a bespoke near-white — the
     page canvas should be the literal brand swatch. --color-surface stays pure #fff, one step
     crisper, so cards still read as "raised" above the page. */
  --color-bg: #f7f7f7;
  --color-surface: #ffffff;
  --color-text: #1b1d29;
  --color-accent: #005bab;
  --color-accent-2: #004e93;
  --color-accent-200: #003f79;
  --color-accent-300: #005bab;
  --color-divider: color-mix(in srgb, #1b1d29 12%, transparent);

  --color-neutral-100: #292b31;
  --color-neutral-200: #3f424d;
  --color-neutral-300: #595d6c;
  --color-neutral-400: #75798c;
  --color-neutral-500: #9397ab;
  --color-neutral-600: #b2b6ca;
  --color-neutral-700: #cfd3e5;
  --color-neutral-800: #e4e7f5;
  --color-neutral-900: #f3f5fe;

  --color-success-bg: color-mix(in srgb, #10b981 14%, transparent);
  --color-success-text: #047857;
  --color-danger-bg: color-mix(in srgb, #ef4444 12%, transparent);
  --color-danger-text: #b91c1c;
  --color-delete-text: #d92d2d;
  --color-status-approved: #059669;
  --color-status-pending: #a67a1f;
  --color-status-suspended: #b91c1c;

  --shadow-sm: 0 0 0 1px #e2e4ef;
  --shadow-md: 0 0 0 1px #d5d8e8, 0 6px 18px rgba(20, 22, 35, 0.12);
  --shadow-lg: 0 0 0 1px #c3c7dc, 0 16px 40px rgba(20, 22, 35, 0.16);
}

/* Nav-brand logo: the EPI wordmark ships in light-text (for dark surfaces) and dark-text (for light
   surfaces) variants — .theme-logo-dark/.theme-logo-light select between them by data-bs-theme
   rather than by .nocturne scoping, since the toggle needs to work identically on the un-scoped
   :root itself. */
.theme-logo-light { display: none; }
:root[data-bs-theme="light"] .theme-logo-dark { display: none !important; }
:root[data-bs-theme="light"] .theme-logo-light { display: block !important; }

.nocturne { background: var(--color-bg); color: var(--color-text); font-family: var(--font-body); }
.nocturne *, .nocturne *::before, .nocturne *::after { box-sizing: border-box; }
.nocturne h1, .nocturne h2, .nocturne h3, .nocturne h4, .nocturne h5, .nocturne h6 {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  line-height: 1.12; letter-spacing: -0.015em; margin: 0 0 var(--space-2);
}
.nocturne h6 { font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; }
.nocturne a { color: var(--color-accent); text-underline-offset: 3px; }
.nocturne :focus { outline: none; }
.nocturne :focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

/* — buttons — */
.nocturne .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none;
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 14px; line-height: 1.2; color: var(--color-text);
  background: transparent; border: 1px solid transparent;
  padding: var(--space-2) calc(var(--space-3) * 1.2);
  border-radius: var(--radius-md);
}
.nocturne .btn:disabled { opacity: 0.45; cursor: not-allowed; }
.nocturne .btn-primary { color: var(--color-accent); border-color: var(--color-accent); }
.nocturne .btn-primary:hover { background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.nocturne .btn-primary:active { background: color-mix(in srgb, var(--color-accent) 22%, transparent); }
.nocturne .btn-secondary { border-color: var(--color-divider); }
.nocturne .btn-secondary:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.nocturne .btn-secondary:active { background: color-mix(in srgb, var(--color-text) 14%, transparent); }
.nocturne .btn-block { width: 100%; margin-top: var(--space-2); }
.nocturne .btn-icon { width: 36px; height: 36px; padding: 0; }

/* — cards — */
.nocturne .card {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-3); border-radius: var(--radius-md); background: var(--color-surface);
}
.nocturne .card-kicker { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-accent); }
.nocturne .card-title {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 17px; line-height: 1.2;
}
.nocturne .card-body { margin: 0; font-size: 13px; opacity: 0.8; flex: 1; }
.nocturne .card-meta {
  display: flex; align-items: center; gap: 6px; font-size: 11px;
  color: color-mix(in srgb, var(--color-text) 50%, transparent);
}
.nocturne .elev-sm { box-shadow: var(--shadow-sm); }
.nocturne .elev-md { box-shadow: var(--shadow-md); }
.nocturne .elev-lg { box-shadow: var(--shadow-lg); }

/* — navigation — */
.nocturne .nav {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-bottom: none;
}
.nocturne .nav-brand {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 18px; margin-right: auto;
}
.nocturne .nav a { color: inherit; text-decoration: none; font-size: 14px; }
.nocturne .nav a:hover, .nocturne .nav a[aria-current='page'] { color: var(--color-accent); }

.nocturne .text-muted { color: color-mix(in srgb, var(--color-text) 55%, transparent); }

/* — forms — */
.nocturne .field > label {
  display: block; font-size: 12px; margin-bottom: 5px;
  color: color-mix(in srgb, var(--color-text) 70%, transparent);
}
.nocturne .input {
  width: 100%; min-height: 36px; padding: 6px 10px; font: inherit;
  font-size: 14px; color: var(--color-text); caret-color: var(--color-accent);
  background: var(--color-surface);
  border: 1px solid var(--color-divider); border-radius: var(--radius-md);
}
.nocturne .input:hover { border-color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.nocturne .input:focus-visible { border-color: var(--color-accent); outline-offset: 0; }
.nocturne textarea.input { min-height: 90px; resize: vertical; }
.nocturne select.input {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239397ab' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 10px 6px;
}
.nocturne select.input::-ms-expand { display: none; }

.nocturne .u-row { transition: background .12s ease; }
.nocturne .u-row:hover { background: color-mix(in srgb, var(--color-text) 4%, transparent); }
.nocturne .u-inp {
  width: 100%; min-height: 34px; padding: 5px 9px; font: inherit;
  font-size: 13px; color: var(--color-text); background: transparent;
  border: 1px solid transparent; border-radius: var(--radius-md);
  transition: border-color .12s, background .12s;
}
.nocturne .u-inp:hover { border-color: var(--color-divider); }
.nocturne .u-inp:focus { outline: none; border-color: var(--color-accent); background: var(--color-bg); }

.nocturne .h-card { background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }

/* Transparency checkerboard (Photoshop-style) for logo previews — a solid-white logo on a
   solid-white swatch is invisible, so these previews need a fixed, theme-agnostic grid rather
   than var(--color-bg)/#fff, the same reason image editors always show one under a canvas. */
.nocturne .checkerboard {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #ccc 25%, transparent 25%), linear-gradient(-45deg, #ccc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ccc 75%), linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.nocturne .checkerboard-sm { background-size: 10px 10px; background-position: 0 0, 0 5px, 5px -5px, -5px 0; }

/* — logo cropper (office form) — */
.nocturne .cropper-stage {
  width: 100%; max-width: 100%; height: 360px;
  border: 1px solid var(--color-divider); border-radius: var(--radius-md);
  padding: 0; box-sizing: border-box; background: #fff; overflow: hidden;
  position: relative; display: flex; align-items: center; justify-content: center;
}
.nocturne .cropper-stage img { display: block; max-width: 100%; }
.nocturne .cropper-stage .cropper-container {
  position: absolute !important; inset: 0 !important;
  width: 100% !important; height: 100% !important; max-width: 100% !important; max-height: 100% !important;
}
.nocturne .cropper-stage .cropper-wrap-box,
.nocturne .cropper-stage .cropper-canvas,
.nocturne .cropper-stage .cropper-drag-box,
.nocturne .cropper-stage .cropper-crop-box {
  max-width: 100% !important; max-height: 100% !important;
}
.nocturne #cropImage { width: auto; height: auto; max-width: 100%; max-height: 100%; display: block; margin: 0 auto; }

.nocturne .mt-active-track { width: 38px; height: 22px; border-radius: 12px; background: var(--color-neutral-800); position: relative; transition: background .15s; display: inline-block; flex: none; }
.nocturne .mt-active-knob { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.nocturne .mt-active-checkbox { position: absolute; opacity: 0; width: 0; height: 0; }
.nocturne .mt-active-checkbox:checked + .mt-active-track { background: var(--color-accent); }
.nocturne .mt-active-checkbox:checked + .mt-active-track .mt-active-knob { left: 19px; }
.nocturne .radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.nocturne .seg { display: inline-flex; overflow: hidden; border: 1px solid var(--color-divider); border-radius: var(--radius-md); }
.nocturne .seg-opt { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; font-size: 13px; cursor: pointer; position: relative; }
.nocturne .seg-opt input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.nocturne .seg-opt + .seg-opt { border-left: 1px solid var(--color-divider); }
.nocturne .seg-opt:has(input:checked) { color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 15%, transparent); }
.nocturne .seg-opt:not(:has(input:checked)):hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }

/* — tags — */
.nocturne .tag {
  display: inline-flex; align-items: center; font-size: 11px;
  letter-spacing: 0.02em; padding: 3px 10px; border-radius: calc(var(--radius-md) * 0.75);
}
.nocturne .tag-accent { background: var(--color-accent-800); color: var(--color-accent-100); }
.nocturne .tag-neutral { color: var(--color-neutral-300); box-shadow: inset 0 0 0 1px var(--color-neutral-700); }

/* — editor chrome — */
.nocturne, .nocturne body { height: 100%; margin: 0; }
.nocturne ::-webkit-scrollbar { width: 10px; height: 10px; }
.nocturne ::-webkit-scrollbar-thumb { background: var(--color-neutral-800); border-radius: 8px; border: 2px solid var(--color-bg); }
.nocturne ::-webkit-scrollbar-track { background: transparent; }
.nocturne .ge-panel::-webkit-scrollbar-thumb { border-color: var(--color-surface); }
.nocturne .ge-dragging, .nocturne .ge-dragging * { cursor: inherit !important; user-select: none; }
