/* ============================================================
   DuplaDesk — Design System v2
   Dark theme inspired by RustDesk / AnyDesk
   Premium, glassmorphism-powered design
   ============================================================ */

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

/* ===== DESIGN TOKENS ===== */
:root {
  /* --- Colors --- */
  --bg-primary: #0a0c14;
  --bg-secondary: #12151f;
  --bg-tertiary: #1a1e2e;
  --bg-elevated: #222738;
  --bg-hover: #2a3048;
  --bg-active: #343a54;
  --bg-glass: rgba(18, 21, 31, 0.85);
  --bg-glass-heavy: rgba(10, 12, 20, 0.92);

  /* Accent */
  --accent-blue: #3B7BF6;
  --accent-blue-hover: #5B93FF;
  --accent-blue-glow: rgba(59, 123, 246, 0.25);
  --accent-blue-subtle: rgba(59, 123, 246, 0.08);
  --accent-green: #22C55E;
  --accent-green-hover: #34D16A;
  --accent-green-glow: rgba(34, 197, 94, 0.25);
  --accent-green-subtle: rgba(34, 197, 94, 0.08);
  --accent-red: #EF4444;
  --accent-red-hover: #F87171;
  --accent-red-glow: rgba(239, 68, 68, 0.25);
  --accent-orange: #F59E0B;
  --accent-orange-hover: #FBBF24;
  --accent-orange-glow: rgba(245, 158, 11, 0.2);
  --accent-purple: #8B5CF6;
  --accent-purple-hover: #A78BFA;
  --accent-purple-glow: rgba(139, 92, 246, 0.25);
  --accent-cyan: #06B6D4;

  /* Gradients */
  --gradient-brand: linear-gradient(135deg, #3B7BF6, #8B5CF6);
  --gradient-brand-hover: linear-gradient(135deg, #5B93FF, #A78BFA);
  --gradient-success: linear-gradient(135deg, #22C55E, #06B6D4);
  --gradient-danger: linear-gradient(135deg, #EF4444, #F97316);
  --gradient-glow: radial-gradient(ellipse at center, var(--accent-blue-glow) 0%, transparent 70%);

  /* Text */
  --text-primary: #F0F2F5;
  --text-secondary: #8B93A8;
  --text-tertiary: #5A6178;
  --text-accent: var(--accent-blue);

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-default: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-accent: var(--accent-blue);
  --border-glow: rgba(59, 123, 246, 0.3);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.55);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.65);
  --shadow-glow-blue: 0 0 24px var(--accent-blue-glow);
  --shadow-glow-green: 0 0 24px var(--accent-green-glow);
  --shadow-glow-red: 0 0 24px var(--accent-red-glow);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.04);

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

  --text-xs: 0.6875rem;
  --text-sm: 0.8125rem;
  --text-base: 0.875rem;
  --text-lg: 1rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;

  /* --- Spacing --- */
  --space-0: 0;
  --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;

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

  /* --- Transitions --- */
  --transition-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===== BASE ===== */
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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

a { color: var(--accent-blue); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--accent-blue-hover); }

::selection {
  background: rgba(59, 123, 246, 0.35);
  color: white;
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--bg-active); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  outline: none;
  position: relative;
  overflow: hidden;
}

.btn > span,
.btn svg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn svg {
  display: block;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0.04), transparent);
  pointer-events: none;
}
.btn:focus-visible {
  box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--accent-blue);
}
.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  filter: saturate(0.5);
}
.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent-blue);
  color: white;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-blue-hover);
  box-shadow: var(--shadow-glow-blue);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--accent-green);
  color: white;
  box-shadow: var(--shadow-sm);
}
.btn-success:hover:not(:disabled) {
  background: var(--accent-green-hover);
  box-shadow: var(--shadow-glow-green);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--accent-red);
  color: white;
  box-shadow: var(--shadow-sm);
}
.btn-danger:hover:not(:disabled) {
  background: var(--accent-red-hover);
  box-shadow: var(--shadow-glow-red);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-subtle {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}
.btn-subtle:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn-icon {
  padding: var(--space-2);
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
}

.btn-icon-sm {
  padding: var(--space-1);
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
}

.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-base);
  font-weight: 600;
  border-radius: var(--radius-md);
}

.btn-xl {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-lg);
  font-weight: 600;
  border-radius: var(--radius-md);
}

/* ===== INPUTS ===== */
.input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-inset);
}
.input:hover {
  border-color: var(--border-strong);
}
.input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-blue-glow), var(--shadow-inset);
  background: var(--bg-elevated);
}
.input::placeholder { color: var(--text-tertiary); }

.input-mono {
  font-family: var(--font-mono);
  letter-spacing: 3px;
  text-align: center;
  font-size: var(--text-lg);
}

.input-lg {
  padding: var(--space-4) var(--space-5);
  font-size: var(--text-xl);
}

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

/* ===== CARDS ===== */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: all var(--transition-base);
  position: relative;
}
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(to bottom, rgba(255,255,255,0.02), transparent);
  pointer-events: none;
}
.card-elevated {
  background: var(--bg-elevated);
  box-shadow: var(--shadow-md);
  border-color: var(--border-default);
}
.card-glass {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-lg);
}
.card-interactive:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.4;
}
.badge-green {
  background: var(--accent-green-subtle);
  color: var(--accent-green);
  border: 1px solid rgba(34, 197, 94, 0.15);
}
.badge-red {
  background: rgba(239, 68, 68, 0.1);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.15);
}
.badge-blue {
  background: var(--accent-blue-subtle);
  color: var(--accent-blue);
  border: 1px solid rgba(59, 123, 246, 0.15);
}
.badge-orange {
  background: rgba(245, 158, 11, 0.1);
  color: var(--accent-orange);
  border: 1px solid rgba(245, 158, 11, 0.15);
}
.badge-purple {
  background: rgba(139, 92, 246, 0.1);
  color: var(--accent-purple);
  border: 1px solid rgba(139, 92, 246, 0.15);
}

/* ===== LED INDICATORS ===== */
.led {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: all var(--transition-base);
}
.led-green {
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green), 0 0 2px var(--accent-green);
}
.led-red {
  background: var(--accent-red);
  box-shadow: 0 0 8px var(--accent-red), 0 0 2px var(--accent-red);
}
.led-orange {
  background: var(--accent-orange);
  box-shadow: 0 0 8px var(--accent-orange), 0 0 2px var(--accent-orange);
}
.led-blue {
  background: var(--accent-blue);
  box-shadow: 0 0 8px var(--accent-blue), 0 0 2px var(--accent-blue);
}
.led-pulse {
  animation: ledPulse 2s ease-in-out infinite;
}
.led-lg {
  width: 10px;
  height: 10px;
}

/* ===== TOASTS ===== */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 10000;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-2);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--bg-glass-heavy);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  font-size: var(--text-sm);
  color: var(--text-primary);
  pointer-events: auto;
  animation: toastIn 350ms var(--transition-spring) forwards;
  max-width: 400px;
}
.toast-success { border-left: 3px solid var(--accent-green); }
.toast-error { border-left: 3px solid var(--accent-red); }
.toast-info { border-left: 3px solid var(--accent-blue); }
.toast-warning { border-left: 3px solid var(--accent-orange); }
.toast-icon { font-size: 1.1em; flex-shrink: 0; }
.toast-exit { animation: toastOut 250ms ease forwards; }

/* ===== PROGRESS BAR ===== */
.progress-track {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  background: var(--gradient-success);
  border-radius: var(--radius-full);
  transition: width var(--transition-base);
  position: relative;
}
.progress-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: shimmer 2s infinite;
}

/* ===== DIVIDER ===== */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-default), transparent);
  margin: var(--space-4) 0;
}

/* ===== TOOLTIP ===== */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: var(--space-1) var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-fast);
  z-index: 100;
  box-shadow: var(--shadow-md);
}
[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-24px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes ledPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to { opacity: 0; transform: translateX(40px) scale(0.95); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 12px var(--accent-blue-glow); }
  50% { box-shadow: 0 0 28px var(--accent-blue-glow), 0 0 8px var(--accent-purple-glow); }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes bgOrb {
  0% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -30px) scale(1.1); }
  66% { transform: translate(-20px, 20px) scale(0.9); }
  100% { transform: translate(0, 0) scale(1); }
}

.fade-in { animation: fadeIn var(--transition-base) ease forwards; }
.fade-in-up { animation: fadeInUp 400ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
.fade-in-down { animation: fadeInDown var(--transition-base) ease forwards; }
.slide-in-right { animation: slideInRight var(--transition-base) ease forwards; }
.slide-in-left { animation: slideInLeft var(--transition-base) ease forwards; }
.scale-in { animation: scaleIn var(--transition-base) ease forwards; }

/* ===== SPINNER ===== */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-lg {
  width: 36px;
  height: 36px;
  border-width: 3px;
}
.spinner-brand {
  border-color: rgba(139, 92, 246, 0.2);
  border-top-color: var(--accent-blue);
  border-right-color: var(--accent-purple);
}

/* ===== UTILITY ===== */
.text-mono { font-family: var(--font-mono); }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-dim { color: var(--text-tertiary); }
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-3xl { font-size: var(--text-3xl); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.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); }
.w-full { width: 100%; }
.h-full { height: 100%; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.relative { position: relative; }
.overflow-hidden { overflow: hidden; }
.pointer { cursor: pointer; }
.select-none { user-select: none; }

/* ===== GLOW EFFECTS ===== */
.glow-blue { box-shadow: var(--shadow-glow-blue); }
.glow-green { box-shadow: var(--shadow-glow-green); }
.glow-pulse { animation: glowPulse 3s ease-in-out infinite; }

/* ===== GRADIENT TEXT ===== */
.text-gradient {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
