/**
 * Estilos canónicos del Comprobador de composición fotográfica y proporción áurea
 * Fijate Tools - fijate.com
 */

:root {
  --tool-bg-canvas: #090a0f;
  --tool-checker-1: #12151f;
  --tool-checker-2: #191c2b;
  --fijate-accent-gold: #f59e0b;
  --fijate-accent-cyan: #06b6d4;
  --fijate-border: rgba(255, 255, 255, 0.1);
  --fijate-surface: #141721;
  --fijate-surface-alt: #1a1e2d;
  --fijate-surface-hover: #22273a;
  --fijate-text: #f8fafc;
  --fijate-text-muted: #94a3b8;
  --fijate-primary: #3b82f6;
  --fijate-primary-hover: #2563eb;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

[data-theme="light"] {
  --tool-bg-canvas: #e2e8f0;
  --tool-checker-1: #f1f5f9;
  --tool-checker-2: #cbd5e1;
  --fijate-border: rgba(0, 0, 0, 0.12);
  --fijate-surface: #ffffff;
  --fijate-surface-alt: #f8fafc;
  --fijate-surface-hover: #f1f5f9;
  --fijate-text: #0f172a;
  --fijate-text-muted: #64748b;
  --fijate-primary: #2563eb;
  --fijate-primary-hover: #1d4ed8;
}

body {
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--fijate-surface-alt);
  color: var(--fijate-text);
  margin: 0;
  padding: 0;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 0;
}

.mono-val {
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
}

/* Layout principal de la herramienta */
.tool-layout {
  max-width: 1380px;
  width: 100%;
  margin: 1rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
}

.tool-with-sidebar {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  width: 100%;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
}

/* Contenedor de la aplicación interactiva */
.composition-app-card {
  background: var(--fijate-surface);
  border: 1px solid var(--fijate-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  margin-bottom: 2rem;
}

/* Barra superior de herramientas y carga */
.app-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  background: var(--fijate-surface-alt);
  border-bottom: 1px solid var(--fijate-border);
  gap: 0.75rem;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid var(--fijate-border);
  background: var(--fijate-surface);
  color: var(--fijate-text);
  user-select: none;
  text-decoration: none;
  box-sizing: border-box;
}

.btn-action:hover {
  background: var(--fijate-surface-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-action.btn-primary {
  background: var(--fijate-primary);
  color: #ffffff;
  border-color: transparent;
}

.btn-action.btn-primary:hover {
  background: var(--fijate-primary-hover);
}

.btn-action.btn-accent {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #ffffff;
  border-color: transparent;
}

.btn-action.btn-accent:hover {
  filter: brightness(1.1);
}

/* Presets de fotos de muestra */
.presets-strip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  background: rgba(0, 0, 0, 0.15);
  border-bottom: 1px solid var(--fijate-border);
  overflow-x: auto;
  white-space: nowrap;
}

.presets-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fijate-text-muted);
  margin-right: 0.3rem;
  flex-shrink: 0;
}

.btn-preset {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 36px;
  padding: 0 0.75rem 0 0.35rem;
  border-radius: 20px;
  background: var(--fijate-surface);
  border: 1px solid var(--fijate-border);
  color: var(--fijate-text);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-preset img {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
}

.btn-preset:hover {
  background: var(--fijate-surface-hover);
  border-color: var(--fijate-accent-gold);
}

.btn-preset.active {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--fijate-accent-gold);
  color: var(--fijate-accent-gold);
  font-weight: 600;
}

/* Área de trabajo dual: Visor interactivo y Panel de controles */
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  min-height: 600px;
  background: var(--fijate-surface);
}

@media (max-width: 1080px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

/* Visor de lienzo */
.viewport-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  background-color: var(--tool-bg-canvas);
  background-image: 
    linear-gradient(45deg, var(--tool-checker-1) 25%, transparent 25%),
    linear-gradient(-45deg, var(--tool-checker-1) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--tool-checker-1) 75%),
    linear-gradient(-45deg, transparent 75%, var(--tool-checker-1) 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0px;
  overflow: hidden;
  user-select: none;
  min-height: 480px;
}

.canvas-container {
  flex: 1 1 0%;
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 460px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: grab;
}

.canvas-container.panning {
  cursor: grabbing;
}

#main-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  transition: transform 0.05s ease-out;
}

/* Zona de arrastrar y soltar (drop overlay) */
.drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(14, 165, 233, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.drop-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.drop-overlay-box {
  border: 3px dashed #ffffff;
  border-radius: var(--radius-lg);
  padding: 3rem 4rem;
  text-align: center;
}

.drop-overlay-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
}

/* Barra flotante de controles rápidos del visor */
.viewport-floating-bar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 30px;
  padding: 0.35rem 0.6rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 20;
}

.btn-tool-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: #f8fafc;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-tool-icon:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.viewport-info-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  padding: 0 0.5rem;
  color: #94a3b8;
  white-space: nowrap;
}

/* Panel lateral de pestañas y configuración */
.controls-sidebar {
  display: flex;
  flex-direction: column;
  background: var(--fijate-surface);
  border-left: 1px solid var(--fijate-border);
  overflow-y: auto;
  max-height: 850px;
}

@media (max-width: 1080px) {
  .controls-sidebar {
    border-left: none;
    border-top: 1px solid var(--fijate-border);
    max-height: none;
  }
}

/* Navegación por pestañas */
.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--fijate-border);
  background: var(--fijate-surface-alt);
}

.panel-tab-btn {
  flex: 1 1 0%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.6rem 0.5rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--fijate-text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.panel-tab-btn:hover {
  color: var(--fijate-text);
  background: var(--fijate-surface-hover);
}

.panel-tab-btn.active {
  color: var(--fijate-primary);
  border-bottom-color: var(--fijate-primary);
  background: var(--fijate-surface);
}

/* Contenido de pestañas */
.tab-pane {
  display: none;
  padding: 1.25rem;
  flex-direction: column;
  gap: 1.25rem;
}

.tab-pane.active {
  display: flex;
}

/* Secciones dentro del panel */
.control-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--fijate-border);
}

.control-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--fijate-text);
  margin: 0;
}

.section-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.15);
  color: var(--fijate-accent-gold);
}

/* Lista de interruptores (toggles) */
.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-md);
  background: var(--fijate-surface-alt);
  border: 1px solid var(--fijate-border);
  cursor: pointer;
  transition: background 0.15s ease;
}

.toggle-item:hover {
  background: var(--fijate-surface-hover);
}

.toggle-label-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.toggle-icon {
  width: 18px;
  height: 18px;
  color: var(--fijate-text-muted);
  flex-shrink: 0;
}

.toggle-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--fijate-text);
  display: block;
}

.toggle-desc {
  font-size: 0.72rem;
  color: var(--fijate-text-muted);
  display: block;
}

/* Switch UI táctil canónico */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--tool-checker-2);
  transition: 0.25s ease;
  border-radius: 24px;
  border: 1px solid var(--fijate-border);
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: 0.25s ease;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

input:checked + .slider {
  background-color: var(--fijate-primary);
  border-color: var(--fijate-primary);
}

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

/* Selector de colores de guía de alto contraste */
.color-picker-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-color-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
  padding: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

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

.btn-color-dot.active {
  border-color: var(--fijate-text);
  transform: scale(1.1);
  box-shadow: 0 0 0 2px var(--fijate-surface), 0 0 0 4px var(--fijate-primary);
}

/* Subcuadrícula de orientación de la espiral en 4 cuadrantes */
.quadrant-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
}

.btn-quadrant {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  background: var(--fijate-surface-alt);
  border: 1px solid var(--fijate-border);
  color: var(--fijate-text);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-quadrant:hover {
  background: var(--fijate-surface-hover);
}

.btn-quadrant.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--fijate-primary);
  color: var(--fijate-primary);
  font-weight: 700;
}

/* Filas de deslizadores y valores */
.range-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.range-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: var(--fijate-text-muted);
}

.range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: var(--tool-checker-2);
  outline: none;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--fijate-primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  transition: transform 0.1s ease;
}

.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Tarjetas de telemetría Sobel y pesos visuales */
.telemetry-card {
  background: var(--fijate-surface-alt);
  border: 1px solid var(--fijate-border);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.telemetry-metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
}

.telemetry-bar-wrap {
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  position: relative;
  display: flex;
}

.telemetry-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--fijate-accent-cyan), var(--fijate-accent-gold));
  border-radius: 4px;
  transition: width 0.3s ease;
}

.balance-bipolar-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.bipolar-left {
  background: #38bdf8;
  transition: width 0.3s ease;
}

.bipolar-right {
  background: #f43f5e;
  transition: width 0.3s ease;
}

.harmony-score-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
}

.harmony-score-val {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--fijate-accent-gold);
}

/* Botones de acción inferior móvil / exportación */
.app-footer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--fijate-surface-alt);
  border-top: 1px solid var(--fijate-border);
  gap: 1rem;
  flex-wrap: wrap;
}

.app-footer-actions .btn-action {
  flex: 1 1 200px;
}

/* Desplegables <select> conforme a los estándares canónicos */
select.fijate-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  min-height: 40px;
  padding: 0.5rem 2.5rem 0.5rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--fijate-border);
  background-color: var(--fijate-surface);
  color: var(--fijate-text);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
}

select.fijate-select option,
select.fijate-select optgroup {
  background-color: #141721;
  color: #f8fafc;
}

[data-theme="light"] select.fijate-select option,
[data-theme="light"] select.fijate-select optgroup {
  background-color: #ffffff;
  color: #0f172a;
}

/* Modales accesibles fijate.com */
.app-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.app-modal-card {
  background: var(--fijate-surface);
  border: 1px solid var(--fijate-border);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.app-modal-title {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1.2rem;
}

.app-modal-text {
  color: var(--fijate-text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.app-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Toast flotante para avisos de copiado/exportación */
.toast-notice {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  font-size: 0.88rem;
  font-weight: 500;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.25s ease;
  pointer-events: none;
}

.toast-notice.show {
  opacity: 1;
  transform: translateY(0);
}

/* Ajustes responsivos en pantallas móviles */
@media (max-width: 640px) {
  .app-topbar {
    flex-direction: column;
    align-items: stretch;
  }
  .topbar-left, .topbar-right {
    width: 100%;
    justify-content: space-between;
  }
  .topbar-right .btn-action {
    flex: 1 1 0%;
  }
  .viewport-panel {
    min-height: 380px;
  }
  .canvas-container {
    min-height: 360px;
  }
}
