@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ================= SHADCN DESIGN SYSTEM TOKENS ================= */
:root {
  --background: #ffffff;
  --foreground: #0f172a;
  --card: #ffffff;
  --card-foreground: #0f172a;
  --popover: #ffffff;
  --popover-foreground: #0f172a;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-foreground: #ffffff;
  --secondary: #f1f5f9;
  --secondary-foreground: #0f172a;
  --muted: #f1f5f9;
  --muted-foreground: #64748b;
  --accent: #f1f5f9;
  --accent-foreground: #0f172a;
  --destructive: #ef4444;
  --destructive-foreground: #ffffff;
  --border: #e2e8f0;
  --input: #e2e8f0;
  --ring: #6366f1;
  --radius: 0.5rem;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

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

body {
  font-family: inherit;
  background-color: var(--background);
  color: var(--foreground);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img, svg, video {
  display: block;
  max-width: 100%;
}

header img {
  width: 1.75rem !important;
  height: 1.75rem !important;
  object-fit: contain;
  flex-shrink: 0;
}

[hidden] {
  display: none !important;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
}

textarea {
  border: 1px solid var(--input);
  border-radius: var(--radius);
  background-color: transparent;
  color: var(--foreground);
  outline: none;
  resize: vertical;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 1px var(--ring);
}

.p-0\.5 { padding: 0.125rem; }
.py-0\.5 { padding-top: 0.125rem; padding-bottom: 0.125rem; }
.border-border\/50 { border-color: rgba(226, 232, 240, 0.5); }

/* ================= UTILITY CLASSES (SHADCN / TAILWIND COMPAT) ================= */

/* Layout & Display */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.hidden { display: none !important; }
.block { display: block; }
.inline-block { display: inline-block; }

.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-1 { flex: 1 1 0%; }
.shrink-0 { flex-shrink: 0; }

.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }

.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }

/* Grid columns */
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }

@media (min-width: 640px) {
  .sm\:flex-row { flex-direction: row; }
  .sm\:items-end { align-items: flex-end; }
  .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sm\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sm\:col-span-1 { grid-column: span 1 / span 1; }
  .sm\:col-span-3 { grid-column: span 3 / span 3; }
  .sm\:px-8 { padding-left: 2rem; padding-right: 2rem; }
  .sm\:text-4xl { font-size: 2.25rem; line-height: 2.5rem; }
}

@media (min-width: 768px) {
  .md\:flex { display: flex !important; }
}

@media (min-width: 1024px) {
  .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lg\:grid-cols-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .lg\:col-span-7 { grid-column: span 7 / span 7; }
  .lg\:col-span-5 { grid-column: span 5 / span 5; }
}

/* Gap */
.gap-1 { gap: 0.25rem; }
.gap-1\.5 { gap: 0.375rem; }
.gap-2 { gap: 0.5rem; }
.gap-2\.5 { gap: 0.625rem; }
.gap-3 { gap: 0.75rem; }
.gap-3\.5 { gap: 0.875rem; }
.gap-4 { gap: 1rem; }
.gap-5 { gap: 1.25rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

/* Dimensions */
.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; }
.max-w-sm { max-width: 24rem; }
.max-w-xl { max-width: 36rem; }
.max-w-7xl { max-width: 80rem; }
.max-w-\[320px\] { max-width: 320px; }
.mx-auto { margin-left: auto; margin-right: auto; }

.w-1\.5 { width: 0.375rem; }
.h-1\.5 { height: 0.375rem; }
.w-3\.5 { width: 0.875rem; }
.h-3\.5 { height: 0.875rem; }
.w-4 { width: 1rem; }
.h-4 { height: 1rem; }
.w-5 { width: 1.25rem; }
.h-5 { height: 1.25rem; }
.w-6 { width: 1.5rem; }
.h-6 { height: 1.5rem; }
.w-7 { width: 1.75rem; }
.h-7 { height: 1.75rem; }
.w-8 { width: 2rem; }
.h-8 { height: 2rem; }
.h-9 { height: 2.25rem; }
.w-10 { width: 2.5rem; }
.h-10 { height: 2.5rem; }
.w-11 { width: 2.75rem; }
.h-12 { height: 3rem; }
.h-14 { height: 3.5rem; }
.h-16 { height: 4rem; }
.w-16 { width: 4rem; }
.h-1 { height: 0.25rem; }
.h-2 { height: 0.5rem; }

/* Positioning */
.relative { position: relative; }
.absolute { position: absolute; }
.sticky { position: sticky; }
.top-0 { top: 0; }
.top-2 { top: 0.5rem; }
.top-4 { top: 1rem; }
.top-20 { top: 5rem; }
.right-4 { right: 1rem; }
.left-3 { left: 0.75rem; }
.left-1\/2 { left: 50%; }
.-translate-x-1\/2 { transform: translateX(-50%); }
.inset-0 { inset: 0; }
.z-20 { z-index: 20; }
.z-40 { z-index: 40; }
.overflow-hidden { overflow: hidden; }

/* Spacing - Padding */
.p-1 { padding: 0.25rem; }
.p-3 { padding: 0.75rem; }
.p-3\.5 { padding: 0.875rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.px-1\.5 { padding-left: 0.375rem; padding-right: 0.375rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-2\.5 { padding-left: 0.625rem; padding-right: 0.625rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-0\.5 { padding-top: 0.125rem; padding-bottom: 0.125rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-1\.5 { padding-top: 0.375rem; padding-bottom: 0.375rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.pt-1 { padding-top: 0.25rem; }
.pt-2 { padding-top: 0.5rem; }
.pt-4 { padding-top: 1rem; }
.pb-4 { padding-bottom: 1rem; }

/* Spacing - Margin */
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mt-0\.5 { margin-top: 0.125rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-1\.5 { margin-top: 0.375rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }

/* Typography */
.text-\[9px\] { font-size: 9px; line-height: 12px; }
.text-\[10px\] { font-size: 10px; line-height: 14px; }
.text-\[11px\] { font-size: 11px; line-height: 15px; }
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.text-3xl { font-size: 1.875rem; line-height: 2.25rem; }

.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

.tracking-tight { letter-spacing: -0.025em; }
.tracking-wider { letter-spacing: 0.05em; }
.uppercase { text-transform: uppercase; }
.leading-none { line-height: 1; }
.leading-relaxed { line-height: 1.625; }
.text-center { text-align: center; }

/* Colors - Text */
.text-foreground { color: var(--foreground); }
.text-muted-foreground { color: var(--muted-foreground); }
.text-primary { color: var(--primary); }
.text-primary-foreground { color: var(--primary-foreground); }
.text-secondary-foreground { color: var(--secondary-foreground); }
.text-destructive { color: var(--destructive); }
.text-white { color: #ffffff; }
.text-white\/90 { color: rgba(255, 255, 255, 0.9); }
.text-slate-900 { color: #0f172a; }
.text-amber-800 { color: #92400e; }
.text-amber-800\/80 { color: rgba(146, 64, 14, 0.8); }
.text-amber-800\/90 { color: rgba(146, 64, 14, 0.9); }
.text-amber-900 { color: #78350f; }
.text-emerald-800\/80 { color: rgba(6, 95, 70, 0.8); }
.text-emerald-950 { color: #022c22; }

/* Colors - Background */
.bg-background { background-color: var(--background); }
.bg-background\/95 { background-color: rgba(255, 255, 255, 0.95); }
.bg-card { background-color: var(--card); }
.bg-muted { background-color: var(--muted); }
.bg-muted\/20 { background-color: rgba(241, 245, 249, 0.4); }
.bg-muted\/30 { background-color: rgba(241, 245, 249, 0.6); }
.bg-muted\/40 { background-color: rgba(241, 245, 249, 0.8); }
.bg-secondary { background-color: var(--secondary); }
.bg-primary { background-color: var(--primary); }
.bg-primary\/5 { background-color: rgba(79, 70, 229, 0.05); }
.bg-primary\/10 { background-color: rgba(79, 70, 229, 0.1); }
.bg-destructive\/10 { background-color: rgba(239, 68, 68, 0.1); }
.bg-amber-50 { background-color: #fffbeb; }
.bg-amber-200 { background-color: #fde68a; }
.bg-emerald-50\/60 { background-color: rgba(236, 253, 245, 0.6); }
.bg-emerald-600 { background-color: #059669; }
.bg-slate-200 { background-color: #e2e8f0; }
.bg-slate-800 { background-color: #1e293b; }
.bg-slate-900 { background-color: #0f172a; }
.bg-black { background-color: #000000; }
.bg-black\/60 { background-color: rgba(0, 0, 0, 0.6); }
.bg-transparent { background-color: transparent; }

/* Borders & Radii */
.border { border: 1px solid var(--border); }
.border-b { border-bottom: 1px solid var(--border); }
.border-t { border-top: 1px solid var(--border); }
.border-2 { border-width: 2px; }
.border-dashed { border-style: dashed; }
.border-border { border-color: var(--border); }
.border-input { border-color: var(--input); }
.border-primary\/20 { border-color: rgba(79, 70, 229, 0.2); }
.border-primary\/80 { border-color: rgba(79, 70, 229, 0.8); }
.border-destructive\/30 { border-color: rgba(239, 68, 68, 0.3); }
.border-amber-300 { border-color: #fcd34d; }
.border-emerald-200 { border-color: #a7f3d0; }
.border-slate-900 { border-color: #0f172a; }
.border-\[5px\] { border-width: 5px; }

.rounded { border-radius: 0.25rem; }
.rounded-md { border-radius: 0.375rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-xl { border-radius: 0.75rem; }
.rounded-full { border-radius: 9999px; }
.rounded-\[28px\] { border-radius: 28px; }

/* Shadows */
.shadow-sm { box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); }
.shadow { box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1); }
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1); }
.shadow-2xl { box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }

/* Aspect ratio & object fit */
.aspect-\[9\/16\] { aspect-ratio: 9 / 16; }
.object-contain { object-fit: contain; }
.object-cover { object-fit: cover; }

/* Effects & Transitions */
.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }
.opacity-60 { opacity: 0.6; }
.select-none { user-select: none; }
.backdrop-blur { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }

.transition-colors { transition-property: color, background-color, border-color; transition-duration: 0.15s; }
.transition-all { transition-property: all; transition-duration: 0.15s; }

.hover\:opacity-90:hover { opacity: 0.9; }
.hover\:underline:hover { text-decoration: underline; }
.hover\:bg-primary\/90:hover { background-color: var(--primary-hover); }
.hover\:bg-accent:hover { background-color: var(--accent); }
.hover\:bg-muted\/40:hover { background-color: rgba(241, 245, 249, 0.8); }
.hover\:bg-emerald-700:hover { background-color: #047857; }
.hover\:text-foreground:hover { color: var(--foreground); }

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ================= COMPONENT SPECIFIC STYLES ================= */

/* Navigation tabs */
.nav-link {
  color: var(--muted-foreground);
  font-weight: 500;
  cursor: pointer;
}

.nav-link:hover {
  color: var(--foreground);
}

.nav-link.active {
  background-color: #ffffff;
  color: var(--foreground);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Stepper Header Tabs */
.step-tab {
  border: none;
  font-size: 13px;
  font-weight: 500;
}

.step-tab.active {
  background-color: #ffffff !important;
  color: var(--foreground) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  opacity: 1 !important;
}

.step-tab.completed {
  color: var(--foreground);
  opacity: 1 !important;
  cursor: pointer;
}

/* Inputs & Form Controls */
.input-control {
  height: 2.35rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  background-color: transparent;
  border: 1px solid var(--input);
  border-radius: var(--radius);
  color: var(--foreground);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-control:focus,
.select-control:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 1px var(--ring);
}

.input-control::placeholder {
  color: var(--muted-foreground);
}

/* YouTube URL Input with non-overlapping icon */
.url-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.url-input-wrap .url-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  display: flex;
  align-items: center;
  pointer-events: none;
  z-index: 2;
}

.url-input-wrap input#url {
  padding-left: 2.35rem !important; /* guarantees zero overlap with 16px icon */
}

/* Select wrapper */
.select-wrap {
  position: relative;
}

.select-control {
  appearance: none;
  -webkit-appearance: none;
  background-color: #ffffff;
  padding-right: 2rem;
  border: 1px solid var(--input);
  border-radius: var(--radius);
  height: 2.35rem;
  padding-left: 0.75rem;
  font-size: 0.875rem;
  color: var(--foreground);
  outline: none;
}

.select-wrap::after {
  content: '';
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 5px;
  background-color: var(--muted-foreground);
  clip-path: polygon(100% 0%, 0 0%, 50% 100%);
  pointer-events: none;
}

/* Range slider */
.slider-control {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background-color: #e2e8f0;
  border-radius: 9999px;
  outline: none;
  cursor: pointer;
}

.slider-control::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.slider-control::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

/* Paste / Drag Zone */
.paste-zone:focus-visible,
.paste-zone.dragover {
  border-color: var(--primary);
  background-color: #f5f3ff;
  outline: none;
}

/* Rating Rows in Editor */
.rating-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) 140px auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 0.65rem;
  background-color: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.rating-row select {
  font-size: 0.8rem;
  height: 2rem;
}

.rating-row-actions {
  display: flex;
  gap: 2px;
}

.rating-row-actions button {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--muted-foreground);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.rating-row-actions button:hover {
  background-color: #e2e8f0;
  color: var(--foreground);
}

.ai-reference {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--primary);
  padding-left: 2px;
}

/* Verdict chips */
.verdict-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  padding: 3px 8px;
  border-radius: 4px;
  line-height: 1.1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.final-rating-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background-color: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
}

/* Progress bar */
progress {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

progress::-webkit-progress-bar {
  background-color: #e2e8f0;
}

progress::-webkit-progress-value {
  background: linear-gradient(90deg, #4f46e5, #7c3aed);
  transition: width 0.3s ease;
}

/* Phone Mockup */
.preview-tab {
  border: none;
  background: none;
  color: var(--muted-foreground);
}

.preview-tab.active {
  background-color: #ffffff !important;
  color: var(--foreground) !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

#preview-bg {
  background: linear-gradient(#090a0f40, #090a0f90), url('/assets/theater.jpeg') center / cover;
  filter: saturate(0.5);
  transition: background-position 0.2s ease;
}

.preview-shade {
  background: linear-gradient(180deg, transparent 50%, rgba(6, 6, 8, 0.75) 100%);
}

.preview-rating {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 0;
}

.preview-rating span {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
}

.preview-rating b.verdict-chip {
  font-size: 15px;
  padding: 6px 14px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Library history card */
.history-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background-color: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
}

.history-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.history-thumb {
  width: 48px;
  height: 64px;
  object-fit: cover;
  border-radius: 4px;
  background-color: #000;
  flex-shrink: 0;
}

/* Toast */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #0f172a;
  color: #ffffff;
  padding: 10px 20px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  z-index: 100;
  max-width: calc(100% - 32px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: slideUp 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 640px) {
  .rating-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .rating-row-actions {
    justify-content: flex-end;
  }
}
