/**
 * Estilos específicos para Rompecabezas jigsaw 3D interactivo
 * Paleta Midnight Slate, tipografías corporativas y diseño 100 % responsivo
 */

:root {
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Outfit', var(--font-main);
  --font-mono: 'JetBrains Mono', monospace;

  /* Colores temáticos */
  --bg-app: #0b0f17;
  --bg-card: #0f172a;
  --bg-card-subtle: #1e293b;
  --border-card: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  --accent-gold: #fbbf24;
  --accent-blue: #38bdf8;
  --accent-green: #10b981;
  --accent-danger: #f43f5e;
}

[data-theme="light"] {
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --border-card: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;
}

/* Layout de contención */
body {
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
}

.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  flex: 1 0 auto;
}

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

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

/* Tarjeta principal del rompecabezas */
.puzzle-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
  padding: 1.25rem;
  box-sizing: border-box;
  margin-bottom: 2rem;
  position: relative;
}

/* Pestañas de modo de juego */
.mode-tabs-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.mode-tab {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-card);
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.75rem 0.5rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  min-height: 44px;
}

.mode-tab svg {
  flex-shrink: 0;
}

.mode-tab:hover {
  background: #334155;
  color: var(--text-main);
}

.mode-tab.active {
  background: #0284c7;
  border-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
}

/* Barra de configuración (desplegable y dificultad) */
.puzzle-controls-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  background: var(--bg-card-subtle);
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border-card);
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.control-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.styled-select {
  font-family: var(--font-main);
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-card);
  padding: 0.45rem 2rem 0.45rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  min-height: 40px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' 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 0.75rem center;
  background-size: 14px;
}

.diff-pill-group {
  display: flex;
  background: var(--bg-card);
  border-radius: 8px;
  padding: 3px;
  border: 1px solid var(--border-card);
}

.btn-diff {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  min-height: 36px;
  transition: all 0.15s ease;
}

.btn-diff.active {
  background: #3b82f6;
  color: #ffffff;
  font-weight: 600;
}

/* Área de subida de fotos personalizadas */
.custom-upload-box {
  background: rgba(56, 189, 248, 0.08);
  border: 1px dashed var(--accent-blue);
  border-radius: 8px;
  padding: 0.65rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.custom-upload-box p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.custom-file-btn {
  background: #0284c7;
  color: #ffffff;
  border: none;
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Contenedor del escenario 3D */
.canvas-wrapper {
  position: relative;
  width: 100%;
  height: 580px;
  background: #0b0f17;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #1e293b;
  touch-action: none;
}

#puzzle-3d-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* HUD flotante sobre el canvas */
.hud-top-bar {
  position: absolute;
  top: 1rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}

.hud-pill {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(51, 65, 85, 0.7);
  color: var(--text-main);
  padding: 0.45rem 0.85rem;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  pointer-events: auto;
}

.hud-progress-bar {
  width: 80px;
  height: 6px;
  background: #334155;
  border-radius: 3px;
  overflow: hidden;
  display: inline-block;
  margin-left: 0.35rem;
}

.hud-progress-fill {
  height: 100%;
  background: var(--accent-green);
  width: 0%;
  transition: width 0.3s ease;
}

.hud-toolbar {
  display: flex;
  gap: 0.45rem;
  pointer-events: auto;
}

.hud-btn {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(51, 65, 85, 0.7);
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hud-btn:hover {
  background: #1e293b;
  border-color: #38bdf8;
  color: #38bdf8;
}

.hud-btn.active {
  background: #0284c7;
  border-color: #38bdf8;
  color: #ffffff;
}

/* Barra inferior del canvas (pista de controles móviles) */
.hud-bottom-bar {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 10;
}

.mobile-rotation-panel {
  display: flex;
  gap: 0.5rem;
  pointer-events: auto;
  opacity: 0.9;
}

.btn-rot {
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid #334155;
  color: #ffffff;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
  min-height: 40px;
  font-weight: 600;
}

.btn-rot:hover {
  background: #0284c7;
  border-color: #38bdf8;
}

.piece-info-badge {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid #334155;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  pointer-events: auto;
}

/* Modales */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 1rem;
  box-sizing: border-box;
}

.modal-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  max-width: 540px;
  width: 100%;
  padding: 1.75rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  margin-top: 0;
  margin-bottom: 0.75rem;
  color: var(--text-main);
}

.modal-body p {
  color: var(--text-muted);
  line-height: 1.6;
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.modal-body ul {
  padding-left: 1.25rem;
  color: var(--text-muted);
  line-height: 1.6;
  font-size: 0.9rem;
}

.modal-body li {
  margin-bottom: 0.5rem;
}

.modal-footer {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.btn-primary {
  background: #0284c7;
  color: #ffffff;
  border: none;
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  font-weight: 600;
  font-family: var(--font-heading);
  cursor: pointer;
  min-height: 40px;
}

.btn-primary:hover {
  background: #0369a1;
}

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-card);
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
}

/* Adaptación responsive para pantallas móviles y tablets */
@media (max-width: 860px) {
  .mode-tabs-container {
    grid-template-columns: repeat(2, 1fr);
  }

  .puzzle-controls-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .control-group {
    justify-content: space-between;
    width: 100%;
  }

  .styled-select {
    flex: 1;
  }

  .canvas-wrapper {
    height: 480px;
  }
}

@media (max-width: 480px) {
  .canvas-wrapper {
    height: 420px;
  }

  .hud-top-bar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .hud-toolbar {
    width: 100%;
    justify-content: space-between;
  }

  .mode-tab span {
    font-size: 0.85rem;
  }
}
