/* ═══════════════════════════════════════════════════════
   NOVA Support Pool — Components
   Buttons · Cards · Inputs · Badges · Modals · Toasts
   ═══════════════════════════════════════════════════════ */

/* ── BUTTONS ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius-lg);
  font-weight: var(--weight-semibold);
  font-size: var(--text-base);
  line-height: 1;
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease-out),
    box-shadow  var(--dur-fast) var(--ease-out),
    transform   var(--dur-fast) var(--ease-out),
    opacity     var(--dur-fast) var(--ease-out);
  position: relative;
  overflow: hidden;
  user-select: none;
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn--primary {
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: var(--shadow-glow-primary);
}
.btn--primary:hover:not(:disabled) {
  box-shadow: 0 0 32px rgba(124,58,237,0.55);
  filter: brightness(1.08);
}

.btn--secondary {
  background: var(--bg-glass);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  backdrop-filter: blur(8px);
}
.btn--secondary:hover:not(:disabled) {
  background: var(--bg-glass-hover);
  border-color: var(--border-strong);
}

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

.btn--danger {
  background: var(--gradient-danger);
  color: #fff;
  box-shadow: var(--shadow-glow-danger);
}
.btn--success {
  background: var(--gradient-success);
  color: #fff;
  box-shadow: var(--shadow-glow-success);
}
.btn--gold {
  background: var(--gradient-gold);
  color: #0a0a14;
  box-shadow: var(--shadow-glow-gold);
  font-weight: var(--weight-bold);
}

.btn--pill   { border-radius: var(--radius-full); }
.btn--sm     { padding: var(--sp-2) var(--sp-3); font-size: var(--text-sm); border-radius: var(--radius-md); }
.btn--lg     { padding: var(--sp-4) var(--sp-8); font-size: var(--text-lg); border-radius: var(--radius-xl); }
.btn--full   { width: 100%; }
.btn--icon   { padding: var(--sp-2); width: 40px; height: 40px; border-radius: var(--radius-md); }
.btn--icon-lg{ padding: var(--sp-3); width: 48px; height: 48px; border-radius: var(--radius-lg); }

/* Ripple */
.btn .ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  background: rgba(255,255,255,0.25);
  animation: ripple 600ms linear;
  pointer-events: none;
}

/* ── CARDS ────────────────────────────────────────────── */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--sp-5);
  position: relative;
  overflow: hidden;
}
.card--glass {
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border-color: var(--border-subtle);
}
.card--elevated {
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-subtle);
}
.card--gold {
  background: linear-gradient(135deg, rgba(232,184,75,0.12) 0%, rgba(245,200,66,0.06) 100%);
  border-color: rgba(232,184,75,0.3);
}
.card--primary {
  background: linear-gradient(135deg, rgba(124,58,237,0.12) 0%, rgba(6,182,212,0.06) 100%);
  border-color: rgba(124,58,237,0.25);
}
.card--success {
  background: linear-gradient(135deg, rgba(16,185,129,0.12) 0%, rgba(5,150,105,0.06) 100%);
  border-color: rgba(16,185,129,0.25);
}
.card--danger {
  background: linear-gradient(135deg, rgba(239,68,68,0.12) 0%, rgba(185,28,28,0.06) 100%);
  border-color: rgba(239,68,68,0.25);
}
.card--interactive {
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.card--interactive:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.card--interactive:active { transform: scale(0.98); }

/* ── INPUTS ───────────────────────────────────────────── */
.input-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.input-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.input {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-glass);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: var(--text-base);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
  backdrop-filter: blur(8px);
}
.input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-soft);
}
.input::placeholder { color: var(--text-tertiary); }
.input--lg { padding: var(--sp-4) var(--sp-5); font-size: var(--text-lg); border-radius: var(--radius-xl); }

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

/* ── BADGES ───────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  padding: 2px var(--sp-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  white-space: nowrap;
}
.badge--primary  { background: var(--accent-primary-soft);  color: var(--accent-primary-hover); }
.badge--success  { background: var(--accent-success-soft);  color: var(--accent-success); }
.badge--warning  { background: var(--accent-warning-soft);  color: var(--accent-warning); }
.badge--danger   { background: var(--accent-danger-soft);   color: var(--accent-danger); }
.badge--gold     { background: var(--accent-gold-soft);     color: var(--accent-gold); }
.badge--dot {
  width: 8px; height: 8px;
  padding: 0; border-radius: 50%;
}
.badge--count {
  min-width: 20px; height: 20px;
  padding: 0 5px;
  background: var(--accent-danger);
  color: #fff;
}

/* ── NOTIFICATION PILL ─────────────────────────────────── */
.notif-pip {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 18px; height: 18px;
  background: var(--accent-danger);
  color: #fff;
  font-size: 10px;
  font-weight: var(--weight-bold);
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg-base);
  line-height: 1;
}

/* ── TOGGLE ───────────────────────────────────────────── */
.toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
  user-select: none;
}
.toggle__track {
  width: 48px; height: 28px;
  background: var(--bg-glass-active);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  position: relative;
  transition: background var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out);
  flex-shrink: 0;
}
.toggle__thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: transform var(--dur-base) var(--ease-spring), background var(--dur-base) var(--ease-out);
  box-shadow: var(--shadow-sm);
}
.toggle input[type="checkbox"] { display: none; }
.toggle input:checked + .toggle__track {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}
.toggle input:checked + .toggle__track .toggle__thumb {
  transform: translateX(20px);
  background: #fff;
}
.toggle__label { font-size: var(--text-base); color: var(--text-primary); }

/* ── MODAL / DIALOG ───────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  /* No padding here — iOS WebKit resolves flex-child width:100% against
     the border-box (ignoring padding), so the card overflows. Use margin
     on the child instead so the width is constrained explicitly. */
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
}
.modal-backdrop.open {
  opacity: 1;
  pointer-events: all;
}
.modal {
  /* calc(100vw - 2×16px) is reliable on iOS; width:100% inside a padded flex
     container can exceed the viewport in Safari due to a long-standing bug. */
  width: calc(100vw - 2 * var(--sp-4));
  max-width: var(--max-w);
  margin: 0 var(--sp-4) var(--sp-4);
  max-height: 90vh;
  max-height: 90svh; /* iOS Safari: excludes browser chrome from height calculation */
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-2xl) var(--radius-2xl) var(--radius-xl) var(--radius-xl);
  padding: var(--sp-6);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(40px);
  transition: transform var(--dur-slow) var(--ease-spring);
}
.modal-backdrop.open .modal { transform: translateY(0); }

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
  flex-shrink: 0;
}
.modal__body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.modal__title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  font-family: var(--font-display);
}
.modal__close {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  transition: color var(--dur-fast), background var(--dur-fast);
}
.modal__close:hover { background: var(--bg-glass-hover); color: var(--text-primary); }

/* ── Animated bell pip (Fix 4: Nav Chat Bell) ──────────────── */
.notif-pip--bell {
  font-size: 13px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: bell-ring 1s ease-in-out infinite;
  background: transparent !important;
  color: var(--accent-warning, #f59e0b);
  min-width: unset;
  padding: 0;
  height: auto;
}
@keyframes bell-ring {
  0%, 60%, 100% { transform: rotate(0deg); }
  10%, 30%      { transform: rotate(-18deg); }
  20%, 40%      { transform: rotate(18deg); }
  50%           { transform: rotate(-10deg); }
}

/* ── TOAST ────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: calc(var(--header-height) + var(--sp-4));
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  align-items: center;
  pointer-events: none;
  width: 100%;
  max-width: var(--max-w);
  padding: 0 var(--sp-4);
}
.toast {
  padding: var(--sp-3) var(--sp-5);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  backdrop-filter: blur(20px);
  animation: slide-up var(--dur-base) var(--ease-spring) both;
  pointer-events: none;
  max-width: 100%;
  text-align: center;
}
.toast--success { border-color: var(--accent-success); color: var(--accent-success); }
.toast--error   { border-color: var(--accent-danger);  color: var(--accent-danger); }
.toast--warning { border-color: var(--accent-warning); color: var(--accent-warning); }
.toast--info    { border-color: var(--accent-secondary); color: var(--accent-secondary); }
.toast.removing { animation: fade-out var(--dur-base) var(--ease-out) both; }

/* ── PROGRESS / RING ──────────────────────────────────── */
.progress-ring {
  transform: rotate(-90deg);
}
.progress-ring__bg { fill: none; stroke: var(--border-default); }
.progress-ring__fill {
  fill: none;
  stroke-linecap: round;
  transition: stroke-dashoffset var(--dur-slow) var(--ease-out);
}

/* ── DIVIDER ──────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border-default);
  margin: var(--sp-4) 0;
}
.divider--label {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.divider--label::before, .divider--label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-default);
}

/* ── AVATAR ───────────────────────────────────────────── */
.avatar {
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar--sm  { width: 32px; height: 32px; font-size: var(--text-sm); }
.avatar--md  { width: 44px; height: 44px; font-size: var(--text-base); }
.avatar--lg  { width: 64px; height: 64px; font-size: var(--text-xl); }
.avatar--xl  { width: 88px; height: 88px; font-size: var(--text-2xl); }

/* ── SKELETON ─────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-glass) 25%,
    var(--bg-glass-hover) 50%,
    var(--bg-glass) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-md);
}

/* ── CHIP ─────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3);
  background: var(--bg-glass);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  user-select: none;
}
.chip:hover, .chip.active {
  background: var(--accent-primary-soft);
  border-color: var(--accent-primary);
  color: var(--accent-primary-hover);
}
.chip.active { font-weight: var(--weight-semibold); }

/* ── SECTION TITLE ────────────────────────────────────── */
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}
.section-title__text {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--text-tertiary);
}
.section-title__action {
  font-size: var(--text-sm);
  color: var(--accent-primary-hover);
  font-weight: var(--weight-medium);
  cursor: pointer;
}

/* ── STAT TILE ────────────────────────────────────────── */
.stat-tile {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-4);
  border-radius: var(--radius-xl);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
}
.stat-tile__value {
  font-size: var(--text-2xl);
  font-weight: var(--weight-black);
  font-family: var(--font-display);
  line-height: 1;
}
.stat-tile__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}

/* ── EMPTY STATE ──────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  padding: var(--sp-12) var(--sp-6);
  color: var(--text-tertiary);
  text-align: center;
}
.empty-state__icon { font-size: 48px; opacity: 0.5; }
.empty-state__text { font-size: var(--text-base); }

/* ── LIST ITEM ────────────────────────────────────────── */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  transition: background var(--dur-fast) var(--ease-out);
}
.list-item:hover { background: var(--bg-glass-hover); }
.list-item + .list-item { margin-top: var(--sp-2); }
.list-item--unread { border-color: var(--accent-primary); background: rgba(124,58,237,.07); }
.list-item__icon  { font-size: 24px; flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%; background: var(--bg-glass-active); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.list-item__body  { flex: 1; min-width: 0; }
.list-item__title { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text-primary); margin-bottom: 2px; }
.list-item__sub   { font-size: var(--text-xs); color: var(--text-secondary); }
.list-item__quote { font-size: var(--text-xs); color: var(--text-tertiary); font-style: italic; margin-bottom: 2px; }
.list-item__time  { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }
.list-item__aside { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: var(--sp-1); }
.list-item__rank  { font-size: 18px; flex-shrink: 0; width: 32px; text-align: center; }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state__title { font-size: var(--text-base); font-weight: var(--weight-semibold); color: var(--text-primary); margin-top: var(--sp-2); }
.empty-state__sub   { font-size: var(--text-sm); color: var(--text-secondary); }

/* ── QUEUE MODAL ─────────────────────────────────────────── */
.queue-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.queue-row {
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
}
.queue-row--active {
  border-color: rgba(34,197,94,.35);
  background: rgba(34,197,94,.06);
}
.queue-row__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.queue-row__live  { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--accent-success); }
.queue-row__sched { font-size: var(--text-sm); font-weight: var(--weight-medium);   color: var(--text-secondary); }
.queue-row__link  { font-size: 12px; color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-row__timer { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }
.queue-bal-warn {
  padding: var(--sp-3) var(--sp-4);
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  color: var(--accent-danger);
  margin-bottom: var(--sp-3);
}
.queue-reset-info {
  font-size: 11px;
  color: var(--text-tertiary);
  text-align: center;
  margin-top: var(--sp-2);
}
.queue-full-msg {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--accent-success);
  padding: var(--sp-3) 0;
  margin-top: var(--sp-2);
}

/* ── LEADERBOARD ─────────────────────────────────────────── */
.lb-list { display: flex; flex-direction: column; gap: var(--sp-2); }
