/* =============================================
   iOS 26 Liquid Glass Design System
   ============================================= */

/* ---------- CSS Variables ---------- */
:root, [data-theme="light"] {
  --background:        #f2f2f7;
  --foreground:        #1c1c1e;
  --card:              rgba(255,255,255,0.72);
  --card-foreground:   #1c1c1e;
  --popover:           rgba(255,255,255,0.88);
  --popover-foreground:#1c1c1e;
  --primary:           #ffffff;
  --primary-foreground:#1c1c1e;
  --primary-hover:     #e5e5ea;
  --secondary:         rgba(120,120,128,0.12);
  --muted:             rgba(120,120,128,0.08);
  --muted-foreground:  #8e8e93;
  --accent:            rgba(255,255,255,0.12);
  --accent-foreground: #1c1c1e;
  --border:            rgba(60,60,67,0.12);
  --border-hover:      rgba(60,60,67,0.22);
  --success:           #34c759;
  --warning:           #ff9500;
  --destructive:       #ff3b30;

  --glass-bg:          rgba(255,255,255,0.65);
  --glass-border:      rgba(255,255,255,0.8);
  --glass-shadow:      0 8px 40px rgba(0,0,0,.10), 0 1.5px 0 rgba(255,255,255,.9) inset;
  --card-shadow:       0 4px 24px rgba(0,0,0,.08);
  --popover-shadow:    0 12px 40px rgba(0,0,0,.14);

  --blob-1: rgba(200,200,200,0.18);
  --blob-2: rgba(52,199,89,0.14);
  --blob-3: rgba(255,149,0,0.10);
}

[data-theme="dark"] {
  --background:        #000000;
  --foreground:        #f5f5f7;
  --card:              rgba(28,28,30,0.82);
  --card-foreground:   #f5f5f7;
  --popover:           rgba(44,44,46,0.92);
  --popover-foreground:#e5e5ea;
  --primary:           #ffffff;
  --primary-foreground:#1c1c1e;
  --primary-hover:     #e5e5ea;
  --secondary:         rgba(120,120,128,0.18);
  --muted:             rgba(120,120,128,0.12);
  --muted-foreground:  #636366;
  --accent:            rgba(255,255,255,0.15);
  --accent-foreground: #ffffff;
  --border:            rgba(255,255,255,0.1);
  --border-hover:      rgba(255,255,255,0.18);
  --success:           #30d158;
  --warning:           #ff9f0a;
  --destructive:       #ff453a;

  --glass-bg:          rgba(28,28,30,0.75);
  --glass-border:      rgba(255,255,255,0.10);
  --glass-shadow:      0 8px 40px rgba(0,0,0,.55), 0 1px 0 rgba(255,255,255,.06) inset;
  --card-shadow:       0 4px 32px rgba(0,0,0,.55);
  --popover-shadow:    0 12px 40px rgba(0,0,0,.5);

  --blob-1: rgba(255,255,255,0.14);
  --blob-2: rgba(48,209,88,0.10);
  --blob-3: rgba(255,159,10,0.08);
}

/* ---------- Ambient blobs ---------- */
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  animation: blob-drift 18s ease-in-out infinite alternate;
}
.blob-1 {
  width: 420px; height: 420px;
  background: var(--blob-1);
  top: -120px; left: -100px;
  animation-delay: 0s;
}
.blob-2 {
  width: 340px; height: 340px;
  background: var(--blob-2);
  bottom: -80px; right: -60px;
  animation-delay: -6s;
}
.blob-3 {
  width: 260px; height: 260px;
  background: var(--blob-3);
  top: 45%; left: 55%;
  animation-delay: -12s;
}
@keyframes blob-drift {
  0%   { transform: translate(0,0) scale(1); }
  50%  { transform: translate(30px,-20px) scale(1.06); }
  100% { transform: translate(-20px,30px) scale(0.96); }
}

/* ---------- Liquid Glass Card ---------- */
.glass-card {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(28px) saturate(1.6);
  backdrop-filter: blur(28px) saturate(1.6);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  box-shadow: var(--glass-shadow);
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}

/* ---------- Flippable Status Card ---------- */
.status-card {
  position: relative;
  perspective: 1600px;
  transition: height 0.38s cubic-bezier(.22,1,.36,1);
}
.status-card-inner {
  position: relative;
  width: 100%;
  transform-style: preserve-3d;
  transition: transform 0.82s cubic-bezier(.22,.9,.24,1);
}
.status-card.is-flipped .status-card-inner {
  transform: rotateY(180deg);
}
.status-face {
  position: absolute;
  inset: 0;
  width: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transform-style: preserve-3d;
}
.status-face-front {
  z-index: 2;
}
.status-face-back {
  transform: rotateY(180deg);
}
.state-panel-shell {
  padding-top: 2px;
}
.state-screen {
  display: none;
}
.state-screen.is-active {
  display: flex;
}

/* ---------- Timer ---------- */
.timer-ring-track {
  stroke: var(--border);
  transition: stroke .3s;
}
.timer-ring-progress {
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset 1s linear, stroke .5s;
}
.timer-icon {
  color: var(--muted-foreground);
}

/* ---------- QR wrapper ---------- */
.qr-wrapper {
  background: #ffffff;
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 2px 16px rgba(0,0,0,.12), 0 0 0 1px rgba(0,0,0,.04);
  display: inline-block;
}

/* ---------- iOS Pill button ---------- */
.ios-pill {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid var(--glass-border);
  border-radius: 99px;
  padding: 6px 13px;
  color: var(--card-foreground);
  transition: background 0.15s, opacity 0.15s;
}
.ios-pill:hover { opacity: 0.82; }
.ios-pill:active { opacity: 0.6; }
.ios-pill.w-9 { padding: 0; justify-content: center; }

/* ---------- iOS Rows ---------- */
.ios-row {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  transition: background 0.12s;
}
.ios-row:active { background: var(--muted); }

/* ---------- Icon button ---------- */
.ios-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 10px;
  color: var(--muted-foreground);
  background: var(--secondary);
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.ios-icon-btn:hover { background: var(--accent); color: var(--primary); }

/* ---------- Primary CTA button ---------- */
.ios-btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  border-radius: 16px;
  padding: 16px 24px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  box-shadow: 0 4px 18px rgba(0,0,0,0.12), 0 1px 0 rgba(255,255,255,.2) inset;
}
[data-theme="dark"] .ios-btn-primary {
  box-shadow: 0 4px 18px rgba(255,255,255,0.18), 0 1px 0 rgba(255,255,255,.12) inset;
}
.ios-btn-primary:hover { background: var(--primary-hover); }
.ios-btn-primary:active { transform: scale(0.97); opacity: 0.9; }
.ios-btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ---------- Secondary button ---------- */
.ios-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--secondary);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 11px 28px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.ios-btn-secondary:hover { background: var(--accent); }
.ios-btn-secondary:active { opacity: 0.7; }

/* ---------- State icon circle ---------- */
.ios-state-icon {
  width: 76px; height: 76px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

/* ---------- Context Menu ---------- */
.ios-menu {
  background: var(--popover);
  -webkit-backdrop-filter: blur(30px) saturate(1.8);
  backdrop-filter: blur(30px) saturate(1.8);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: var(--popover-shadow);
  overflow: hidden;
}
.ios-menu.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}
.ios-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 15px;
  font-size: 14px;
  font-weight: 500;
  color: var(--card-foreground);
  cursor: pointer;
  transition: background 0.1s;
}
.ios-menu-item:hover { background: var(--accent); }
.ios-menu-item.is-selected { color: var(--primary); font-weight: 600; }
.ios-menu-item + .ios-menu-item { border-top: 1px solid var(--border); }

/* ---------- Select states ---------- */
.select-trigger.is-open { opacity: 0.8; }
.select-trigger.is-open .select-chevron { transform: rotate(180deg); }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(28,28,30,0.88);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  z-index: 9999;
  white-space: nowrap;
}
[data-theme="light"] #toast {
  background: rgba(44,44,46,0.9);
}

/* ---------- Animations ---------- */
@keyframes state-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- View Transition ---------- */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
::view-transition-old(root) { z-index: 1; }
::view-transition-new(root) { z-index: 9; }

/* ---------- Debug toolbar ---------- */
#debug-bar {
  position: fixed; bottom: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
#debug-toggle {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: #7c3aed; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 12px rgba(124,58,237,.5);
  transition: background .15s, transform .1s;
}
#debug-toggle:hover { background: #6d28d9; }
#debug-toggle:active { transform: scale(.92); }
#debug-panel {
  display: none; flex-direction: column; gap: 5px;
  background: rgba(15,15,20,.92);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(124,58,237,.35); border-radius: 14px;
  padding: 12px; min-width: 150px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
#debug-panel.is-open { display: flex; }
.debug-label {
  font-size: 10px; font-weight: 700; color: #a78bfa;
  letter-spacing: .12em; text-transform: uppercase;
  margin-bottom: 4px; padding-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.debug-btn {
  background: rgba(255,255,255,.07); color: #d1d5db;
  border: 1px solid rgba(255,255,255,.1); border-radius: 8px;
  padding: 6px 10px; font-size: 12px; font-weight: 500;
  cursor: pointer; text-align: left; font-family: inherit;
  transition: background .12s, color .12s;
}
.debug-btn:hover { background: rgba(255,255,255,.14); color: #fff; }
.debug-btn--reset:hover   { border-color: #60a5fa; color: #93c5fd; }
.debug-btn--success:hover { border-color: #34d399; color: #6ee7b7; }
.debug-btn--expired:hover { border-color: #f87171; color: #fca5a5; }
.debug-btn--timeout:hover { border-color: #fb923c; color: #fdba74; }
.debug-btn--urgent:hover  { border-color: #facc15; color: #fde68a; }
.debug-btn--not-found {
  background: rgba(142,142,147,.15);
  color: #8e8e93;
}

@media (prefers-reduced-motion: reduce) {
  .status-card,
  .status-card-inner,
  .status-face,
  .timer-ring-progress {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
