/* ==========================================================================
   base.css — Design tokens, reset, typography, utility classes
   Staff Portal — fourhorsemen
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties (Design Tokens)
   -------------------------------------------------------------------------- */
:root {
  /* Colours */
  --col-bg:        #0f1117;
  --col-surface:   #1a1d27;
  --col-surface2:  #21253a;
  --col-surface3:  #2d3248;
  --col-border:    #2d3248;
  --col-border-hi: #4a5072;

  --col-primary:   #6366f1;
  --col-primary-h: #818cf8;
  --col-primary-d: #4f46e5;

  --col-success:   #22c55e;
  --col-warning:   #f59e0b;
  --col-danger:    #ef4444;
  --col-info:      #38bdf8;

  --col-text:      #e2e8f0;
  --col-text-mute: #94a3b8;
  --col-text-dim:  #64748b;

  /* Status colours */
  --col-status-new:         #818cf8;
  --col-status-open:        #38bdf8;
  --col-status-in-progress: #f59e0b;
  --col-status-pending:     #94a3b8;
  --col-status-investigating:#c084fc;
  --col-status-resolved:    #22c55e;
  --col-status-closed:      #64748b;
  --col-status-cancelled:   #ef4444;

  /* Priority colours */
  --col-priority-low:      #22c55e;
  --col-priority-medium:   #38bdf8;
  --col-priority-high:     #f59e0b;
  --col-priority-critical: #ef4444;

  /* Dispute status */
  --col-dispute-filed:       #38bdf8;
  --col-dispute-investigating:#c084fc;
  --col-dispute-approved:    #22c55e;
  --col-dispute-rejected:    #ef4444;

  /* Wager status */
  --col-wager-open:      #22c55e;
  --col-wager-active:    #38bdf8;
  --col-wager-disputed:  #ef4444;
  --col-wager-resolved:  #22c55e;
  --col-wager-cancelled: #64748b;

  /* Presence */
  --col-online:  #22c55e;
  --col-away:    #f59e0b;
  --col-busy:    #ef4444;
  --col-offline: #64748b;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'Fira Code', 'Consolas', monospace;

  --text-xs:   11px;
  --text-sm:   13px;
  --text-base: 14px;
  --text-md:   15px;
  --text-lg:   17px;
  --text-xl:   20px;
  --text-2xl:  24px;
  --text-3xl:  30px;

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semi:   600;
  --weight-bold:   700;

  /* Radius */
  --r-sm:   4px;
  --r-md:   6px;
  --r-lg:   8px;
  --r-xl:   12px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.6);

  /* Transitions */
  --t-fast:   100ms ease;
  --t-normal: 200ms ease;
  --t-slow:   350ms ease;

  /* Layout */
  --sidebar-w:  240px;
  --header-h:   60px;

  /* Legacy aliases still referenced by page templates */
  --space-1: var(--sp-1);
  --space-2: var(--sp-2);
  --space-3: var(--sp-3);
  --space-4: var(--sp-4);
  --space-5: var(--sp-5);
  --space-6: var(--sp-6);
  --space-8: var(--sp-8);
  --space-10: var(--sp-10);
  --space-12: var(--sp-12);

  --primary: var(--col-primary);
  --border-color: var(--col-border);
  --text-muted: var(--col-text-mute);
  --surface-hover: var(--col-surface2);
  --col-surface1: var(--col-surface);
}

/* --------------------------------------------------------------------------
   CSS Reset
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-normal);
  line-height: 1.5;
  color: var(--col-text);
  background: var(--col-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--col-primary-h); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font: inherit; }

ul, ol { list-style: none; }

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

hr {
  border: none;
  border-top: 1px solid var(--col-border);
  margin: var(--sp-4) 0;
}

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--weight-semi);
  line-height: 1.3;
  color: var(--col-text);
}
h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-md); }
h6 { font-size: var(--text-base); }

p { margin-bottom: var(--sp-3); }
p:last-child { margin-bottom: 0; }

code, pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

pre {
  background: var(--col-surface2);
  border: 1px solid var(--col-border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  overflow-x: auto;
}

/* --------------------------------------------------------------------------
   Utility Classes
   -------------------------------------------------------------------------- */
.text-xs   { font-size: var(--text-xs); }
.text-sm   { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg   { font-size: var(--text-lg); }
.text-xl   { font-size: var(--text-xl); }

.text-mute  { color: var(--col-text-mute); }
.text-muted { color: var(--col-text-mute); }
.text-dim   { color: var(--col-text-dim); }
.text-primary { color: var(--col-primary-h); }
.text-success { color: var(--col-success); }
.text-warning { color: var(--col-warning); }
.text-danger  { color: var(--col-danger); }
.text-info    { color: var(--col-info); }

.font-mono   { font-family: var(--font-mono); }
.font-medium { font-weight: var(--weight-medium); }
.font-semi   { font-weight: var(--weight-semi); }
.font-bold   { font-weight: var(--weight-bold); }

.truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

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

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-4); }

.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mb-1 { margin-bottom: var(--sp-1); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }

.p-2 { padding: var(--sp-2); }
.p-3 { padding: var(--sp-3); }
.p-4 { padding: var(--sp-4); }
.p-6 { padding: var(--sp-6); }
.px-2 { padding-left: var(--sp-2); padding-right: var(--sp-2); }
.px-3 { padding-left: var(--sp-3); padding-right: var(--sp-3); }
.px-4 { padding-left: var(--sp-4); padding-right: var(--sp-4); }
.py-2 { padding-top: var(--sp-2); padding-bottom: var(--sp-2); }
.py-3 { padding-top: var(--sp-3); padding-bottom: var(--sp-3); }

.hidden  { display: none !important; }
.visible { display: block !important; }

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

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

.border   { border: 1px solid var(--col-border); }
.border-t { border-top: 1px solid var(--col-border); }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.skeleton-cell {
  display: inline-block;
  width: 100%;
  height: 14px;
  background: var(--col-surface2);
  border-radius: var(--r-sm);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}
.border-b { border-bottom: 1px solid var(--col-border); }

.surface  { background: var(--col-surface); }
.surface2 { background: var(--col-surface2); }

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

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

/* Scrollbars */
::-webkit-scrollbar        { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: var(--col-border-hi); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--col-text-dim); }

/* Focus ring */
:focus-visible {
  outline: 2px solid var(--col-primary);
  outline-offset: 2px;
}

/* Skeleton loading animation */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1;   }
}
.skeleton {
  background: var(--col-surface2);
  border-radius: var(--r-md);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}
.skeleton-text { height: 14px; margin-bottom: var(--sp-2); }
.skeleton-text.w-3\/4 { width: 75%; }
.skeleton-text.w-1\/2 { width: 50%; }

/* Fade in */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn var(--t-normal) ease forwards; }
