/* Widget Editor Styles */

/* TV Canvas Container - 16:9 aspect ratio */
.tv-canvas-container {
  width: 100%;
  max-width: 1200px;
  /* Increased from 800px to 1200px */
  aspect-ratio: 16 / 9;
  background: #fff !important;
  /* Always white background for TV display */
  border-radius: 8px;
  overflow: visible;
  /* Allow widget controls to be visible */
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  position: relative;
  margin: 20px;
  /* Reduced margin to allow for larger screen */
  border: 1px solid #e5e7eb;
}

.tv-canvas {
  width: 100%;
  height: 100%;
  background: #fff !important;
  /* Always white background for TV display */
  position: relative;
  overflow: visible;
  /* Allow controls to be visible outside bounds */
  padding: 20px;
  /* Add padding to accommodate widget controls */
}

/* Override dark mode for TV canvas - TV displays always show white background */
.dark .tv-canvas-container,
body.dark .tv-canvas-container,
html.dark .tv-canvas-container,
[data-theme="dark"] .tv-canvas-container {
  background: #fff !important;
  border-color: #e5e7eb !important;
}

.dark .tv-canvas,
body.dark .tv-canvas,
html.dark .tv-canvas,
[data-theme="dark"] .tv-canvas {
  background: #fff !important;
}

/* Ensure TV canvas content is always in light mode - but exclude config modal */
.tv-canvas *:not([data-widget-canvas-target="configModal"]):not([data-widget-canvas-target="configModal"] *) {
  color: #1f2937 !important;
  /* Dark text on white background */
}

.tv-canvas .dark\:text-white,
.tv-canvas .dark\:text-gray-100,
.tv-canvas .dark\:text-gray-200,
.tv-canvas .dark\:text-gray-300 {
  color: #1f2937 !important;
}

@media (prefers-color-scheme: dark) {
  .tv-canvas-container {
    background: #fff !important;
    border-color: #e5e7eb !important;
  }

  .tv-canvas {
    background: #fff !important;
  }
}

/* Widget Tool Items */
.widget-tool-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  background: #f9fafb;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 60px;
  gap: 4px;
}

.widget-tool-item:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.widget-tool-item:active {
  transform: translateY(0);
}

/* Dark mode widget tool items */
.dark .widget-tool-item {
  background: #374151;
  border-color: #4b5563;
  color: #f9fafb;
}

.dark .widget-tool-item:hover {
  background: #4b5563;
  border-color: #6b7280;
}

/* Dark mode overrides - using multiple selectors for better compatibility */
body.dark .widget-tool-item,
html.dark .widget-tool-item,
[data-theme="dark"] .widget-tool-item {
  background: #374151 !important;
  border-color: #4b5563 !important;
  color: #f9fafb !important;
}

body.dark .widget-tool-item:hover,
html.dark .widget-tool-item:hover,
[data-theme="dark"] .widget-tool-item:hover {
  background: #4b5563 !important;
  border-color: #6b7280 !important;
}

/* Additional dark mode support for system preference */
@media (prefers-color-scheme: dark) {
  .widget-tool-item {
    background: #374151 !important;
    border-color: #4b5563 !important;
    color: #f9fafb !important;
  }

  .widget-tool-item:hover {
    background: #4b5563 !important;
    border-color: #6b7280 !important;
  }
}

/* TV Grid Overlay */
.tv-grid-overlay {
  background-image:
    linear-gradient(to right, rgba(59, 130, 246, 0.3) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(59, 130, 246, 0.3) 1px, transparent 1px);
  background-size: calc(100% / 12) 60px;
  pointer-events: none;
}

/* Widget edit mode styling */
.widget-edit-wrapper {
  pointer-events: none;
  overflow: visible;
}

.widget-control-bar {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.resize-handles-container {
  overflow: visible;
}


/* Preview overlay */
.preview-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.preview-overlay .tv-canvas-container {
  max-width: 90vw;
  max-height: 90vh;
}

.preview-close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background-color 0.2s ease;
}

.preview-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Responsive adjustments */
@media (max-width: 1440px) {
  .tv-canvas-container {
    max-width: 1000px;
  }
}

@media (max-width: 1024px) {
  .tv-canvas-container {
    max-width: 800px;
  }
}

@media (max-width: 768px) {
  .tv-canvas-container {
    max-width: 600px;
    margin: 10px;
  }
}
