/* Room Visualizer Styles */

.page-container {
  min-height: 100vh;
  padding: 1rem;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
}

.content-wrapper {
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.page-header {
  text-align: center;
  margin-bottom: 1rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 0.25rem;
}

.page-subtitle {
  font-size: 0.875rem;
  color: #6b7280;
  display: none; /* Hide subtitle on mobile to save space */
}

@media (min-width: 768px) {
  .page-subtitle {
    display: block;
  }
  .page-title {
    font-size: 2rem;
  }
  .page-header {
    margin-bottom: 2rem;
  }
}

/* Feature Badge */
.feature-badge {
  display: inline-block;
  background: #10b981;
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  font-size: 0.65rem;
  font-weight: 600;
  margin-left: 0.5rem;
  text-transform: uppercase;
  vertical-align: middle;
}

/* Visualizer Layout - Stacked vertically for better canvas aspect ratio */
.visualizer-container {
  display: flex;
  flex-direction: column; /* Always column - canvas on top, controls below */
  gap: 1rem;
  flex: 1;
  min-height: 600px; 
}

/* On larger screens, give canvas more breathing room */
@media (min-width: 768px) {
  .visualizer-container {
    gap: 1.5rem;
  }
}

/* Side-by-side layout for Ultra-Wide screens only */
@media (min-width: 1921px) {
  .visualizer-container {
    flex-direction: row;
    align-items: stretch;
    min-height: 800px;
    height: auto;
  }

  .canvas-section {
    flex: 1; /* Take up remaining space */
    min-height: 800px;
  }

  .controls-sidebar {
    width: 400px !important;
    min-height: 800px;
    display: flex;
    flex-direction: column;
  }

  .controls-content {
    overflow-y: auto;
    max-height: 900px; /* Prevent infinite grow */
  }
}

/* Canvas Area (Top) */
.canvas-section {
  width: 100%;
  background: #1f2937; /* Dark background for focus */
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  /* Large canvas height for immersive editing */
  height: 90vh;
  transition: all 0.3s ease;
}

/* Full Screen Mode */
.canvas-section.full-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 100;
  border-radius: 0;
  padding: 0;
}

.full-screen-exit {
  display: none;
}

.canvas-section.full-screen .full-screen-exit {
  display: flex;
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 50;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-weight: 600;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.canvas-wrapper {
  flex: 1;
  position: relative;
  background: #111827;
  border-radius: 8px;
  overflow: hidden; 
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none; /* Crucial for custom touch handling */
}

.canvas-section.full-screen .canvas-wrapper {
  border-radius: 0;
}

.canvas-wrapper.empty {
  background: #f3f4f6;
  border: 2px dashed #d1d5db;
}

#visualizer-canvas {
  max-width: 100%;
  max-height: 100%;
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

/* Toolbar overlay on canvas */
.canvas-toolbar {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  padding: 0.5rem;
  border-radius: 30px; 
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: flex;
  gap: 0.25rem;
  z-index: 20;
  max-width: 95%;
  overflow-x: auto; 
}

.toolbar-btn {
  width: 40px; 
  height: 40px;
  border: 1px solid transparent;
  border-radius: 50%; 
  background: transparent;
  color: #4b5563;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.toolbar-btn:hover {
  background: #f3f4f6;
  color: #2563eb;
}

.toolbar-btn.active {
  background: #eff6ff;
  color: #2563eb;
  border-color: #bfdbfe;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.1);
}

.toolbar-btn svg {
  width: 20px;
  height: 20px;
}

/* Vertical Slider for Brush Size */
.brush-slider-container {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  height: 200px;
  max-height: 60vh; /* Prevent it from being too tall on mobile landscape */
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  border-radius: 20px;
  padding: 1rem 0.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 19;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  overflow: hidden; /* Ensure slider doesn't poke out */
}

.brush-slider-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0; /* Critical for flex child to shrink */
  width: 100%;
  position: relative;
}

/* Modern vertical range slider (using writing-mode instead of deprecated appearance) */
.vertical-range {
  writing-mode: vertical-lr;
  direction: rtl;
  width: 8px;
  height: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: linear-gradient(to top, #e5e7eb 0%, #3b82f6 100%);
  border-radius: 4px;
  outline: none;
  margin: 0;
}

.vertical-range::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  border: 2px solid #3b82f6;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.vertical-range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  border: 2px solid #3b82f6;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.brush-preview {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ef4444; 
  border: 1px solid rgba(0,0,0,0.1);
}

/* Canvas Controls (Bottom Right) */
.canvas-controls {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 10;
}

.control-fab {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: white;
  color: #4b5563;
  border: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  cursor: pointer;
}

/* Magnifier */
.magnifier-loupe {
  position: absolute;
  width: 120px;
  height: 120px;
  border: 4px solid white;
  border-radius: 50%;
  background: #fff;
  pointer-events: none; /* Click through */
  display: none;
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  z-index: 30;
  /* Reticle (Crosshair) */
}

.magnifier-loupe::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  border-left: 2px solid rgba(255,0,0,0.5);
  border-top: 2px solid rgba(255,0,0,0.5);
  transform: translate(-50%, -50%);
}

.magnifier-loupe canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Brush Cursor Overlay */
.brush-cursor {
  position: absolute;
  border: 1px solid white;
  border-radius: 50%;
  background: rgba(255, 0, 0, 0.2);
  pointer-events: none;
  z-index: 15;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 2px rgba(0,0,0,0.5);
}


/* Controls Section (Below Canvas) */
.controls-sidebar {
  width: 100%;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* On larger screens, use horizontal scrolling carpet grid */
@media (min-width: 768px) {
  .controls-sidebar {
    max-height: none;
  }
  
  /* Make carpet grid horizontal on desktop */
  .controls-sidebar .carpet-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    max-height: none;
    overflow-x: auto;
    overflow-y: visible;
  }
}

.controls-header {
  padding: 1rem;
  border-bottom: 1px solid #e5e7eb;
}

.controls-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #111827;
}

.controls-content {
  flex: 1;
  /* Allow natural height */
  padding: 1rem;
}

/* Steps Indicator */
.steps-indicator {
  display: flex;
  margin-bottom: 1rem;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0.5rem;
}

.step-item {
  flex: 1;
  text-align: center;
  position: relative;
  font-size: 0.75rem;
  font-weight: 500;
  color: #9ca3af;
  padding-bottom: 0.5rem;
}

.step-item.active {
  color: #2563eb;
  font-weight: 600;
}

.step-item.active::after {
  content: '';
  position: absolute;
  bottom: -0.5rem;
  left: 0;
  width: 100%;
  height: 2px;
  background: #2563eb;
}

/* Carpet Grid - Responsive grid for full-width layout */
.carpet-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr); 
  gap: 0.75rem;
}

/* On tablet and up, show more columns */
@media (min-width: 640px) {
  .carpet-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 768px) {
  .carpet-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 1024px) {
  .carpet-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (min-width: 1921px) {
  .carpet-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.carpet-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.carpet-card:hover {
  border-color: #93c5fd;
}

.carpet-card.selected {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.carpet-thumb {
  height: 80px;
  background-size: cover;
  background-position: center;
  position: relative;
}

/* Colorway Badge */
.colorway-badge {
  position: absolute;
  bottom: 0.25rem;
  right: 0.25rem;
  background: rgba(0,0,0,0.6);
  color: white;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.carpet-info {
  padding: 0.5rem;
}

.carpet-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.carpet-price {
  font-size: 0.7rem;
  color: #6b7280;
}

/* Colorway Modal/Drawer */
.colorway-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  z-index: 50;
  transform: translateY(100%);
  transition: transform 0.3s ease-out;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.colorway-drawer.open {
  transform: translateY(0);
}

.colorway-header {
  padding: 1rem;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.colorway-grid {
  padding: 1rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  overflow-y: auto;
}

.colorway-item {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
}

.colorway-item.selected {
  border-color: #2563eb;
}

.colorway-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Action Footer */
.controls-footer {
  padding: 1rem;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
}

/* Upload Prompt */
.upload-prompt {
  text-align: center;
  color: #9ca3af;
  padding: 2rem;
}

.upload-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  color: #4b5563;
}

/* Buttons */
.btn {
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-primary { background: #2563eb; color: white; }
.btn-secondary { background: white; color: #374151; border: 1px solid #d1d5db; }

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