/* ============================================================
   GLOBAL CSS — Restaurant Management System
   Theme: Premium Dark | Accent: Royal Blue #3b82f6
   Spacing: 8px system | Transitions: 0.2s–0.3s
   ============================================================ */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-base:        #0f172a;   /* deepest bg */
  --bg-surface:     #1e293b;   /* card / panel surface */
  --bg-elevated:    #253352;   /* elevated card */
  --bg-hover:       #2d3d5a;   /* hover state */
  --bg-overlay:     rgba(15, 23, 42, 0.85);

  /* Accent — Royal Blue */
  --accent:         #3b82f6;
  --accent-hover:   #2563eb;
  --accent-active:  #1d4ed8;
  --accent-muted:   rgba(59, 130, 246, 0.12);
  --accent-glow:    rgba(59, 130, 246, 0.35);

  /* Text */
  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --text-inverse:   #0f172a;

  /* Status */
  --success:        #22c55e;
  --success-muted:  rgba(34, 197, 94, 0.12);
  --warning:        #f59e0b;
  --warning-muted:  rgba(245, 158, 11, 0.12);
  --danger:         #ef4444;
  --danger-muted:   rgba(239, 68, 68, 0.12);
  --info:           #06b6d4;
  --info-muted:     rgba(6, 182, 212, 0.12);

  /* Order status colors */
  --status-pending:   #f59e0b;
  --status-confirmed: #3b82f6;
  --status-preparing: #8b5cf6;
  --status-ready:     #22c55e;
  --status-served:    #64748b;
  --status-cancelled: #ef4444;
  --status-closed:    #334155;

  /* Borders */
  --border:         rgba(148, 163, 184, 0.1);
  --border-accent:  rgba(59, 130, 246, 0.3);
  --border-focus:   #3b82f6;

  /* Glass */
  --glass-bg:       rgba(30, 41, 59, 0.7);
  --glass-border:   rgba(255, 255, 255, 0.07);
  --glass-shadow:   0 8px 32px rgba(0, 0, 0, 0.4);

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md:   0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg:   0 8px 32px rgba(0, 0, 0, 0.45);
  --shadow-xl:   0 20px 60px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.3);

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

  /* Typography */
  --font-sans:  'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', monospace;
  --text-xs:    0.75rem;
  --text-sm:    0.875rem;
  --text-base:  1rem;
  --text-lg:    1.125rem;
  --text-xl:    1.25rem;
  --text-2xl:   1.5rem;
  --text-3xl:   1.875rem;
  --text-4xl:   2.25rem;

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

  /* Transitions */
  --transition-fast:   0.15s ease;
  --transition-normal: 0.2s ease;
  --transition-slow:   0.3s ease;

  /* Sidebar */
  --sidebar-width:         260px;
  --sidebar-collapsed-w:   72px;
  --topbar-height:         64px;
}

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

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

::selection {
  background: var(--accent-muted);
  color: var(--accent);
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar          { width: 6px; height: 6px; }
::-webkit-scrollbar-track    { background: var(--bg-base); }
::-webkit-scrollbar-thumb    { background: var(--bg-hover); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Typography ────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

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-base); }
h6 { font-size: var(--text-sm); }

p  { color: var(--text-secondary); line-height: 1.7; }
a  { color: var(--accent); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--accent-hover); }

small { font-size: var(--text-xs); color: var(--text-muted); }
code, pre { font-family: var(--font-mono); background: var(--bg-surface); }
code { padding: 2px 6px; border-radius: var(--radius-sm); font-size: var(--text-sm); }
hr { border: none; border-top: 1px solid var(--border); margin: var(--space-3) 0; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  box-shadow: var(--shadow-md);
}

.card-elevated {
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  box-shadow: var(--shadow-lg);
}

.card-glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--glass-shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    background var(--transition-normal),
    color var(--transition-normal),
    border-color var(--transition-normal),
    box-shadow var(--transition-normal),
    transform var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  outline: none;
}

.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 0 0 3px var(--accent-muted), var(--shadow-md);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-accent);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: #dc2626; }

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-success:hover { background: #16a34a; }

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

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-md);
  aspect-ratio: 1;
}

.btn-sm { padding: 6px 14px; font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn-lg { padding: 14px 28px; font-size: var(--text-base); }
.btn-full { width: 100%; }

.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Form Elements ──────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--space-2);
}

.form-group:last-child { margin-bottom: 0; }

.form-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition:
    border-color var(--transition-normal),
    background var(--transition-normal),
    box-shadow var(--transition-normal);
  -webkit-appearance: none;
}

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

.form-input:hover,
.form-select:hover,
.form-textarea:hover { border-color: rgba(148, 163, 184, 0.25); }

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--border-focus);
  background: var(--bg-hover);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.form-input.is-error,
.form-select.is-error,
.form-textarea.is-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

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

.form-feedback {
  font-size: var(--text-xs);
  margin-top: 4px;
}
.form-feedback.error  { color: var(--danger); }
.form-feedback.success { color: var(--success); }

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

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

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}
.form-select option { background: var(--bg-surface); color: var(--text-primary); }

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}
.input-group .form-input { flex: 1; }
.input-icon-left  { position: absolute; left: 12px; color: var(--text-muted); pointer-events: none; z-index: 1; }
.input-icon-right { position: absolute; right: 12px; color: var(--text-muted); z-index: 1; cursor: pointer; }
.input-has-left-icon  .form-input { padding-left: 40px; }
.input-has-right-icon .form-input { padding-right: 40px; }

/* ── Toggle Switch ──────────────────────────────────────────── */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 40px;
  height: 22px;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  transition: background var(--transition-normal), border-color var(--transition-normal);
  flex-shrink: 0;
}
.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform var(--transition-normal), background var(--transition-normal);
}
.toggle input:checked + .toggle-track { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(18px); background: #fff; }
.toggle-label { font-size: var(--text-sm); color: var(--text-secondary); }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge-primary  { background: var(--accent-muted);   color: var(--accent); }
.badge-success  { background: var(--success-muted);  color: var(--success); }
.badge-warning  { background: var(--warning-muted);  color: var(--warning); }
.badge-danger   { background: var(--danger-muted);   color: var(--danger); }
.badge-info     { background: var(--info-muted);     color: var(--info); }
.badge-muted    { background: rgba(100,116,139,0.15); color: var(--text-muted); }

/* Order status badges */
.badge-status-pending    { background: rgba(245,158,11,0.12);  color: #f59e0b; }
.badge-status-confirmed  { background: rgba(59,130,246,0.12);  color: #3b82f6; }
.badge-status-preparing  { background: rgba(139,92,246,0.12);  color: #8b5cf6; }
.badge-status-ready      { background: rgba(34,197,94,0.12);   color: #22c55e; }
.badge-status-served     { background: rgba(100,116,139,0.15); color: #94a3b8; }
.badge-status-cancelled  { background: rgba(239,68,68,0.12);   color: #ef4444; }
.badge-status-closed     { background: rgba(51,65,85,0.4);     color: #64748b; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

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

.data-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
}

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

.data-table tbody td {
  padding: 13px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table .td-muted { color: var(--text-secondary); }
.data-table .td-center { text-align: center; }
.data-table .td-actions { display: flex; gap: 6px; align-items: center; }

/* ── Alerts / Toasts ────────────────────────────────────────── */
.alert {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  border-left: 3px solid transparent;
  font-size: var(--text-sm);
}

.alert-success { background: var(--success-muted); border-color: var(--success);  color: var(--success); }
.alert-danger  { background: var(--danger-muted);  border-color: var(--danger);   color: var(--danger); }
.alert-warning { background: var(--warning-muted); border-color: var(--warning);  color: var(--warning); }
.alert-info    { background: var(--info-muted);    border-color: var(--info);     color: var(--info); }

/* ── Toast container ────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: var(--space-2);
  right: var(--space-2);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  max-width: 380px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  pointer-events: auto;
  animation: slideInRight var(--transition-slow) ease forwards;
  transition: opacity var(--transition-normal), transform var(--transition-normal);
}

.toast.removing {
  opacity: 0;
  transform: translateX(110%);
}

.toast-icon   { flex-shrink: 0; width: 18px; height: 18px; }
.toast-content { flex: 1; }
.toast-title  { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); }
.toast-msg    { font-size: var(--text-xs); color: var(--text-secondary); margin-top: 2px; }
.toast-close  { flex-shrink: 0; background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 2px; }
.toast-close:hover { color: var(--text-primary); }

.toast-success .toast-icon { color: var(--success); }
.toast-error   .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info    .toast-icon { color: var(--info); }

/* ── Loading ────────────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.spinner-lg { width: 40px; height: 40px; border-width: 3px; }

.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 800;
  padding: var(--space-2);
  animation: fadeIn var(--transition-normal);
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp var(--transition-slow);
}

.modal-lg  { max-width: 780px; }
.modal-sm  { max-width: 400px; }
.modal-2xl { max-width: 1100px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title { font-size: var(--text-lg); font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-elevated); }

.modal-body {
  padding: var(--space-4);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Dropdown ───────────────────────────────────────────────── */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 500;
  overflow: hidden;
  animation: fadeIn var(--transition-fast);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.dropdown-item.danger:hover { background: var(--danger-muted); color: var(--danger); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ── Tabs ───────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 4px;
  width: fit-content;
}

.tab {
  padding: 8px 18px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  cursor: pointer;
  border: none;
  background: none;
  transition: all var(--transition-normal);
}

.tab:hover { color: var(--text-primary); background: var(--bg-elevated); }

.tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
  text-align: center;
  gap: var(--space-2);
}

.empty-state-icon {
  font-size: 3rem;
  opacity: 0.3;
  margin-bottom: var(--space-1);
}
.empty-state h3 { font-size: var(--text-lg); color: var(--text-secondary); }
.empty-state p  { font-size: var(--text-sm); color: var(--text-muted); max-width: 300px; }

/* ── Divider ────────────────────────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-xs);
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Utility ────────────────────────────────────────────────── */
.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: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }
.gap-4 { gap: 32px; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.hidden { display: none !important; }
.visible { display: block !important; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }
.text-xs    { font-size: var(--text-xs) !important; }
.text-sm    { font-size: var(--text-sm) !important; }
.text-base  { font-size: var(--text-base) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-accent { color: var(--accent) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* ── Animations ─────────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

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

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.animate-pulse { animation: pulse 2s cubic-bezier(0.4,0,0.6,1) infinite; }
.animate-spin  { animation: spin 1s linear infinite; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --space-4: 24px;
    --space-6: 40px;
  }

  h1 { font-size: var(--text-2xl); }
  h2 { font-size: var(--text-xl); }

  .modal { border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 95vh; }
  .modal-backdrop { align-items: flex-end; padding: 0; }

  .data-table thead { display: none; }
  .data-table tr { display: block; margin-bottom: var(--space-2); }
  .data-table td {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
  }
  .data-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    font-size: var(--text-xs);
    text-transform: uppercase;
  }

  #toast-container {
    left: var(--space-1);
    right: var(--space-1);
    max-width: none;
  }
}

/* ============================================================
   ELITE ENHANCEMENTS — Premium UI Layer
   ============================================================ */

/* ── Premium background mesh ─────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(59,130,246,.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 110%, rgba(139,92,246,.04) 0%, transparent 55%);
}

/* ── Premium gradient button ─────────────────────────────── */
.btn-gradient {
  background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(59,130,246,.35);
}
.btn-gradient:hover {
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
  box-shadow: 0 6px 20px rgba(59,130,246,.5);
  transform: translateY(-1px);
}
.btn-gradient:active { transform: translateY(0); }

.btn-outline-accent {
  background: transparent;
  color: var(--accent);
  border-color: var(--border-accent);
}
.btn-outline-accent:hover {
  background: var(--accent-muted);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}

/* ── Glow card variant ───────────────────────────────────── */
.card-glow {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-3);
  box-shadow: var(--shadow-md);
  transition: border-color .25s, box-shadow .25s, transform .2s;
}
.card-glow:hover {
  border-color: var(--border-accent);
  box-shadow: 0 0 0 1px var(--accent-muted), 0 8px 32px rgba(59,130,246,.12), var(--shadow-lg);
  transform: translateY(-2px);
}

/* Enhanced default card hover */
.card:hover {
  border-color: rgba(148,163,184,.2);
  box-shadow: var(--shadow-lg);
}

/* ── Skeleton loader ─────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position: 600px 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
  background-size: 1200px 100%;
  animation: shimmer 1.6s infinite linear;
  border-radius: var(--radius-md);
  display: block;
}
.skeleton-text  { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 20px; width: 60%; margin-bottom: 12px; }
.skeleton-avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.skeleton-btn   { height: 36px; width: 100px; border-radius: var(--radius-md); }
.skeleton-card  { height: 80px; border-radius: var(--radius-lg); }

/* ── Enhanced badge variants ─────────────────────────────── */
.badge-purple  { background: rgba(139,92,246,.12);  color: #8b5cf6; }
.badge-pink    { background: rgba(236,72,153,.12);  color: #ec4899; }
.badge-orange  { background: rgba(249,115,22,.12);  color: #f97316; }
.badge-teal    { background: rgba(20,184,166,.12);  color: #14b8a6; }

.badge-dot {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--text-xs); font-weight: 600; color: var(--text-secondary);
}
.badge-dot::before {
  content: '';
  width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0;
}
.badge-dot.green  { color: var(--success); }
.badge-dot.red    { color: var(--danger); }
.badge-dot.yellow { color: var(--warning); }
.badge-dot.blue   { color: var(--accent); }
.badge-dot.muted  { color: var(--text-muted); }

/* ── Stat card pulse on update ───────────────────────────── */
.stat-card.pulse-once {
  animation: statPulse .6s var(--transition-slow) forwards;
}
@keyframes statPulse {
  0%   { box-shadow: 0 0 0 0 var(--accent-glow); }
  60%  { box-shadow: 0 0 0 8px rgba(59,130,246,0); }
  100% { box-shadow: none; }
}

/* ── Premium table enhancements ──────────────────────────── */
.data-table thead th:first-child { border-radius: var(--radius-lg) 0 0 0; }
.data-table thead th:last-child  { border-radius: 0 var(--radius-lg) 0 0; }
.data-table tbody tr:hover td { color: var(--text-primary); }

/* Sortable column header */
.data-table th.sortable {
  cursor: pointer;
  user-select: none;
}
.data-table th.sortable:hover { color: var(--text-primary); }
.data-table th.sortable::after {
  content: '↕';
  margin-left: 4px;
  opacity: .3;
  font-size: .7em;
}
.data-table th.sort-asc::after  { content: '↑'; opacity: 1; color: var(--accent); }
.data-table th.sort-desc::after { content: '↓'; opacity: 1; color: var(--accent); }

/* ── Premium form input ──────────────────────────────────── */
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  background: rgba(37, 52, 82, 0.9);
}

.form-group label.form-label::after {
  content: '';
  display: none;
}

/* Prefix adornment */
.input-prefix {
  display: flex;
  align-items: stretch;
}
.input-prefix-text {
  padding: 0 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  color: var(--text-muted);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  white-space: nowrap;
}
.input-prefix .form-input {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* ── Toast polish ────────────────────────────────────────── */
.toast {
  border-left: 3px solid transparent;
}
.toast-success { border-left-color: var(--success); }
.toast-error   { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-info    { border-left-color: var(--info); }

/* ── Divider label ───────────────────────────────────────── */
.divider-label {
  position: relative;
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin: var(--space-2) 0;
}
.divider-label::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: var(--border);
}
.divider-label span {
  position: relative;
  background: var(--bg-base);
  padding: 0 12px;
}

/* ── Step indicator ──────────────────────────────────────── */
.steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: var(--space-3);
}
.step {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  position: relative;
}
.step:not(:last-child)::after {
  content: '';
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 8px;
}
.step-done:not(:last-child)::after { background: var(--accent); }
.step-num {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--bg-elevated); border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-xs); font-weight: 700; color: var(--text-muted);
  transition: all var(--transition-normal);
}
.step-done .step-num {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.step-active .step-num {
  border-color: var(--accent); color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-muted);
}
.step-label { font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; }
.step-active .step-label { color: var(--text-primary); font-weight: 600; }
.step-done .step-label   { color: var(--accent); }

/* ── Pagination ──────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
  margin-top: var(--space-3);
}
.page-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-sm); font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-muted); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity:.4; pointer-events:none; }

/* ── Animated gradient text ──────────────────────────────── */
.gradient-text {
  background: linear-gradient(135deg, #60a5fa, #a78bfa, #f472b6);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 4s linear infinite;
}
@keyframes gradientShift {
  0%   { background-position: 0%   center; }
  100% { background-position: 200% center; }
}

/* ── Neon glow utility ───────────────────────────────────── */
.glow-blue    { box-shadow: 0 0 16px rgba(59,130,246,.4); }
.glow-green   { box-shadow: 0 0 16px rgba(34,197,94,.4); }
.glow-purple  { box-shadow: 0 0 16px rgba(139,92,246,.4); }
.glow-red     { box-shadow: 0 0 16px rgba(239,68,68,.4); }

/* ── Hover lift ──────────────────────────────────────────── */
.hover-lift {
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}
.hover-lift:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

/* ── Counter fade-in ─────────────────────────────────────── */
@keyframes countUp {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.stat-value { animation: countUp .5s ease; }

/* ── Scrollbar premium ───────────────────────────────────── */
::-webkit-scrollbar           { width: 5px; height: 5px; }
::-webkit-scrollbar-track     { background: transparent; }
::-webkit-scrollbar-thumb     { background: rgba(100,116,139,.35); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(100,116,139,.6); }

/* ── Context menu ────────────────────────────────────────── */
.context-menu {
  position: fixed;
  z-index: 9000;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  min-width: 160px;
  overflow: hidden;
  animation: fadeIn .1s ease;
}
.context-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px;
  font-size: var(--text-sm); color: var(--text-secondary);
  cursor: pointer; transition: background var(--transition-fast), color var(--transition-fast);
}
.context-menu-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.context-menu-item.danger:hover { background: var(--danger-muted); color: var(--danger); }
.context-menu-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ── Focus ring ──────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ── Slide-down reveal animation ─────────────────────────── */
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-slide-down { animation: slideDown .2s ease forwards; }

/* ── Fade-in-up for page content blocks ─────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page-content > * {
  animation: fadeInUp .35s ease backwards;
}
.page-content > *:nth-child(1) { animation-delay: .04s; }
.page-content > *:nth-child(2) { animation-delay: .08s; }
.page-content > *:nth-child(3) { animation-delay: .12s; }
.page-content > *:nth-child(4) { animation-delay: .16s; }

/* ── Collapsible section ─────────────────────────────────── */
.collapsible-header {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none; padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}
.collapsible-header iconify-icon {
  transition: transform var(--transition-normal);
  color: var(--text-muted);
}
.collapsible-header.open iconify-icon { transform: rotate(180deg); }
.collapsible-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height .35s ease;
}
.collapsible-body.open { max-height: 2000px; }

/* ── Keyboard shortcut badge ─────────────────────────────── */
.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-secondary);
  box-shadow: 0 1px 0 var(--border);
}

/* ── Highlight row ───────────────────────────────────────── */
.data-table tbody tr.highlight {
  background: rgba(59,130,246,.06);
  border-left: 3px solid var(--accent);
}
.data-table tbody tr.highlight-green { background: rgba(34,197,94,.05); border-left: 3px solid var(--success); }
.data-table tbody tr.highlight-red   { background: rgba(239,68,68,.05); border-left: 3px solid var(--danger); }
