/* ═══════════════════════════════════════════════════════════
   SLIDEMETER — DESIGN SYSTEM
   Core tokens, resets, and shared utilities
═══════════════════════════════════════════════════════════ */

:root {
  /* Brand Palette */
  --brand-900: #1e1b4b;
  --brand-800: #2e27a6;
  --brand-700: #3730a3;
  --brand-600: #4338ca;
  --brand-500: #4f46e5;
  --brand-400: #6366f1;
  --brand-300: #818cf8;
  --brand-200: #a5b4fc;
  --brand-100: #c7d2fe;
  --brand-50:  #eef2ff;

  /* Accent / CTA */
  --accent-primary:   #4f46e5;
  --accent-secondary: #7c3aed;
  --accent-glow:      rgba(79,70,229,0.2);
  --accent-success:   #059669;
  --accent-warning:   #d97706;
  --accent-danger:    #dc2626;
  --accent-info:      #0284c7;

  /* Surfaces — light mode */
  --surface-0:     #f1f5f9;
  --surface-1:     #ffffff;
  --surface-2:     #f8fafc;
  --surface-3:     #f1f5f9;
  --surface-4:     #e2e8f0;
  --surface-hover: rgba(0,0,0,0.03);
  --surface-active: rgba(79,70,229,0.08);

  /* Borders — light mode */
  --border-subtle:  rgba(0,0,0,0.06);
  --border-default: rgba(0,0,0,0.1);
  --border-strong:  rgba(0,0,0,0.18);
  --border-accent:  rgba(79,70,229,0.35);

  /* Text — light mode */
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-accent:    #4f46e5;
  --text-success:   #059669;
  --text-danger:    #dc2626;
  --text-warning:   #d97706;

  /* Background */
  --bg-app: #f1f5f9;

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

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

  /* Radii */
  --r-sm:  6px;
  --r-md:  10px;
  --r-lg:  14px;
  --r-xl:  20px;
  --r-2xl: 28px;
  --r-full: 9999px;

  /* Shadows — adjusted for light bg */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.1);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.12);
  --shadow-xl:  0 16px 64px rgba(0,0,0,0.16);
  --shadow-accent: 0 0 24px rgba(79,70,229,0.2);
  --shadow-glow:   0 0 48px rgba(79,70,229,0.12);

  /* Transitions */
  --t-fast:   0.12s ease;
  --t-normal: 0.22s ease;
  --t-slow:   0.4s cubic-bezier(0.4,0,0.2,1);
  --t-spring: 0.5s cubic-bezier(0.34,1.56,0.64,1);

  /* Z-index scale */
  --z-base:    0;
  --z-raised:  10;
  --z-overlay: 100;
  --z-modal:   200;
  --z-toast:   300;
  --z-fullscreen: 999;
}

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

html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--surface-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  height: 100%;
  position: relative;
}

/* ── Screen System ── */
.screen {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-normal);
}

.screen.active {
  opacity: 1;
  pointer-events: all;
}

/* ── Shared Components ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-md);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--t-fast);
  white-space: nowrap;
  user-select: none;
  letter-spacing: 0.01em;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 12px rgba(99,102,241,0.4);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(99,102,241,0.55);
}

.btn-secondary {
  background: var(--surface-1);
  color: var(--text-primary);
  border-color: var(--border-default);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.btn-danger {
  background: rgba(239,68,68,0.15);
  color: var(--accent-danger);
  border-color: rgba(239,68,68,0.25);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(239,68,68,0.25);
}

.btn-success {
  background: rgba(16,185,129,0.15);
  color: var(--accent-success);
  border-color: rgba(16,185,129,0.25);
}
.btn-success:hover:not(:disabled) {
  background: rgba(16,185,129,0.25);
}

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 15px; border-radius: var(--r-lg); }
.btn-icon { padding: 8px; aspect-ratio: 1; justify-content: center; }

/* ── Input System ── */
.input, .textarea, .select {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  transition: all var(--t-fast);
  outline: none;
}

.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

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

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

.select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239aa3bf' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ── Label ── */
.label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
}

/* ── Form Group ── */
.form-group {
  margin-bottom: var(--sp-4);
}

/* ── Toggle Switch ── */
.toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.toggle-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.toggle {
  position: relative;
  width: 36px;
  height: 20px;
  cursor: pointer;
}

.toggle input { display: none; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--surface-4);
  border-radius: var(--r-full);
  border: 1px solid var(--border-default);
  transition: all var(--t-fast);
}

.toggle input:checked + .toggle-track {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--t-fast);
  box-shadow: var(--shadow-sm);
}

.toggle input:checked ~ .toggle-thumb {
  transform: translateX(16px);
}

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
}
.badge-accent { background: rgba(99,102,241,0.2); color: var(--text-accent); border: 1px solid rgba(99,102,241,0.3); }
.badge-success { background: rgba(16,185,129,0.15); color: var(--text-success); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--text-warning); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--text-danger); }

/* ── Divider ── */
.divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: var(--sp-4) 0;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ── Toast Notification ── */
#toast-container {
  position: fixed;
  top: var(--sp-5);
  right: var(--sp-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-lg);
  font-size: 13px;
  font-weight: 500;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: toastIn 0.3s var(--t-spring);
  max-width: 340px;
}

.toast.fade-out { animation: toastOut 0.25s ease forwards; }

.toast-success { background: #d1fae5; border: 1px solid #6ee7b7; color: #065f46; }
.toast-error   { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; }
.toast-info    { background: #e0e7ff; border: 1px solid #a5b4fc; color: #3730a3; }
.toast-warning { background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; }

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

/* ── Spinner ── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--surface-2);
  border: 1px solid var(--border-default);
  border-radius: var(--r-xl);
  padding: var(--sp-8);
  max-width: 440px;
  width: 90%;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.3s var(--t-spring);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: var(--sp-2);
}

.modal-body { color: var(--text-secondary); font-size: 14px; margin-bottom: var(--sp-6); }
.modal-actions { display: flex; gap: var(--sp-3); justify-content: flex-end; }

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

/* ── Share / Invite Modal ── */
.share-modal { max-width: 520px !important; }

/* QRCode.js injects canvas or img — make it fill its box */
#share-qr-box canvas, #share-qr-box img,
#pres-qr-box canvas, #pres-qr-box img {
  width: 100% !important;
  height: 100% !important;
  display: block;
  object-fit: contain;
}

/* Shimmer placeholder while QR renders */
.qr-loading {
  background: linear-gradient(90deg,
    var(--surface-3) 25%, var(--surface-4) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: qrShimmer 1.2s ease-in-out infinite;
  border-radius: var(--r-md);
}
@keyframes qrShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Color picker ── */
.color-picker-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  border: 2px solid var(--border-default);
  cursor: pointer;
  overflow: hidden;
}
.color-swatch input[type="color"] {
  width: 100%;
  height: 100%;
  border: none;
  padding: 0;
  cursor: pointer;
  background: none;
}
.color-hex-input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ── Utility ── */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.w-full { width: 100%; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.mt-auto { margin-top: auto; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }

/* ── Lucide Icon Sizing ── */
[data-lucide] {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}
.icon-xs  { width: 12px; height: 12px; }
.icon-sm  { width: 14px; height: 14px; }
.icon-md  { width: 16px; height: 16px; }
.icon-lg  { width: 20px; height: 20px; }
.icon-xl  { width: 24px; height: 24px; }
.icon-2xl { width: 32px; height: 32px; }
