/* =============================================================
   MaxPanel design system — theme.css
   Foundation stylesheet for the public site + customer portal.
   Loaded FIRST (before public.css / portal.css). Dependency-free:
   system font stack, no external CDN, no @font-face.

   Brand hue is #FE64B0 (--brand-400) used for accents / glows /
   gradients ONLY. Interactive surfaces that carry white text use
   --brand-600 (#C81E78), which passes WCAG AA (4.6:1 on white).

   Contains: design tokens, base reset, and the shared component
   layer (buttons, cards, forms, badges, tables, nav, footer, flash,
   icons) + motion utilities. Respects prefers-reduced-motion.
   ============================================================= */

:root {
  /* ---- Fonts ---- */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  /* ---- Brand scale (derived from #FE64B0) ---- */
  --brand-50:  #FFF1F8;
  --brand-100: #FFE0F0;
  --brand-200: #FFC2E1;
  --brand-300: #FF9BCE;
  --brand-400: #FE64B0;  /* the brand hue — accents / glow / gradients only */
  --brand-500: #ED3B95;
  --brand-600: #C81E78;  /* primary button bg — white text 4.6:1 (AA) */
  --brand-700: #A4135F;  /* hover / links on white — 6.4:1 (AA) */
  --brand-800: #7E0E49;  /* active / pressed */

  /* ---- Neutrals (slate ramp) ---- */
  --gray-50:  #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;
  --ink:      #0F172A;   /* dark surfaces (footer) */

  /* ---- Semantic ---- */
  --success: #15803D;  --success-soft: #DCFCE7;
  --warn:    #B45309;  --warn-soft:    #FEF3C7;
  --danger:  #B3261E;  --danger-soft:  #FEE2E2;
  --info:    var(--brand-700);

  /* ---- Glow ---- */
  --brand-glow: rgba(254, 100, 176, 0.45);

  /* ---- Semantic surface layer (preferred for new code) ---- */
  --surface:        #ffffff;
  --surface-2:      var(--gray-50);
  --text:           var(--gray-900);
  --text-muted:     var(--gray-500);
  --text-soft:      var(--gray-700);
  --border:         var(--gray-200);
  --primary:        var(--brand-600);
  --primary-hover:  var(--brand-700);
  --on-primary:     #ffffff;
  --link:           var(--brand-700);
  --ring:           0 0 0 3px var(--brand-glow);

  /* ---- Legacy --c-* aliases (repointed to the pink system).
          public.css consumes these; do NOT remove. ---- */
  --c-bg:           var(--gray-50);
  --c-surface:      #ffffff;
  --c-text:         var(--gray-900);
  --c-muted:        var(--gray-500);
  --c-text-soft:    var(--gray-700);
  --c-border:       var(--gray-200);
  --c-primary:      var(--brand-600);
  --c-primary-hover:var(--brand-700);
  --c-accent:       var(--brand-400);
  --c-success:      var(--success);
  --c-warn:         var(--warn);
  --c-primary-soft: rgba(254, 100, 176, 0.10);
  --c-accent-soft:  rgba(254, 100, 176, 0.14);

  /* ---- Typography scale ---- */
  --fs-xs:   0.8125rem;
  --fs-sm:   0.875rem;
  --fs-base: 1rem;
  --fs-md:   1.125rem;
  --fs-lg:   1.25rem;
  --fs-xl:   1.5rem;
  --fs-2xl:  1.875rem;
  --fs-3xl:  2.25rem;
  --fs-4xl:  clamp(2.4rem, 5.5vw, 3.6rem);
  --fw-normal: 400; --fw-medium: 500; --fw-semibold: 600; --fw-bold: 700;
  --lh-tight: 1.15; --lh-snug: 1.35; --lh-normal: 1.6;
  --ls-tight: -0.02em;

  /* ---- Spacing scale (4px base) ---- */
  --space-1: 0.25rem; --space-2: 0.5rem;  --space-3: 0.75rem;
  --space-4: 1rem;    --space-5: 1.5rem;  --space-6: 2rem;
  --space-8: 3rem;    --space-10: 4rem;   --space-12: 6rem;
  --container-max: 1200px;
  --container-narrow: 760px;
  --container-pad: 1.5rem;

  /* ---- Radii ---- */
  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 14px;
  --radius-xl: 20px; --radius-pill: 999px;

  /* ---- Shadows ---- */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 48px -12px rgba(15, 23, 42, 0.16);
  --shadow-glow: 0 8px 30px -6px var(--brand-glow);

  /* ---- Motion ---- */
  --dur-fast: 120ms; --dur-base: 200ms; --dur-slow: 360ms; --dur-reveal: 600ms;
  --ease-out: cubic-bezier(0.2, 0.7, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* =============================================================
   Base reset
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--c-bg);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 0.5em; line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight); font-weight: var(--fw-semibold);
}
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-lg); }
p { margin: 0 0 1em; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre {
  font-family: var(--font-mono); font-size: 0.9em;
}
pre {
  background: var(--gray-100); padding: 0.75em 1em; border-radius: var(--radius-sm);
  overflow-x: auto; white-space: pre-wrap; word-break: break-all;
}
pre.token { background: #0e1217; color: #c6d0f5; border: 1px solid #303742; }
img, svg, video { max-width: 100%; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }
.small { font-size: var(--fs-sm); }
.muted { color: var(--text-muted); }

/* =============================================================
   Layout
   ============================================================= */
.container { max-width: var(--container-max); margin: 1.5em auto; padding: 0 var(--container-pad); }
.container.narrow { max-width: var(--container-narrow); }
.auth-container { max-width: 420px; margin: 4em auto; padding: 0 1em; }
.auth-container h1 { text-align: center; }

.section { padding: var(--space-10) var(--container-pad); }
.section.alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section.center { text-align: center; }
.section-inner { max-width: 1100px; margin: 0 auto; }
.section-inner.narrow { max-width: var(--container-narrow); }

.row-head { display: flex; justify-content: space-between; align-items: center; gap: 1em; flex-wrap: wrap; margin-bottom: 1em; }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }

/* =============================================================
   Buttons
   ============================================================= */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4em;
  padding: 0.55em 1.1em; border: 1px solid var(--border); border-radius: var(--radius-md);
  font-family: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium); line-height: 1.2;
  color: var(--text); background: var(--surface); cursor: pointer; text-decoration: none;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
button:hover, .btn:hover { background: var(--gray-100); text-decoration: none; }
button.primary, .btn.primary {
  background: var(--brand-600); color: var(--on-primary); border-color: var(--brand-600);
}
button.primary:hover, .btn.primary:hover {
  background: var(--brand-700); border-color: var(--brand-700);
  transform: translateY(-1px); box-shadow: var(--shadow-glow);
}
button.primary:active, .btn.primary:active { background: var(--brand-800); transform: translateY(0); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--gray-100); }
button.danger, .btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
button.danger:hover, .btn.danger:hover { background: #8f1d17; border-color: #8f1d17; }
.btn.lg { padding: 0.75em 1.4em; font-size: var(--fs-md); border-radius: var(--radius-md); }
button.small, .btn.sm, .btn.small { padding: 0.3em 0.7em; font-size: var(--fs-xs); }
.btn.full { width: 100%; text-align: center; }
.linkish { background: transparent; border: none; color: inherit; padding: 0; cursor: pointer; text-decoration: underline; font-size: inherit; }

/* =============================================================
   Cards
   ============================================================= */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-5); margin-bottom: 1.25em; box-shadow: var(--shadow-xs);
}
.card.warn { background: var(--warn-soft); border-color: #fde68a; }
.card.success { background: var(--success-soft); border-color: #bbf7d0; }
.card.feature { transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out); }
.card.feature:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--brand-200); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--space-5); }

/* =============================================================
   Forms
   ============================================================= */
form.card label, form label { display: block; margin-bottom: 0.75em; font-size: var(--fs-sm); color: var(--text-soft); }
form input[type=text], form input[type=email], form input[type=password],
form input[type=search], form input[type=number], form select, form textarea {
  display: block; width: 100%; margin-top: 0.25em;
  padding: 0.55em 0.7em; border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
  font-family: inherit; font-size: var(--fs-sm); background: #fff; color: var(--text);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
form input:focus, form select:focus, form textarea:focus {
  outline: none; border-color: var(--brand-400); box-shadow: var(--ring);
}
form label.checkbox { display: flex; align-items: center; gap: 0.5em; }
form label.checkbox input { width: auto; margin-top: 0; }
.field-hint { font-size: var(--fs-sm); color: var(--text-muted); }
.inline-form { display: flex; gap: 0.75em; flex-wrap: wrap; align-items: end; }
.inline-form label { flex: 1 0 180px; }
.filter-bar { display: flex; gap: 0.5em; margin-bottom: 1em; flex-wrap: wrap; }
.filter-bar input[type=search], .filter-bar select { max-width: 280px; }

/* =============================================================
   Badges & state pills
   ============================================================= */
.badge { display: inline-block; padding: 0.15em 0.6em; border-radius: var(--radius-pill); font-size: var(--fs-xs); font-weight: var(--fw-semibold); }
.badge.brand   { background: var(--brand-50);  color: var(--brand-700); }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warn    { background: var(--warn-soft);    color: var(--warn); }
.badge.danger  { background: var(--danger-soft);  color: var(--danger); }

.state { padding: 0.15em 0.55em; border-radius: var(--radius-pill); font-size: var(--fs-xs); font-weight: var(--fw-semibold); display: inline-block; }
.state-active  { background: var(--success-soft); color: var(--success); }
.state-revoked { background: var(--danger-soft);  color: var(--danger); }
.state-expired { background: var(--warn-soft);     color: var(--warn); }

/* =============================================================
   Tables
   ============================================================= */
table.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
table.list th, table.list td { padding: 0.6em 0.8em; text-align: left; border-bottom: 1px solid var(--gray-100); vertical-align: top; }
table.list th { background: var(--gray-50); font-size: var(--fs-sm); color: var(--text-soft); font-weight: var(--fw-semibold); }
table.list tr:last-child td { border-bottom: none; }
table.list td.empty { text-align: center; color: var(--text-muted); padding: 1.5em; }
table.list pre { margin: 0; font-size: 0.8em; max-width: 700px; }

/* Definition list (key/value) */
dl.kv { display: grid; grid-template-columns: 170px 1fr; gap: 0.4em 1em; margin: 0; }
dl.kv dt { color: var(--text-muted); font-size: var(--fs-sm); }
dl.kv dd { margin: 0; }

/* =============================================================
   Flash messages
   ============================================================= */
.flash {
  padding: 0.7em 1em; border-radius: var(--radius-sm); margin-bottom: 1em; font-size: var(--fs-sm);
  border: 1px solid transparent; animation: fade-up var(--dur-base) var(--ease-out);
}
.flash.ok   { background: var(--success-soft); color: var(--success); border-color: #aed9ae; }
.flash.err  { background: var(--danger-soft);  color: var(--danger);  border-color: #e7a9a9; }
.flash.warn { background: var(--warn-soft);     color: var(--warn);    border-color: #ffeeba; }

/* =============================================================
   Shared nav (.site-nav) — public & portal
   ============================================================= */
.site-nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-nav-inner {
  max-width: var(--container-max); margin: 0 auto;
  padding: 0.85em var(--container-pad);
  display: flex; align-items: center; gap: 2em;
}
.site-nav .brand {
  font-weight: var(--fw-bold); font-size: 1.2em; color: var(--text);
  text-decoration: none; letter-spacing: var(--ls-tight);
}
.site-nav .brand:hover { text-decoration: none; }
.nav-links { flex: 1; display: flex; gap: 1.75em; }
.nav-links a {
  position: relative; color: var(--text-muted); text-decoration: none;
  font-weight: var(--fw-medium); font-size: var(--fs-sm); padding: 0.25em 0;
  transition: color var(--dur-fast) var(--ease-out);
}
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-links a.active { color: var(--brand-700); }
.nav-links a.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px;
  background: var(--brand-400); border-radius: var(--radius-pill);
  animation: nav-underline var(--dur-base) var(--ease-out);
}
.nav-actions { display: flex; align-items: center; gap: 0.75em; }
.nav-actions span { color: var(--text-muted); font-size: var(--fs-sm); }
.nav-toggle {
  display: none; flex-direction: column; justify-content: center; gap: 4px;
  width: 40px; height: 36px; padding: 0; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); cursor: pointer;
}
.nav-toggle span { display: block; width: 18px; height: 2px; margin: 0 auto; background: var(--text); border-radius: 2px; transition: transform var(--dur-base) var(--ease-out), opacity var(--dur-base) var(--ease-out); }
.nav-open .nav-toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 720px) {
  .site-nav-inner { flex-wrap: wrap; gap: 1em; }
  .nav-toggle { display: inline-flex; margin-left: auto; order: 2; }
  .brand { order: 1; }
  .nav-links, .nav-actions {
    order: 3; flex-basis: 100%; flex-direction: column; align-items: flex-start; gap: 0.75em;
    max-height: 0; overflow: hidden; opacity: 0;
    transition: max-height var(--dur-base) var(--ease-out), opacity var(--dur-base) var(--ease-out);
  }
  .nav-open .nav-links, .nav-open .nav-actions { max-height: 60vh; opacity: 1; }
  .nav-actions .btn { width: 100%; }
}

/* =============================================================
   Shared footer (.site-foot)
   ============================================================= */
.site-foot { background: var(--ink); color: #cbd5e1; padding: 3em var(--container-pad) 2em; margin-top: 4em; }
.site-foot a { color: #94a3b8; text-decoration: none; }
.site-foot a:hover { color: #fff; }
.site-foot-inner { max-width: 1100px; margin: 0 auto; }
.site-foot .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 2em; margin-bottom: 2em; }
.site-foot .cols div { display: flex; flex-direction: column; gap: 0.4em; }
.site-foot .cols strong { color: #fff; margin-bottom: 0.25em; font-size: 0.9em; text-transform: uppercase; letter-spacing: 0.05em; }
.site-foot .cols a, .site-foot .cols .linkish { color: #94a3b8; font-size: var(--fs-sm); }
.site-foot .foot-bottom { color: #64748b; border-top: 1px solid #1e293b; padding-top: 1.5em; font-size: var(--fs-sm); }

/* =============================================================
   Icons (dual-tone container) — kept consistent with public.css
   ============================================================= */
.icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: var(--radius-md);
  background: var(--c-primary-soft); color: var(--brand-600); flex-shrink: 0;
}
.icon svg { width: 26px; height: 26px; }
.icon.icon-accent  { background: var(--c-accent-soft); color: var(--brand-500); }
.icon.icon-success { background: rgba(21, 128, 61, 0.12); color: var(--success); }
.icon.icon-pink    { background: rgba(254, 100, 176, 0.12); color: var(--brand-500); }
.icon.icon-violet  { background: rgba(139, 92, 246, 0.14); color: #7c3aed; }
.icon.icon-cyan    { background: rgba(6, 182, 212, 0.14); color: #0891b2; }
.icon.icon-lg { width: 56px; height: 56px; border-radius: var(--radius-lg); }
.icon.icon-lg svg { width: 30px; height: 30px; }

/* =============================================================
   Motion utilities & keyframes
   ============================================================= */
.reveal, [data-reveal] {
  opacity: 0; transform: translateY(18px);
  transition: opacity var(--dur-reveal) var(--ease-out), transform var(--dur-reveal) var(--ease-out);
}
.reveal.in-view, [data-reveal].in-view { opacity: 1; transform: translateY(0); }
.reveal.delay-1 { transition-delay: 0.08s; }
.reveal.delay-2 { transition-delay: 0.16s; }
.reveal.delay-3 { transition-delay: 0.24s; }
.reveal.delay-4 { transition-delay: 0.32s; }

.hover-lift { transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out); }
.hover-lift:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes nav-underline { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 0 0 var(--brand-glow); }
  50% { box-shadow: 0 0 0 8px rgba(254, 100, 176, 0); }
}
@keyframes float-a { 0%,100% { transform: translate(0,0); } 50% { transform: translate(20px,-30px); } }
@keyframes float-b { 0%,100% { transform: translate(0,0); } 50% { transform: translate(-25px,20px); } }

/* =============================================================
   Reduced motion
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .reveal, [data-reveal] { opacity: 1 !important; transform: none !important; }
  .hover-lift:hover, .btn.primary:hover { transform: none; }
}
