/**
 * Fijate Tools - Laboratorio químico interactivo
 * style.css - Estilos corporativos, diseño de mesa de laboratorio, instrumental y telemetría
 */

:root {
  --bg-app: #090d16;
  --bg-card: #0f172a;
  --bg-card-hover: #1e293b;
  --bg-surface: #131d33;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-strong: rgba(255, 255, 255, 0.16);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-cyan: #00e5ff;
  --accent-blue: #38bdf8;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-emerald: #10b981;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-surface: #e2e8f0;
  --border-color: rgba(0, 0, 0, 0.08);
  --border-color-strong: rgba(0, 0, 0, 0.16);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --accent-cyan: #0284c7;
  --accent-blue: #0284c7;
}

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

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  margin-top: 0;
}

.mono-text {
  font-family: var(--font-mono);
}

/* Layout institucional Fijate Tools */
.tool-layout {
  max-width: 1380px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
  box-sizing: border-box;
}

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

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ==========================================================================
   ESTRUCTURA PRINCIPAL DEL LABORATORIO QUÍMICO
   ========================================================================== */
.lab-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1.15fr);
  gap: 1.5rem;
  width: 100%;
}

@media (max-width: 1024px) {
  .lab-grid {
    grid-template-columns: 1fr;
  }
}

/* Tarjeta contenedora de la mesa de trabajo */
.lab-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ==========================================================================
   CANVAS DE LA MESA Y EL MATRAZ
   ========================================================================== */
.canvas-wrapper {
  position: relative;
  width: 100%;
  height: 520px;
  background: #090d16;
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 2px 8px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .canvas-wrapper {
  background: radial-gradient(circle at 50% 35%, #e2e8f0 0%, #cbd5e1 100%);
}

#chem-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Barra superior de herramientas y controles rápidos */
.canvas-toolbar {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  right: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  pointer-events: none;
}

.canvas-toolbar-group {
  display: flex;
  gap: 0.5rem;
  pointer-events: auto;
}

.btn-tool-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 38px;
  padding: 0 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-sans);
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(8px);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-tool-icon:hover {
  background: rgba(30, 41, 59, 0.95);
  border-color: var(--accent-cyan);
}

.btn-tool-icon.is-active {
  background: rgba(0, 229, 255, 0.2);
  border-color: var(--accent-cyan);
  color: #38bdf8;
}

.btn-tool-icon.btn-danger-tool:hover {
  border-color: var(--accent-rose);
  color: #fda4af;
}

/* Control del mechero Bunsen en la barra */
.burner-control-group {
  display: flex;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  overflow: hidden;
  pointer-events: auto;
}

.btn-burner-step {
  height: 38px;
  padding: 0 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  background: transparent;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-burner-step:hover {
  color: var(--text-main);
}

.btn-burner-step.is-active {
  background: rgba(245, 158, 11, 0.25);
  color: #fbbf24;
}

.btn-burner-step.is-active[data-level="2"] {
  background: rgba(56, 189, 248, 0.25);
  color: #38bdf8;
}

/* ==========================================================================
   TELEMETRÍA DE INSTRUMENTOS EN DIRECTO
   ========================================================================== */
.telemetry-dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  width: 100%;
}

@media (max-width: 640px) {
  .telemetry-dashboard {
    grid-template-columns: repeat(2, 1fr);
  }
}

.telemetry-gauge {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.gauge-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: none;
}

.gauge-value {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.gauge-bar-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0.2rem;
  position: relative;
}

.gauge-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-cyan);
  border-radius: 3px;
  transition: width 0.15s ease, background-color 0.2s ease;
}

/* Barra cromática continua de pH */
.ph-rainbow-track {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right,
    #ef4444 0%,
    #f97316 20%,
    #eab308 40%,
    #22c55e 50%,
    #06b6d4 70%,
    #3b82f6 85%,
    #8b5cf6 100%
  );
  position: relative;
  margin-top: 0.25rem;
}

.ph-indicator-pin {
  position: absolute;
  top: -3px;
  left: 50%;
  width: 5px;
  height: 14px;
  background: #ffffff;
  border: 1.5px solid #000000;
  border-radius: 2px;
  transform: translateX(-50%);
  transition: left 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Cartela de reacción activa */
.reaction-banner {
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.12), rgba(56, 189, 248, 0.05));
  border: 1px solid rgba(0, 229, 255, 0.35);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: none;
  animation: fadeIn 0.3s ease;
}

.reaction-banner-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-cyan);
  margin-bottom: 0.25rem;
}

.reaction-banner-formula {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 0.02em;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   ESTANTE DE REACTIVOS (SHELF) Y DOSIFICADOR
   ========================================================================== */
.shelf-header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

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

.shelf-title {
  font-size: 1.15rem;
  margin: 0;
}

/* Filtros en chips (sin scrollbars, envueltos con flex-wrap) */
.filter-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  width: 100%;
}

.chip-filter {
  height: 36px;
  padding: 0 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-sans);
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip-filter:hover {
  color: var(--text-main);
  border-color: var(--border-color-strong);
}

.chip-filter.is-active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #ffffff;
}

/* Grid de reactivos */
.reagents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.65rem;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.reagent-card {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.7rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}

.reagent-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-color-strong);
}

.reagent-card.is-selected {
  border-color: var(--accent-cyan);
  background: rgba(0, 229, 255, 0.08);
  box-shadow: 0 0 0 1px var(--accent-cyan);
}

.reagent-swatch-box {
  width: 28px;
  height: 38px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.reagent-state-badge {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.6);
  color: #ffffff;
  width: 100%;
  text-align: center;
  padding: 1px 0;
}

.reagent-card-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.reagent-card-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reagent-card-formula {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Panel de dosificación interactivo */
.dosing-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.dosing-selected-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.dosing-item-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.dosing-item-formula {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-cyan);
}

.dosing-item-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.dosing-hazard-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  align-self: flex-start;
}

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

.dose-slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.dose-slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
  outline: none;
  cursor: pointer;
  accent-color: var(--accent-cyan);
}

.dose-quick-row {
  display: flex;
  gap: 0.4rem;
}

.btn-quick-dose {
  flex: 1;
  height: 32px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-mono);
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-quick-dose:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-color-strong);
}

/* Botón principal de acción: 100% ancho, >= 40px altura táctil */
.btn-action-primary {
  width: 100%;
  min-height: 44px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: var(--font-sans);
  color: #ffffff;
  background: linear-gradient(135deg, #0284c7 0%, #00e5ff 100%);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 14px rgba(0, 229, 255, 0.3);
  transition: all 0.2s ease;
}

.btn-action-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 20px rgba(0, 229, 255, 0.45);
}

.btn-action-primary:active {
  transform: translateY(1px);
}

/* ==========================================================================
   RECETAS DE EXPERIMENTOS GUIADOS
   ========================================================================== */
.recipes-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.recipes-select-wrapper {
  display: flex;
  gap: 0.65rem;
  width: 100%;
}

@media (max-width: 640px) {
  .recipes-select-wrapper {
    flex-direction: column;
  }
}

.lab-select {
  flex: 1 1 0%;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  height: 42px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 0 0.85rem;
  font-size: 0.88rem;
  font-family: var(--font-sans);
  outline: none;
}

.btn-load-recipe {
  height: 42px;
  min-width: 150px;
  font-weight: 700;
  font-size: 0.85rem;
  color: #ffffff;
  background: #1e293b;
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn-load-recipe:hover {
  background: #334155;
  border-color: var(--accent-cyan);
}

.recipe-notes-box {
  background: var(--bg-surface);
  border-left: 3px solid var(--accent-cyan);
  padding: 0.65rem 0.85rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* ==========================================================================
   CUADERNO DE NOTAS Y OBSERVACIONES (LOGBOOK)
   ========================================================================== */
.logbook-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

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

.log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.78rem;
}

.log-item {
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  background: var(--bg-surface);
  display: flex;
  gap: 0.5rem;
  line-height: 1.4;
}

.log-time {
  font-family: var(--font-mono);
  color: var(--text-muted);
  flex-shrink: 0;
}

.log-text {
  color: var(--text-main);
}

.log-danger {
  border-left: 3px solid var(--accent-rose);
  background: rgba(244, 63, 94, 0.12);
}

.log-warning {
  border-left: 3px solid var(--accent-amber);
  background: rgba(245, 158, 11, 0.12);
}

.log-reaction {
  border-left: 3px solid var(--accent-cyan);
  background: rgba(0, 229, 255, 0.1);
}

/* ==========================================================================
   MODAL DIDÁCTICO Y DE SEGURIDAD
   ========================================================================== */
.safety-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

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

.safety-modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.safety-modal-title {
  font-size: 1.25rem;
  margin: 0;
  color: var(--accent-rose);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.safety-modal-body {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.safety-modal-body strong {
  color: var(--text-main);
}

.safety-modal-footer {
  display: flex;
  justify-content: flex-end;
}

.btn-modal-close {
  min-height: 40px;
  padding: 0 1.25rem;
  font-weight: 700;
  font-size: 0.85rem;
  color: #ffffff;
  background: var(--accent-blue);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* ==========================================================================
   SECCIÓN EDUCATIVA Y DIDÁCTICA DE CIENCIA
   ========================================================================== */
.educational-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.educational-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

@media (max-width: 850px) {
  .educational-grid {
    grid-template-columns: 1fr;
  }
}

.educational-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.educational-box h3 {
  font-size: 0.95rem;
  margin: 0;
  color: var(--accent-cyan);
}

.educational-box p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0;
}
