/* ══════════════════════════════════════════════════════════════
   Components — Card, Badge, Button, Input, Tabs, Modal, Toast, etc.
   ══════════════════════════════════════════════════════════════ */

/* ── Card — Glassmorphism with subtle red glow border ── */
.card {
  background: var(--glass-bg);
  color: hsl(var(--card-foreground));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  border-color: hsl(var(--neon-red) / 0.25);
}

.card-header {
  padding: 1.25rem 1.5rem 0.75rem;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.3;
}

.card-description {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.25rem;
}

.card-content {
  padding: 0 1.5rem 1.25rem;
}

.card-footer {
  padding: 0.75rem 1.5rem;
  border-top: 1px solid hsl(var(--border));
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.card.hover-lift {
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.3s ease;
}

.card.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px hsl(0 0% 0% / 0.3), var(--shadow-glow-red);
  border-color: hsl(var(--neon-red) / 0.3);
}

.card.selected {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 1px hsl(var(--primary) / 0.3);
}

/* ── Button ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.4;
  font-family: inherit;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: linear-gradient(135deg, hsl(var(--primary)), hsl(var(--neon-cyan)));
  color: hsl(var(--primary-foreground));
  border: none;
}

.btn-primary:hover {
  box-shadow: 0 0 20px hsl(var(--primary) / 0.4), 0 0 40px hsl(var(--neon-cyan) / 0.2);
  transform: translateY(-1px);
}

.btn-secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

.btn-secondary:hover {
  background: hsl(var(--secondary) / 0.9);
}

.btn-outline {
  background: transparent;
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
}

.btn-outline:hover {
  background: hsl(var(--muted));
}

.btn-ghost {
  background: transparent;
  color: hsl(var(--foreground));
}

.btn-ghost:hover {
  background: hsl(var(--muted));
}

.btn-destructive {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.btn-destructive:hover {
  background: hsl(var(--destructive) / 0.9);
}

.btn-sm {
  padding: 0.25rem 0.625rem;
  font-size: 0.8125rem;
}

.btn-xs {
  padding: 0.125rem 0.5rem;
  font-size: 0.7rem;
  gap: 0.25rem;
}

.chip-sm {
  padding: 0.125rem 0.5rem;
  font-size: 0.7rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.btn-icon {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
}

.btn-icon.sm {
  width: 1.75rem;
  height: 1.75rem;
}

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-primary {
  background: hsl(var(--primary) / 0.15);
  color: hsl(var(--primary));
}

.badge-secondary {
  background: hsl(var(--secondary) / 0.15);
  color: hsl(var(--secondary));
}

.badge-success {
  background: hsl(var(--success) / 0.15);
  color: hsl(var(--success));
}

.badge-warning {
  background: hsl(var(--warning) / 0.15);
  color: hsl(var(--warning));
}

.badge-destructive {
  background: hsl(var(--destructive) / 0.15);
  color: hsl(var(--destructive));
}

.badge-info {
  background: hsl(var(--info) / 0.15);
  color: hsl(var(--info));
}

.badge-accent {
  background: hsl(var(--accent) / 0.15);
  color: hsl(var(--accent));
}

.badge-muted {
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}

.badge-outline {
  background: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
}

/* ── Input / Select / Textarea ── */
.input, .select, .textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: hsl(var(--background) / 0.6);
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  color: hsl(var(--foreground));
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  backdrop-filter: blur(8px);
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: hsl(var(--neon-violet));
  box-shadow: 0 0 0 2px hsl(var(--neon-violet) / 0.15), 0 0 12px hsl(var(--neon-violet) / 0.1);
}

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

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}

.textarea {
  min-height: 5rem;
  resize: vertical;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.input-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--foreground));
}

.input-sm {
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem;
}

/* ── Search Input ── */
.search-input {
  position: relative;
}

.search-input .icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  color: hsl(var(--muted-foreground));
  pointer-events: none;
}

.search-input input {
  padding-left: 2.25rem;
}

/* ── Toggle / Switch ── */
.toggle {
  position: relative;
  width: 2.75rem;
  height: 1.5rem;
  background: hsl(var(--muted));
  border-radius: 9999px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  border: none;
  flex-shrink: 0;
}

.toggle.active {
  background: hsl(var(--primary));
}

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1.25rem;
  height: 1.25rem;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.toggle.active::after {
  transform: translateX(1.25rem);
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid hsl(var(--border));
  margin-bottom: 1rem;
}

.tab {
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
  font-family: inherit;
  white-space: nowrap;
}

.tab:hover {
  color: hsl(var(--foreground));
}

.tab.active {
  color: hsl(var(--foreground));
  border-bottom-color: hsl(var(--primary));
}

.tab-content {
  animation: fadeIn 0.2s ease-out;
}

/* ── Modal / Dialog ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: hsl(0 0% 0% / 0.6);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease-out;
}

.modal {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 16px 48px hsl(0 0% 0% / 0.4);
  max-width: 32rem;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease-out;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid hsl(var(--border));
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid hsl(var(--border));
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 24rem;
}

.toast {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  box-shadow: 0 8px 24px hsl(0 0% 0% / 0.3);
  animation: slideInRight 0.3s ease-out;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.toast.success {
  border-left: 3px solid hsl(var(--success));
}

.toast.error {
  border-left: 3px solid hsl(var(--destructive));
}

.toast.warning {
  border-left: 3px solid hsl(var(--warning));
}

.toast.info {
  border-left: 3px solid hsl(var(--info));
}

.toast-title {
  font-size: 0.875rem;
  font-weight: 600;
}

.toast-message {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.125rem;
}

.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  padding: 0.25rem;
  margin-left: auto;
}

/* ── Progress Bar ── */
.progress {
  width: 100%;
  height: 0.5rem;
  background: hsl(var(--muted));
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: hsl(var(--primary));
  border-radius: 9999px;
  transition: width 0.5s ease;
}

.progress-bar.success { background: hsl(var(--success)); }
.progress-bar.warning { background: hsl(var(--warning)); }
.progress-bar.destructive { background: hsl(var(--destructive)); }

/* ── Stat Card ── */
.stat-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
}

.stat-card .stat-icon {
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card .stat-icon.primary { background: hsl(var(--primary) / 0.15); color: hsl(var(--primary)); }
.stat-card .stat-icon.success { background: hsl(var(--success) / 0.15); color: hsl(var(--success)); }
.stat-card .stat-icon.warning { background: hsl(var(--warning) / 0.15); color: hsl(var(--warning)); }
.stat-card .stat-icon.info { background: hsl(var(--info) / 0.15); color: hsl(var(--info)); }
.stat-card .stat-icon.secondary { background: hsl(var(--secondary) / 0.15); color: hsl(var(--secondary)); }
.stat-card .stat-icon.accent { background: hsl(var(--accent) / 0.15); color: hsl(var(--accent)); }
.stat-card .stat-icon.destructive { background: hsl(var(--destructive) / 0.15); color: hsl(var(--destructive)); }

.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-card .stat-label {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
}

/* ── Score display ── */
.score {
  font-weight: 700;
}

.score.high { color: hsl(var(--score-high)); }
.score.medium { color: hsl(var(--score-medium)); }
.score.low { color: hsl(var(--score-low)); }

/* ── Loading Spinner ── */
.spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid hsl(var(--muted));
  border-top-color: hsl(var(--primary));
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner.sm { width: 1rem; height: 1rem; }
.spinner.lg { width: 2rem; height: 2rem; border-width: 3px; }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: hsl(var(--muted-foreground));
}

.empty-state .icon {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 1rem;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.125rem;
  color: hsl(var(--foreground));
  margin-bottom: 0.5rem;
}

/* ── Skeleton Loading ── */
.skeleton {
  background: linear-gradient(90deg, hsl(var(--muted)) 25%, hsl(var(--muted) / 0.5) 50%, hsl(var(--muted)) 75%);
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
  border-radius: var(--radius);
}

.skeleton.h-4 { height: 1rem; }
.skeleton.h-6 { height: 1.5rem; }
.skeleton.h-8 { height: 2rem; }
.skeleton.h-32 { height: 8rem; }
.skeleton.w-24 { width: 6rem; }
.skeleton.w-32 { width: 8rem; }
.skeleton.w-48 { width: 12rem; }

/* ── Tooltip ── */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 0.375rem 0.625rem;
  background: hsl(var(--foreground));
  color: hsl(var(--background));
  font-size: 0.75rem;
  border-radius: calc(var(--radius) - 4px);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* ── Chip (selectable badge) ── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid hsl(var(--border));
  background: transparent;
  color: hsl(var(--foreground));
  font-family: inherit;
}

.chip:hover {
  background: hsl(var(--muted));
}

.chip.selected {
  background: hsl(var(--primary) / 0.15);
  border-color: hsl(var(--primary));
  color: hsl(var(--primary));
}

.chip .check-icon {
  width: 0.875rem;
  height: 0.875rem;
}

/* ── Table ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th, .data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.875rem;
}

.data-table th {
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  border-bottom: 1px solid hsl(var(--border));
}

.data-table td {
  border-bottom: 1px solid hsl(var(--border) / 0.5);
}

.data-table tr:hover td {
  background: hsl(var(--muted) / 0.5);
}

/* ── Alert ── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.875rem;
}

.alert.warning {
  background: hsl(var(--warning) / 0.1);
  border-color: hsl(var(--warning) / 0.3);
  color: hsl(var(--warning));
}

.alert.error {
  background: hsl(var(--destructive) / 0.1);
  border-color: hsl(var(--destructive) / 0.3);
  color: hsl(var(--destructive));
}

.alert.info {
  background: hsl(var(--info) / 0.1);
  border-color: hsl(var(--info) / 0.3);
  color: hsl(var(--info));
}

.alert.success {
  background: hsl(var(--success) / 0.1);
  border-color: hsl(var(--success) / 0.3);
  color: hsl(var(--success));
}

/* ── Scroll Area ── */
.scroll-area {
  overflow-y: auto;
  max-height: 100%;
}

/* ── Dropdown ── */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 10rem;
  background: hsl(var(--popover));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 8px 24px hsl(0 0% 0% / 0.3);
  z-index: 50;
  animation: fadeIn 0.1s ease-out;
  padding: 0.25rem;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  cursor: pointer;
  border-radius: calc(var(--radius) - 4px);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.dropdown-item:hover {
  background: hsl(var(--muted));
}

/* ── Recording indicator (Script to Reel) ─────────────────────────── */
/* A live red dot while the microphone is on, so it is never ambiguous whether
   the page is listening. */
.rec-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
    animation: recPulse 1.4s ease-out infinite;
    flex-shrink: 0;
}
@keyframes recPulse {
    0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
    70%  { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .rec-dot { animation: none; }
}
.chip:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
