/* ============================================================
   Ecosystem de Bacterias — Interface Styles (v3)
   ============================================================
   Three-column layout using a single flex row that slides
   via transform: translateX(). All three panels move as one
   unit, guaranteeing they never overlap.

   Normal mode (translateX(0)):
     Viewport shows [Eco 85vw][Mgmt 15vw]

   Viz mode (translateX(-80vw)):
     Viewport shows [5vw eco strip][Mgmt 15vw][Viz 80vw]
   ============================================================ */

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a1a;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  color: #e0e0e0;
}

/* ---- Viewport container ---- */

#viewport {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* ---- P5 Canvas layer (fixed, behind panels) ---- */

#p5-canvas-layer {
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  pointer-events: auto;
}

#p5-canvas-layer canvas {
  display: block;
}

/* ---- Row — flex container for all three panels ---- */

#row {
  position: absolute;
  left: 0;
  top: 0;
  width: 180vw;
  height: 100vh;
  display: flex;
  flex-direction: row;
  z-index: 10;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

#row.viz-mode {
  transform: translateX(-80vw);
}

/* ---- Ecosystem area (first column, behind canvas so it's transparent) ---- */

#ecosystem-area {
  width: 85vw;
  height: 100%;
  flex-shrink: 0;
  position: relative;
  z-index: 0;
}

/* ---- Ecosystem title ---- */

#eco-title {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 5;
  pointer-events: none;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #39ff14;
  user-select: none;
}

/* ---- Biopus link ---- */

#biopus-link {
  position: absolute;
  bottom: 62px;
  left: 14px;
  z-index: 5;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #39ff14;
  text-decoration: none;
  opacity: 0.5;
  transition: opacity 0.2s ease, text-decoration 0.2s ease;
  cursor: pointer;
}

#biopus-link:hover {
  opacity: 1;
  text-decoration: underline;
}

/* ---- Bottom bar ---- */

#ecosystem-bottom-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(10, 10, 26, 0.92);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 5;
  transition: opacity 0.5s ease;
}

#row.viz-mode #ecosystem-bottom-bar {
  opacity: 0;
  pointer-events: none;
}

#bacteria-counter {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.3);
  letter-spacing: 0.5px;
  font-weight: 400;
}

.btn-generar {
  padding: 9px 24px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #2a6dd4, #1d4f9e);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 12px rgba(42, 109, 212, 0.3);
}

.btn-generar:hover {
  background: linear-gradient(135deg, #347de8, #2559b0);
  box-shadow: 0 4px 20px rgba(42, 109, 212, 0.45);
  transform: translateY(-1px);
}

.btn-generar:active {
  transform: translateY(0);
  box-shadow: 0 1px 6px rgba(42, 109, 212, 0.3);
}

/* ---- Management Column ---- */

#management-column {
  width: 15vw;
  height: 100%;
  flex-shrink: 0;
  background: rgba(12, 12, 30, 0.98);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 10;
}

#management-header {
  padding: 18px 12px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(255, 255, 255, 0.35);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  text-align: center;
  flex-shrink: 0;
}

/* ---- Management Sections ---- */

.management-section {
  flex: 1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 10px 6px;
  transition: background 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  min-height: 0;
  overflow-y: auto;
}

/* ---- Background images for management panels ---- */

#section-viz::before,
#section-comb::before,
#section-lib::before {
  content: '';
  position: absolute;
  inset: 0;
  background-size: 50%;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.30;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: -1;
  will-change: opacity;
}

#section-viz::before {
  background-image: url(microscopio.jpg);
}

#section-comb::before {
  background-image: url(reproduccion.jpg);
  background-size: 62%;
}

#section-lib::before {
  background-image: url(desaparece.jpg);
  background-size: 62%;
}

/* Reduce image opacity when dragging over a section (subdued anticipation) */
.management-section.drop-highlight::before {
  opacity: 0.18;
}

/* Reduce image opacity when content (bacterium) is inside the section */
#section-viz:has(.bacterium-entry)::before,
#section-comb:has(.bacterium-entry)::before {
  opacity: 0.12;
}

/* Dim section icon and label when a bacterium is inside */
#section-viz:has(.bacterium-entry) .section-icon,
#section-comb:has(.bacterium-entry) .section-icon {
  color: rgba(255, 255, 255, 0.2);
}

#section-viz:has(.bacterium-entry) .section-label,
#section-comb:has(.bacterium-entry) .section-label {
  color: rgba(255, 255, 255, 0.35);
}

.management-section:last-child {
  border-bottom: none;
}

.management-section.drop-highlight {
  background: rgba(42, 109, 212, 0.12);
  box-shadow: inset 0 0 20px rgba(42, 109, 212, 0.08);
}

.management-section.drop-highlight#section-lib {
  background: rgba(212, 42, 42, 0.12);
  box-shadow: inset 0 0 20px rgba(212, 42, 42, 0.08);
}

.management-section.drop-highlight#section-comb {
  background: rgba(42, 212, 109, 0.10);
  box-shadow: inset 0 0 20px rgba(42, 212, 109, 0.08);
}

.section-icon {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.50);
  margin-bottom: 2px;
  line-height: 1;
  transition: color 0.3s ease;
}

.section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.65);
  margin-bottom: 6px;
  text-align: center;
  transition: color 0.3s ease;
}

.section-content {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 0;
}

.section-placeholder {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
  text-align: center;
  line-height: 1.4;
  padding: 4px;
  margin-top: auto;
}

/* ---- Bacterium entry in a section ---- */

.bacterium-entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  width: 100%;
  transition: opacity 0.3s ease, background 0.3s ease;
}

.bacterium-entry .entry-thumb {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  flex-shrink: 0;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: block;
}

.bacterium-entry .entry-name {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.5);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
  text-align: center;
}

.bacterium-entry.dimmed {
  opacity: 0.75;
}

.bacterium-entry.dimmed .entry-thumb {
  filter: saturate(0.7) brightness(0.85);
  border-color: rgba(57, 255, 20, 0.25);
  box-shadow: 0 0 0 1.5px rgba(57, 255, 20, 0.2), 0 0 8px rgba(57, 255, 20, 0.1);
}

.bacterium-entry.dimmed .entry-name {
  color: rgba(57, 255, 20, 0.55);
}

.bacterium-entry.highlighted {
  opacity: 1;
}

.bacterium-entry.highlighted .entry-name {
  color: #39ff14;
  font-weight: 600;
}

.bacterium-entry.highlighted .entry-thumb {
  border-color: rgba(57, 255, 20, 0.6);
  box-shadow: 0 0 0 2px rgba(57, 255, 20, 0.5), 0 0 12px rgba(57, 255, 20, 0.3);
}

#section-viz .section-icon {
  color: rgba(150, 210, 255, 0.55);
}

#section-comb .section-icon {
  color: rgba(130, 255, 180, 0.55);
}

#section-lib .section-icon {
  color: rgba(255, 120, 120, 0.55);
}

/* Colored icons also dim when a bacterium is inside */
#section-viz:has(.bacterium-entry) .section-icon {
  color: rgba(100, 180, 255, 0.3);
}

#section-comb:has(.bacterium-entry) .section-icon {
  color: rgba(100, 255, 150, 0.3);
}

/* ---- Visualization Panel ---- */

#visualization-panel {
  width: 80vw;
  height: 100%;
  flex-shrink: 0;
  background: rgba(8, 8, 20, 0.98);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 11;
}

#viz-panel-header {
  padding: 14px 18px 10px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255, 255, 255, 0.4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

#viz-preview-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#viz-preview-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

#viz-preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.15);
  font-size: 13px;
}

#viz-preview-placeholder .placeholder-icon {
  font-size: 36px;
}

/* ---- Hydra Code Display ---- */

#viz-code-section {
  height: 30%;
  min-height: 100px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
}

#viz-code-header {
  padding: 6px 18px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

#viz-code-display {
  flex: 1;
  margin: 0;
  padding: 8px 18px;
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 11px;
  line-height: 1.7;
  color: #a0c0e0;
  background: rgba(0, 0, 0, 0.4);
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  tab-size: 2;
}

.code-placeholder {
  color: rgba(255, 255, 255, 0.12);
  font-style: italic;
}

/* ---- Copy Hydra Code Button ---- */

.btn-copy-hydra {
  flex-shrink: 0;
  display: block;
  width: calc(100% - 24px);
  margin: 6px auto 10px;
  padding: 7px 14px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.btn-copy-hydra:hover {
  color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-copy-hydra:active {
  transform: translateY(0);
}

/* ---- Drop zone cursor ---- */

body.dragging-active {
  cursor: grabbing;
}

/* ---- Responsive: narrower screens ---- */

@media (max-width: 900px) {
  #ecosystem-area {
    width: 78vw;
  }
  #management-column {
    width: 22vw;
  }
  #visualization-panel {
    width: 70vw;
  }
  #row {
    width: 170vw;
  }
  #row.viz-mode {
    transform: translateX(-70vw);
  }
}
