/* =========================================================
   dibujar-moleculas.css
   Layout tipo MolView: barra superior clara + panel 2D/3D 50/50
   ========================================================= */

/* Reset básico */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

/* Fondo general oscuro como MolView */
html {
  background: #20242b;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               Helvetica, Arial, sans-serif;
  color: #000;
  background: transparent;      /* dejamos ver el fondo del html */
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------
   BARRA SUPERIOR (MolView-like)
   --------------------------------------------------------- */

.mv-bar {
  /* altura parecida a la de MolView */
  height: 2.5em;
  min-height: 2.5em;

  display: flex;
  align-items: center;
  background: #f0f2f5;
  padding: 0 0.75em;
  gap: 0.75em;
  border-bottom: 1px solid hsl(210, 20%, 70%);
  user-select: none;
}

/* Tres zonas: izquierda, centro (buscador), derecha */
.mv-bar-left,
.mv-bar-right {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
}

.mv-bar-center {
  flex-shrink: 0;
  width: min(30em, max(15em, 30%)); /* como MolView */
}

/* ------------------ logo ------------------ */

.mv-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1.8em;
  padding-right: 0.75em;
  margin-right: 0.25em;
  border-right: 1px solid hsl(210, 20%, 80%);
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  color: #29333d;
}

/* ------------------ grupo de botones Save/View/Help ------------------ */

.mv-bar-buttons {
  display: flex;
  align-items: center;
  gap: 0.4em;
}

.mv-group {
  position: relative;
}

/* Botón tipo pastilla */
.mv-btn {
  border-radius: 999px;
  border: 1px solid #c2ccd6;
  background: #f9fafb;
  padding: 0.1em 0.9em;
  font-size: 0.9rem;
  line-height: 1.6;
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  cursor: pointer;
  white-space: nowrap;
}

.mv-btn:hover {
  background: #f0f2f5;
}

/* Variante más pequeña (Sign up / Sign in / EN) */
.mv-btn-small {
  font-size: 0.85rem;
  padding: 0.05em 0.8em;
}

/* Menús desplegables de Save / View / Help */
.mv-menu {
  position: absolute;
  top: 120%;
  right: 0;
  min-width: 180px;
  padding: 0.25em 0;
  border-radius: 0.3rem;
  border: 1px solid hsl(210, 20%, 60%);
  background: #eaedf1;
  box-shadow: 0 0 6px #0003;
  display: none; /* se mostrará con JS cambiando aria-hidden */
  z-index: 50;
}

.mv-menu[aria-hidden="false"] {
  display: block;
}

.mv-menu > button,
.mv-menu > a {
  display: block;
  width: 100%;
  padding: 0.45em 0.9em;
  font-size: 0.9rem;
  border: 0;
  background: transparent;
  text-align: left;
  text-decoration: none;
  color: #29333d;
  cursor: pointer;
  white-space: nowrap;
}

.mv-menu > button:hover,
.mv-menu > a:hover {
  background: #f9fafb;
}

/* ------------------ buscador centrado ------------------ */

.mv-search {
  width: 100%;
}

.mv-search input {
  width: 100%;
  border-radius: 2em;
  border: 1px solid hsl(210, 20%, 80%);
  background: #f9fafb;
  padding: 0.25em 0.9em;
  font-size: 0.9rem;
  line-height: 1.6;
}

.mv-search input:focus-visible {
  outline: 0.2em solid hsla(210, 100%, 50%, 0.25);
  border-color: #0080ff;
}

/* ------------------ derecha: Discord + auth ------------------ */

.mv-bar-right {
  justify-content: flex-end;
  gap: 0.75em;
}

.mv-discord {
  text-decoration: none;
  white-space: nowrap;
  color: #8599ad;
  font-weight: 600;
  font-size: 0.85rem;
}

.mv-discord:hover {
  text-decoration: underline;
  color: #0080ff;
}

.mv-auth {
  display: flex;
  align-items: center;
  gap: 0.35em;
}

/* ---------------------------------------------------------
   LAYOUT PRINCIPAL: sketcher izquierda, viewer derecha
   --------------------------------------------------------- */

.mv-main {
  flex: 1;                 /* ocupa todo el alto restante */
  display: flex;
  min-height: 0;           /* para que flex funcione bien con hijos */
}

/* Paneles 2D/3D */
.mv-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-top: 1px solid hsl(210, 20%, 70%);
  overflow: hidden;
  min-width: 0;
}

/* Cuerpo del panel (contiene iframe o div 3D) */
.mv-panel-body {
  flex: 1;
  position: relative;
  min-height: 0;
}

/* Editor 2D: fondo blanco como en MolView */
.mv-panel-editor {
  background: #ffffff;
}

/* Visor 3D: fondo negro */
.mv-panel-viewer {
  background: #000000;
}

/* Iframe de Ketcher: que rellene todo el panel */
.ketcher-host {
  border: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Contenedor del visor 3D (3Dmol) */
.viewer3d-host {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000000;
}

/* En muchos casos 3Dmol pinta un <canvas> dentro; lo forzamos a ocupar todo */
#viewer3d canvas {
  position: absolute !important;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

/* ---------------------------------------------------------
   RESPONSIVE: apilar en móviles
   --------------------------------------------------------- */

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .mv-main {
    flex-direction: column;
  }

  .mv-panel {
    height: 50vh;
  }
}
