/* Design System & Styling (Vanilla CSS with Premium Dark Theme) */
:root {
  --bg-gradient: radial-gradient(circle at 50% 0%, #111827 0%, #0b0f19 100%);
  --panel-bg: rgba(17, 24, 39, 0.75);
  --panel-border: rgba(255, 255, 255, 0.08);
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.35);
  --accent-green: #10b981;
  --accent-green-hover: #059669;
  --accent-red: #ef4444;
  --accent-red-hover: #dc2626;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --glass-blur: blur(16px);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* Base Body Style for standalone dark look overlay */
body.video-slide-extractor-page {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Content Box layout adjustment to match modern-web theme */
.content-box.video-slide-extractor-box {
  background: transparent;
  border: none;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

.container {
  max-width: 1400px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  flex-grow: 1;
  width: 100%;
}

/* Upload Area */
.upload-zone {
  background: var(--panel-bg);
  border: 2px dashed rgba(99, 102, 241, 0.3);
  border-radius: 1.25rem;
  padding: 4rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
}

.upload-zone:hover {
  border-color: var(--primary);
  background: rgba(17, 24, 39, 0.9);
  box-shadow: 0 0 25px rgba(99, 102, 241, 0.15);
  transform: translateY(-2px);
}

.upload-icon {
  width: 4rem;
  height: 4rem;
  color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
  transition: var(--transition);
}

.upload-zone:hover .upload-icon {
  transform: scale(1.1);
  background: rgba(99, 102, 241, 0.2);
}

.upload-zone h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
}

.upload-zone p {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 400px;
}

.file-input {
  display: none;
}

/* Main Workspace */
.workspace {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 2rem;
  margin-top: 1rem;
}

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

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 1.25rem;
  padding: 1.5rem;
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Video Section */
.video-wrapper {
  position: relative;
  background: #000;
  border-radius: 0.75rem;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  aspect-ratio: 16 / 9;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.6);
}

.main-video {
  width: 100%;
  height: 100%;
  max-height: 70vh;
  object-fit: contain;
}

/* Crop Overlay & Box */
.crop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: auto;
  z-index: 10;
  cursor: crosshair;
}

.crop-box {
  position: absolute;
  border: 2px dashed var(--primary);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.65), 0 0 15px rgba(99, 102, 241, 0.4);
  cursor: move;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.crop-box-label {
  position: absolute;
  top: -24px;
  left: 0;
  background: var(--primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px 4px 0 0;
  white-space: nowrap;
  pointer-events: none;
}

/* Resize Handles */
.handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background-color: #fff;
  border: 2px solid var(--primary);
  border-radius: 50%;
  z-index: 12;
  transition: transform 0.15s ease;
}

.handle:hover {
  transform: scale(1.3);
}

.handle-tl { top: -6px; left: -6px; cursor: nwse-resize; }
.handle-tr { top: -6px; right: -6px; cursor: nesw-resize; }
.handle-bl { bottom: -6px; left: -6px; cursor: nesw-resize; }
.handle-br { bottom: -6px; right: -6px; cursor: nwse-resize; }

/* Video Control Buttons */
.video-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.75rem;
  border-radius: 0.75rem;
}

.btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  padding: 0.6rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  border-color: transparent;
  box-shadow: 0 4px 10px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.5);
}

.btn-success {
  background: var(--accent-green);
  border-color: transparent;
}

.btn-success:hover:not(:disabled) {
  background: var(--accent-green-hover);
}

.btn-danger {
  background: var(--accent-red);
  border-color: transparent;
}

.btn-danger:hover:not(:disabled) {
  background: var(--accent-red-hover);
}

.btn-icon-only {
  padding: 0.6rem;
  border-radius: 0.5rem;
}

.time-display {
  font-family: monospace;
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-left: auto;
  display: flex;
  gap: 0.25rem;
}

/* Slider styling */
.scrub-timeline {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.scrub-timeline::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 0 8px var(--primary-glow);
  transition: transform 0.1s;
}

.scrub-timeline::-webkit-slider-thumb:hover {
  transform: scale(1.25);
}

/* Control Panel Side Details */
.section-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: #fff;
  border-left: 3px solid var(--primary);
  padding-left: 0.5rem;
  margin-bottom: 0.5rem;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.03);
  padding: 1rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.setting-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.setting-value {
  color: var(--primary);
  font-weight: 600;
}

.slider-input {
  width: 100%;
  -webkit-appearance: none;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  outline: none;
}

.slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
}

/* Process Progress */
.progress-card {
  background: rgba(99, 102, 241, 0.05);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 0.75rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary) 0%, #818cf8 100%);
  border-radius: 4px;
  transition: width 0.15s ease-out;
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.4);
}

.progress-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stat-box {
  background: rgba(0, 0, 0, 0.15);
  padding: 0.5rem;
  border-radius: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-val {
  font-family: monospace;
  font-size: 0.95rem;
  color: #fff;
  font-weight: 600;
}

/* Instructions */
.instructions {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.instructions ol {
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Gallery Section */
.gallery-container {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 0.75rem;
}

.gallery-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #fff;
}

.slide-badge {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

.gallery-actions {
  display: flex;
  gap: 0.75rem;
}

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

.empty-gallery {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 0.75rem;
  border: 1px dashed rgba(255, 255, 255, 0.06);
}

.empty-gallery svg {
  width: 2.5rem;
  height: 2.5rem;
  color: rgba(255, 255, 255, 0.15);
}

.slide-card {
  background: rgba(17, 24, 39, 0.5);
  border: 1px solid var(--panel-border);
  border-radius: 0.75rem;
  overflow: hidden;
  transition: var(--transition);
  position: relative;
  display: flex;
  flex-direction: column;
}

.slide-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
}

.slide-img-wrapper {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
  cursor: pointer;
}

.slide-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.2s;
}

.slide-img-wrapper:hover img {
  transform: scale(1.05);
}

.slide-meta {
  padding: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
}

.slide-index {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.slide-timestamp {
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

.slide-card-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 5;
}

.slide-card:hover .slide-card-actions {
  opacity: 1;
}

.card-action-btn {
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid var(--panel-border);
  color: #fff;
  padding: 4px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.card-action-btn:hover {
  background: var(--accent-red);
  color: white;
  border-color: transparent;
}

.card-action-btn.btn-dl:hover {
  background: var(--primary);
}

/* Modal for Image Preview */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(3, 7, 18, 0.9);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  max-width: 90%;
  max-height: 80%;
  box-shadow: var(--shadow-lg);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  background: #000;
}

.modal-content img {
  width: 100%;
  height: auto;
  max-height: 80vh;
  display: block;
  object-fit: contain;
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.1);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--accent-red);
  transform: rotate(90deg);
}

/* Helper Utilities */
.hidden {
  display: none !important;
}
