/* ============================================================
   SCREENFLOW BACKOFFICE — CORE.CSS
   Design System: Tokens, Reset, Typography, Base
   ============================================================ */

/* ---- Google Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Raleway:wght@300;400;500;600;700;800&family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

/* ============================================================
   DESIGN TOKENS — CSS CUSTOM PROPERTIES
   ============================================================ */
:root {
  /* Brand */
  --brand-primary:        #F26F26;
  --brand-primary-hover:  #D95F1A;
  --brand-primary-light:  #FEF1E9;
  --brand-primary-muted:  rgba(242,111,38,0.12);
  --brand-secondary:      #1E1C24;
  --brand-accent:         #623BD7;

  /* Content */
  --color-text-primary:   #1E1C24;
  --color-text-secondary: #4E5359;
  --color-text-tertiary:  #A3ACB6;
  --color-text-disabled:  #DADEE2;
  --color-text-inverse:   #FFFFFF;
  --color-text-link:      #F26F26;
  --color-text-link-hover:#D95F1A;

  /* Backgrounds */
  --color-bg-app:         #F5F7FA;
  --color-bg-surface:     #FFFFFF;
  --color-bg-subtle:      #F1F4F7;
  --color-bg-muted:       #E7ECF2;
  --color-bg-overlay:     rgba(30,28,36,0.48);

  /* Status */
  --color-success:        #36915F;
  --color-success-bg:     #ECF8F1;
  --color-success-border: #43B577;
  --color-warning:        #977620;
  --color-warning-bg:     #FEF9EB;
  --color-warning-border: #F8C236;
  --color-danger:         #A32700;
  --color-danger-bg:      #FAE3DD;
  --color-danger-border:  #CC3100;
  --color-info:           #3E76BB;
  --color-info-bg:        #EDF4FD;
  --color-info-border:    #4D92E7;

  /* Borders */
  --color-border:         #D1D8DE;
  --color-border-strong:  #C9CACF;
  --color-border-hover:   #ADB0B6;
  --color-border-focus:   #F26F26;

  /* Shadows */
  --shadow-xs:   0 1px 2px rgba(30,28,36,0.06);
  --shadow-sm:   0 1px 4px rgba(30,28,36,0.08), 0 1px 2px rgba(30,28,36,0.04);
  --shadow-md:   0 4px 12px rgba(30,28,36,0.10), 0 2px 4px rgba(30,28,36,0.06);
  --shadow-lg:   0 8px 24px rgba(30,28,36,0.12), 0 4px 8px rgba(30,28,36,0.06);
  --shadow-xl:   0 16px 48px rgba(30,28,36,0.16), 0 8px 16px rgba(30,28,36,0.08);
  --shadow-focus:0 0 0 3px rgba(242,111,38,0.22);

  /* Radius */
  --radius-xs:   4px;
  --radius-sm:   6px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-2xl:  24px;
  --radius-full: 9999px;

  /* Spacing (8px grid) */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-7:  28px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Typography */
  --font-display: 'Raleway', sans-serif;
  --font-body:    'DM Sans', sans-serif;
  --font-mono:    'DM Mono', monospace;

  --text-xs:   11px;
  --text-sm:   12px;
  --text-base: 14px;
  --text-md:   15px;
  --text-lg:   16px;
  --text-xl:   18px;
  --text-2xl:  20px;
  --text-3xl:  24px;
  --text-4xl:  28px;
  --text-5xl:  36px;

  --leading-tight:  1.25;
  --leading-snug:   1.375;
  --leading-normal: 1.5;
  --leading-relaxed:1.625;

  /* Layout */
  --sidebar-width:       228px;
  --sidebar-width-mini:  64px;
  --topbar-height:       56px;
  --content-max-width:   1440px;

  /* Transitions */
  --transition-fast:   all 0.12s ease;
  --transition-base:   all 0.18s ease;
  --transition-slow:   all 0.28s ease;
  --transition-spring: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Z-index */
  --z-dropdown:  1000;
  --z-sticky:    1020;
  --z-fixed:     1030;
  --z-modal-bg:  1040;
  --z-offcanvas: 1050;
  --z-modal:     1060;
  --z-popover:   1070;
  --z-toast:     1090;
  --z-tooltip:   1100;

  /* ── Compatibility aliases ─────────────────────────────────
     Some pages use alternate token names. These aliases ensure
     they resolve correctly without altering every HTML file.
  ──────────────────────────────────────────────────────────── */
  /* Background aliases */
  --bg-tertiary:           var(--color-bg-subtle);
  --color-bg-secondary:    var(--color-bg-subtle);
  --color-bg-tertiary:     var(--color-bg-subtle);
  --color-surface:         var(--color-bg-surface);
  --color-hover:           var(--color-bg-muted);

  /* Brand / primary aliases */
  --primary:               var(--brand-primary);
  --color-primary:         var(--brand-primary);
  --color-primary-light:   var(--brand-primary-light);
  --color-primary-muted:   var(--brand-primary-muted);
  --color-purple:          var(--brand-accent);

  /* Semantic color aliases */
  --success:               var(--color-success);
  --warning:               var(--color-warning);
  --danger:                var(--color-danger);
  --info:                  var(--color-info);

  /* Muted / bg semantic aliases */
  --color-success-muted:   var(--color-success-bg);
  --color-warning-muted:   var(--color-warning-bg);
  --color-danger-muted:    var(--color-danger-bg);
}

/* ============================================================
   DARK MODE TOKENS
   ============================================================ */
[data-theme="dark"] {
  --color-text-primary:   rgba(255,255,255,0.92);
  --color-text-secondary: rgba(255,255,255,0.65);
  --color-text-tertiary:  rgba(255,255,255,0.42);
  --color-text-disabled:  rgba(255,255,255,0.28);
  --color-text-inverse:   #1E1C24;

  --color-bg-app:         #1A1D27;
  --color-bg-surface:     #222531;
  --color-bg-subtle:      #2A2E3B;
  --color-bg-muted:       #323645;
  --color-bg-overlay:     rgba(0,0,0,0.6);

  --color-border:         rgba(255,255,255,0.10);
  --color-border-strong:  rgba(255,255,255,0.15);
  --color-border-hover:   rgba(255,255,255,0.22);

  --color-success-bg:     rgba(67,181,119,0.12);
  --color-warning-bg:     rgba(248,194,54,0.12);
  --color-danger-bg:      rgba(204,49,0,0.12);
  --color-info-bg:        rgba(77,146,231,0.12);

  --shadow-sm:  0 1px 4px rgba(0,0,0,0.24);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.28);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.36);
  --shadow-xl:  0 16px 48px rgba(0,0,0,0.44);
}

/* ============================================================
   RESET & BOX MODEL
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, svg, video {
  max-width: 100%;
  display: block;
}

a {
  color: var(--color-text-link);
  text-decoration: none;
  transition: var(--transition-fast);
}
a:hover { color: var(--color-text-link-hover); }

ul, ol { list-style: none; }

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ============================================================
   TYPOGRAPHY SYSTEM
   ============================================================ */
.font-display { font-family: var(--font-display); }
.font-body    { font-family: var(--font-body); }
.font-mono    { font-family: var(--font-mono); }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--leading-tight);
  color: var(--color-text-primary);
  letter-spacing: -0.01em;
}

h1 { font-size: var(--text-5xl); }
h2 { font-size: var(--text-4xl); }
h3 { font-size: var(--text-3xl); }
h4 { font-size: var(--text-2xl); }
h5 { font-size: var(--text-xl); }
h6 { font-size: var(--text-lg); }

.page-title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.02em;
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-text-primary);
}

.label-sm {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-tertiary);
}

.text-muted    { color: var(--color-text-secondary) !important; }
.text-tertiary { color: var(--color-text-tertiary) !important; }
.text-disabled { color: var(--color-text-disabled) !important; }
.text-primary  { color: var(--brand-primary) !important; }
.text-success  { color: var(--color-success) !important; }
.text-warning  { color: var(--color-warning) !important; }
.text-danger   { color: var(--color-danger) !important; }
.text-info     { color: var(--color-info) !important; }
.text-sm       { font-size: var(--text-sm) !important; }
.text-xs       { font-size: var(--text-xs) !important; }
.text-base     { font-size: var(--text-base) !important; }
.text-lg       { font-size: var(--text-lg) !important; }
.text-xl       { font-size: var(--text-xl) !important; }
.fw-400        { font-weight: 400; }
.fw-500        { font-weight: 500; }
.fw-600        { font-weight: 600; }
.fw-700        { font-weight: 700; }

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.d-flex        { display: flex; }
.d-grid        { display: grid; }
.d-block       { display: block; }
.d-inline-flex { display: inline-flex; }
.d-none        { display: none !important; }

.flex-col      { flex-direction: column; }
.flex-wrap     { flex-wrap: wrap; }
.align-center  { align-items: center; }
.align-start   { align-items: flex-start; }
.align-end     { align-items: flex-end; }
.justify-center{ justify-content: center; }
.justify-between{ justify-content: space-between; }
.justify-end   { justify-content: flex-end; }
.flex-1        { flex: 1 1 0%; }
.gap-1  { gap: var(--space-1); }
.gap-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.gap-4  { gap: var(--space-4); }
.gap-5  { gap: var(--space-5); }
.gap-6  { gap: var(--space-6); }

.p-0  { padding: 0 !important; }
.p-2  { padding: var(--space-2); }
.p-3  { padding: var(--space-3); }
.p-4  { padding: var(--space-4); }
.p-5  { padding: var(--space-5); }
.p-6  { padding: var(--space-6); }
.p-8  { padding: var(--space-8); }
.px-2 { padding-inline: var(--space-2); }
.px-3 { padding-inline: var(--space-3); }
.px-4 { padding-inline: var(--space-4); }
.px-6 { padding-inline: var(--space-6); }
.py-2 { padding-block: var(--space-2); }
.py-3 { padding-block: var(--space-3); }
.py-4 { padding-block: var(--space-4); }
.py-6 { padding-block: var(--space-6); }

.mt-0 { margin-top: 0 !important; }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.ms-auto { margin-left: auto; }
.me-auto { margin-right: auto; }

.w-full  { width: 100%; }
.h-full  { height: 100%; }
.min-w-0 { min-width: 0; }

.rounded-sm   { border-radius: var(--radius-sm); }
.rounded-md   { border-radius: var(--radius-md); }
.rounded-lg   { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

.shadow-sm  { box-shadow: var(--shadow-sm); }
.shadow-md  { box-shadow: var(--shadow-md); }
.shadow-lg  { box-shadow: var(--shadow-lg); }

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

.overflow-hidden { overflow: hidden; }
.overflow-auto   { overflow: auto; }
.text-ellipsis   { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.text-center     { text-align: center; }
.text-right      { text-align: right; }
.whitespace-nowrap{ white-space: nowrap; }
.pointer-none    { pointer-events: none; }
.opacity-0       { opacity: 0; }
.opacity-50      { opacity: 0.5; }

.cursor-pointer  { cursor: pointer; }
.select-none     { user-select: none; }

.position-relative { position: relative; }
.position-absolute { position: absolute; }

/* ============================================================
   SCROLLBAR STYLING
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--color-border-strong);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--color-border-hover); }

/* ============================================================
   FOCUS VISIBLE
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}
