@import url("./colors.css");

/* ==== BASE Y RESETEO GENERAL ==== */
* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-family: "Georgia", serif;
  background-color: var(--bg-color);
  color: var(--text-color);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
/* ==========================================================================
   ENCABEZADO PRINCIPAL
   ========================================================================== */
header {
  background: linear-gradient(
    135deg,
    var(--accent-color),
    var(--primary-color)
  );
  color: var(--text-color);
  padding: 16px 12px;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.header-content h1 {
  font-size: 2em;
  margin: 0;
}

/* Navegación */
nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px 20px;
  margin: 15px 0 0 0;
  padding: 0;
}

nav a {
  color: var(--text-color);
  text-decoration: none;
  font-weight: bold;
  transition: var(--transition);
}

nav a:hover {
  color: var(--btn-color);
}

.lang-switch-link {
  background: var(--btn-color);
  color: #fff !important;
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: bold;
  border: 1px solid rgba(255, 255, 255, 0.4);
  transition: var(--transition);
}

.lang-switch-link:hover {
  background: var(--btn-hover);
  color: #fff !important;
}

/* ==========================================================================
   MODAL DE INSTRUCCIONES (responsive, scrollable en móvil)
   ========================================================================== */
.modal-instrucciones {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 16px;
}

.modal-contenido {
  background: var(--card-bg);
  padding: 28px;
  border: 2px solid var(--accent-color);
  border-radius: 14px;
  max-width: 500px;
  width: 100%;
  color: var(--text-color);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-contenido h1 {
  font-size: 1.5em;
  margin-top: 0;
}

.modal-contenido button {
  display: block;
  width: 100%;
  margin: 20px auto 0;
  padding: 12px 24px;
  background-color: var(--btn-color);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1em;
  font-weight: bold;
  transition: var(--transition);
}

.modal-contenido button:hover {
  background-color: var(--btn-hover);
}

.consejos-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
}

/* ==========================================================================
   CONTENIDO PRINCIPAL
   ========================================================================== */
#contenido-principal {
  display: flex;
  flex-direction: column;
  flex: 1;
}

main {
  flex: 1;
  overflow-y: auto;
  text-align: center;
  padding: 20px;
  padding-bottom: 110px;
}

.hero-section h1 {
  color: var(--text-color);
}

.hero-section p {
  color: var(--muted);
}

/* ==========================================================================
   GALERÍA (Mano - Modelo 3D - Pluma). El chat ya NO vive aquí dentro:
   ahora es una burbuja flotante independiente (ver más abajo).
   ========================================================================== */
.galeria {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
  margin-top: 20px;
}

#Mano {
  height: 300px;
}

#Pluma {
  height: 450px;
}

/* Contenedor del modelo 3D */
#modelo-container {
  width: 400px;
  height: 535px;
  position: fixed;
  bottom: 80px;
  left: -20px;
  z-index: 400;
  pointer-events: none;
}

/* ==========================================================================
   BURBUJA FLOTANTE DEL CHAT (FAB)
   --------------------------------------------------------------------------
   Botón circular siempre visible que abre/cierra el panel de chat sin
   tapar la lectura ni el resto de la página.
   ========================================================================== */
#chat-fab-btn {
  position: fixed;
  bottom: 96px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--btn-color), var(--secondary-color));
  color: #fff;
  border: 2px solid #fff;
  font-size: 1.6em;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  z-index: 6000;
  transition: var(--transition);
}

#chat-fab-btn:hover {
  background: linear-gradient(135deg, var(--btn-hover), var(--accent-color));
  transform: scale(1.06);
}

#chat-fab-btn.has-unread::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-success);
  border: 2px solid var(--card-bg);
}

/* ==========================================================================
   PANEL DE CHAT (oculto por defecto, se muestra al abrir la burbuja)
   ========================================================================== */
#chat-container {
  width: 340px;
  max-width: calc(100vw - 32px);
  height: 420px;
  max-height: 65vh;
  background: var(--card-bg);
  border: 1px solid var(--accent-color);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  padding: 0;
  border-radius: 16px;
  position: fixed;
  bottom: 166px;
  right: 20px;
  z-index: 5000;
  font-family: "Georgia", serif;
  overflow: hidden;

  /* Estado colapsado por defecto */
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  visibility: hidden;
  transition: var(--transition);
}

#chat-container.chat-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
}

.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  background: linear-gradient(
    135deg,
    var(--accent-color),
    var(--primary-color)
  );
  color: var(--text-color);
  flex: 0 0 auto;
}

.chat-panel-title {
  font-weight: bold;
  font-size: 0.95em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#chat-close-btn {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-color);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9em;
  line-height: 1;
  flex: 0 0 auto;
  transition: var(--transition);
}

#chat-close-btn:hover {
  background: var(--red);
}

#chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 0;
  display: flex;
  flex-direction: column;
}

/* Mensajes del chat */
.msg {
  margin: 6px 0;
  font-size: 0.9em;
  line-height: 1.4;
  padding: 8px 12px;
  border-radius: 10px;
  max-width: 88%;
  word-wrap: break-word;
}

.msg.user {
  background-color: var(--btn-color);
  color: #fff;
  text-align: right;
  align-self: flex-end;
  border: 1px solid var(--btn-hover);
}

.msg.bot {
  background-color: var(--surface2);
  color: var(--text-color);
  text-align: left;
  align-self: flex-start;
  border: 1px solid var(--border);
}

#chat-container .input-group {
  padding: 10px 12px;
  margin-top: 0 !important;
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
}

#chat-container input,
#chat-container button {
  font-family: "Georgia", serif;
  font-size: 0.9em;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--accent-color);
  background: var(--surface);
  color: var(--text-color);
}

#chat-container input::placeholder {
  color: var(--muted);
}

#chat-container button {
  background-color: var(--btn-color);
  color: white;
  cursor: pointer;
  border: none;
  transition: var(--transition);
}

#chat-container button:hover {
  background-color: var(--btn-hover);
}

#mic-btn.active {
  background-color: var(--color-error) !important;
}

#technical-metrics {
  padding: 0 12px 10px;
  color: var(--muted) !important;
}

/* ==== TEXTO SINCRONIZADO CON AUDIO ==== */
#texto-sincronizado {
  margin: 50px auto 160px;
  max-width: 700px;
  padding: 20px;
  font-size: 1.1em;
  line-height: 1.6;
  text-align: justify;
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.highlight {
  background-color: var(--accent-color);
  color: #fff;
  border-radius: 3px;
  transition: background-color 0.3s ease;
}

/* ==========================================================================
   REPRODUCTOR DE AUDIO FIJO ("mini player" unificado con la interfaz)
   ========================================================================== */
#reproductor-fijo {
/* MINI PLAYER PERSONALIZADO */
}
.mini-player {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  border-radius: 16px;
  padding: 8px 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}
.mini-player button {
  background: var(--btn-color);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.2em;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}
.mini-player button:hover {
  background: var(--btn-hover);
}
.mini-player #seek-bar {
  flex: 1;
  accent-color: var(--accent-color);
  height: 4px;
  border-radius: 2px;
}
.mini-player span {
  min-width: 38px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Botón flotante capítulos */
.btn-capitulos-flotante {
  position: fixed;
  bottom: 120px;
  right: 18px;
  z-index: 6001;
  background: var(--btn-color);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 12px 18px;
  font-size: 1em;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  cursor: grab;
  user-select: none;
  transition: background 0.2s, box-shadow 0.2s;
}
.btn-capitulos-flotante:active {
  cursor: grabbing;
  background: var(--btn-hover);
}

@media (max-width: 900px) {
  .btn-capitulos-flotante {
    display: block !important;
  }
  #chapter-container {
    display: none !important;
  }
  #chapter-container.visible {
    display: flex !important;
    position: fixed;
    bottom: 180px;
    right: 10px;
    left: 10px;
    z-index: 6000;
    background: var(--surface2);
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    padding: 10px 0;
    flex-wrap: wrap;
    max-height: 220px;
    overflow-y: auto;
  }
}
@media (min-width: 901px) {
  .btn-capitulos-flotante {
    display: none !important;
  }
  #chapter-container {
    display: flex !important;
    position: static !important;
    background: inherit !important;
    box-shadow: none !important;
    border-radius: 12px !important;
    padding: 8px 6px !important;
    max-height: none !important;
    overflow-y: visible !important;
  }
}

  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(180deg, var(--card-bg), var(--surface));
  border-top: 1px solid var(--accent-color);
  border-radius: 18px 18px 0 0;
  color: var(--text-color);
  padding: 10px 14px 8px;
  z-index: 4999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.45);
}

.player-top-row {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 14px;
  flex-wrap: wrap;
}

#reproductor-fijo audio {
  flex: 1;
  min-width: 200px;
  max-width: 520px;
  height: 34px;
  border-radius: 20px;
  accent-color: var(--btn-color);
}

.player-jump {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 6px 4px 12px;
}

.player-jump input {
  width: 66px;
  padding: 4px 2px;
  border: none;
  background: transparent;
  color: var(--text-color);
  font-size: 0.8em;
  outline: none;
}

.player-jump input::placeholder {
  color: var(--muted);
}

.player-jump button {
  padding: 5px 14px;
  font-size: 0.8em;
  background: var(--btn-color);
  color: #fff;
  border: none;
  border-radius: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: var(--transition);
}

.player-jump button:hover {
  background: var(--btn-hover);
}

#botones-audio button {
  margin: 0 4px;
  padding: 5px 10px;
  background: var(--btn-color);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#botones-audio button:hover {
  background: var(--btn-hover);
}

/* ==========================================================================
   NAVEGACIÓN DE CAPÍTULOS (integrada al mini player)
   ========================================================================== */
#chapter-container {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
  gap: 8px;
  padding: 8px 6px;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  scrollbar-width: thin;
  scrollbar-color: var(--accent-color) var(--surface2);
  scroll-snap-type: x proximity;
}

#chapter-container::-webkit-scrollbar {
  height: 6px;
}

#chapter-container::-webkit-scrollbar-thumb {
  background: var(--accent-color);
  border-radius: 10px;
}

#chapter-container::-webkit-scrollbar-track {
  background: var(--surface2);
}

#chapter-container button {
  flex: 0 0 auto;
  padding: 8px 16px;
  font-size: 0.85em;
  background: var(--surface2);
  color: var(--text-color);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.1s,
    box-shadow 0.2s,
    border-color 0.2s;
  scroll-snap-align: start;
}

#chapter-container button:hover {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

#chapter-container button:active {
  transform: scale(0.95);
}

#chapter-container button.active {
  background: var(--btn-color);
  border-color: var(--btn-color);
  color: #fff;
  font-weight: bold;
  box-shadow: 0 0 0 2px rgba(8, 102, 255, 0.35);
}

/* ==========================================================================
   PIE DE PÁGINA
   ========================================================================== */
footer {
  background-color: var(--surface2);
  color: var(--muted);
  padding: 10px 0;
  text-align: center;
  border-top: 1px solid var(--border);
}

footer a {
  text-decoration: none;
  color: var(--text-color);
}

footer a:hover {
  color: var(--btn-color);
}

/* ==========================================================================
   Estilo del Spinner (Escribiendo...)
   ========================================================================== */
#spinner {
  padding: 6px 12px 0;
  margin-bottom: 0;
  font-size: 0.85em;
  color: var(--muted);
  font-family: "Georgia", serif;
  font-style: italic;
  animation: escribir-latido 1.5s infinite ease-in-out;
}

@keyframes escribir-latido {
  0% {
    opacity: 0.4;
  }

  50% {
    opacity: 1;
  }

  100% {
    opacity: 0.4;
  }
}
