/* ==========================================================================
   Estilos principales: Eliminador de fondos de imágenes (Fijate Tools)
   ========================================================================== */

:root {
  --primary: #ff8507;
  --primary-hover: #e07400;
  --primary-light: rgba(255, 133, 7, 0.12);
  --primary-glow: rgba(255, 133, 7, 0.35);

  --bg-main: #0b0f17;
  --bg-card: #131b26;
  --bg-card-hover: #1a2434;
  --bg-input: #0e1520;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(255, 133, 7, 0.5);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #f8fafc;
  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(255, 133, 7, 0.6);

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

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Cabecera estándar de la aplicación */
.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.btn-back-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-back-tools:hover {
  color: var(--text-main);
  border-color: var(--primary);
  transform: translateX(-2px);
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo-box {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #fbbf24);
  color: #0b0f17;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
  margin: 0;
}

.brand-subtitle {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

/* Contenedor principal */
.main-wrapper {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

/* Hero */
.tool-hero {
  text-align: center;
  margin-bottom: 2rem;
}

.tool-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.8rem;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  border: 1px solid rgba(255, 133, 7, 0.25);
}

.tool-hero h2 {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-bottom: 0.5rem;
}

.tool-hero p {
  color: var(--text-muted);
  max-width: 680px;
  margin: 0 auto;
  font-size: 0.98rem;
}

/* Zona de arrastre de fotos */
.drop-zone-card {
  background: var(--bg-card);
  border: 2px dashed var(--border-color);
  border-radius: 20px;
  padding: 4rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  max-width: 720px;
  margin: 0 auto 2rem;
}

.drop-zone-card:hover,
.drop-zone-card.drag-over {
  border-color: var(--primary);
  background: var(--bg-card-hover);
  box-shadow: 0 0 25px var(--primary-glow);
}

.upload-icon-box {
  width: 70px;
  height: 70px;
  border-radius: 16px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}

.drop-zone-card h3 {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.drop-zone-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* Overlay de carga de IA */
.ai-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(11, 15, 23, 0.85);
  backdrop-filter: blur(8px);
  z-index: 50;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

[data-theme="light"] .ai-loading-overlay {
  background: rgba(248, 250, 252, 0.88);
}

.ai-loading-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 2rem;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.spinner-ai {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255, 133, 7, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1.25rem;
}

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

.progress-bar-container {
  height: 8px;
  background: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #fbbf24, var(--primary));
  background-size: 200% 100%;
  animation: progressShimmer 1.2s infinite linear;
  transition: width 0.25s ease;
}

@keyframes progressShimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Espacio de trabajo */
.editor-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  align-items: start;
}

.canvas-viewport-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 480px;
}

.canvas-container {
  max-width: 100%;
  max-height: 520px;
  overflow: auto;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  /* Patrón de ajedrez para transparencia */
  background-color: #ffffff;
  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;
}

[data-theme="dark"] .canvas-container {
  background-color: #1e293b;
  background-image: linear-gradient(45deg, #0f172a 25%, transparent 25%),
                    linear-gradient(-45deg, #0f172a 25%, transparent 25%),
                    linear-gradient(45deg, transparent 75%, #0f172a 75%),
                    linear-gradient(-45deg, transparent 75%, #0f172a 75%);
}

#main-canvas {
  display: block;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

/* Panel de control */
.controls-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.control-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
}

.slider-header span {
  color: var(--text-muted);
}

.slider-header strong {
  font-family: var(--font-mono);
  color: var(--primary);
}

.slider-input {
  width: 100%;
  accent-color: var(--primary);
}

/* Pincel y herramientas */
.tools-button-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

.btn-tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.6rem 0.3rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

/* Fondos */
.bg-choices-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
}

.btn-bg-choice {
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.btn-bg-choice:hover, .btn-bg-choice.active {
  border-color: var(--primary);
  transform: scale(1.05);
  box-shadow: 0 0 10px var(--primary-glow);
}

.bg-choice-transp {
  background: repeating-conic-gradient(#808080 0% 25%, #ffffff 0% 50%) 50% / 10px 10px;
}
.bg-choice-white { background: #ffffff; }
.bg-choice-passport { background: #4a90e2; }
.bg-choice-gradient { background: linear-gradient(135deg, #2c3e50, #000000); }

/* Acciones principales */
.btn-primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.4rem;
  background: var(--primary);
  color: #0b0f17 !important;
  font-weight: 700;
  border-radius: 10px;
  border: none;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.2rem;
  background: transparent;
  color: var(--text-main);
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

/* Sección educativa */
.edu-section {
  margin-top: 3rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.edu-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
}

.edu-card h4 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.edu-card p {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

/* Responsive */
@media (max-width: 860px) {
  .editor-grid, .edu-section {
    grid-template-columns: 1fr;
  }
}
