/* ============================================================
   PRODUCTION MAIN — GLOBAL THEME
   ------------------------------------------------------------
   Single source of truth for design tokens, base styles and the
   shared page background. Load this BEFORE any page-specific
   stylesheet so tokens resolve consistently across the system.

     <link rel="stylesheet"
           href="{{ url_for('static', filename='css/theme.css') }}">
   ============================================================ */


/* ------------------------------------------------------------
   1. DESIGN TOKENS
   ------------------------------------------------------------ */
:root {
  color-scheme: light;

  /* Brand */
  --blue: #315cce;
  --blue-600: #2a51ba;
  --blue-700: #2448a9;
  --blue-soft: #edf3ff;
  --orange: #ff8a3d;
  --orange-500: #ff964f;
  --orange-soft: #fff2e6;
  --green: #39b987;

  /* Neutrals */
  --ink: #17243b;
  --muted: #718097;
  --line: #e6ebf2;
  --surface: #ffffff;
  --white: #ffffff;
  --page: #f5f7fa;
  --page-2: #eef2f8;

  /* Effects */
  --shadow-xs: 0 2px 7px rgba(25, 44, 76, 0.035);
  --shadow: 0 6px 20px rgba(25, 44, 76, 0.08);
  --shadow-lg: 0 16px 48px rgba(24, 42, 72, 0.10);
  --glass-surface: rgba(255, 255, 255, 0.76);
  --glass-border: rgba(255, 255, 255, 0.78);
  --radius: 11px;
  --radius-lg: 18px;

  /* Type */
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Focus ring */
  --focus: rgba(49, 92, 206, 0.34);

  /* Global background image (Production Main) */
  --bg-image: url("../image/background.webp");
  --bg-image-opacity: 0.78;
  --bg-image-size: cover;
  --bg-image-position: center;

  /* ------------------------------------------------------------
     LOGIN DESIGN TOKENS (shared across all login pages)
     ------------------------------------------------------------ */
  --login-primary: #2563eb;
  --login-primary-hover: #1d4ed8;
  --login-primary-soft: #eff6ff;
  --login-surface: #ffffff;
  --login-surface-soft: #f5f7fa;
  --login-text: #17243b;
  --login-text-secondary: #4b5563;
  --login-text-muted: #9ca3af;
  --login-border: #e1e7ef;
  --login-border-focus: rgba(37, 99, 235, 0.34);
  --login-radius: 12px;
  --login-radius-lg: 18px;
  --login-shadow: 0 15px 45px rgba(25, 49, 84, 0.08);
  --login-shadow-lg: 0 30px 70px rgba(16, 40, 80, 0.14);
  --login-transition: 180ms ease;
  --login-font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}


/* ------------------------------------------------------------
   2. BASE / RESET
   ------------------------------------------------------------ */
* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--page);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

::selection {
  background: rgba(49, 92, 206, 0.16);
}

/* Shared translucent card surface. Apply the class to page-specific cards;
   avoid targeting generic divs so tables, dialogs, and print layouts stay intact. */
.glass-card {
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  background: var(--glass-surface);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.68);
  -webkit-backdrop-filter: blur(14px) saturate(1.12);
  backdrop-filter: blur(14px) saturate(1.12);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass-card { background: rgba(255, 255, 255, 0.94); }
}

@media print {
  .glass-card { border-color: #d5dbe4; background: #fff; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* Scrollbar (Firefox + WebKit) */
* {
  scrollbar-width: thin;
  scrollbar-color: #c7d0de transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #c7d0de;
  border: 2px solid transparent;
  background-clip: content-box;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #aeb9cc;
  background-clip: content-box;
}


/* ------------------------------------------------------------
   3. SHARED PAGE BACKGROUND
   ------------------------------------------------------------
   Drop this markup as the first child of <body> on any page:

     <div class="page-background" aria-hidden="true">
       <div class="background-orb orb-blue"></div>
       <div class="background-orb orb-orange"></div>
       <div class="background-grid"></div>
     </div>
   ------------------------------------------------------------ */
.page-background {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  pointer-events: none;
  background:
    radial-gradient(1100px 520px at 12% -10%, rgba(85, 145, 255, 0.10), transparent 60%),
    radial-gradient(900px 520px at 105% 110%, rgba(255, 150, 79, 0.10), transparent 60%),
    linear-gradient(135deg, #f7f9fc, var(--page-2));
}

/* Global background image layer (sits above the gradient, below orbs/grid).
   Adjust --bg-image-opacity to make the image stronger or more subtle. */
.page-background::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--bg-image);
  background-size: var(--bg-image-size);
  background-position: var(--bg-image-position);
  background-repeat: no-repeat;
  opacity: var(--bg-image-opacity);
  pointer-events: none;
}

.background-grid {
  position: absolute;
  inset: 0;
  opacity: 0.16;
  background-image:
    linear-gradient(rgba(103, 128, 165, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(103, 128, 165, 0.12) 1px, transparent 1px);
  background-size: 40px 40px;
  -webkit-mask-image: linear-gradient(90deg, #000, transparent 90%);
  mask-image: linear-gradient(90deg, #000, transparent 90%);
}

.background-orb {
  position: absolute;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  filter: blur(75px);
  opacity: 0.14;
  will-change: transform;
  animation: orb-float 18s ease-in-out infinite;
}

.orb-blue {
  top: -160px;
  left: 8%;
  background: #5591ff;
}

.orb-orange {
  right: 5%;
  bottom: -180px;
  background: #ff9f5d;
  animation-delay: -9s;
}

@keyframes orb-float {

  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }

  50% {
    transform: translate3d(0, 18px, 0) scale(1.05);
  }
}


/* ------------------------------------------------------------
   4. OPTIONAL DARK THEME  (starter — opt in with:
        <html lang="en" data-theme="dark">
   Note: some component panels use hard-coded light surfaces and
   will need follow-up for a fully dark experience.)
   ------------------------------------------------------------ */
[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e8edf6;
  --muted: #9aa7bd;
  --line: #27324a;
  --surface: #172033;
  --white: #1b2537;
  --page: #0e1626;
  --page-2: #0b1320;
  --blue-soft: #1c2740;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.45);
  --focus: rgba(120, 165, 255, 0.5);
}

[data-theme="dark"] .page-background {
  background:
    radial-gradient(1100px 520px at 12% -10%, rgba(85, 145, 255, 0.16), transparent 60%),
    radial-gradient(900px 520px at 105% 110%, rgba(255, 150, 79, 0.12), transparent 60%),
    linear-gradient(135deg, #101a2c, #0b1320);
}

[data-theme="dark"] body > :not(.page-background) {
  position: relative;
  z-index: 1;
}

[data-theme="dark"] .page-background::before {
  opacity: 0.4;
}

[data-theme="dark"] .background-grid {
  background-image:
    linear-gradient(rgba(150, 175, 220, 0.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(150, 175, 220, 0.10) 1px, transparent 1px);
}


/* ------------------------------------------------------------
   5. MOTION PREFERENCES
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}