/* ============================================================================
   CARD SCANNER PRO — Premium SaaS Admin Design System
   Inspired by: Stripe, Linear, Vercel, Clerk
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ============================================================================
   LIGHT MODE (DEFAULT)
   ============================================================================ */
:root {
    /* === BRAND === */
    --brand-50:  #eef2ff;
    --brand-100: #e0e7ff;
    --brand-200: #c7d2fe;
    --brand-300: #a5b4fc;
    --brand-400: #818cf8;
    --brand-500: #6366f1;
    --brand-600: #4f46e5;
    --brand-700: #4338ca;
    --brand-800: #3730a3;
    --brand-900: #312e81;

    /* === NEUTRALS === */
    --gray-0:   #ffffff;
    --gray-25:  #fafafa;
    --gray-50:  #f7f7f8;
    --gray-100: #f0f0f2;
    --gray-150: #e8e8ec;
    --gray-200: #e2e2e8;
    --gray-300: #c8c8d4;
    --gray-400: #9898aa;
    --gray-500: #70708a;
    --gray-600: #52526e;
    --gray-700: #3a3a52;
    --gray-800: #26263a;
    --gray-900: #16162a;
    --gray-950: #0c0c1a;

    /* === SEMANTIC BACKGROUNDS === */
    --bg-page:       var(--gray-50);
    --bg-surface:    var(--gray-0);
    --bg-elevated:   var(--gray-0);
    --bg-sunken:     var(--gray-100);
    --bg-overlay:    rgba(0, 0, 0, 0.48);

    /* === SEMANTIC TEXT === */
    --text-primary:   var(--gray-900);
    --text-secondary: var(--gray-500);
    --text-tertiary:  var(--gray-400);
    --text-disabled:  var(--gray-300);
    --text-inverse:   var(--gray-0);
    --text-brand:     var(--brand-600);
    --text-on-brand:  #ffffff;

    /* === BORDERS === */
    --border-subtle:  var(--gray-150);
    --border-default: var(--gray-200);
    --border-strong:  var(--gray-300);
    --border-brand:   var(--brand-500);

    /* === BRAND ALIAS === */
    --color-primary:       var(--brand-600);
    --color-primary-hover: var(--brand-700);
    --color-primary-light: var(--brand-50);
    --color-primary-dark:  var(--brand-800);

    /* === STATUS COLORS === */
    --color-success:       #10b981;
    --color-success-light: #d1fae5;
    --color-success-text:  #065f46;
    --color-success-bg:    #ecfdf5;

    --color-warning:       #f59e0b;
    --color-warning-light: #fde68a;
    --color-warning-text:  #78350f;
    --color-warning-bg:    #fffbeb;

    --color-danger:        #ef4444;
    --color-danger-light:  #fecaca;
    --color-danger-text:   #7f1d1d;
    --color-danger-bg:     #fef2f2;

    --color-info:          #3b82f6;
    --color-info-light:    #dbeafe;
    --color-info-text:     #1e3a5f;
    --color-info-bg:       #eff6ff;

    --color-purple:        #8b5cf6;
    --color-purple-light:  #ede9fe;
    --color-purple-text:   #4c1d95;
    --color-purple-bg:     #f5f3ff;

    /* === COMPATIBILITY ALIASES === */
    --bg-primary:    var(--bg-surface);
    --bg-secondary:  var(--bg-page);
    --bg-tertiary:   var(--bg-sunken);
    --border-color:  var(--border-default);
    --border-light:  var(--border-subtle);
    --border-dark:   var(--border-strong);
    --success-bg:    var(--color-success-bg);
    --success-text:  var(--color-success-text);
    --warning-bg:    var(--color-warning-bg);
    --warning-text:  var(--color-warning-text);
    --danger-bg:     var(--color-danger-bg);
    --danger-text:   var(--color-danger-text);
    --info-bg:       var(--color-info-bg);
    --info-text:     var(--color-info-text);

    /* === LEGACY ALIASES (referenced in tables.css, operations.css, etc.) === */
    /* These map old naming conventions to the design system tokens */
    --bg-card:        var(--bg-surface);
    --bg-card-hover:  var(--bg-sunken);
    --bg-subtle:      var(--bg-sunken);
    --border:         var(--border-default);
    --accent:         var(--brand-500);
    --text-muted:     var(--text-tertiary);
    --transition:     all var(--duration-base) var(--easing-in-out);
    --color-primary-subtle: var(--brand-50);

    /* === EXTRA FONT SIZES === */
    --font-size-xxs: 0.625rem;   /* 10px */

    /* === WARNING SEMANTIC === */
    --color-warning-hover: #d97706;
    --btn-warning-bg:      var(--color-warning);
    --btn-warning-border:  var(--color-warning-hover);

    /* === TABLE COLUMN WIDTHS (design system) === */
    --col-w-avatar:   80px;
    --col-w-name:     220px;
    --col-w-email:    280px;
    --col-w-username: 180px;
    --col-w-phone:    170px;
    --col-w-role:     180px;
    --col-w-status:   140px;
    --col-w-perms:    220px;
    --col-w-date:     180px;
    --col-w-actions:  160px;
    --col-w-id:        80px;

    /* === SHADOWS === */
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.1), 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.1), 0 2px 4px -2px rgba(16, 24, 40, 0.06);
    --shadow-lg: 0 12px 24px -4px rgba(16, 24, 40, 0.12), 0 4px 8px -2px rgba(16, 24, 40, 0.08);
    --shadow-xl: 0 24px 48px -12px rgba(16, 24, 40, 0.18);
    --shadow-brand: 0 0 0 3px rgba(99, 102, 241, 0.15);
    --shadow-card: 0 1px 3px rgba(16,24,40,0.08), 0 1px 2px rgba(16,24,40,0.04);

    /* === SPACING === */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;

    /* === BORDER RADIUS === */
    --radius-xs: 3px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --radius-full: 9999px;

    /* === TYPOGRAPHY === */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Monaco', 'Courier New', monospace;

    --font-size-xs:   0.6875rem;  /* 11px */
    --font-size-sm:   0.8125rem;  /* 13px */
    --font-size-base: 0.875rem;   /* 14px */
    --font-size-md:   0.9375rem;  /* 15px */
    --font-size-lg:   1.0625rem;  /* 17px */
    --font-size-xl:   1.25rem;    /* 20px */
    --font-size-2xl:  1.5rem;     /* 24px */
    --font-size-3xl:  1.875rem;   /* 30px */
    --font-size-4xl:  2.25rem;    /* 36px */

    --font-weight-normal:   400;
    --font-weight-medium:   500;
    --font-weight-semibold: 600;
    --font-weight-bold:     700;
    --font-weight-extrabold:800;

    --line-height-tight:   1.2;
    --line-height-snug:    1.375;
    --line-height-normal:  1.5;
    --line-height-relaxed: 1.625;

    /* === LAYOUT === */
    --sidebar-width: 248px;
    --sidebar-width-collapsed: 68px;
    --header-height: 60px;
    --content-padding: 1.75rem;
    --max-content-width: 1600px;

    /* === TRANSITIONS === */
    --duration-fast:   100ms;
    --duration-base:   200ms;
    --duration-slow:   350ms;
    --easing-in:       cubic-bezier(0.4, 0, 1, 1);
    --easing-out:      cubic-bezier(0, 0, 0.2, 1);
    --easing-in-out:   cubic-bezier(0.4, 0, 0.2, 1);
    --easing-spring:   cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================================================
   DARK MODE
   ============================================================================ */
:root.dark-mode {
    --bg-page:       #0e0e1a;
    --bg-surface:    #16162a;
    --bg-elevated:   #1e1e36;
    --bg-sunken:     #0a0a14;
    --bg-overlay:    rgba(0, 0, 0, 0.72);

    --text-primary:   #f0f0f8;
    --text-secondary: #9898b8;
    --text-tertiary:  #6060808;
    --text-disabled:  #404058;
    --text-inverse:   #0e0e1a;
    --text-brand:     var(--brand-400);

    --border-subtle:  rgba(255,255,255,0.04);
    --border-default: rgba(255,255,255,0.08);
    --border-strong:  rgba(255,255,255,0.14);

    --color-primary:       var(--brand-500);
    --color-primary-hover: var(--brand-400);
    --color-primary-light: rgba(99,102,241,0.12);
    --color-primary-dark:  var(--brand-300);

    --color-success:       #34d399;
    --color-success-bg:    rgba(52,211,153,0.1);
    --color-success-text:  #6ee7b7;
    --color-success-light: rgba(52,211,153,0.2);

    --color-warning:       #fbbf24;
    --color-warning-bg:    rgba(251,191,36,0.1);
    --color-warning-text:  #fde68a;
    --color-warning-light: rgba(251,191,36,0.2);

    --color-danger:        #f87171;
    --color-danger-bg:     rgba(248,113,113,0.1);
    --color-danger-text:   #fca5a5;
    --color-danger-light:  rgba(248,113,113,0.2);

    --color-info:          #60a5fa;
    --color-info-bg:       rgba(96,165,250,0.1);
    --color-info-text:     #93c5fd;
    --color-info-light:    rgba(96,165,250,0.2);

    --color-purple:        #a78bfa;
    --color-purple-bg:     rgba(167,139,250,0.1);
    --color-purple-text:   #c4b5fd;
    --color-purple-light:  rgba(167,139,250,0.2);

    /* compatibility */
    --bg-primary:    var(--bg-surface);
    --bg-secondary:  var(--bg-page);
    --bg-tertiary:   var(--bg-sunken);
    --border-color:  var(--border-default);
    --border-light:  var(--border-subtle);
    --border-dark:   var(--border-strong);
    --success-bg:    var(--color-success-bg);
    --success-text:  var(--color-success-text);
    --warning-bg:    var(--color-warning-bg);
    --warning-text:  var(--color-warning-text);
    --danger-bg:     var(--color-danger-bg);
    --danger-text:   var(--color-danger-text);
    --info-bg:       var(--color-info-bg);
    --info-text:     var(--color-info-text);

    --shadow-xs: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.4);
    --shadow-lg: 0 12px 24px rgba(0,0,0,0.5);
    --shadow-xl: 0 24px 48px rgba(0,0,0,0.6);
    --shadow-card: 0 1px 3px rgba(0,0,0,0.4);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
    color: var(--text-primary);
    background-color: var(--bg-page);
    transition: background-color var(--duration-base), color var(--duration-base);
    min-height: 100vh;
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img, svg { display: block; }
button { font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ============================================================================
   TYPOGRAPHY UTILITIES
   ============================================================================ */
.text-xs       { font-size: var(--font-size-xs); }
.text-sm       { font-size: var(--font-size-sm); }
.text-base     { font-size: var(--font-size-base); }
.text-lg       { font-size: var(--font-size-lg); }
.text-xl       { font-size: var(--font-size-xl); }
.text-2xl      { font-size: var(--font-size-2xl); }

.text-primary   { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-tertiary  { color: var(--text-tertiary) !important; }
.text-brand     { color: var(--color-primary) !important; }
.text-success   { color: var(--color-success) !important; }
.text-warning   { color: var(--color-warning) !important; }
.text-danger    { color: var(--color-danger) !important; }

.font-normal    { font-weight: var(--font-weight-normal); }
.font-medium    { font-weight: var(--font-weight-medium); }
.font-semibold  { font-weight: var(--font-weight-semibold); }
.font-bold      { font-weight: var(--font-weight-bold); }

.text-center    { text-align: center; }
.text-right     { text-align: right; }
.text-left      { text-align: left; }
.text-mono      { font-family: var(--font-mono); }
.uppercase      { text-transform: uppercase; letter-spacing: 0.05em; }
.truncate       { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================================
   LAYOUT UTILITIES
   ============================================================================ */
.flex           { display: flex; }
.flex-col       { display: flex; flex-direction: column; }
.flex-center    { display: flex; align-items: center; justify-content: center; }
.flex-between   { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap      { flex-wrap: wrap; }
.items-center   { align-items: center; }
.items-start    { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-end    { justify-content: flex-end; }
.flex-1         { flex: 1; }
.shrink-0       { flex-shrink: 0; }

.grid           { display: grid; }
.hidden         { display: none !important; }
.invisible      { visibility: hidden; }

.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-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

/* ============================================================================
   INTERACTIVE STATES
   ============================================================================ */
.cursor-pointer { cursor: pointer; }
.cursor-default { cursor: default; }
.pointer-events-none { pointer-events: none; }
.select-none { user-select: none; }

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

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }
