/* ============================================================
   Media AI Box - Components (Apple 2026 style)
   ============================================================ */

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  transition: all 0.2s var(--ease-out);
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border);
}

.card:hover {
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-4);
  gap: var(--s-3);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
  font-weight: 400;
}

.card-interactive {
  cursor: pointer;
}

.card-interactive:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.card-interactive:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

/* ===== Form Inputs ===== */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: -0.005em;
}

.field-hint {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
  font-weight: 400;
}

.input,
.textarea,
.select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 9px var(--s-3);
  color: var(--text);
  font-size: 14px;
  width: 100%;
  outline: none;
  transition: all 0.15s;
  font-family: inherit;
  letter-spacing: -0.005em;
}

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

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}

.textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.5;
  padding: 10px var(--s-3);
}

.textarea-lg {
  min-height: 220px;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='%236e6e73' d='M5 8l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  background-size: 14px;
  padding-inline-start: 36px;
  cursor: pointer;
}

/* Color picker */
.color-input {
  width: 40px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  cursor: pointer;
  background: transparent;
  padding: 2px;
}

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  gap: var(--s-3);
}

.toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-switch {
  width: 42px;
  height: 24px;
  background: var(--surface-pressed);
  border-radius: 14px;
  position: relative;
  transition: background 0.2s;
}

.toggle-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: all 0.2s var(--ease-out);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.toggle-input:checked + .toggle-switch {
  background: var(--green);
}

.toggle-input:checked + .toggle-switch::after {
  transform: translateX(-18px);
}

[dir="rtl"] .toggle-input:checked + .toggle-switch::after {
  transform: translateX(-18px);
}

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.005em;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}

.badge-primary {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

.badge-success {
  background: rgba(52, 199, 89, 0.12);
  color: #137a30;
  border-color: transparent;
}

.badge-warning {
  background: rgba(255, 149, 0, 0.12);
  color: #b25c00;
  border-color: transparent;
}

.badge-info {
  background: rgba(90, 200, 250, 0.16);
  color: #006a8e;
  border-color: transparent;
}

.badge-muted {
  background: var(--surface-2);
  color: var(--text-3);
  border-color: var(--border);
}

/* ===== Tabs (segmented control) ===== */
.tabs {
  display: inline-flex;
  gap: 2px;
  background: var(--surface-pressed);
  border-radius: var(--r-sm);
  padding: 2px;
}

.tab {
  padding: 6px var(--s-4);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}

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

.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

/* ===== Progress ===== */
.progress {
  width: 100%;
  height: 4px;
  background: var(--surface-pressed);
  border-radius: var(--r-pill);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: var(--r-pill);
  transition: width 0.3s var(--ease-out);
  position: relative;
}

.progress-bar.animated::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.5),
    transparent
  );
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  to {
    transform: translateX(200%);
  }
}

/* ===== Empty State ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--s-16) var(--s-6);
  text-align: center;
  gap: var(--s-3);
}

.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: var(--s-2);
  border: 1px solid var(--border);
}

.empty-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.empty-desc {
  font-size: 13px;
  color: var(--text-3);
  max-width: 380px;
  line-height: 1.5;
}

/* ===== Avatar / Thumb ===== */
.thumb {
  background: var(--surface-2);
  border-radius: var(--r-md);
  position: relative;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  box-shadow: var(--shadow-xs);
}

.thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--text-muted);
  height: 100%;
}

.thumb-aspect-video {
  aspect-ratio: 16/9;
}

.thumb-aspect-square {
  aspect-ratio: 1;
}

/* ===== Chip ===== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.chip.active {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}

.chip-remove {
  color: var(--text-3);
  font-size: 13px;
  line-height: 1;
}

/* ===== Loading Skeleton ===== */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-2) 0%,
    var(--surface-hover) 50%,
    var(--surface-2) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.4s infinite;
  border-radius: var(--r-xs);
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ===== Divider ===== */
.divider {
  height: 1px;
  background: var(--divider);
  margin: var(--s-4) 0;
}

.divider-text {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: var(--s-4) 0;
}

.divider-text::before,
.divider-text::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--divider);
}

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

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--surface);
  padding: 4px 10px;
  border-radius: var(--r-xs);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 50;
}

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

/* ===== Dropdown ===== */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  inset-inline-end: 0;
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 4px;
  min-width: 200px;
  box-shadow: var(--shadow-lg);
  z-index: 40;
  display: none;
  border: 1px solid var(--border);
  animation: dropdownIn 0.15s var(--ease-out);
}

.dropdown.open .dropdown-menu {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

@keyframes dropdownIn {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.dropdown-item {
  padding: 8px 12px;
  border-radius: var(--r-xs);
  color: var(--text);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  cursor: pointer;
  transition: background 0.1s;
}

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

.dropdown-item.danger {
  color: var(--red);
}

.dropdown-item.danger:hover {
  background: rgba(255, 59, 48, 0.08);
}

/* ===== Stepper ===== */
.stepper {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-7);
}

.step {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.step-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  flex-shrink: 0;
  transition: all 0.25s var(--ease-out);
}

.step.active .step-circle {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.step.completed .step-circle {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.step-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: -0.005em;
}

.step.active .step-label {
  color: var(--text);
  font-weight: 600;
}

.step.completed .step-label {
  color: var(--text-2);
}

.step-line {
  flex: 1;
  height: 1.5px;
  background: var(--border);
  margin: 0 var(--s-2);
  border-radius: 1px;
  min-width: 24px;
}

.step-line.completed {
  background: var(--green);
}

/* Lazy route transition spinner */
.route-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 40vh;
  color: var(--text-3);
}

.route-loading-spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2.5px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--accent);
  animation: routeSpin 0.75s linear infinite;
}

.route-loading-text {
  font-size: 14px;
  font-weight: 500;
}

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

@media (prefers-reduced-motion: reduce) {
  .route-loading-spinner {
    animation: none;
  }
}

/* Project workspace loading gate (cloud + local prefetch) */
.workspace-root {
  position: relative;
}

.workspace-root--loading {
  min-height: 50vh;
}

.project-load-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(6px);
  border-radius: var(--r-lg);
  color: var(--text-3);
}

.project-load-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-2);
}

.project-load-progress {
  font-size: 13px;
  font-weight: 500;
  min-height: 1.25em;
  color: var(--text-3);
}
