/* ============================================================
   DANH DESIGN SYSTEM — v1.0
   CSS Variables + Components cho mọi dự án
   ============================================================ */

/* ============================================================
   1. THEME VARIABLES (Light + Dark)
   ============================================================ */

:root {
  /* --- Màu nền --- */
  --bg-base:        #f8f7f4;
  --bg-surface:     #ffffff;
  --bg-elevated:    #f0ede8;
  --bg-overlay:     rgba(0, 0, 0, 0.45);

  /* --- Màu chính (Primary) --- */
  --primary-50:     #fff7ed;
  --primary-100:    #ffedd5;
  --primary-200:    #fed7aa;
  --primary-300:    #fdba74;
  --primary-400:    #fb923c;
  --primary-500:    #f97316;
  --primary-600:    #ea6c0c;
  --primary-700:    #c2560a;
  --primary-800:    #9a4209;
  --primary-900:    #7c3409;

  --primary:        var(--primary-500);
  --primary-hover:  var(--primary-600);
  --primary-active: var(--primary-700);
  --primary-light:  var(--primary-100);
  --primary-fg:     #ffffff;

  /* --- Màu phụ (Secondary) --- */
  --secondary:      #0ea5e9;
  --secondary-hover:#0284c7;
  --secondary-light:#e0f2fe;
  --secondary-fg:   #ffffff;

  /* --- Màu accent --- */
  --accent:         #8b5cf6;
  --accent-hover:   #7c3aed;
  --accent-light:   #ede9fe;
  --accent-fg:      #ffffff;

  /* --- Màu ngữ nghĩa --- */
  --success:        #22c55e;
  --success-light:  #dcfce7;
  --success-fg:     #14532d;

  --warning:        #f59e0b;
  --warning-light:  #fef3c7;
  --warning-fg:     #78350f;

  --error:          #ef4444;
  --error-light:    #fee2e2;
  --error-fg:       #7f1d1d;

  --info:           #3b82f6;
  --info-light:     #dbeafe;
  --info-fg:        #1e3a8a;

  /* --- Màu chữ --- */
  --text-primary:   #1a1714;
  --text-secondary: #6b6560;
  --text-muted:     #a09890;
  --text-inverted:  #ffffff;
  --text-link:      var(--primary);
  --text-link-hover:var(--primary-hover);

  /* --- Viền (Border) --- */
  --border-color:   #e5e0d8;
  --border-strong:  #c8c0b5;
  --border-subtle:  #f0ede8;
  --border-focus:   var(--primary);
  --border-radius-xs: 4px;
  --border-radius-sm: 6px;
  --border-radius:  10px;
  --border-radius-md: 14px;
  --border-radius-lg: 20px;
  --border-radius-xl: 28px;
  --border-radius-full: 9999px;

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

  /* --- Typography --- */
  --font-display:  'Playfair Display', Georgia, serif;
  --font-body:     'DM Sans', 'Segoe UI', sans-serif;
  --font-mono:     'JetBrains Mono', 'Fira Code', monospace;
  --font-ui:       'DM Sans', system-ui, sans-serif;

  --text-xs:   0.75rem;    /* 12px */
  --text-sm:   0.875rem;   /* 14px */
  --text-base: 1rem;       /* 16px */
  --text-md:   1.125rem;   /* 18px */
  --text-lg:   1.25rem;    /* 20px */
  --text-xl:   1.5rem;     /* 24px */
  --text-2xl:  1.875rem;   /* 30px */
  --text-3xl:  2.25rem;    /* 36px */
  --text-4xl:  3rem;       /* 48px */
  --text-5xl:  3.75rem;    /* 60px */
  --text-6xl:  4.5rem;     /* 72px */

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

  --tracking-tight: -0.025em;
  --tracking-normal: 0em;
  --tracking-wide:  0.025em;
  --tracking-wider: 0.05em;
  --tracking-widest:0.1em;

  --font-thin:       100;
  --font-light:      300;
  --font-normal:     400;
  --font-medium:     500;
  --font-semibold:   600;
  --font-bold:       700;
  --font-extrabold:  800;
  --font-black:      900;

  /* --- Bóng đổ (Shadows) --- */
  --shadow-xs:  0 1px 2px rgba(0,0,0,.06);
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow:     0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-md:  0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.05);
  --shadow-lg:  0 20px 25px -5px rgba(0,0,0,.09), 0 8px 10px -6px rgba(0,0,0,.05);
  --shadow-xl:  0 25px 50px -12px rgba(0,0,0,.18);
  --shadow-inner:0 2px 4px 0 rgba(0,0,0,.06) inset;
  --shadow-glow:0 0 20px rgba(249,115,22,.25);
  --shadow-glow-secondary: 0 0 20px rgba(14,165,233,.25);
  --shadow-glow-accent: 0 0 20px rgba(139,92,246,.25);
  --shadow-colored: 0 8px 24px -4px rgba(249,115,22,.35);

  /* --- Transitions --- */
  --duration-instant: 50ms;
  --duration-fast:    150ms;
  --duration-normal:  250ms;
  --duration-slow:    400ms;
  --duration-slower:  600ms;

  --ease-linear:  linear;
  --ease-in:      cubic-bezier(0.4, 0, 1, 1);
  --ease-out:     cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out:  cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce:  cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-spring:  cubic-bezier(0.175, 0.885, 0.32, 1.275);

  --transition-all:    all var(--duration-normal) var(--ease-in-out);
  --transition-colors: color var(--duration-fast) var(--ease-in-out),
                       background-color var(--duration-fast) var(--ease-in-out),
                       border-color var(--duration-fast) var(--ease-in-out);
  --transition-transform: transform var(--duration-normal) var(--ease-out);
  --transition-shadow:  box-shadow var(--duration-normal) var(--ease-in-out);
  --transition-opacity: opacity var(--duration-normal) var(--ease-in-out);

  /* --- Z-index --- */
  --z-below:    -1;
  --z-base:      0;
  --z-raised:    10;
  --z-dropdown:  100;
  --z-sticky:    200;
  --z-overlay:   300;
  --z-modal:     400;
  --z-popover:   500;
  --z-toast:     600;
  --z-tooltip:   700;
  --z-top:       999;

  /* --- Layout --- */
  --container-sm:  640px;
  --container-md:  768px;
  --container-lg:  1024px;
  --container-xl:  1280px;
  --container-2xl: 1536px;

  /* --- Opacity --- */
  --opacity-disabled: 0.45;
  --opacity-muted:    0.65;
  --opacity-overlay:  0.8;
}

/* ============================================================
   2. DARK MODE
   ============================================================ */

[data-theme="dark"], .dark {
  --bg-base:        #0f0e0c;
  --bg-surface:     #1a1814;
  --bg-elevated:    #252220;
  --bg-overlay:     rgba(0, 0, 0, 0.65);

  --text-primary:   #f0ede8;
  --text-secondary: #a09285;
  --text-muted:     #6e635a;
  --text-inverted:  #0f0e0c;

  --border-color:   #2e2a25;
  --border-strong:  #3d3830;
  --border-subtle:  #1f1d1a;

  --shadow-xs:  0 1px 2px rgba(0,0,0,.25);
  --shadow-sm:  0 1px 3px rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.25);
  --shadow:     0 4px 6px -1px rgba(0,0,0,.40), 0 2px 4px -2px rgba(0,0,0,.25);
  --shadow-md:  0 10px 15px -3px rgba(0,0,0,.45), 0 4px 6px -4px rgba(0,0,0,.25);
  --shadow-lg:  0 20px 25px -5px rgba(0,0,0,.50), 0 8px 10px -6px rgba(0,0,0,.30);
  --shadow-xl:  0 25px 50px -12px rgba(0,0,0,.60);
  --shadow-inner: 0 2px 4px 0 rgba(0,0,0,.30) inset;
}

/* ============================================================
   3. RESET & BASE
   ============================================================ */

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

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

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

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

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

/* ============================================================
   4. TYPOGRAPHY
   ============================================================ */

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

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); }

p {
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
}

.text-xs    { font-size: var(--text-xs); }
.text-sm    { font-size: var(--text-sm); }
.text-base  { font-size: var(--text-base); }
.text-md    { font-size: var(--text-md); }
.text-lg    { font-size: var(--text-lg); }
.text-xl    { font-size: var(--text-xl); }
.text-2xl   { font-size: var(--text-2xl); }
.text-3xl   { font-size: var(--text-3xl); }
.text-4xl   { font-size: var(--text-4xl); }
.text-5xl   { font-size: var(--text-5xl); }

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

.font-display { font-family: var(--font-display); }
.font-body    { font-family: var(--font-body); }
.font-mono    { font-family: var(--font-mono); }

.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-brand     { color: var(--primary); }
.text-success   { color: var(--success); }
.text-warning   { color: var(--warning); }
.text-error     { color: var(--error); }
.text-info      { color: var(--info); }

.text-left   { text-align: left; }
.text-center { text-align: center; }
.text-right  { text-align: right; }

.uppercase   { text-transform: uppercase; }
.lowercase   { text-transform: lowercase; }
.capitalize  { text-transform: capitalize; }

.tracking-tight   { letter-spacing: var(--tracking-tight); }
.tracking-wide    { letter-spacing: var(--tracking-wide); }
.tracking-widest  { letter-spacing: var(--tracking-widest); }

.leading-tight   { line-height: var(--leading-tight); }
.leading-normal  { line-height: var(--leading-normal); }
.leading-loose   { line-height: var(--leading-loose); }

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

code, kbd, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

code {
  background: var(--bg-elevated);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: var(--border-radius-xs);
  border: 1px solid var(--border-color);
}

pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: var(--space-6);
  overflow-x: auto;
  line-height: var(--leading-relaxed);
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-primary);
}

blockquote {
  border-left: 3px solid var(--primary);
  padding: var(--space-4) var(--space-6);
  background: var(--primary-light);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  color: var(--text-secondary);
  font-style: italic;
  margin: var(--space-6) 0;
}

hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: var(--space-8) 0;
}

/* ============================================================
   5. LAYOUT HELPERS
   ============================================================ */

.container {
  width: 100%;
  max-width: var(--container-xl);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-6);
  padding-right: var(--space-6);
}
.container-sm  { max-width: var(--container-sm); }
.container-md  { max-width: var(--container-md); }
.container-lg  { max-width: var(--container-lg); }

.flex          { display: flex; }
.inline-flex   { display: inline-flex; }
.grid          { display: grid; }
.block         { display: block; }
.inline-block  { display: inline-block; }
.hidden        { display: none; }

.flex-col      { flex-direction: column; }
.flex-row      { flex-direction: row; }
.flex-wrap     { flex-wrap: wrap; }
.flex-nowrap   { flex-wrap: nowrap; }

.items-start   { align-items: flex-start; }
.items-center  { align-items: center; }
.items-end     { align-items: flex-end; }
.items-stretch { align-items: stretch; }

.justify-start   { justify-content: flex-start; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.justify-around  { justify-content: space-around; }

.flex-1    { flex: 1; }
.flex-none { flex: none; }
.shrink-0  { flex-shrink: 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); }
.gap-8  { gap: var(--space-8); }

.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
.col-span-full { grid-column: 1 / -1; }

.relative { position: relative; }
.absolute { position: absolute; }
.fixed    { position: fixed; }
.sticky   { position: sticky; }

.inset-0  { inset: 0; }
.top-0    { top: 0; }
.bottom-0 { bottom: 0; }
.left-0   { left: 0; }
.right-0  { right: 0; }

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

.overflow-hidden   { overflow: hidden; }
.overflow-auto     { overflow: auto; }
.overflow-x-auto   { overflow-x: auto; }
.overflow-y-auto   { overflow-y: auto; }

.min-h-screen { min-height: 100vh; }

/* Padding / Margin utilities */
.p-0  { padding: 0; }
.p-1  { padding: var(--space-1); }
.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-left: var(--space-2);  padding-right: var(--space-2); }
.px-3 { padding-left: var(--space-3);  padding-right: var(--space-3); }
.px-4 { padding-left: var(--space-4);  padding-right: var(--space-4); }
.px-6 { padding-left: var(--space-6);  padding-right: var(--space-6); }
.px-8 { padding-left: var(--space-8);  padding-right: var(--space-8); }

.py-2 { padding-top: var(--space-2);  padding-bottom: var(--space-2); }
.py-3 { padding-top: var(--space-3);  padding-bottom: var(--space-3); }
.py-4 { padding-top: var(--space-4);  padding-bottom: var(--space-4); }
.py-6 { padding-top: var(--space-6);  padding-bottom: var(--space-6); }
.py-8 { padding-top: var(--space-8);  padding-bottom: var(--space-8); }

.m-auto { margin: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }
.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); }

/* ============================================================
   6. BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  line-height: 1;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition-all);
  white-space: nowrap;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.btn:disabled {
  opacity: var(--opacity-disabled);
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
  box-shadow: var(--shadow-sm), 0 0 0 0 rgba(249,115,22,0);
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-colored);
  transform: translateY(-1px);
}
.btn-primary:active {
  background: var(--primary-active);
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-fg);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
  background: var(--secondary-hover);
  box-shadow: var(--shadow-glow-secondary);
  transform: translateY(-1px);
}

.btn-accent {
  background: var(--accent);
  color: var(--accent-fg);
  box-shadow: var(--shadow-sm);
}
.btn-accent:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-glow-accent);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  box-shadow: none;
}
.btn-outline:hover {
  background: var(--primary-light);
  box-shadow: var(--shadow-sm);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  box-shadow: none;
}
.btn-ghost:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--error);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-danger:hover {
  background: #dc2626;
  transform: translateY(-1px);
}

/* Sizes */
.btn-xs { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); border-radius: var(--border-radius-sm); }
.btn-sm { padding: var(--space-2) var(--space-4); font-size: var(--text-sm); }
.btn-md { padding: var(--space-3) var(--space-5); font-size: var(--text-base); }
.btn-lg { padding: var(--space-4) var(--space-8); font-size: var(--text-md); border-radius: var(--border-radius-md); }
.btn-xl { padding: var(--space-5) var(--space-10); font-size: var(--text-lg); border-radius: var(--border-radius-md); }
.btn-full { width: 100%; }
.btn-pill { border-radius: var(--border-radius-full); }
.btn-square { padding: var(--space-3); aspect-ratio: 1; }

/* Loading state */
.btn-loading {
  pointer-events: none;
  opacity: 0.75;
}
.btn-loading::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: var(--space-2);
}

/* ============================================================
   7. FORM ELEMENTS
   ============================================================ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  font-family: var(--font-ui);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--error);
}

.input, .select, .textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius);
  outline: none;
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
  appearance: none;
}

.input:hover, .select:hover, .textarea:hover {
  border-color: var(--border-strong);
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(249,115,22,.15);
}

.input::placeholder, .textarea::placeholder {
  color: var(--text-muted);
}

.input.is-error { border-color: var(--error); }
.input.is-error:focus { box-shadow: 0 0 0 3px rgba(239,68,68,.15); }

.input.is-success { border-color: var(--success); }

.textarea { resize: vertical; min-height: 100px; }

.input-sm { padding: var(--space-2) var(--space-3); font-size: var(--text-xs); }
.input-lg { padding: var(--space-4) var(--space-5); font-size: var(--text-md); }

/* Input icon wrappers */
.input-wrapper {
  position: relative;
}
.input-wrapper .input {
  padding-left: var(--space-10);
}
.input-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* Checkbox / Radio */
.checkbox, .radio {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  user-select: none;
}
.checkbox input[type="checkbox"],
.radio input[type="radio"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-surface);
  border-radius: var(--border-radius-xs);
  cursor: pointer;
  transition: var(--transition-all);
  flex-shrink: 0;
  position: relative;
}
.radio input[type="radio"] { border-radius: 50%; }
.checkbox input:checked, .radio input:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.checkbox input:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  color: white;
  font-size: 11px;
  font-weight: 700;
}
.radio input:checked::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  width: 7px;
  height: 7px;
  background: white;
  border-radius: 50%;
}

/* Toggle switch */
.toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  user-select: none;
}
.toggle-track {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--border-strong);
  border-radius: var(--border-radius-full);
  transition: background var(--duration-fast) var(--ease-out);
  flex-shrink: 0;
}
.toggle input:checked + .toggle-label .toggle-track,
.toggle-track.active {
  background: var(--primary);
}
.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-fast) var(--ease-bounce);
}
.toggle-track.active .toggle-thumb {
  transform: translateX(20px);
}

/* ============================================================
   8. CARDS
   ============================================================ */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-out);
}

.card-hover:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-color);
}

.card-body {
  padding: var(--space-6);
}

.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-color);
  background: var(--bg-elevated);
}

.card-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0;
}

.card-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.card-image {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
}

.card-flat {
  border: none;
  box-shadow: none;
  background: var(--bg-elevated);
}

.card-outlined {
  background: transparent;
  box-shadow: none;
}

.card-glow:hover {
  box-shadow: var(--shadow-glow);
}

/* ============================================================
   9. BADGES & TAGS
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  border-radius: var(--border-radius-full);
  font-family: var(--font-ui);
  letter-spacing: var(--tracking-wide);
  line-height: 1.5;
}

.badge-default   { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border-color); }
.badge-primary   { background: var(--primary-light); color: var(--primary-700); }
.badge-secondary { background: var(--secondary-light); color: var(--secondary-hover); }
.badge-accent    { background: var(--accent-light); color: var(--accent-hover); }
.badge-success   { background: var(--success-light); color: var(--success-fg); }
.badge-warning   { background: var(--warning-light); color: var(--warning-fg); }
.badge-error     { background: var(--error-light); color: var(--error-fg); }
.badge-info      { background: var(--info-light); color: var(--info-fg); }

.badge-solid-primary { background: var(--primary); color: white; }
.badge-solid-success { background: var(--success); color: white; }
.badge-solid-error   { background: var(--error); color: white; }

/* Tag */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  cursor: default;
  transition: var(--transition-colors);
}
.tag:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary-200); }
.tag .tag-remove {
  cursor: pointer;
  opacity: 0.6;
  font-size: 14px;
  line-height: 1;
  margin-left: 2px;
}
.tag .tag-remove:hover { opacity: 1; color: var(--error); }

/* ============================================================
   10. ALERTS & NOTICES
   ============================================================ */

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--border-radius);
  border: 1px solid transparent;
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.alert-icon { font-size: var(--text-md); flex-shrink: 0; margin-top: 1px; }
.alert-title { font-weight: var(--font-semibold); margin-bottom: 2px; }

.alert-info    { background: var(--info-light);    color: var(--info-fg);    border-color: var(--info); }
.alert-success { background: var(--success-light); color: var(--success-fg); border-color: var(--success); }
.alert-warning { background: var(--warning-light); color: var(--warning-fg); border-color: var(--warning); }
.alert-error   { background: var(--error-light);   color: var(--error-fg);   border-color: var(--error); }

/* ============================================================
   11. PROGRESS & LOADING
   ============================================================ */

.progress {
  width: 100%;
  height: 8px;
  background: var(--bg-elevated);
  border-radius: var(--border-radius-full);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: var(--border-radius-full);
  transition: width var(--duration-slow) var(--ease-out);
}
.progress-bar-secondary { background: var(--secondary); }
.progress-bar-success   { background: var(--success); }
.progress-bar-warning   { background: var(--warning); }
.progress-bar-error     { background: var(--error); }
.progress-bar-striped {
  background-image: repeating-linear-gradient(
    45deg, transparent, transparent 5px,
    rgba(255,255,255,.2) 5px, rgba(255,255,255,.2) 10px
  );
}
.progress-bar-animated {
  animation: progress-stripes 1s linear infinite;
}
.progress-sm { height: 4px; }
.progress-lg { height: 12px; }

/* Spinner */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-sm { width: 16px; height: 16px; border-width: 2px; }
.spinner-lg { width: 36px; height: 36px; border-width: 3px; }
.spinner-secondary { border-top-color: var(--secondary); }

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg,
    var(--bg-elevated) 25%,
    var(--border-color) 50%,
    var(--bg-elevated) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: var(--border-radius);
}
.skeleton-text {
  height: 1em;
  border-radius: var(--border-radius-sm);
}
.skeleton-circle {
  border-radius: 50%;
  aspect-ratio: 1;
}

/* ============================================================
   12. AVATAR
   ============================================================ */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: var(--font-bold);
  font-family: var(--font-ui);
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-xs { width: 24px; height: 24px; font-size: 10px; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-md { width: 40px; height: 40px; font-size: 15px; }
.avatar-lg { width: 52px; height: 52px; font-size: 18px; }
.avatar-xl { width: 64px; height: 64px; font-size: 22px; }
.avatar-2xl { width: 80px; height: 80px; font-size: 28px; }

.avatar-group { display: flex; }
.avatar-group .avatar { border: 2px solid var(--bg-surface); margin-left: -8px; }
.avatar-group .avatar:first-child { margin-left: 0; }

/* ============================================================
   13. TOOLTIP & POPOVER
   ============================================================ */

[data-tooltip] { position: relative; cursor: default; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--text-primary);
  color: var(--text-inverted);
  font-size: var(--text-xs);
  font-family: var(--font-ui);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--border-radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
  z-index: var(--z-tooltip);
  box-shadow: var(--shadow-md);
}
[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   14. TABLE
   ============================================================ */

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-color);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th {
  padding: var(--space-3) var(--space-5);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-color);
}

.table td {
  padding: var(--space-4) var(--space-5);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover td {
  background: var(--bg-elevated);
}
.table-striped tbody tr:nth-child(even) td {
  background: var(--bg-elevated);
}

/* ============================================================
   15. MODAL / DIALOG
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
}
.modal-overlay.show { opacity: 1; }

.modal {
  background: var(--bg-surface);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--duration-normal) var(--ease-spring);
  overflow: hidden;
}
.modal-overlay.show .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-color);
}
.modal-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
}
.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-elevated);
  border-radius: var(--border-radius);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-colors);
}
.modal-close:hover { background: var(--error-light); color: var(--error); }
.modal-body { padding: var(--space-6); }
.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  background: var(--bg-elevated);
}

/* ============================================================
   16. DROPDOWN / MENU
   ============================================================ */

.dropdown { position: relative; display: inline-flex; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 180px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  padding: var(--space-2) 0;
  opacity: 0;
  transform: translateY(-6px) scale(0.97);
  pointer-events: none;
  transition: opacity var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}
.dropdown-menu.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-colors);
}
.dropdown-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.dropdown-item.active { color: var(--primary); font-weight: var(--font-medium); }
.dropdown-item.danger { color: var(--error); }
.dropdown-item.danger:hover { background: var(--error-light); }
.dropdown-divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: var(--space-2) 0;
}

/* ============================================================
   17. NAVIGATION
   ============================================================ */

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  height: 64px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,.88);
}

.dark .navbar { background: rgba(26,24,20,.88); }

.navbar-brand {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  text-decoration: none;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  list-style: none;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  border-radius: var(--border-radius);
  text-decoration: none;
  transition: var(--transition-colors);
}
.nav-link:hover { color: var(--text-primary); background: var(--bg-elevated); text-decoration: none; }
.nav-link.active { color: var(--primary); background: var(--primary-light); font-weight: var(--font-semibold); }

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
  list-style: none;
  flex-wrap: wrap;
}
.breadcrumb li::after { content: '/'; margin-left: var(--space-2); color: var(--border-strong); }
.breadcrumb li:last-child::after { content: none; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); text-decoration: none; }
.breadcrumb li:last-child { color: var(--text-primary); font-weight: var(--font-medium); }

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border-color);
  gap: 0;
  overflow-x: auto;
}
.tab-item {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition-colors);
  white-space: nowrap;
}
.tab-item:hover { color: var(--text-primary); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Pills tabs */
.tabs-pills {
  display: flex;
  gap: var(--space-2);
  background: var(--bg-elevated);
  padding: var(--space-1);
  border-radius: var(--border-radius-md);
  border: none;
}
.tabs-pills .tab-item {
  border: none;
  border-radius: var(--border-radius);
  margin-bottom: 0;
}
.tabs-pills .tab-item.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  border-bottom-color: transparent;
}

/* ============================================================
   18. DIVIDER / SECTION
   ============================================================ */

.section { padding: var(--space-16) 0; }
.section-sm { padding: var(--space-8) 0; }
.section-lg { padding: var(--space-24) 0; }

.divider {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-sm);
  margin: var(--space-6) 0;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border-color);
}

/* ============================================================
   19. UTILITY CLASSES (misc)
   ============================================================ */

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

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

.bg-base     { background: var(--bg-base); }
.bg-surface  { background: var(--bg-surface); }
.bg-elevated { background: var(--bg-elevated); }
.bg-primary  { background: var(--primary); color: var(--primary-fg); }
.bg-success  { background: var(--success-light); }
.bg-warning  { background: var(--warning-light); }
.bg-error    { background: var(--error-light); }

.border          { border: 1px solid var(--border-color); }
.border-strong   { border: 1px solid var(--border-strong); }
.border-primary  { border: 1px solid var(--primary); }
.border-none     { border: none; }

.opacity-50  { opacity: 0.5; }
.opacity-75  { opacity: 0.75; }
.opacity-muted { opacity: var(--opacity-muted); }

.cursor-pointer { cursor: pointer; }
.cursor-default { cursor: default; }
.cursor-not-allowed { cursor: not-allowed; }

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

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

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

/* ============================================================
   20. ANIMATIONS / KEYFRAMES
   ============================================================ */

@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes ping {
  75%, 100% { transform: scale(2); opacity: 0; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); animation-timing-function: cubic-bezier(0.8,0,1,1); }
  50% { transform: translateY(-20%); animation-timing-function: cubic-bezier(0,0,0.2,1); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in-down {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes scale-in {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes progress-stripes {
  from { background-position: 0 0; }
  to { background-position: 20px 0; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.animate-spin      { animation: spin 1s linear infinite; }
.animate-ping      { animation: ping 1s cubic-bezier(0,0,0.2,1) infinite; }
.animate-pulse     { animation: pulse 2s ease-in-out infinite; }
.animate-bounce    { animation: bounce 1s infinite; }
.animate-fade-in   { animation: fade-in var(--duration-normal) var(--ease-out) both; }
.animate-fade-in-up{ animation: fade-in-up var(--duration-normal) var(--ease-out) both; }
.animate-scale-in  { animation: scale-in var(--duration-normal) var(--ease-spring) both; }
.animate-float     { animation: float 3s ease-in-out infinite; }

/* ============================================================
   21. RESPONSIVE BREAKPOINTS
   ============================================================ */

@media (max-width: 640px) {
  h1 { font-size: var(--text-3xl); }
  h2 { font-size: var(--text-2xl); }
  h3 { font-size: var(--text-xl); }
  .hide-mobile { display: none !important; }
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 { grid-template-columns: 1fr; }
}

@media (min-width: 641px) and (max-width: 1023px) {
  .hide-tablet { display: none !important; }
  .grid-cols-3,
  .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .hide-desktop { display: none !important; }
}

/* ============================================================
   22. SCROLL & SELECTION
   ============================================================ */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

::selection {
  background: var(--primary-200);
  color: var(--primary-900);
}
