/**
 * Midnight Command Design System
 * Modern dark theme for Trailhead Event Kiosk
 *
 * This file contains core design tokens (colors, typography, spacing)
 * and reusable utility classes. It's meant to be used alongside
 * component-specific CSS files (kiosk-modern.css, admin-modern.css).
 */

/* ============================================================================
   CSS CUSTOM PROPERTIES (Design Tokens)
   ============================================================================ */

:root {
  /* PRIMARY - Deep slate backgrounds (dark theme base) */
  --primary-950: #0a0a0f;  /* True black for deepest backgrounds */
  --primary-900: #0f172a;  /* Slate 900 - main background */
  --primary-800: #1e293b;  /* Slate 800 - elevated panels */
  --primary-700: #334155;  /* Slate 700 - borders and dividers */
  --primary-600: #475569;  /* Slate 600 - muted elements */

  /* BRAND - Electric indigo (primary actions, highlights) */
  --brand-900: #312e81;    /* Indigo 900 - dark state */
  --brand-800: #3730a3;    /* Indigo 800 */
  --brand-700: #4338ca;    /* Indigo 700 - primary brand color */
  --brand-600: #4f46e5;    /* Indigo 600 - hover state */
  --brand-500: #6366f1;    /* Indigo 500 - bright brand */
  --brand-400: #818cf8;    /* Indigo 400 - light state */

  /* ACCENT - Electric cyan (CTAs, highlights, success moments) */
  --accent-600: #0891b2;   /* Cyan 600 - dark accent */
  --accent-500: #06b6d4;   /* Cyan 500 - primary accent */
  --accent-400: #22d3ee;   /* Cyan 400 - bright accent */
  --accent-300: #67e8f9;   /* Cyan 300 - glow effects */

  /* STATUS - Functional colors for states */
  --status-available: #10b981;  /* Emerald 500 - ready, success */
  --status-pending: #f59e0b;    /* Amber 500 - in progress */
  --status-busy: #ef4444;       /* Red 500 - occupied, error */
  --status-offline: #6b7280;    /* Gray 500 - unavailable */

  /* NEUTRALS - Grayscale for text and subtle elements */
  --neutral-50: #fafafa;   /* Near white - primary text */
  --neutral-100: #f4f4f5;  /* Very light gray */
  --neutral-200: #e4e4e7;  /* Light gray - borders */
  --neutral-300: #d4d4d8;  /* Medium-light gray */
  --neutral-400: #a1a1aa;  /* Medium gray - secondary text */
  --neutral-500: #71717a;  /* Medium-dark gray - muted text */
  --neutral-600: #52525b;  /* Dark gray - tertiary text */
  --neutral-700: #3f3f46;  /* Very dark gray - dark borders */
  --neutral-800: #27272a;  /* Near black - dark panels */
  --neutral-900: #18181b;  /* True black text */

  /* TYPOGRAPHY */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
               'Ubuntu', 'Cantarell', 'Helvetica Neue', 'Inter', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Droid Sans Mono',
               'Courier New', monospace;

  /* Type Scale */
  --text-4xl: 3.5rem;      /* 56px - Display text */
  --text-3xl: 2.5rem;      /* 40px - Large headings */
  --text-2xl: 2rem;        /* 32px - Section titles */
  --text-xl: 1.5rem;       /* 24px - Card titles */
  --text-lg: 1.25rem;      /* 20px - Emphasized text */
  --text-base: 1rem;       /* 16px - Body text */
  --text-sm: 0.875rem;     /* 14px - Small text */
  --text-xs: 0.75rem;      /* 12px - Captions */

  /* Spacing Scale (4px increments) */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

  /* Transitions */
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);

  /* Z-index scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;

  /* Header offset for sticky elements (accounting for status bar) */
  --header-offset: 4rem;
}

/* ============================================================================
   ANIMATION KEYFRAMES
   ============================================================================ */

/* Fade In - General entrance */
@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Fade In Up - Cards, panels */
@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Pulse - Status indicators */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Scale In - Buttons, badges */
@keyframes scale-in {
  from {
    opacity: 0;
    transform: scale(0);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Pulse Error - For disconnected state (duplicated from original for clarity) */
@keyframes pulse-error {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Spin - Loading spinner */
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Shimmer - Skeleton loader */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Gradient Flow - Animated border & background animation */
@keyframes gradient-flow {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* Alias for gradient-flow (used for ambient backgrounds) */
@keyframes gradient-ambient {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* Pulse Ambient - Subtle background glow */
@keyframes pulse-ambient {
  0%, 100% {
    opacity: 0.4;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 0.7;
    transform: translate(-50%, -50%) scale(1.1);
  }
}

/* Flip Number - Odometer effect */
@keyframes flip-number {
  0% {
    transform: perspective(400px) rotateX(0deg);
    opacity: 1;
  }
  50% {
    transform: perspective(400px) rotateX(90deg);
    opacity: 0;
  }
  51% {
    transform: perspective(400px) rotateX(-90deg);
    opacity: 0;
  }
  100% {
    transform: perspective(400px) rotateX(0deg);
    opacity: 1;
  }
}

/* Particle Burst - Success animation */
@keyframes particle-burst {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(0);
    opacity: 0;
  }
}

/* Toast Slide In - From right edge */
@keyframes toast-slide-in {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Modal Slide Up - From bottom */
@keyframes modal-slide-up {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

/* Transitions */
.transition-all {
  transition: all 0.2s var(--ease-in-out);
}

.transition-colors {
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.transition-transform {
  transition: transform 0.2s var(--ease-in-out);
}

.transition-opacity {
  transition: opacity 0.2s ease;
}

/* Glassmorphism - Frosted glass effect
   Note: Duplicate classes for clarity - both .glass and .glass-heavy serve
   slightly different blur levels for various UI needs */
.glass {
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
}

.glass-heavy {
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}

/* Text Utilities */
.text-gradient {
  background: linear-gradient(135deg, var(--neutral-50), var(--accent-400));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text-gradient-brand {
  background: linear-gradient(135deg, var(--brand-500), var(--accent-400));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

.text-muted {
  color: var(--neutral-400);
}

.text-bold {
  font-weight: 700;
}

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

/* Icon Sizing */
.icon {
  display: inline-block;
  flex-shrink: 0;
}

.icon-xs { width: 16px; height: 16px; }
.icon-sm { width: 20px; height: 20px; }
.icon-md { width: 24px; height: 24px; }
.icon-lg { width: 32px; height: 32px; }
.icon-xl { width: 48px; height: 48px; }

/* Spacing Utilities */
.p-sm { padding: var(--space-2); }
.p-md { padding: var(--space-4); }
.p-lg { padding: var(--space-6); }
.p-xl { padding: var(--space-8); }

/* Skeleton Loaders */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.03) 25%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.03) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
  border-radius: var(--radius-md);
}

.skeleton--text {
  height: 1rem;
  margin-bottom: 0.5rem;
}

.skeleton--title {
  height: 2rem;
  width: 60%;
  margin-bottom: 1rem;
}

.skeleton--button {
  height: 3rem;
  border-radius: var(--radius-lg);
}

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

/* Focus Visible */
*:focus {
  outline: none;
}

*:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
}

/* Reduce Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================================
   COMPONENT LIBRARY
   ============================================================================ */

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-4);
  text-align: center;
  color: var(--neutral-400);
}

.empty-state__icon {
  margin-bottom: var(--space-4);
  color: var(--neutral-500);
}

.empty-state__title {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--neutral-50);
  margin-bottom: var(--space-2);
}

.empty-state__description {
  font-size: var(--text-sm);
  color: var(--neutral-400);
  max-width: 400px;
}

/* Card */
.card {
  background: rgba(30, 41, 59, 0.6);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.card__header {
  padding: var(--space-6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card__title {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--neutral-50);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

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

/* Loading State */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-10);
  gap: var(--space-4);
}

.loading-text {
  color: var(--neutral-400);
  font-size: var(--text-sm);
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--brand-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner--sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.spinner--lg {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

.spinner-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
}

/* ============================================================================
   TOAST NOTIFICATIONS
   ============================================================================ */

.toast {
  position: fixed;
  bottom: var(--space-8);
  right: var(--space-8);
  min-width: 320px;
  max-width: 500px;
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-lg);
  background: rgba(31, 41, 55, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 10000;
  animation: toast-slide-in 0.3s var(--ease-out);
}

.toast--success {
  border-color: var(--status-available);
  box-shadow: 0 0 24px rgba(16, 185, 129, 0.3), 0 8px 32px rgba(0, 0, 0, 0.5);
}

.toast--error {
  border-color: var(--status-busy);
  box-shadow: 0 0 24px rgba(239, 68, 68, 0.3), 0 8px 32px rgba(0, 0, 0, 0.5);
}

.toast--warning {
  border-color: var(--status-pending);
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.3), 0 8px 32px rgba(0, 0, 0, 0.5);
}

.toast__content {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.toast__icon {
  flex-shrink: 0;
}

.toast__message {
  flex: 1;
  color: var(--neutral-50);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.4;
}

.toast__close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--neutral-400);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast__close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--neutral-50);
}

/* ============================================================================
   ALERT COMPONENT
   ============================================================================ */

.alert {
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-lg);
  border-left: 4px solid;
  margin-bottom: var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.alert__icon {
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.alert__content {
  flex: 1;
}

.alert__title {
  font-weight: 600;
  margin-bottom: var(--space-1);
  color: var(--neutral-50);
}

.alert__message {
  font-size: var(--text-sm);
  color: var(--neutral-300);
  line-height: 1.5;
}

.alert--error {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--status-busy);
}

.alert--success {
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--status-available);
}

.alert--warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: var(--status-pending);
}

.alert--info {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--brand-500);
}

/* ============================================================================
   MODAL / DIALOG
   ============================================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.2s ease-out;
}

.modal {
  background: var(--primary-800);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modal-slide-up 0.3s var(--ease-out);
}

.modal__header {
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--space-4);
  color: var(--neutral-50);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal__close {
  background: none;
  border: none;
  color: var(--neutral-400);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal__close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--neutral-50);
}

.modal__body {
  color: var(--neutral-400);
  margin-bottom: var(--space-6);
  line-height: 1.6;
}

.modal__footer {
  display: flex;
  gap: var(--space-4);
  justify-content: flex-end);
}
