/* Variables y tipografías corporativas */
:root {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Tema oscuro por defecto */
  --bg-primary: #0b0f17;
  --bg-card: #131b26;
  --bg-card-hover: #1a2433;
  --bg-input: #1a2433;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;

  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: rgba(59, 130, 246, 0.15);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #f8fafc;
  --border-color: #e2e8f0;
  --border-focus: #2563eb;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: rgba(37, 99, 235, 0.1);
}

/* Regla estricta: sólo box-sizing en * */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.tool-layout {
  max-width: 1380px;
  margin: 1.25rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
}

.painter-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  margin-bottom: 2rem;
}

/* Barra superior */
.painter-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.photo-selection-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.painter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.btn-action-outline,
.btn-action-solid {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 40px;
  text-decoration: none;
}

.btn-action-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-action-outline:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}

.btn-action-solid {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #ffffff;
}

.btn-action-solid:hover {
  background: var(--accent-hover);
}

/* Banner de color activo */
.color-active-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1rem;
}

.color-sample-box {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

.color-sample-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.active-color-name {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.active-color-code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.lighting-mode-indicator {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

@media (max-width: 640px) {
  .lighting-mode-indicator {
    margin-left: 0;
    align-items: flex-start;
  }
}

.stat-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.stat-val {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Espacio de trabajo */
.painter-workspace {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 1rem;
  min-height: 600px;
}

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

/* Barra lateral */
.painter-sidebar {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-height: 720px;
  overflow-y: auto;
}

.sidebar-tabs {
  display: flex;
  background: var(--bg-card);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  gap: 3px;
}

.tab-btn {
  flex: 1;
  padding: 0.45rem 0.2rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
  min-height: 36px;
}

.tab-btn.active {
  background: var(--accent);
  color: #ffffff;
}

.tab-pane {
  display: none;
  flex-direction: column;
  gap: 0.85rem;
}

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

.pane-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pane-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.pane-help {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Desplegables de formulario obligatorios */
select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  height: 42px;
  padding: 0 40px 0 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-input);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.88rem;
  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='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

select option {
  background: var(--bg-card);
  color: var(--text-main);
}

.form-group-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group-field label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-badge {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  height: 6px;
}

/* Grid de colores */
.colors-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 2px;
}

.color-swatch-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.color-swatch-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.color-swatch-card.active {
  border-color: var(--accent);
  background: var(--accent-light);
}

.swatch-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.swatch-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.swatch-title {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.swatch-code {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-dim);
}

/* Custom color picker */
.custom-color-row {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-color);
}

.section-microtitle {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.4rem;
}

.custom-color-picker-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
}

.custom-color-picker-box input[type="color"] {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
}

.custom-color-label {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Botones de herramientas de selección */
.tools-buttons-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.btn-tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0.6rem 0.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 52px;
}

.btn-tool:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
  color: var(--text-main);
}

.btn-tool.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* Presets de iluminación */
.lighting-presets-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.btn-lighting {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 50px;
}

.btn-lighting:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
}

.btn-lighting.active {
  border-color: var(--accent);
  background: var(--accent-light);
}

.light-icon {
  font-size: 1.4rem;
}

.light-info {
  display: flex;
  flex-direction: column;
}

.light-info strong {
  font-size: 0.84rem;
  color: var(--text-main);
}

.light-info span {
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* Área del Lienzo Canvas con Cortinilla Split View */
.painter-canvas-area {
  position: relative;
  background: #000000;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  min-height: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-floating-tip {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 20;
  pointer-events: none;
  display: flex;
  justify-content: center;
}

.canvas-floating-tip span {
  background: rgba(11, 15, 23, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
}

.canvas-split-container {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.canvas-layer {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.split-after-clip {
  position: absolute;
  top: 0;
  left: 0;
  width: 50%; /* Controlado por el split slider */
  height: 100%;
  overflow: hidden;
  z-index: 5;
}

.split-after-clip .canvas-layer {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.split-divider {
  position: absolute;
  top: 0;
  left: 50%;
  width: 4px;
  height: 100%;
  background: #ffffff;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  cursor: ew-resize;
  z-index: 10;
  transform: translateX(-50%);
}

.split-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ffffff;
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.canvas-interactive {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 100%;
  max-height: 100%;
  z-index: 15;
  cursor: crosshair;
}

/* Títulos acotados */
.tool-layout h1,
.tool-layout h2,
.tool-layout h3,
.tool-layout h4 {
  font-family: var(--font-heading);
}

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-main);
}
