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

:root {
  --bg-color: #080b11;
  --bg-gradient: radial-gradient(circle at 50% -20%, #151a2e 0%, #080b11 70%);
  --panel-bg: rgba(17, 22, 37, 0.6);
  --panel-border: rgba(255, 255, 255, 0.06);
  --panel-hover-border: rgba(255, 255, 255, 0.12);
  
  --primary: #00f0ff;
  --primary-glow: rgba(0, 240, 255, 0.25);
  --secondary: #7000ff;
  --secondary-glow: rgba(112, 0, 255, 0.25);
  --accent: #ff007a;
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dark: #4b5563;
  
  --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
  background-color: var(--bg-color);
  background-image: var(--bg-gradient);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  padding: 2rem;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Glassmorphism utility */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  transition: var(--transition-smooth);
}

.glass-panel:hover {
  border-color: var(--panel-hover-border);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
}

/* Header Styles */
header {
  max-width: 1400px;
  margin: 0 auto 2rem auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 1.5rem;
}

.logo-section h1 {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 30%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-section h1 span {
  font-weight: 300;
  opacity: 0.8;
}

.logo-section p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

.header-stats {
  display: flex;
  gap: 1.5rem;
}

.stat-badge {
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 30px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stat-badge .value {
  color: var(--primary);
  font-weight: 600;
  text-shadow: 0 0 8px var(--primary-glow);
}

/* Main Grid Layout */
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

@media (max-width: 1024px) {
  .app-container {
    grid-template-columns: 1fr;
  }
}

/* Video Section (Left Column) */
.video-workspace {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.video-container {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
}

#preview-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.dropzone-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(8, 11, 17, 0.9);
  z-index: 10;
  cursor: pointer;
  transition: var(--transition-smooth);
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
}

.dropzone-overlay:hover {
  border-color: var(--primary);
  background: rgba(13, 21, 38, 0.95);
}

.dropzone-overlay.dragover {
  border-color: var(--primary);
  background: rgba(0, 240, 255, 0.08);
}

.upload-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 2rem;
  color: var(--text-muted);
  transition: var(--transition-smooth);
}

.dropzone-overlay:hover .upload-icon {
  transform: translateY(-5px);
  color: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.2);
}

.video-controls {
  margin-top: 1rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid transparent;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #00bcff 100%);
  color: #04060b;
  box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 240, 255, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.btn-accent {
  background: linear-gradient(135deg, var(--secondary) 0%, #9e00ff 100%);
  color: #fff;
  box-shadow: 0 4px 15px var(--secondary-glow);
}

.btn-accent:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(112, 0, 255, 0.4);
}

.btn-danger {
  background: rgba(255, 0, 122, 0.1);
  color: #ff3399;
  border: 1px solid rgba(255, 0, 122, 0.2);
}

.btn-danger:hover {
  background: rgba(255, 0, 122, 0.2);
  border-color: #ff007a;
}

/* Control Panel Section (Right Column) */
.controls-panel {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.75rem;
}

.control-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

input[type="number"], select {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #fff;
  padding: 0.6rem 0.8rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  flex-grow: 1;
  transition: var(--transition-smooth);
}

input[type="number"]:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
}

/* Dynamic range slider */
.slider-container {
  display: flex;
  align-items: center;
  gap: 1rem;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px var(--primary);
  transition: var(--transition-smooth);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.slider-val {
  min-width: 3rem;
  text-align: right;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--primary);
}

/* Scene Detection progress display */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
  display: none;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--secondary) 0%, var(--primary) 100%);
  border-radius: 4px;
  transition: width 0.1s ease;
}

/* Reference Gallery Section & Split Workspace */
.gallery-workspace {
  max-width: 1400px;
  margin: 2rem auto 0 auto;
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .gallery-workspace {
    grid-template-columns: 1fr;
  }
}

.gallery-section {
  padding: 1.5rem;
}

.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.gallery-title {
  font-size: 1.4rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.gallery-title span {
  color: var(--text-muted);
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.25rem;
}

.frame-card {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(17, 22, 37, 0.8);
  aspect-ratio: 16/10;
  cursor: pointer;
  transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), border-color 0.3s;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.frame-card:hover {
  transform: translateY(-6px) scale(1.02);
  border-color: var(--primary);
  box-shadow: 0 10px 25px rgba(0, 240, 255, 0.15);
}

.frame-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Card Selection Overlays */
.frame-card .select-circle {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  background: rgba(8, 11, 17, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
  transition: var(--transition-smooth);
}

.frame-card .select-circle svg {
  display: none;
  color: #04060b;
}

.frame-card:hover .select-circle {
  border-color: rgba(255, 255, 255, 0.8);
}

.frame-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 15px var(--primary-glow);
}

.frame-card.selected .select-circle {
  background: var(--primary);
  border-color: var(--primary);
}

.frame-card.selected .select-circle svg {
  display: block;
}

.frame-info-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 1.5rem 0.75rem 0.5rem 0.75rem;
  background: linear-gradient(transparent, rgba(8, 11, 17, 0.95));
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.frame-card:hover .frame-info-overlay {
  opacity: 1;
}

.frame-timestamp {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.6);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-delete-frame {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 0, 122, 0.15);
  border: 1px solid rgba(255, 0, 122, 0.3);
  color: #ff3399;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-delete-frame:hover {
  background: var(--accent);
  color: #fff;
  transform: scale(1.15);
}

.btn-note-frame {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(0, 240, 255, 0.12);
  border: 1px solid rgba(0, 240, 255, 0.25);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-note-frame:hover {
  background: var(--primary);
  color: #04060b;
  transform: scale(1.15);
  box-shadow: 0 0 10px var(--primary-glow);
}

.frame-note-drawer {
  animation: slideUpNote 0.25s cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

@keyframes slideUpNote {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.empty-gallery {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
  border: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  transition: var(--transition-smooth);
}

.empty-gallery:hover {
  border-color: var(--primary);
  background: rgba(0, 240, 255, 0.02);
}

.empty-gallery:hover .empty-gallery-icon svg {
  color: var(--primary) !important;
  transform: translateY(-4px);
  filter: drop-shadow(0 0 8px var(--primary-glow));
}

.empty-gallery-icon {
  font-size: 3rem;
  opacity: 0.3;
  transition: var(--transition-smooth);
}

/* Summary Section Styling */
.summary-section {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.summary-item {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  animation: fadeIn 0.4s ease forwards;
}

.summary-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.summary-item h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.4rem;
}

.summary-item p {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-main);
  transition: var(--transition-smooth);
}

.summary-item p strong {
  color: #fff;
  background: rgba(0, 240, 255, 0.08);
  padding: 1px 4px;
  border-radius: 4px;
  font-weight: 600;
}

/* Loading animations */
@keyframes pulseGlow {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; filter: drop-shadow(0 0 10px var(--primary)); }
}

.sparkle-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
  text-align: center;
  gap: 1rem;
}

.sparkle-icon-pulse {
  font-size: 2.5rem;
  animation: pulseGlow 1.5s infinite ease-in-out;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
  animation: fadeIn 0.4s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
}

/* Hidden elements */
.hidden-canvas {
  display: none;
}

.hidden-file-input {
  display: none;
}
