/* Importación de Google Fonts para una tipografía premium */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

.taltufix-tool-app {
  --bg-primary: #090d16;
  --bg-secondary: #111827;
  --bg-tertiary: #1f2937;
  --bg-card: rgba(17, 24, 39, 0.7);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #8b5cf6;
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --accent-primary: #8b5cf6; /* Violeta */
  --accent-secondary: #ec4899; /* Rosa */
  --accent-cyan: #06b6d4; /* Cian */
  --accent-green: #10b981; /* Verde */
  
  --gradient-accent: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  --gradient-cyan-blue: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-primary) 100%);
  --gradient-dark: linear-gradient(180deg, rgba(17, 24, 39, 0.8) 0%, rgba(9, 13, 22, 0.9) 100%);
  
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 15px rgba(139, 92, 246, 0.2);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-title: 'Outfit', sans-serif;
}

.taltufix-tool-app,
.taltufix-tool-app * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.taltufix-tool-app {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Todo lo de aquí abajo queda confinado a .taltufix-tool-app y sus
   descendientes: nunca puede afectar el header/footer/menú del sitio
   (antes "header", "main", etc. eran selectores sueltos que coincidían
   con esos mismos tags en el resto de la página), y tampoco puede heredar
   colores que el tema le imponga a etiquetas genéricas fuera de esta app. */
@scope (.taltufix-tool-app) {

:scope * {
  color: inherit;
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: url(#logo-grad);
  stroke-width: 2.5;
}

.logo h1 {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo span {
  font-size: 0.8rem;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  margin-left: 5px;
  font-weight: 500;
}

/* Controles de Modo en Header */
.mode-selector {
  display: flex;
  background: rgba(9, 13, 22, 0.6);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.mode-btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
  transition: stroke 0.2s ease;
}

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

.mode-btn.active {
  background: var(--gradient-accent);
  color: #fff;
  box-shadow: var(--shadow-glow);
}

/* Contenedor Principal (Layout de Rejilla / Flex) */
.app-container {
  display: flex;
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* Panel Lateral (Controles) */
aside.sidebar {
  width: 320px;
  background: rgba(11, 15, 25, 0.9);
  backdrop-filter: blur(8px);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 20px;
  overflow-y: auto;
  z-index: 5;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(31, 41, 55, 0.25);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: var(--radius-md);
}

.sidebar-section h3 {
  font-family: var(--font-title);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-section h3 svg {
  width: 16px;
  height: 16px;
  color: var(--accent-primary);
}

/* Ajustes e Inputs */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
}

.control-val {
  color: var(--accent-cyan);
  font-family: monospace;
  font-weight: bold;
}

.range-input {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  outline: none;
}

.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.range-input::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: var(--accent-secondary);
}

/* Botones y Acciones */
.btn-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.btn-icon {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: var(--font-main);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: rgba(139, 92, 246, 0.15);
  border-color: var(--accent-primary);
}

.btn-icon svg {
  width: 14px;
  height: 14px;
}

.btn-action-primary {
  grid-column: span 2;
  background: var(--gradient-accent);
  color: white;
  border: none;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(139, 92, 246, 0.2);
}

.btn-action-primary:hover {
  background: linear-gradient(135deg, #7c3aed 0%, #db2777 100%);
  transform: translateY(-1px);
}

/* Área del Workspace de Imágenes */
.workspace {
  flex: 1;
  background: radial-gradient(circle at center, #111c2e 0%, #06090e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Dashboard de Carga Inicial */
.upload-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
  opacity: 1;
  transition: opacity 0.4s ease;
}

.upload-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.upload-card {
  width: 90%;
  max-width: 800px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.upload-header {
  text-align: center;
}

.upload-header h2 {
  font-family: var(--font-title);
  font-size: 2rem;
  font-weight: 700;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.upload-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.drop-zones-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

@media (max-width: 600px) {
  .drop-zones-container {
    grid-template-columns: 1fr;
  }
}

.drop-zone {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-md);
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  overflow: hidden;
}

.drop-zone.dragover {
  border-color: var(--accent-primary);
  background: rgba(139, 92, 246, 0.08);
  transform: scale(1.02);
}

.drop-zone.loaded {
  border-color: var(--accent-green);
  background: rgba(16, 185, 129, 0.05);
}

.drop-zone svg {
  width: 44px;
  height: 44px;
  color: var(--text-muted);
  transition: color 0.3s ease;
}

.drop-zone.loaded svg {
  color: var(--accent-green);
}

.drop-zone:hover svg {
  color: var(--accent-primary);
}

.drop-zone h4 {
  font-size: 1rem;
  font-weight: 600;
}

.drop-zone p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.file-input {
  display: none;
}

.thumb-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.25;
  transition: opacity 0.3s ease;
}

.drop-zone:hover .thumb-preview {
  opacity: 0.45;
}

.sample-trigger-container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.btn-sample {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 24px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-sample:hover {
  background: var(--gradient-cyan-blue);
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.25);
  transform: translateY(-1px);
}

/* Área de Visualización Comparativa (Lienzo interactivo) */
.viewer-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  cursor: grab;
}

.canvas-wrapper:active {
  cursor: grabbing;
}

.canvas-item {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#canvas-b {
  /* En modo Blend de opacidad, controlamos esto con JS */
}

/* Control del Slider / Wipe (Cortinilla) */
.slider-wipe-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--gradient-accent);
  cursor: ew-resize;
  z-index: 3;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
  pointer-events: auto;
}

.slider-wipe-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-primary);
  border: 3px solid var(--accent-primary);
  box-shadow: 0 4px 10px rgba(0,0,0,0.5), 0 0 15px rgba(139, 92, 246, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: ew-resize;
}

.slider-wipe-handle::before,
.slider-wipe-handle::after {
  content: '';
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

.slider-wipe-handle::before {
  border-right: 6px solid var(--text-primary);
  margin-right: 3px;
}

.slider-wipe-handle::after {
  border-left: 6px solid var(--text-primary);
  margin-left: 3px;
}

/* Controles de Shift Offset y Alineación */
.offset-joystick {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 4px;
  width: 100px;
  height: 100px;
  margin: 0 auto;
}

.joy-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.joy-btn:hover {
  background: var(--accent-primary);
  color: white;
}

.joy-btn.joy-center {
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.65rem;
  font-weight: bold;
}

.joy-btn.joy-center:hover {
  background: var(--accent-secondary);
}

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

/* Barra de Estado inferior */
.status-bar {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 6px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  z-index: 10;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-indicator.ready {
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

/* Vista Lado a Lado (Flex layout para sincronizados) */
.side-by-side-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  height: 100%;
  gap: 12px;
  padding: 16px;
}

.side-panel {
  background: rgba(9, 13, 22, 0.4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.side-panel-header {
  padding: 8px 16px;
  background: rgba(17, 24, 39, 0.8);
  border-bottom: 1px solid var(--border-color);
  font-family: var(--font-title);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 2;
}

.side-panel-badge {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent-cyan);
}

.side-canvas-container {
  flex: 1;
  position: relative;
  cursor: grab;
}

.side-canvas-container:active {
  cursor: grabbing;
}

.side-canvas {
  position: absolute;
  top: 0;
  left: 0;
}

/* Feedback visual de Diferencia de Pixeles */
.color-swatch-container {
  display: flex;
  gap: 6px;
}

.color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s ease;
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.active {
  border-color: white;
  box-shadow: 0 0 6px rgba(255,255,255,0.5);
}

/* Indicador flotante de Zoom */
.zoom-indicator {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(8px);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: monospace;
  color: var(--text-primary);
  pointer-events: none;
  z-index: 4;
}

.pulse-primary {
  animation: pulseGlow 2s infinite ease-in-out;
}

} /* fin de @scope (.taltufix-tool-app) */

/* @keyframes queda fuera del @scope a propósito: no tiene selectores que
   escopar y algunos navegadores no lo procesan bien si queda anidado. */
@keyframes pulseGlow {
  0% { box-shadow: 0 0 5px rgba(139, 92, 246, 0.2); }
  50% { box-shadow: 0 0 20px rgba(139, 92, 246, 0.6); }
  100% { box-shadow: 0 0 5px rgba(139, 92, 246, 0.2); }
}
