/**
 * Estilos del Visor, Paleta de Color, Comparador y Visor de Código
 * Fijate Tools - SVG Surgeon
 */

/* Contenedor del Visor Principal */
.preview-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.preview-toolbar {
  padding: 0.75rem 1.2rem;
  background-color: rgba(30, 41, 59, 0.4);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

[data-theme="light"] .preview-toolbar {
  background-color: rgba(241, 245, 249, 0.9);
}

.view-mode-tabs {
  display: flex;
  align-items: center;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.2rem;
  gap: 0.2rem;
}

.view-tab-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
}

.view-tab-btn:hover {
  color: var(--text-primary);
}

.view-tab-btn.active {
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.viewport-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.bg-selector-btn {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.bg-selector-btn:hover, .bg-selector-btn.active {
  transform: scale(1.15);
  border-color: var(--accent-primary);
}

.bg-checkered-dark {
  background-color: #111827;
  background-image: 
    linear-gradient(45deg, #1f2937 25%, transparent 25%), 
    linear-gradient(-45deg, #1f2937 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #1f2937 75%), 
    linear-gradient(-45deg, transparent 75%, #1f2937 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

.bg-checkered-light {
  background-color: #f8fafc;
  background-image: 
    linear-gradient(45deg, #e2e8f0 25%, transparent 25%), 
    linear-gradient(-45deg, #e2e8f0 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #e2e8f0 75%), 
    linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

.bg-solid-white {
  background-color: #ffffff;
}

.bg-solid-black {
  background-color: #050811;
}

/* Área de Lienzo / Canvas */
.preview-stage {
  flex: 1;
  min-height: 480px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.stage-canvas {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  transition: background-color 0.2s ease;
}

/* Modo Lado a Lado (Split View) */
.split-view-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  height: 100%;
  gap: 1rem;
}

.split-card {
  display: flex;
  flex-direction: column;
  background-color: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

[data-theme="light"] .split-card {
  background-color: rgba(255, 255, 255, 0.6);
}

.split-card-header {
  padding: 0.6rem 1rem;
  background-color: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
}

.split-card-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.split-card-body svg {
  max-width: 100%;
  max-height: 380px;
  width: auto;
  height: auto;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Modo Comparador Deslizante (Slider Curtain Before/After) */
.slider-compare-container {
  position: relative;
  width: 100%;
  max-width: 600px;
  height: 400px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-subtle);
}

.compare-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.compare-layer.layer-original {
  z-index: 1;
}

.compare-layer.layer-optimized {
  z-index: 2;
  overflow: hidden;
  width: 50%;
  border-right: 2px solid var(--accent-primary);
  background-color: inherit;
}

.compare-layer svg {
  max-width: 100%;
  max-height: 340px;
  width: auto;
  height: auto;
}

.compare-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 4px;
  margin-left: -2px;
  background-color: var(--accent-primary);
  z-index: 10;
  cursor: ew-resize;
  display: flex;
  align-items: center;
  justify-content: center;
}

.compare-handle-knob {
  width: 32px;
  height: 32px;
  background-color: var(--accent-primary);
  color: #ffffff;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
  font-size: 0.75rem;
  user-select: none;
}

/* Resaltador de Diferencias de Código (Code Diff) */
.code-diff-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  height: 100%;
  gap: 1rem;
  background-color: var(--bg-code);
  border-radius: var(--radius-lg);
  padding: 1rem;
  overflow: hidden;
}

@media (max-width: 900px) {
  .code-diff-container {
    grid-template-columns: 1fr;
  }
}

.code-pane {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.code-pane-header {
  padding: 0.5rem 0.85rem;
  background-color: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.code-pane-body {
  flex: 1;
  overflow: auto;
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.6;
  color: #cbd5e1;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 440px;
}

.code-tag { color: #f43f5e; }
.code-attr { color: #38bdf8; }
.code-val { color: #a7f3d0; }
.code-comment { color: #64748b; font-style: italic; }

/* Editor Visual de Paleta de Colores */
.palette-section {
  border-top: 1px solid var(--border-subtle);
  padding: 1.25rem;
  background-color: rgba(15, 23, 42, 0.6);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

[data-theme="light"] .palette-section {
  background-color: rgba(248, 250, 252, 0.9);
}

.palette-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.palette-title-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.palette-title-group h3 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.palette-quick-filters {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.swatches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
}

.swatch-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.swatch-card:hover {
  border-color: var(--border-focus);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.swatch-preview-box {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
}

.swatch-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.swatch-hex {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.swatch-count {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.swatch-color-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* Efecto de Resaltado en SVG al pasar por el color */
.svg-highlight-pulse {
  animation: svgPulse 1.2s infinite alternate ease-in-out;
  outline: 3px solid #3b82f6 !important;
}

@keyframes svgPulse {
  0% { filter: drop-shadow(0 0 4px #3b82f6) brightness(1.2); }
  100% { filter: drop-shadow(0 0 14px #06b6d4) brightness(1.6); }
}

/* Barra de Reemplazo Masivo de Paleta */
.mass-replace-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem;
  background-color: var(--bg-input);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  flex-wrap: wrap;
}

.mass-replace-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.color-input-bubble {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background-color: var(--bg-surface-elevated);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.color-circle {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
}
