/**
 * Editor Modal - Celestial Geometry Design
 * Clean, modern styling for the star map editor
 */

/* ===========================================
   BACKDROP
   =========================================== */

.editor-modal-backdrop {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 1000;
}

.editor-modal-backdrop.is-active {
  opacity: 1;
  visibility: visible;
}

/* ===========================================
   MODAL CONTAINER
   =========================================== */

.editor-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 92vw;
  max-width: 1400px;
  height: 88vh;
  max-height: 920px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-modal.is-active {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  visibility: visible;
}

/* ===========================================
   ERROR BANNER
   =========================================== */

.editor-error-banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.5rem;
  background: var(--color-error, #d64545);
  color: #ffffff;
  transform: translateY(-100%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.editor-error-banner.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.editor-error-banner-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.editor-error-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.editor-error-message {
  font-size: 0.875rem;
  font-weight: 500;
}

.editor-error-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 4px;
  color: #ffffff;
  cursor: pointer;
  transition: background 0.15s ease;
}

.editor-error-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Error state for inputs */
.editor-modal .form-input.has-error,
.editor-modal .mapboxgl-ctrl-geocoder--input.has-error {
  border-color: var(--color-error, #d64545) !important;
  box-shadow: 0 0 0 3px rgba(214, 69, 69, 0.15) !important;
}

.editor-modal .form-group.has-error .form-label {
  color: var(--color-error, #d64545);
}

/* ===========================================
   HEADER
   =========================================== */

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: #fafafa;
  border-bottom: 2px solid #c45d4a;
  flex-shrink: 0;
}

.editor-header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.editor-close-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  font-size: 0.875rem;
  color: #636366;
  cursor: pointer;
  transition: all 0.2s ease;
}

.editor-close-btn:hover {
  background: #ffffff;
  border-color: #c45d4a;
  color: #c45d4a;
}

.editor-close-btn svg {
  width: 16px;
  height: 16px;
}

.editor-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #1c1c1e;
}

.editor-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.editor-undo-redo {
  display: flex;
  gap: 0.25rem;
}

.editor-undo-redo button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  color: #636366;
  cursor: pointer;
  transition: all 0.2s ease;
}

.editor-undo-redo button:hover:not(:disabled) {
  background: #ffffff;
  border-color: #c45d4a;
  color: #c45d4a;
}

.editor-undo-redo button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.editor-undo-redo button svg {
  width: 18px;
  height: 18px;
}

/* ===========================================
   BODY - GRID LAYOUT
   =========================================== */

.editor-body {
  display: grid;
  grid-template-columns: 1fr 380px;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ===========================================
   PREVIEW AREA (DARK)
   =========================================== */

.editor-preview {
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  position: relative;
  overflow: hidden;
}

.editor-preview-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  /* Ensure container has dimensions for SVG to size against */
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;              /* Clip transformed content */
  contain: layout style paint;  /* CSS containment for performance */
}

.editor-preview-container:active {
  cursor: grabbing;
}

/* City Roads editor: move cursor for map panning (its own drag system) */
[data-product-type="city-roads"] .editor-preview-container {
  cursor: move;
}

[data-product-type="city-roads"] .editor-preview-container:active {
  cursor: grabbing;
}

/* City Roads: Centered loading bar with progress animation */
.city-roads-loading-bar {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Blurred background behind loading bar */
.city-roads-loading-bar::before {
  content: '';
  position: absolute;
  top: -12px;
  left: -16px;
  right: -16px;
  bottom: -12px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  border-radius: 8px;
}

/* Loading bar track */
.city-roads-loading-bar-track {
  position: relative;
  width: 200px;
  height: 3px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

/* Animated progress indicator */
.city-roads-loading-bar-track::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 30%;
  background: #c45d4a;
  border-radius: 2px;
  animation: city-roads-progress 1.2s ease-in-out infinite;
}

[data-product-type="city-roads"] .editor-preview-container.is-loading .city-roads-loading-bar {
  opacity: 1;
}

@keyframes city-roads-progress {
  0% { left: -30%; }
  100% { left: 100%; }
}

.editor-preview-svg {
  /* SVG with viewBox and no width/height scales to fill container */
  max-width: 100%;
  max-height: calc(85vh - 180px);
  width: auto;
  height: auto;
  filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.45));
  transition: opacity 0.2s ease;  /* Only opacity transitions, not transform */
  /* Ensure SVG renders as block element */
  display: block;
  /* Transform scaling from center for zoom/pan */
  transform-origin: center center;
}

.editor-preview-svg.is-updating {
  opacity: 0.6;
}

/* Zoom Controls - Collapsible */
.editor-zoom-controls {
  position: absolute;
  bottom: 3rem;
  left: 50%;
  transform: translateX(-50%);
  /* Container needs explicit size for absolute children */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Expand button - black arrow, absolutely positioned */
.editor-zoom-controls .editor-zoom-expand {
  position: absolute;
  width: 36px;
  height: 24px;
  background: transparent !important;
  border: none;
  border-radius: 8px;
  color: rgba(0, 0, 0, 0.9) !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease-out, visibility 0.3s ease-out;
}

.editor-zoom-controls .editor-zoom-expand:hover {
  background: transparent !important;
  color: rgba(0, 0, 0, 0.9) !important;
}

.editor-zoom-expand svg {
  width: 16px;
  height: 16px;
  stroke-width: 3;
}

/* Hide expand arrow when controls are expanded */
.editor-zoom-controls.is-expanded .editor-zoom-expand {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Buttons container - absolutely positioned, same spot as arrow */
.editor-zoom-buttons {
  position: absolute;
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.3s ease-out, visibility 0.3s ease-out, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.editor-zoom-controls.is-expanded .editor-zoom-buttons {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.editor-zoom-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: all 0.2s ease;
}

.editor-zoom-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.editor-zoom-btn svg {
  width: 18px;
  height: 18px;
}

.editor-zoom-separator {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 0.25rem;
}

.editor-download-btn {
  position: relative;
}

.editor-download-menu {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 0.5rem;
  background: #1c1c1e;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.editor-download-menu.is-open {
  opacity: 1;
  visibility: visible;
}

.editor-download-option {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 0.875rem;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s ease;
}

.editor-download-option:hover {
  background: rgba(196, 93, 74, 0.3);
}

/* ===========================================
   SIDEBAR (LIGHT)
   =========================================== */

.editor-sidebar {
  background: #ffffff;
  border-left: 1px solid #e5e5e5;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

/* Scrollbar styling */
.editor-sidebar-scroll::-webkit-scrollbar {
  width: 6px;
}

.editor-sidebar-scroll::-webkit-scrollbar-track {
  background: #f5f5f5;
}

.editor-sidebar-scroll::-webkit-scrollbar-thumb {
  background: #d1d1d1;
  border-radius: 3px;
}

.editor-sidebar-scroll::-webkit-scrollbar-thumb:hover {
  background: #c45d4a;
}

/* Hide drawer handle on desktop - only visible on mobile */
.editor-sidebar-handle {
  display: none;
}

/* ===========================================
   SECTIONS
   =========================================== */

.editor-section {
  margin-bottom: 1.75rem;
}

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

.editor-section-header {
  margin-bottom: 1rem;
}

.editor-section-title {
  font-family: var(--font-primary);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #c45d4a;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e5e5e5;
}

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

/* ===========================================
   FORM ELEMENTS
   =========================================== */

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

.form-label {
  font-family: var(--font-primary);
  font-size: 0.8125rem;
  font-weight: 500;
  color: #1c1c1e;
}

.form-label-required::after {
  content: ' *';
  color: #c45d4a;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: #ffffff;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  font-family: var(--font-primary);
  font-size: 0.9375rem;
  color: #1c1c1e;
  transition: border-color 0.2s ease;
}

.form-input:focus {
  outline: none;
  border-color: #c45d4a;
}

.form-input::placeholder {
  color: #aeaeb2;
}

/* ===========================================
   ROTATING PLACEHOLDER
   =========================================== */

.input-with-placeholder {
  position: relative;
  background: #fff;
  border-radius: 8px;
}

.input-with-placeholder .form-input {
  background: transparent;
  position: relative;
  z-index: 1;
}

.rotating-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  padding-left: 16px;
  pointer-events: none;
  overflow: hidden;
  color: #aeaeb2;
  font-size: 0.9375rem;
  font-family: var(--font-primary);
  z-index: 0;
}

.rotating-placeholder .placeholder-text {
  position: absolute;
  opacity: 0;
  transform: translateY(100%);
  animation: placeholder-rotate 9s infinite;
  white-space: nowrap;
}

.rotating-placeholder .placeholder-text:nth-child(1) { animation-delay: 0s; }
.rotating-placeholder .placeholder-text:nth-child(2) { animation-delay: 3s; }
.rotating-placeholder .placeholder-text:nth-child(3) { animation-delay: 6s; }

@keyframes placeholder-rotate {
  0% { opacity: 0; transform: translateY(100%); }
  5% { opacity: 1; transform: translateY(0); }
  28% { opacity: 1; transform: translateY(0); }
  33% { opacity: 0; transform: translateY(-100%); }
  100% { opacity: 0; transform: translateY(-100%); }
}

/* Hide when input has value or focus */
.form-input:focus + .rotating-placeholder,
.input-has-value .rotating-placeholder {
  display: none;
}

.datetime-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.char-counter {
  display: flex;
  justify-content: flex-end;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: #aeaeb2;
}

/* Mapbox Geocoder Override */
#editor-geocoder-container .mapboxgl-ctrl-geocoder {
  width: 100%;
  max-width: 100%;
  font-family: var(--font-primary);
  box-shadow: none;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
}

#editor-geocoder-container .mapboxgl-ctrl-geocoder--input {
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
}

#editor-geocoder-container .mapboxgl-ctrl-geocoder--input:focus {
  outline: none;
}

#editor-geocoder-container .mapboxgl-ctrl-geocoder:focus-within {
  border-color: #c45d4a;
}

/* ===========================================
   THEME SWATCHES
   =========================================== */

.theme-categories {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.theme-category-btn {
  padding: 0.375rem 0.75rem;
  background: transparent;
  border: 1px solid #e5e5e5;
  border-radius: 20px;
  font-family: var(--font-primary);
  font-size: 0.75rem;
  color: #636366;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-category-btn:hover {
  border-color: #c45d4a;
  color: #c45d4a;
}

.theme-category-btn.is-active {
  background: #c45d4a;
  border-color: #c45d4a;
  color: #ffffff;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
}

.theme-swatch {
  aspect-ratio: 1;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.theme-swatch:hover {
  transform: scale(1.05);
}

.theme-swatch.is-active {
  border-color: #c45d4a;
  box-shadow: 0 0 0 2px rgba(196, 93, 74, 0.3);
}

.theme-swatch-bg {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.theme-swatch-star {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.theme-swatch-accent {
  position: absolute;
  top: 4px;
  right: 4px;
  bottom: 4px;
  left: 4px;
  border: 1px solid;
  border-radius: 2px;
}

/* ===========================================
   FONT SELECTOR
   =========================================== */

.font-selector {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.font-option {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem;
  background: #ffffff;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.font-option:hover {
  border-color: #c45d4a;
}

.font-option.is-active {
  border-color: #c45d4a;
  background: rgba(196, 93, 74, 0.05);
}

.font-option-name {
  font-size: 1rem;
  color: #1c1c1e;
  text-align: center;
  padding: 0.25rem 0;
}

/* ===========================================
   TOGGLE SWITCHES
   =========================================== */

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.toggle-label {
  font-family: var(--font-primary);
  font-size: 0.875rem;
  color: #1c1c1e;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 2;
}

.toggle-slider {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: #e5e5e5;
  border-radius: 24px;
  transition: background 0.2s ease;
  pointer-events: none;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease;
}

.toggle-switch input:checked + .toggle-slider {
  background: #c45d4a;
}

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

/* ===========================================
   TOGGLE-INPUT MERGED COMPONENT
   =========================================== */

.toggle-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  background: #f9f9f9;
  border-radius: 8px;
  margin-bottom: 0.75rem;
}

.toggle-input-group.toggle-only {
  padding: 0.5rem 0.75rem;
}

.toggle-input-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toggle-input-header .form-label {
  margin-bottom: 0;
  font-weight: 500;
}

.toggle-input-group .form-input {
  margin-top: 0.25rem;
}

.toggle-input-group .datetime-row {
  margin-top: 0.25rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.toggle-input-group .datetime-field {
  min-width: 0;
  margin-bottom: 0;
}

.toggle-input-group .char-counter {
  margin-top: 0.25rem;
}

/* Hide input area when toggle is off */
.toggle-input-group.is-disabled .form-input,
.toggle-input-group.is-disabled .datetime-row,
.toggle-input-group.is-disabled .char-counter {
  opacity: 0.4;
  pointer-events: none;
}

/* ===========================================
   SIZE SELECTOR
   =========================================== */

.size-selector {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.size-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  background: #ffffff;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.size-option:hover {
  border-color: #c45d4a;
}

.size-option.is-active {
  border-color: #c45d4a;
  background: rgba(196, 93, 74, 0.05);
}

.size-option-info {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.size-option-name {
  font-family: var(--font-primary);
  font-size: 0.9375rem;
  font-weight: 500;
  color: #1c1c1e;
}

.size-option-dimensions {
  font-size: 0.75rem;
  color: #aeaeb2;
}

.size-option-price {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
  color: #1c1c1e;
}

/* ===========================================
   FOOTER
   =========================================== */

.editor-footer {
  padding: 1.25rem 1.5rem;
  background: #fafafa;
  border-top: 2px solid #c45d4a;
  flex-shrink: 0;
}

.editor-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.editor-price-label {
  font-family: var(--font-primary);
  font-size: 0.875rem;
  color: #636366;
}

.editor-price-value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: #c45d4a;
}

.editor-add-to-cart {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 1rem 1.5rem;
  background: #1c1c1e;
  border: 2px solid #1c1c1e;
  border-radius: 6px;
  font-family: var(--font-primary);
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.editor-add-to-cart:hover {
  background: transparent;
  color: #1c1c1e;
}

.editor-add-to-cart:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.editor-add-to-cart svg {
  width: 18px;
  height: 18px;
}

/* ===========================================
   RESPONSIVE - TABLET
   =========================================== */

@media (max-width: 1024px) {
  .editor-modal {
    width: 95vw;
    height: 90vh;
  }

  .editor-body {
    grid-template-columns: 1fr 340px;
  }
}

@media (max-width: 900px) {
  .editor-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(300px, 1fr) auto;
  }

  .editor-preview {
    min-height: 300px;
  }

  .editor-sidebar {
    border-left: none;
    border-top: 1px solid #e5e5e5;
    max-height: 50vh;
  }

  .editor-preview-svg {
    max-height: 280px;
  }
}

/* ===========================================
   RESPONSIVE - MOBILE
   =========================================== */

@media (max-width: 600px) {
  .editor-modal {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
  }

  .editor-body {
    grid-template-columns: 1fr;                    /* Reset to single column - fixes white space */
    grid-template-rows: minmax(250px, 40vh) 1fr;  /* Give preview fixed space */
  }

  .editor-preview {
    min-height: 250px;
    max-height: 40vh;
    overflow: hidden;
    min-width: 0;                /* Safari flex fix */
    padding: 0.5rem;             /* Reduce padding on mobile */
  }

  .editor-preview-container {
    width: 100%;
    height: 100%;
    min-height: 200px;
    min-width: 0;                /* Safari flex fix */
    overflow: hidden;            /* Clip during zoom/pan */
    contain: layout style;       /* Remove 'paint' and 'strict' - let shadow repaint freely */
  }

  .editor-preview-svg {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    min-height: 150px;           /* Fallback minimum for Safari */
    display: block;
    /* Use filter drop-shadow - works with GPU acceleration and overflow:hidden */
    filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.45));
    /* Force isolated GPU layer to prevent cascade/ghosting */
    transform: translateZ(0);
    isolation: isolate;
  }

  .editor-preview-svg svg {
    width: 100% !important;      /* Override JS removal for Safari */
    height: auto !important;
    max-width: 100%;
    max-height: 100%;
  }

  /* Full shadow during drag - viewport paradigm eliminates ghosting */
  /* .editor-preview-svg.is-dragging class still added/removed for potential future use */

  .editor-header {
    padding: 0.75rem 1rem;
  }

  .editor-title {
    font-size: 1.125rem;
  }

  .editor-close-btn span {
    display: none;
  }

  .editor-sidebar-scroll {
    padding: 1rem;
  }

  /* Prevent mobile browser zoom on input focus - must be 16px+ */
  .form-input,
  .form-select,
  .editor-modal input,
  .editor-modal select,
  .editor-modal textarea,
  .mapboxgl-ctrl-geocoder--input,
  .photon-autocomplete-input {
    font-size: 16px !important;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Datetime fields stacked on separate rows on mobile */
  .editor-modal .datetime-row,
  .editor-modal .toggle-input-group .datetime-row {
    display: block !important;
    grid-template-columns: none !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .editor-modal .datetime-row > .form-group,
  .editor-modal .datetime-row > .datetime-field,
  .editor-modal .toggle-input-group .datetime-field {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 0.75rem !important;
    box-sizing: border-box !important;
  }

  .editor-modal .datetime-row > .form-group:last-child,
  .editor-modal .datetime-row > .datetime-field:last-child,
  .editor-modal .toggle-input-group .datetime-field:last-child {
    margin-bottom: 0 !important;
  }

  .editor-modal .datetime-row .form-input,
  .editor-modal .datetime-row input[type="date"],
  .editor-modal .datetime-row input[type="time"],
  .editor-modal input[type="date"],
  .editor-modal input[type="time"] {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 0.75rem 1rem !important;
    -webkit-appearance: none !important;
    appearance: none !important;
  }

  .editor-section-title {
    font-size: 0.625rem;
  }

  .theme-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .editor-footer {
    padding: 1rem;
  }

  .editor-price-value {
    font-size: 1.5rem;
  }

  /* Hide zoom controls on mobile - use touch gestures instead */
  .editor-zoom-controls {
    display: none;
  }

  /* Sidebar as bottom sheet drawer */
  .editor-sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70vh;                /* Fixed height for reliable transform */
    max-height: 70vh;
    transform: translateY(calc(70vh - 60px));  /* Show only 60px handle area */
    transition: transform 0.3s ease;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    z-index: 100;                /* Higher z-index to ensure visibility */
    border-left: none;
    border-top: 1px solid #e5e5e5;
    background: #ffffff;         /* Ensure background is set */
  }

  .editor-sidebar.is-expanded {
    transform: translateY(0);
  }

  /* Drag handle - visible only on mobile */
  .editor-sidebar-handle {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px 0 8px;
    cursor: grab;
    background: #ffffff;         /* Match sidebar background */
    border-radius: 16px 16px 0 0;
    -webkit-tap-highlight-color: transparent;  /* Remove tap highlight on iOS */
    touch-action: pan-y;         /* Lock to vertical scroll only */
    user-select: none;           /* Prevent text selection */
    -webkit-user-select: none;
  }

  .editor-sidebar-handle:active {
    cursor: grabbing;
  }

  /* Lock sidebar to vertical movement only */
  .editor-sidebar {
    touch-action: pan-y;
    overscroll-behavior: contain;  /* Prevent scroll chaining */
  }

  .editor-sidebar-handle .handle-bar {
    width: 40px;
    height: 4px;
    background: #c4c4c4;
    border-radius: 2px;
  }

  /* Sidebar scroll area needs to account for handle */
  .editor-sidebar .editor-sidebar-scroll {
    height: calc(70vh - 60px - 80px);  /* Total height - handle - footer */
    overflow-y: auto;
  }

  /* Preview takes remaining space */
  .editor-preview {
    min-height: calc(100vh - 60px - 60px);  /* Full height minus header and handle peek */
    max-height: calc(100vh - 60px - 60px);
  }

  .editor-body {
    grid-template-rows: 1fr;  /* Single row, preview fills space */
    overflow: hidden;
  }
}

/* ===========================================
   LOADING STATE
   =========================================== */

.editor-preview-svg.is-loading {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* ===========================================
   LOADING OVERLAY
   =========================================== */

.editor-loading-overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.editor-loading-overlay.is-active {
  opacity: 1;
  visibility: visible;
}

.editor-loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.editor-loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid #e0e0e0;
  border-top-color: #333;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.editor-loading-text {
  font-size: 0.875rem;
  color: #666;
  margin: 0;
}

/* Editor body content reveal transition */
/* Only hide when loading overlay is active */
.editor-modal.is-loading .editor-body {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.editor-body.is-ready {
  opacity: 1;
  transition: opacity 0.3s ease;
}

/* Preview loading state */
.preview-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 1rem;
  color: #666;
}

.preview-loading-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid #e0e0e0;
  border-top-color: #333;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Preview error state */
.preview-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 0.5rem;
  color: #d64545;
  text-align: center;
  padding: 2rem;
}

.preview-error-icon {
  width: 48px;
  height: 48px;
  border: 2px solid currentColor;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: bold;
}

/* Editor error in modal */
.editor-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
}

.editor-error-icon {
  width: 48px;
  height: 48px;
  border: 2px solid #d64545;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d64545;
  font-size: 1.5rem;
  font-weight: bold;
}

/* ===========================================
   LABEL WITH INFO ICON
   =========================================== */

/* Label with info icon inside - all on one row */
label.form-label.form-label-has-info {
  display: inline-flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 0 !important;
}

/* Info Icon - positioned after the asterisk */
label.form-label-has-info .label-info-icon {
  position: relative;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  padding: 2px;
  color: #8e8e93;
  cursor: pointer;
  order: 1;
  flex-shrink: 0;
}

/* Override reset.css for info icon SVG */
label.form-label-has-info .label-info-icon svg {
  display: inline !important;
  max-width: none !important;
  width: 14px !important;
  height: 14px !important;
  vertical-align: middle !important;
}

.label-info-icon:hover {
  color: #555;
}

/* Tooltip via data-tooltip attribute - slides in from left (appears on right) */
.label-info-icon[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: 50%;
  left: calc(100% + 8px);
  transform: translateY(-50%) translateX(-8px);
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  color: #1c1c1e;
  font-size: 12px;
  font-weight: 400;
  width: 200px;                /* Fixed width - adjust as needed */
  white-space: normal;
  text-align: left;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
}

/* Show tooltip on hover only - slide in from left */
.label-info-icon[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) translateX(0);
}
