/**
 * Estilos canónicos del Explorador interactivo 3D del ADN y código genético
 * Fijate Tools - explorador-adn-3d
 */

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

  /* Colores canónicos tema oscuro (predeterminado) */
  --bg-primary: #0a0f1d;
  --bg-secondary: #0f172a;
  --bg-card: rgba(15, 23, 42, 0.75);
  --border-card: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(56, 189, 248, 0.4);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  /* Acentos moleculares */
  --color-adenine: #10b981;
  --color-thymine: #f43f5e;
  --color-guanine: #f59e0b;
  --color-cytosine: #3b82f6;
  --color-uracil: #8b5cf6;
  --color-accent: #38bdf8;
  --color-strand1: #06b6d4;
  --color-strand2: #ec4899;

  /* Sombras y desenfoques */
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  --glass-blur: blur(12px);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.85);
  --border-card: rgba(0, 0, 0, 0.08);
  --border-highlight: rgba(14, 165, 233, 0.4);
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
}

/* Reset y estructura canónica */
*, *::before, *::after {
  box-sizing: border-box;
}

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

.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%;
}

/* Contenedor principal de la herramienta */
.dna-app-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
}

/* Tarjeta contenedora del visor 3D */
.dna-stage-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  backdrop-filter: var(--glass-blur);
  display: flex;
  flex-direction: column;
}

.dna-stage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-card);
  background: rgba(15, 23, 42, 0.4);
}

.dna-stage-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.dna-badge-pill {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--color-accent);
  border: 1px solid rgba(56, 189, 248, 0.3);
  font-weight: 600;
}

.dna-stage-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Visor 3D y canvas */
.dna-viewport-3d-wrap {
  position: relative;
  width: 100%;
  height: 480px;
  min-height: 380px;
  background: #0a0f1d;
  cursor: grab;
}

.dna-viewport-3d-wrap:active {
  cursor: grabbing;
}

#dna-viewport-3d {
  width: 100%;
  height: 100%;
  display: block;
}

/* Barra de herramientas flotante sobre el viewport 3D */
.viewport-floating-toolbar {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 10;
}

.btn-float-action {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--border-card);
  color: var(--text-main);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: var(--glass-blur);
  transition: all 0.2s ease;
  min-width: 40px;
  min-height: 40px;
}

.btn-float-action:hover, .btn-float-action.active {
  background: var(--color-accent);
  color: #0f172a;
  border-color: var(--color-accent);
}

/* Barra inferior de modos de representación en el 3D */
.viewport-mode-bar {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.4rem;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-card);
  padding: 0.35rem;
  border-radius: 999px;
  backdrop-filter: var(--glass-blur);
  z-index: 10;
}

.btn-render-mode {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-render-mode:hover {
  color: var(--text-main);
}

.btn-render-mode.active {
  background: var(--color-accent);
  color: #0a0f1d;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
}

/* Leyenda de bases flotante en el visor */
.viewport-bases-legend {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--border-card);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  backdrop-filter: var(--glass-blur);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  z-index: 10;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot-a { background: var(--color-adenine); }
.dot-t { background: var(--color-thymine); }
.dot-g { background: var(--color-guanine); }
.dot-c { background: var(--color-cytosine); }
.dot-u { background: var(--color-uracil); }

/* Ficha del inspector de base seleccionada */
.base-inspector-card {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-card);
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: all 0.3s ease;
}

.inspector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.inspector-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  color: var(--color-accent);
}

.inspector-formula {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-dim);
}

.inspector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  font-size: 0.85rem;
}

.inspector-field strong {
  color: var(--text-muted);
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.15rem;
}

/* Cuadrícula de telemetría biofísica (KPIs) */
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.85rem;
  width: 100%;
}

.telemetry-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-card);
  backdrop-filter: var(--glass-blur);
  display: flex;
  flex-direction: column;
}

.telemetry-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.telemetry-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.telemetry-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
}

/* Panel de control de secuencia y presets */
.control-panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  backdrop-filter: var(--glass-blur);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.control-panel-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.preset-selector-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

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

.custom-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 40px 0 0.85rem;
  font-family: var(--font-main);
  font-size: 0.9rem;
  color: var(--text-main);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  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%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.custom-select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

/* Secuenciador y hebra complementaria */
.sequence-editor-box {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sequence-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.strand-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-strand1);
  font-weight: 600;
}

.strand-tag-comp {
  color: var(--color-strand2);
}

.dna-sequence-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  background: var(--bg-secondary);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  box-sizing: border-box;
}

.dna-sequence-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.complementary-display-box {
  padding: 0.65rem 1rem;
  background: rgba(15, 23, 42, 0.5);
  border: 1px dashed var(--border-card);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: var(--color-strand2);
  word-break: break-all;
}

.sequence-action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-dna {
  height: 42px;
  padding: 0 1.15rem;
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.btn-dna-primary {
  background: var(--color-accent);
  color: #0a0f1d;
}

.btn-dna-primary:hover {
  background: #7dd3fc;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

.btn-dna-secondary {
  background: var(--bg-secondary);
  border-color: var(--border-card);
  color: var(--text-main);
}

.btn-dna-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--text-muted);
}

.btn-dna-danger {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.3);
  color: #fb7185;
}

.btn-dna-danger:hover {
  background: #f43f5e;
  color: #ffffff;
}

/* Alerta de mutación detectada */
.mutation-alert-box {
  display: none;
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-md);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fbbf24;
}

.mutation-alert-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.mutation-alert-desc {
  font-size: 0.85rem;
  color: var(--text-main);
}

/* Etapas del Dogma Central (Transcripción y Traducción) */
.dogma-stage-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  backdrop-filter: var(--glass-blur);
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.dogma-step-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.dogma-step-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.dogma-step-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

/* Badges y tiras de nucleótidos */
.mrna-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.75rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
}

.mrna-triplet {
  display: inline-flex;
  gap: 0.15rem;
  padding: 0.2rem 0.35rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.base-badge {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.base-A { background: rgba(16, 185, 129, 0.25); color: #34d399; }
.base-T { background: rgba(244, 63, 94, 0.25); color: #fb7185; }
.base-G { background: rgba(245, 158, 11, 0.25); color: #fbbf24; }
.base-C { background: rgba(59, 130, 246, 0.25); color: #60a5fa; }
.base-U { background: rgba(139, 92, 246, 0.25); color: #a78bfa; }

/* Cadena polipeptídica de aminoácidos */
.peptide-chain {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.85rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  align-items: center;
}

.aa-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: help;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid transparent;
}

.aa-pill:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.aa-standard {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}

.aa-start {
  background: rgba(16, 185, 129, 0.25);
  border-color: rgba(16, 185, 129, 0.5);
  color: #34d399;
}

.aa-stop {
  background: rgba(244, 63, 94, 0.25);
  border-color: rgba(244, 63, 94, 0.5);
  color: #fb7185;
}

.aa-pos {
  font-size: 0.65rem;
  opacity: 0.7;
}

.highlight-pulse {
  animation: pulse-glow 0.4s ease-out;
}

@keyframes pulse-glow {
  0% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.18); filter: brightness(1.6); }
  100% { transform: scale(1); filter: brightness(1); }
}

/* Acordeón didáctico y guía pedagógica */
.edu-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1rem;
}

.edu-item {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.edu-summary {
  padding: 1rem 1.25rem;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-main);
  user-select: none;
}

.edu-summary::-webkit-details-marker {
  display: none;
}

.edu-summary::after {
  content: '+';
  font-size: 1.4rem;
  color: var(--color-accent);
  transition: transform 0.2s ease;
}

details[open] .edu-summary::after {
  transform: rotate(45deg);
}

.edu-content {
  padding: 0 1.25rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.edu-content p {
  margin: 0.5rem 0;
}

.edu-content ul {
  padding-left: 1.25rem;
  margin: 0.5rem 0;
}

.edu-content li {
  margin-bottom: 0.35rem;
}

/* Modal accesible */
.accessible-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.accessible-modal.is-open {
  display: flex;
}

.modal-content-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border-card);
}

.modal-header h3 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.2rem;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
}

.modal-body {
  padding: 1.2rem 1.5rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Responsive móvil */
@media (max-width: 992px) {
  .tool-with-sidebar {
    flex-direction: column;
    gap: 1.5rem;
  }

  .dna-viewport-3d-wrap {
    height: 380px;
  }

  .sequence-action-buttons .btn-dna {
    flex: 1 1 calc(50% - 0.5rem);
    width: auto;
  }
}

@media (max-width: 640px) {
  .viewport-mode-bar {
    width: 90%;
    justify-content: center;
  }

  .btn-render-mode {
    padding: 0.3rem 0.55rem;
    font-size: 0.72rem;
  }

  .sequence-action-buttons .btn-dna {
    flex: 1 1 100%;
  }

  .dna-viewport-3d-wrap {
    height: 320px;
  }
}
