/* ============================================
   Edge Products Detection - Main Styles
   Clean, modern, professional design system
   ============================================ */

/* Design System Variables - Professional Dark Theme */
:root {
  /* Dark Theme Colors */
  --color-bg-primary: #0f1419;
  --color-bg-secondary: #1a1f2e;
  --color-bg-tertiary: #232837;
  --color-border: #2a3141;
  --color-border-hover: #3a4151;

  --color-text-primary: #e8eaed;
  --color-text-secondary: #9ca3af;
  --color-text-muted: #6b7280;

  --color-accent: #4a9eff;
  --color-accent-hover: #357abd;
  --color-accent-light: #1e3a5f;

  --color-success: #10b981;
  --color-success-bg: #064e3b;
  --color-error: #ef4444;
  --color-error-bg: #7f1d1d;
  --color-warning: #f59e0b;
  --color-warning-bg: #78350f;

  /* Video Controls */
  --video-controls-height: 60px;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Spacing (8px grid) */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;
  --spacing-3xl: 4rem;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-full: 9999px;

  /* Shadows - Dark Theme */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 12px 24px rgba(0, 0, 0, 0.7);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;
}

/* ============================================
   Base Reset & Typography
   ============================================ */

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

html {
  font-size: 16px;
  height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: 1.5;
  color: var(--color-text-primary);
  background: linear-gradient(135deg, #0f1419 0%, #1a1f2e 100%);
  height: 100%;
  margin: 0;
  overflow: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: var(--font-weight-semibold);
  line-height: 1.2;
  margin-bottom: var(--spacing-sm);
}

h1 {
  font-size: var(--font-size-2xl);
}

h2 {
  font-size: var(--font-size-xl);
}

h3 {
  font-size: var(--font-size-lg);
}

p {
  margin-bottom: var(--spacing-md);
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-accent-hover);
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.text-muted {
  color: var(--color-text-secondary);
}

.text-small {
  font-size: var(--font-size-sm);
}

/* ============================================
   Layout Structure
   ============================================ */

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ============================================
   Header
   ============================================ */

.header {
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 var(--spacing-xl);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header__container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1920px;
  margin: 0 auto;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.header__title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.header__icon {
  color: var(--color-accent);
  font-size: var(--font-size-xl);
}

.header__logo {
  height: 32px;
  width: auto;
  margin-right: var(--spacing-sm);
}

.header__controls {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
}

/* Header Navigation */
.header__nav {
  display: flex;
  gap: var(--spacing-sm);
  margin-left: var(--spacing-xl);
}

.header__nav-btn {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-lg);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  font-family: var(--font-family);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.header__nav-btn:hover {
  color: var(--color-text-primary);
  background: var(--color-bg-tertiary);
}

.header__nav-btn--active {
  color: var(--color-accent);
  background: var(--color-accent-light);
  border-color: var(--color-accent);
}

.header__nav-btn i {
  font-size: 14px;
}

@media (max-width: 768px) {
  .header__nav-btn span {
    display: none;
  }

  .header__nav {
    margin-left: var(--spacing-md);
  }
}

/* Video Selector - Professional Horizontal Design */
.video-selector {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.video-selector__button {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.video-selector__button:hover {
  background: var(--color-bg-tertiary);
  border-color: var(--color-border-hover);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.video-selector__button[aria-expanded="true"] {
  background: var(--color-bg-tertiary);
  border-color: var(--color-accent);
  box-shadow: 0 0 0 1px var(--color-accent);
}

.video-selector__icon {
  margin-left: var(--spacing-xs);
  transition: transform 0.2s ease;
  font-size: 10px;
  color: var(--color-text-secondary);
}

.video-selector__button[aria-expanded="true"] .video-selector__icon {
  transform: rotate(180deg);
}

.video-selector__menu {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  max-width: 0;
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
  transition: max-width 0.3s ease, opacity 0.2s ease 0.1s, visibility 0s 0.3s;
}

.video-selector__menu--open {
  max-width: 800px;
  opacity: 1;
  visibility: visible;
  transition: max-width 0.3s ease, opacity 0.2s ease;
}

.video-selector__option {
  padding: var(--spacing-sm) var(--spacing-md);
  cursor: pointer;
  transition: all 0.2s ease;
  list-style: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.video-selector__option:hover {
  background: var(--color-bg-tertiary);
  border-color: var(--color-border-hover);
  color: var(--color-text-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.video-selector__option--active {
  background: rgba(74, 158, 255, 0.1);
  color: var(--color-accent);
  border-color: var(--color-accent);
  font-weight: var(--font-weight-semibold);
  box-shadow: 0 0 0 1px var(--color-accent), 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Products Display Toggle */
.products-display-toggle {
  display: flex;
  align-items: center;
}

.toggle-container {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-xs);
  position: relative;
}

.toggle-container:hover {
  background: var(--color-bg-tertiary);
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-sm);
}

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

.toggle-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  transition: all var(--transition-base);
  flex-shrink: 0;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  background: var(--color-text-secondary);
  border-radius: 50%;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-sm);
}

.toggle-input:checked+.toggle-slider {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.toggle-input:checked+.toggle-slider::before {
  transform: translateX(20px);
  background: white;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  user-select: none;
}

.toggle-label i {
  color: var(--color-accent);
  font-size: var(--font-size-sm);
}

.toggle-text {
  white-space: nowrap;
}

/* Button Styles */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-lg);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.button--primary {
  background-color: var(--color-accent);
  color: #ffffff;
  border: 1px solid var(--color-accent);
}

.button--primary:hover {
  background-color: var(--color-accent-hover);
  box-shadow: 0 0 15px rgba(74, 158, 255, 0.4);
}

.button--secondary {
  background-color: var(--color-bg-tertiary);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}

.button--secondary:hover {
  background-color: var(--color-border);
  border-color: var(--color-border-hover);
}

/* ============================================
   Main Content Layout
   ============================================ */

.content {
  display: flex;
  flex: 1;
  min-height: 0;
  /* Critical for overflow to work */
  overflow: hidden;
}

.content__main {
  flex: 1;
  min-width: 0;
  /* Prevent horizontal overflow */
  display: flex;
  flex-direction: column;
  background: var(--color-bg-primary);
  overflow: hidden;
}

.content__sidebar {
  width: 30%;
  min-width: 320px;
  max-width: 450px;
  background: var(--color-bg-secondary);
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* Critical for overflow */
  overflow: hidden;
  transition: all 0.3s ease;
}

.content__sidebar--hidden {
  width: 0;
  min-width: 0;
  max-width: 0;
  opacity: 0;
  border-left: none;
}

/* ============================================
   Video Section
   ============================================ */

.video-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xl);
  overflow: hidden;
  min-width: 0;
  /* Prevent overflow */
}

/* Upload Area */
.upload {
  width: 100%;
  max-width: 600px;
  background: var(--color-bg-tertiary);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-3xl) var(--spacing-xl);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-base);
}

.upload:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
  box-shadow: 0 0 20px rgba(74, 158, 255, 0.2);
}

.upload__icon {
  font-size: 3rem;
  color: var(--color-accent);
  margin-bottom: var(--spacing-lg);
  opacity: 0.9;
}

.upload__title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--spacing-sm);
}

.upload__text {
  color: var(--color-text-secondary);
  margin: 0;
}

.upload__input {
  display: none;
}

/* Video Player */
.video-player {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: 100%;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-xl);
}

.video-player__element {
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

/* Hide native video loading indicators */
.video-player__element::-webkit-media-controls-start-playback-button {
  display: none !important;
}

.video-player__element::-webkit-media-controls-overlay-play-button {
  display: none !important;
}

.video-player__element::-internal-media-controls-loading-panel {
  display: none !important;
}

.video-player__overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

/* Video Click Overlay - for product detection */
#videoClickOverlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: var(--video-controls-height);
  z-index: 100;
  cursor: crosshair;
  pointer-events: auto;
  /* Override video-player__overlay class which has pointer-events: none */
}

/* Polygon Overlay for detection visualization */
#polygonOverlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: calc(100% - var(--video-controls-height));
  pointer-events: none;
  z-index: 10;
}

/* Video QR Code Container - Top Right (same styling as products container) */
/* Video QR Code Container - Bottom Right of Products Grid */
.video-qr-container {
  position: relative;
  z-index: 103;
  pointer-events: auto;
  align-self: stretch;
  aspect-ratio: 1;
  min-width: 100px;
  max-width: 200px;
  flex-shrink: 0;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Show when products are displayed */
.video-qr-container[style*="display: flex"] {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.video-qr-code {
  width: 100%;
  height: 100%;
  background: transparent;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: qrFadeIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  box-sizing: border-box;
  overflow: visible;
}

.video-qr-code:hover {
  transform: scale(1.05);
}

@keyframes qrFadeIn {
  0% {
    opacity: 0;
    transform: scale(0.85) translateY(-10px);
  }

  50% {
    opacity: 0.7;
  }

  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.video-qr-code>div {
  width: 100% !important;
  height: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.video-qr-code img,
.video-qr-code canvas,
.video-qr-code svg {
  max-width: 100% !important;
  max-height: 100% !important;
  width: 100% !important;
  height: 100% !important;
  display: block !important;
  margin: 0 auto !important;
}

/* Video Products Container */
/* Video Products Container - X-Ray Style Bottom Overlay */
.video-products-container {
  position: absolute;
  bottom: var(--video-controls-height);
  /* Aligned with video controls height */
  left: 0;
  right: 0;
  z-index: 101;
  /* Higher than click overlay (100) */
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: var(--spacing-lg);
  pointer-events: auto;
  /* Allow scrolling */
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);

  /* Removed gradient background for cleaner UI */
  padding: 40px 200px 30px var(--spacing-xl);
  /* More padding at bottom */
  /* width: 100% removed to rely on left/right positioning */
  box-sizing: border-box;
}

/* Show container when it has products */
.video-products-container:not(.no-products) {
  opacity: 1;
  transform: translateY(0);
}

/* Hide container completely when no products */
.video-products-container.no-products {
  display: none;
}

/* Products Toggle Button - Left side */
.video-products-toggle {
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-full);
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-text-primary);
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-size: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateX(-10px) scale(0.9);
  animation: toggleFadeInLeft 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  animation-delay: 0.2s;
  z-index: 102;
  /* Higher than products container */
}

.video-products-toggle:hover {
  background: rgba(74, 158, 255, 0.9);
  border-color: var(--color-accent);
  transform: scale(1.15) rotate(5deg);
  box-shadow: 0 8px 24px rgba(74, 158, 255, 0.5);
}

.video-products-toggle:active {
  transform: scale(1.05);
  transition: all 0.1s ease;
}

.video-products-toggle i {
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.15s ease;
  display: inline-block;
}

/* Simple icon fade transition when toggling */
.video-products-toggle.rotating i {
  opacity: 0;
  transform: scale(0.85);
}

@keyframes toggleFadeInLeft {
  0% {
    opacity: 0;
    transform: translateX(-15px) scale(0.85);
  }

  50% {
    opacity: 0.7;
  }

  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

/* Video Products Grid - CSS Grid Layout with reserved first column for logo */
/* Column 1: logo/QR area, Columns 2-5: products (4 per row) */
.video-products-grid {
  flex: 1;
  display: grid;
  /* 5 columns: 130px for logo, 4 equal columns for products */
  grid-template-columns: 130px repeat(4, 1fr);
  grid-auto-rows: 130px;
  gap: var(--spacing-sm);
  padding: 10px 50px 10px 0;
  background: none;
  pointer-events: auto;
  align-items: end;
  align-content: end;
  overflow: visible;
  width: 100%;
  position: relative;

  /* Smooth transition */
  opacity: 1;
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hide/show products with animation */
.video-products-grid.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Hide products when playing (if show on pause only is enabled) */
.video-products-container.hide-on-play {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

/* Collapsing animation - products disappear into chevron */
.video-product-item.collapsing {
  animation: productCollapseOut 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards !important;
}

@keyframes productCollapseOut {
  0% {
    opacity: 1;
    transform: translateY(0) translateX(0) scale(1);
    filter: blur(0px);
  }

  30% {
    opacity: 0.8;
    transform: translateY(4px) translateX(-15px) scale(0.9);
    filter: blur(0.5px);
  }

  60% {
    opacity: 0.4;
    transform: translateY(8px) translateX(-35px) scale(0.6);
    filter: blur(2px);
  }

  100% {
    opacity: 0;
    transform: translateY(10px) translateX(-55px) scale(0.35);
    filter: blur(3px);
  }
}

/* Product Item - Vertical rectangle cards */
/* Product Item - Rectangular X-Ray Style */
.video-product-item {
  position: relative !important;
  /* Grid positioning set by JS */
  min-width: 0;
  max-width: none;
  min-height: 120px;
  height: 120px;
  display: flex !important;
  flex-direction: row !important;
  gap: var(--spacing-md) !important;
  align-items: center !important;
  align-self: end !important; /* Align to bottom of grid cell */
  margin: 0 !important;
  padding: 0 !important;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  opacity: 0;
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    opacity 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    background 0.3s ease,
    border-color 0.3s ease,
    box-shadow 0.3s ease;
  animation: productFadeInUp 0.4s ease forwards;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.video-product-item:hover {
  background: rgba(0, 0, 0, 0.35);
  border-color: var(--color-accent);
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6),
    0 0 0 1px var(--color-accent),
    0 0 20px rgba(74, 158, 255, 0.15);
  z-index: 10;
}

@keyframes productFadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Stagger animation */
.video-product-item:nth-child(1) {
  animation-delay: 0.05s;
}

.video-product-item:nth-child(2) {
  animation-delay: 0.1s;
}

.video-product-item:nth-child(3) {
  animation-delay: 0.15s;
}

.video-product-item:nth-child(4) {
  animation-delay: 0.2s;
}

.video-product-item:nth-child(5) {
  animation-delay: 0.25s;
}

.video-product-item:nth-child(n+6) {
  animation-delay: 0.3s;
}

/* QR Code as Grid Item - Absolute positioned at right corner */
.video-qr-grid-item {
  position: absolute !important;
  right: -100px;
  bottom: 10px;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 130px !important;
  min-width: 130px !important;
  max-width: 130px !important;
  height: 130px !important;
  padding: 0 !important;
  margin: 0 !important;
  transform: none !important;
  background: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  overflow: visible;
}

.video-qr-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
}

.video-qr-wrapper img {
  width: 130px !important;
  height: 130px !important;
  object-fit: cover !important;
  display: block;
  padding: 0;
  margin: 0;
  border: none;
}

/* Logo Image - First column, row is set dynamically by JS to span bottom */
.video-logo-grid-item {
  grid-column: 1 !important;
  /* grid-row set dynamically by JS based on total rows */
  position: relative !important;
  width: 120px !important;
  height: 120px !important;
  background: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  align-self: end !important;
  border-radius: 50%;
  z-index: 5;
}

.video-logo-grid-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
}

/* Empty spacers for column 1 in rows above the logo */
.video-grid-spacer {
  grid-column: 1 !important;
  width: 120px !important;
  height: 120px !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  pointer-events: none !important;
  opacity: 0 !important;
}

/* Product Image - Left Side */
.video-product-item>img {
  position: relative;
  width: 120px !important;
  height: 120px !important;
  aspect-ratio: 1/1 !important;
  object-fit: cover;
  border-radius: 0 !important;
  margin: 0 !important;
  flex-shrink: 0;
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.video-product-item:hover>img {
  transform: scale(1.05);
}

/* Product Info - Right Side */
.video-product-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px 12px 8px 0;
  overflow: hidden;
  text-align: left;
}

/* Product Title */
.video-product-title {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 4px;
  line-height: 1.3;
  /* Allow wrapping, limit to 3 lines */
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* Product Meta (Brand • Price) */
.video-product-meta {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 4px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-price {
  color: #fff;
  font-weight: 500;
}

/* AI Reason / Subtitle */
.video-product-ai-reason {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  line-height: 1.3;
  white-space: normal;
  overflow: hidden;
  max-height: 15px;
  /* Approx 1 line */
  transition: max-height 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), color 0.3s ease;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  -webkit-box-orient: vertical;
}

.video-product-item:hover .video-product-ai-reason {
  max-height: 80px;
  /* Allow expansion */
  -webkit-line-clamp: 4;
  line-clamp: 4;
  color: rgba(255, 255, 255, 0.9);
}

/* Hover state adjustments */
.video-product-item:hover .video-product-title {
  color: #ffffff;
}

.video-product-item:hover .video-product-ai-reason {
  color: rgba(255, 255, 255, 0.8);
}

@keyframes productFadeIn {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.88) rotateX(10deg);
    filter: blur(3px);
  }

  60% {
    opacity: 0.8;
    transform: translateY(-2px) scale(1.02);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotateX(0deg);
    filter: blur(0px);
  }
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .video-products-container {
    bottom: calc(var(--video-controls-height) + var(--spacing-xs));
    left: var(--spacing-xs);
    right: var(--spacing-xs);
    gap: var(--spacing-xs);
  }

  .video-products-toggle {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }

  .video-products-grid {
    /* On mobile: 3 products per row */
    grid-template-columns: 100px repeat(3, 1fr);
    grid-auto-rows: 100px;
    gap: var(--spacing-xs);
  }

  .video-product-item {
    min-height: 90px;
    height: 90px;
  }

  .video-logo-grid-item {
    width: 90px !important;
    height: 90px !important;
  }

  .video-product-title {
    font-size: 11px;
  }

  .video-product-ai-reason {
    font-size: 10px;
  }

  .video-product-match-icon {
    width: 20px;
    height: 20px;
    font-size: 9px;
    top: 4px;
    left: 4px;
  }

  .video-product-qr-code {
    padding: 0;
  }
}

.video-player__loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: white;
}

.video-player__spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto var(--spacing-md);
}

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

/* ============================================
   Sidebar Components
   ============================================ */

/* Section transition animations */
@keyframes sectionPulse {
  0% {
    opacity: 1;
  }

  50% {
    opacity: 0.95;
  }

  100% {
    opacity: 1;
  }
}

.sidebar--transitioning {
  animation: sectionPulse 0.6s ease;
}

/* Smooth entry for new frames */
@keyframes frameEntry {
  from {
    opacity: 0;
    transform: scale(0.9) translateX(-10px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateX(0);
  }
}

.frame-thumb--new {
  animation: frameEntry 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Sidebar Header */
.sidebar__header {
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--color-bg-secondary);
  border-bottom: 2px solid var(--color-border);
}

.sidebar__title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Frames Section */
.frames-section {
  flex: 0 0 auto;
  background: var(--color-bg-tertiary);
}

.frames-section__header {
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
}

.frames-section__title {
  font-size: 13px;
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin: 0 0 var(--spacing-xs) 0;
  display: flex;
  align-items: center;
}

.frames-section__subtitle {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin: 0;
  font-weight: var(--font-weight-normal);
}

/* Frames Carousel */
.frames-carousel {
  height: 160px;
  background: var(--color-bg-tertiary);
  border-bottom: 1px solid var(--color-border);
  position: relative;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.frames-carousel__track {
  flex: 1;
  display: flex;
  gap: var(--spacing-sm);
  padding: 10px 0;
  /* Vertical padding only */
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  align-items: center;
  /* Hide scrollbar but keep functionality */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.frames-carousel__track::-webkit-scrollbar {
  display: none;
}

/* Navigation Buttons */
.frames-carousel__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: all var(--transition-fast);
  color: var(--color-text-secondary);
  font-size: 12px;
}

.frames-carousel__nav:hover {
  background: var(--color-accent);
  color: #ffffff;
  border-color: var(--color-accent);
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 0 10px rgba(74, 158, 255, 0.4);
}

.frames-carousel__nav:active {
  transform: translateY(-50%) scale(0.95);
}

.frames-carousel__nav--prev {
  left: 8px;
}

.frames-carousel__nav--next {
  right: 8px;
}

.frames-carousel__nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.frames-carousel__nav:disabled:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text-muted);
  border-color: var(--color-border);
  transform: translateY(-50%);
  box-shadow: none;
}

/* Frame Thumbnail */
.frame-thumb {
  flex-shrink: 0;
  width: 120px;
  height: 140px;
  background: var(--color-bg-tertiary);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
}

.frame-thumb:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-border-hover);
}

.frame-thumb--active {
  border-color: var(--color-border-hover);
  border-left: 3px solid var(--color-accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.frame-thumb__image-container {
  position: relative;
  width: 100%;
  height: 90px;
  overflow: hidden;
}

.frame-thumb__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--color-bg-primary);
  transition: transform var(--transition-base);
}

.frame-thumb:hover .frame-thumb__image {
  transform: scale(1.05);
}

/* Play icon overlay */
.frame-thumb__play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 32px;
  color: white;
  opacity: 0;
  transition: all var(--transition-base);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.frame-thumb:hover .frame-thumb__play-overlay {
  opacity: 0.9;
}

/* Film strip perforations */
.frame-thumb__film-perfs {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: repeating-linear-gradient(to bottom,
      var(--color-bg-primary) 0px,
      var(--color-bg-primary) 6px,
      transparent 6px,
      transparent 10px);
  opacity: 0.4;
}

.frame-thumb__film-perfs::after {
  content: '';
  position: absolute;
  right: -116px;
  top: 0;
  bottom: 0;
  width: 4px;
  background: repeating-linear-gradient(to bottom,
      var(--color-bg-primary) 0px,
      var(--color-bg-primary) 6px,
      transparent 6px,
      transparent 10px);
}

.frame-thumb__info {
  padding: var(--spacing-sm);
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
}

/* Video timecode styling */
.frame-thumb__timecode {
  font-size: 11px;
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  font-family: 'Courier New', monospace;
  background: var(--color-bg-primary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
}

/* Products Section */
.products {
  flex: 1;
  min-height: 0;
  /* Critical for overflow to work */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.products__header {
  flex: 0 0 auto;
  /* Fixed, doesn't grow/shrink */
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
}

.products__title {
  font-size: 11px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.products__grid {
  flex: 1;
  min-height: 0;
  /* Critical for overflow to work */
  width: 100%;
  box-sizing: border-box;
  padding: var(--spacing-sm);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.products__grid::-webkit-scrollbar {
  width: 6px;
}

.products__grid::-webkit-scrollbar-track {
  background: transparent;
}

.products__grid::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

.products__grid::-webkit-scrollbar-thumb:hover {
  background: var(--color-border-hover);
}

/* Product Card - Clean Design */
.product-card {
  width: 100%;
  box-sizing: border-box;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: visible;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s ease;
  margin-bottom: var(--spacing-sm);
  text-decoration: none;
  color: inherit;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.product-card:hover {
  border-color: var(--color-accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(74, 158, 255, 0.1);
}

/* AI Justification - Sophisticated Highlight */
.product-card__ai-reason {
  background: var(--color-bg-secondary);
  border-left: 3px solid var(--color-accent);
  padding: var(--spacing-sm);
  margin: var(--spacing-sm);
  margin-bottom: 0;
}

.product-card__ai-label {
  font-size: 10px;
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
  display: block;
}

.product-card__ai-text {
  font-size: var(--font-size-xs);
  line-height: 1.5;
  color: var(--color-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

/* Product Body */
.product-card__body {
  padding: var(--spacing-sm);
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
  flex-shrink: 0;
  /* Ensure it's always visible */
  min-height: auto;
}

.product-card__image {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  object-fit: cover;
  background: var(--color-bg-primary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.product-card__details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.product-card__title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
  word-wrap: break-word;
}

/* Match Type */
.product-card__match-type {
  font-size: 10px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.product-card__match-icon {
  font-size: 12px;
  color: var(--color-accent);
  opacity: 0.8;
}

.badge--saw {
  background-color: rgba(74, 158, 255, 0.2);
  color: var(--color-accent);
}

.badge--heard {
  background-color: rgba(16, 185, 129, 0.2);
  color: var(--color-success);
}

.badge--mentioned {
  background-color: rgba(239, 68, 68, 0.2);
  color: var(--color-error);
}

.badge--context {
  background-color: rgba(245, 158, 11, 0.2);
  color: var(--color-warning);
}

/* Empty State */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-2xl);
  text-align: center;
}

.empty-state__icon {
  font-size: 4rem;
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-lg);
  opacity: 0.5;
}

.empty-state__title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  margin-bottom: var(--spacing-sm);
}

.empty-state__text {
  color: var(--color-text-secondary);
  margin: 0;
}

/* ============================================
   Toast Notifications
   ============================================ */

.toast-container {
  position: fixed;
  top: var(--spacing-xl);
  right: var(--spacing-xl);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  pointer-events: none;
}

.toast {
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--spacing-md) var(--spacing-lg);
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  min-width: 320px;
  max-width: 500px;
  pointer-events: auto;
  animation: slideIn var(--transition-base);
  backdrop-filter: blur(10px);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }

  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.toast--success {
  background: var(--color-success-bg);
  border-color: var(--color-success);
}

.toast--error {
  background: var(--color-error-bg);
  border-color: var(--color-error);
}

.toast--warning {
  background: var(--color-warning-bg);
  border-color: var(--color-warning);
}

.toast--info {
  background: var(--color-accent-light);
  border-color: var(--color-accent);
}

.toast__icon {
  font-size: var(--font-size-xl);
  flex-shrink: 0;
}

.toast--success .toast__icon {
  color: var(--color-success);
}

.toast--error .toast__icon {
  color: var(--color-error);
}

.toast--warning .toast__icon {
  color: var(--color-warning);
}

.toast--info .toast__icon {
  color: var(--color-accent);
}

.toast__content {
  flex: 1;
}

.toast__title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  margin-bottom: var(--spacing-xs);
  color: var(--color-text-primary);
}

.toast__message {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin: 0;
}

.toast__close {
  background: none;
  border: none;
  font-size: var(--font-size-lg);
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 0;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.toast__close:hover {
  opacity: 1;
}

/* Skeleton Loading State for Toast */
.toast--loading {
  background: var(--color-bg-tertiary);
}

.toast__skeleton {
  height: 16px;
  background: linear-gradient(90deg,
      var(--color-bg-tertiary) 25%,
      var(--color-border) 50%,
      var(--color-bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* ============================================
   Modal
   ============================================ */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xl);
}

.modal__backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.modal__content {
  position: relative;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--spacing-xl);
}

.modal__close {
  position: absolute;
  top: var(--spacing-md);
  right: var(--spacing-md);
  background: none;
  border: none;
  font-size: var(--font-size-xl);
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: var(--spacing-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.modal__close:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
}

.modal__body {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.modal__image {
  width: 100%;
  border-radius: var(--radius-md);
  background: var(--color-bg-tertiary);
}

.modal__title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin: 0;
}

.modal__description {
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin: 0;
}

/* Stream URL Input Styles */
.stream-url-input-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.stream-url-input {
  width: 100%;
  padding: var(--spacing-md);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  transition: all var(--transition-fast);
  box-sizing: border-box;
}

.stream-url-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.1);
}

.stream-url-input::placeholder {
  color: var(--color-text-muted);
}

.stream-url-actions {
  display: flex;
  gap: var(--spacing-md);
  justify-content: flex-end;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 1024px) {
  .content__sidebar {
    width: 320px;
  }

  .products__grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  :root {
    --video-controls-height: 60px;
  }

  .header {
    padding: 0 var(--spacing-md);
  }

  .header__title {
    font-size: var(--font-size-base);
  }

  .header__title span {
    display: none;
  }

  .content {
    flex-direction: column;
  }

  .content__sidebar {
    width: 100%;
    height: 50%;
    border-left: none;
    border-top: 1px solid var(--color-border);
  }

  .frames-carousel {
    height: 120px;
  }

  .frame-thumb {
    width: 100px;
    height: 110px;
  }

  .frame-thumb__image {
    height: 70px;
  }
}

@media (max-width: 480px) {
  :root {
    --video-controls-height: 70px;
  }

  .video-selector {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .video-selector::-webkit-scrollbar {
    display: none;
  }

  .video-selector__button {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 12px;
    min-width: auto;
  }

  .video-selector__option {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 12px;
  }

  .video-selector__menu--open {
    max-width: 600px;
  }

  .toggle-container {
    padding: var(--spacing-xs) var(--spacing-sm);
    gap: var(--spacing-sm);
  }

  .toggle-slider {
    width: 38px;
    height: 22px;
  }

  .toggle-slider::before {
    width: 16px;
    height: 16px;
  }

  .toggle-input:checked+.toggle-slider::before {
    transform: translateX(16px);
  }

  .toggle-text {
    font-size: 12px;
  }

  .button {
    padding: var(--spacing-xs) var(--spacing-md);
    font-size: var(--font-size-sm);
  }

  .toast-container {
    top: var(--spacing-md);
    right: var(--spacing-md);
    left: var(--spacing-md);
  }

  .toast {
    min-width: auto;
    width: 100%;
  }
}

/* ============================================
   Additional Responsive Adjustments for Sidebar
   ============================================ */

/* Ensure sidebar is responsive */
@media (max-width: 1400px) {
  .content__sidebar {
    width: 32%;
    min-width: 340px;
  }
}

@media (max-width: 1200px) {
  .content__sidebar {
    width: 35%;
    min-width: 320px;
  }
}

/* Tablet adjustments */
@media (max-width: 968px) {
  .content__sidebar {
    width: 38%;
    min-width: 300px;
  }
}

/* Mobile layout */
@media (max-width: 768px) {
  .content {
    flex-direction: column;
  }

  .content__main {
    flex: 1 1 60%;
  }

  .content__sidebar {
    width: 100%;
    max-width: none;
    min-width: unset;
    flex: 0 0 40%;
    border-left: none;
    border-top: 2px solid var(--color-border);
  }
}

/* Small screens - compact cards */
@media (max-width: 400px) {
  .product-card__image {
    width: 40px;
    height: 40px;
  }

  .product-card__ai-text {
    font-size: 11px;
  }

  .product-card__title {
    font-size: 12px;
  }

  .product-card__match-type {
    font-size: 9px;
  }

  .frames-carousel {
    height: 140px;
  }

  .frame-thumb {
    width: 100px;
    height: 120px;
  }
}

/* ============================================
   Skeleton Toast System
   ============================================ */

.toast-container {
  position: fixed;
  top: 80px;
  right: var(--spacing-xl);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  pointer-events: none;
  max-width: 380px;
  min-width: 320px;
}

.skeleton-toast {
  background: var(--color-bg-tertiary);
  backdrop-filter: blur(20px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: var(--spacing-md);
  overflow: hidden;
  position: relative;
  min-width: 320px;
  max-width: 500px;
  pointer-events: auto;
  cursor: default;
  animation: slideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.skeleton-toast::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--color-accent);
  animation: skeletonPulse 2s ease-in-out infinite;
}

.skeleton-toast.success::before {
  background: var(--color-success);
  animation: none;
}

.skeleton-toast.error::before {
  background: var(--color-error);
  animation: none;
}

.skeleton-toast.success {
  cursor: pointer;
}

.skeleton-toast.success:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
}

/* Skeleton Content Layout */
.skeleton-content {
  display: flex;
  gap: var(--spacing-sm);
  align-items: flex-start;
}

.skeleton-image {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg,
      var(--color-bg-primary) 0%,
      var(--color-border) 50%,
      var(--color-bg-primary) 100%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--color-border);
}

.skeleton-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  justify-content: center;
}

.skeleton-title {
  height: 16px;
  width: 80%;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg,
      var(--color-bg-primary) 0%,
      var(--color-border) 50%,
      var(--color-bg-primary) 100%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
  animation-delay: 0.1s;
}

.skeleton-description {
  height: 12px;
  width: 100%;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg,
      var(--color-bg-primary) 0%,
      var(--color-border) 50%,
      var(--color-bg-primary) 100%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
  animation-delay: 0.2s;
}

.skeleton-description:last-of-type {
  width: 60%;
}

.skeleton-link-hint {
  height: 10px;
  width: 70px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg,
      var(--color-bg-primary) 0%,
      var(--color-border) 50%,
      var(--color-bg-primary) 100%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
  animation-delay: 0.3s;
  margin-top: var(--spacing-xs);
}

@keyframes skeletonShimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

@keyframes skeletonPulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

/* Product Toast Content */
.product-card-content {
  display: flex;
  gap: var(--spacing-sm);
  align-items: flex-start;
  position: relative;
  width: 100%;
}

.product-image-container {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
}

.product-main-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.product-main-image:hover {
  transform: scale(1.05);
}

.product-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  justify-content: center;
  min-width: 0;
}

.product-title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin: 0;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.product-description {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  margin: 0;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.product-name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin: 0;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.product-link-hint {
  font-size: var(--font-size-xs);
  color: var(--color-accent);
  display: flex;
  align-items: center;
  gap: 4px;
}

.toast-close {
  position: absolute;
  top: var(--spacing-sm);
  right: var(--spacing-sm);
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0;
  transition: color var(--transition-fast);
  z-index: 10;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-close:hover {
  color: var(--color-text-primary);
}

.toast-body {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  line-height: 1.5;
}

/* Responsive Toast */
@media (max-width: 768px) {
  .toast-container {
    right: var(--spacing-md);
    max-width: 320px;
    min-width: 280px;
  }

  .skeleton-toast {
    padding: var(--spacing-sm);
  }

  .product-image-container,
  .skeleton-image {
    width: 56px;
    height: 56px;
  }
}

/* ============================================
   Menu Button & Settings Panel
   ============================================ */

/* Menu Button */
.menu-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  cursor: pointer;
  transition: all var(--transition-base);
  font-size: 18px;
}

.menu-button:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #ffffff;
  box-shadow: 0 0 15px rgba(74, 158, 255, 0.4);
}

/* Settings Panel */
.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1000;
  pointer-events: none;
}

.settings-panel--open {
  pointer-events: auto;
}

/* Backdrop */
.settings-panel__backdrop {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.settings-panel--open .settings-panel__backdrop {
  opacity: 1;
}

/* Panel Content */
.settings-panel__content {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  background: linear-gradient(135deg, rgba(26, 31, 46, 0.98) 0%, rgba(35, 40, 55, 0.98) 100%);
  backdrop-filter: blur(20px);
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.settings-panel--open .settings-panel__content {
  transform: translateX(0);
}

/* Panel Header */
.settings-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-xl);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-panel__title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin: 0;
}

.settings-panel__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 18px;
}

.settings-panel__close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-text-primary);
}

/* Panel Body */
.settings-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-xl);
}

/* Settings Sections */
.settings-section {
  margin-bottom: var(--spacing-2xl);
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section__title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--spacing-md);
}

/* Settings Actions */
.settings-actions {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.button--full-width {
  width: 100%;
}

/* Vendor Selector Styles */
.vendor-selector {
  position: relative;
}

.vendor-selector__button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--spacing-md);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  cursor: pointer;
  transition: all var(--transition-base);
}

.vendor-selector__button:hover {
  background: var(--color-bg-tertiary);
  border-color: var(--color-border-hover);
}

.vendor-selector__button[aria-expanded="true"] {
  background: var(--color-bg-tertiary);
  border-color: var(--color-accent);
}

.vendor-selector__icon {
  transition: transform var(--transition-base);
  color: var(--color-text-secondary);
}

.vendor-selector__button[aria-expanded="true"] .vendor-selector__icon {
  transform: rotate(180deg);
}

.vendor-selector__menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--spacing-sm);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all var(--transition-base);
  z-index: 1000;
  max-height: 200px;
  overflow-y: auto;
}

.vendor-selector__menu.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.vendor-selector__option {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
  list-style: none;
}

.vendor-selector__option:hover {
  background: var(--color-bg-tertiary);
}

.vendor-selector__checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--color-accent);
}

.vendor-selector__label {
  flex: 1;
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  cursor: pointer;
  user-select: none;
}

/* Video Selector in Panel */
.settings-section .video-selector__button {
  width: 100%;
  justify-content: space-between;
}

.settings-section .video-selector__menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--spacing-sm);
  display: none;
  flex-direction: column;
  gap: var(--spacing-xs);
  z-index: 1000;
}

.settings-section .video-selector__button[aria-expanded="true"]+.video-selector__menu {
  display: flex;
}

.settings-section .video-selector__option {
  width: 100%;
  text-align: left;
  justify-content: flex-start;
}

/* Scrollbar Styling */
.settings-panel__body::-webkit-scrollbar,
.vendor-selector__menu::-webkit-scrollbar {
  width: 6px;
}

.settings-panel__body::-webkit-scrollbar-track,
.vendor-selector__menu::-webkit-scrollbar-track {
  background: transparent;
}

.settings-panel__body::-webkit-scrollbar-thumb,
.vendor-selector__menu::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.settings-panel__body::-webkit-scrollbar-thumb:hover,
.vendor-selector__menu::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Responsive */
@media (max-width: 768px) {
  .settings-panel__content {
    width: 100%;
    max-width: 380px;
  }
}