@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700;800;900&display=swap');

/* ═══════════════════════════════════════════════════════════
   NEST GLB Viewer
   Navy #0E2841 · Teal #207888 · Teal claro #4EC9C0
═══════════════════════════════════════════════════════════ */
:root {
  --navy:   #0E2841;
  --navy-d: #081828;
  --navy-2: #16293c;
  --teal:   #207888;
  --teal-l: #4EC9C0;
  --line:   rgba(255,255,255,0.10);
  --txt:    rgba(233,241,246,0.72);
  --txt-2:  rgba(233,241,246,0.42);
  --ease:   cubic-bezier(0.25,0.8,0.25,1);
}

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

html, body {
  height: 100%;
  overflow: hidden;                 /* el lienzo ocupa la ventana */
  background: var(--navy-d);
  font-family: 'Montserrat', system-ui, sans-serif;
  color: #fff;
  overscroll-behavior: none;
}

.app { display: flex; flex-direction: column; height: 100dvh; }

/* ═══ Barra superior ═══════════════════════════════════════ */
.vbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 1rem;
  height: 60px; padding: 0 1rem 0 1.3rem;
  background: linear-gradient(180deg, rgba(16,45,71,0.96) 0%, rgba(11,32,52,0.96) 100%);
  border-bottom: 1px solid rgba(78,201,192,0.20);
  box-shadow: 0 6px 22px rgba(8,24,40,0.35);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  position: relative; z-index: 20;
}
.vbar-logo {
  display: flex; align-items: center; text-decoration: none; flex-shrink: 0;
  opacity: 0.95; transition: opacity 0.2s var(--ease);
}
.vbar-logo:hover { opacity: 1; }
.vbar-logo img { height: 24px; width: auto; display: block; }
.vbar-sep { width: 1px; height: 24px; background: rgba(255,255,255,0.16); flex-shrink: 0; }
.vbar-title {
  font-size: 0.82rem; font-weight: 800; letter-spacing: 0.12em;
  text-transform: uppercase; color: rgba(255,255,255,0.92); white-space: nowrap;
}
.vbar-title b { color: var(--teal-l); font-weight: 800; }
.vbar-spacer { flex: 1 1 auto; }

.vbtn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  height: 36px; padding: 0 0.95rem;
  font-family: inherit; font-size: 0.78rem; font-weight: 700;
  color: var(--txt); background: rgba(255,255,255,0.05);
  border: 1px solid var(--line); border-radius: 8px;
  cursor: pointer; white-space: nowrap;
  transition: all 0.2s var(--ease);
}
.vbtn:hover:not(:disabled) { background: rgba(32,120,136,0.22); border-color: rgba(78,201,192,0.4); color: #fff; }

.vbtn:disabled { opacity: 0.35; cursor: not-allowed; }
.vbtn i { font-size: 0.85rem; color: var(--teal-l); }
.vbtn.is-on { background: rgba(32,120,136,0.3); border-color: var(--teal-l); color: #fff; }
.vbtn-primary {
  background: var(--teal); border-color: var(--teal); color: #fff;
  box-shadow: 0 4px 16px rgba(32,120,136,0.4);
}
.vbtn-primary:hover:not(:disabled) { background: #258a9c; border-color: #258a9c; }
.vbtn-primary i { color: #fff; }
.vbtn-ico { padding: 0; width: 36px; justify-content: center; }
.vbtn-ico i { font-size: 0.9rem; }

/* ═══ Escenario ════════════════════════════════════════════ */
.stage {
  flex: 1 1 auto; position: relative; min-height: 0;
  background:
    radial-gradient(ellipse 70% 60% at 50% 42%, rgba(32,120,136,0.16) 0%, transparent 70%),
    linear-gradient(160deg, var(--navy) 0%, var(--navy-d) 100%);
}
.stage::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background-image:
    linear-gradient(rgba(255,255,255,0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.022) 1px, transparent 1px);
  background-size: 58px 58px;
}
.stage.is-light {
  background: radial-gradient(ellipse 70% 60% at 50% 42%, #ffffff 0%, #d7dee6 100%);
}
.stage.is-light::before {
  background-image:
    linear-gradient(rgba(14,40,65,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(14,40,65,0.05) 1px, transparent 1px);
}
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 2; }

/* Marca de agua discreta */
.stage-mark {
  position: absolute; right: 18px; top: 14px; z-index: 3;
  font-size: 0.6rem; font-weight: 800; letter-spacing: 0.2em;
  text-transform: uppercase; color: rgba(255,255,255,0.16);
  pointer-events: none;
}
.stage.is-light .stage-mark { color: rgba(14,40,65,0.2); }

/* ═══ Estado vacío / zona de carga ═════════════════════════ */
.drop {
  position: absolute; inset: 0; z-index: 6;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1.1rem; text-align: center; padding: 2rem;
}
.drop[hidden] { display: none; }
.drop-box {
  width: min(560px, 100%);
  padding: 3rem 2.4rem;
  border: 2px dashed rgba(78,201,192,0.32);
  border-radius: 20px;
  background: rgba(14,40,65,0.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: all 0.25s var(--ease);
}
.app.is-dragging .drop-box {
  border-color: var(--teal-l);
  background: rgba(32,120,136,0.25);
  transform: scale(1.015);
}
.drop-ico {
  width: 66px; height: 66px; margin: 0 auto 1.3rem;
  border-radius: 16px; display: flex; align-items: center; justify-content: center;
  font-size: 1.7rem; color: var(--teal-l);
  background: rgba(32,120,136,0.18); border: 1px solid rgba(78,201,192,0.3);
}
.drop-box h1 { font-size: 1.45rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 0.6rem; }
.drop-box h1 span { color: var(--teal-l); }
.drop-box p { font-size: 0.88rem; color: var(--txt); line-height: 1.7; margin-bottom: 1.6rem; }
.drop-actions { display: flex; gap: 0.7rem; justify-content: center; flex-wrap: wrap; }
.drop-note {
  margin-top: 1.5rem; padding-top: 1.2rem; border-top: 1px solid var(--line);
  font-size: 0.72rem; color: var(--txt-2); line-height: 1.6;
}
.drop-note i { color: var(--teal-l); margin-right: 0.35rem; }

/* ═══ Carga ════════════════════════════════════════════════ */
.loading {
  position: absolute; inset: 0; z-index: 8;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2rem;
  background: rgba(8,24,40,0.82);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.loading[hidden] { display: none; }
.loading-txt { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--txt); }
.loading-bar { width: min(340px, 70vw); height: 4px; border-radius: 4px; background: rgba(255,255,255,0.12); overflow: hidden; }
.loading-bar i { display: block; height: 100%; width: 0%; background: var(--teal-l); border-radius: 4px; transition: width 0.2s linear; }
.loading-pct { font-size: 1.5rem; font-weight: 900; color: #fff; letter-spacing: -0.02em; }

/* ═══ Herramientas flotantes ═══════════════════════════════ */
.tools {
  position: absolute; z-index: 7; right: 16px; bottom: 16px;
  display: flex; flex-direction: column; gap: 0.4rem;
}
.tools[hidden] { display: none; }
.tools .vbtn {
  background: rgba(14,40,65,0.86);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.stage.is-light .tools .vbtn { background: rgba(14,40,65,0.9); }

/* ═══ Ficha del modelo ═════════════════════════════════════ */
.info {
  position: absolute; z-index: 7; left: 16px; bottom: 16px;
  min-width: 236px; max-width: min(330px, calc(100vw - 100px));
  padding: 1rem 1.1rem;
  background: rgba(14,40,65,0.86);
  border: 1px solid var(--line); border-radius: 12px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.info[hidden] { display: none; }
.info-name {
  font-size: 0.8rem; font-weight: 800; color: #fff;
  margin-bottom: 0.85rem; padding-bottom: 0.7rem; border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere; line-height: 1.45;
}
.info-row { display: flex; justify-content: space-between; gap: 1rem; padding: 0.2rem 0; }
.info-row dt { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--txt-2); }
.info-row dd { font-size: 0.76rem; font-weight: 700; color: var(--teal-l); font-variant-numeric: tabular-nums; }

/* ═══ Ayuda de controles ═══════════════════════════════════ */
.hint {
  position: absolute; z-index: 7; left: 50%; bottom: 16px; transform: translateX(-50%);
  display: flex; gap: 1.3rem; padding: 0.6rem 1.1rem;
  background: rgba(14,40,65,0.78);
  border: 1px solid var(--line); border-radius: 50px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  white-space: nowrap;
}
.hint[hidden] { display: none; }
.hint span { font-size: 0.68rem; font-weight: 600; color: var(--txt-2); display: inline-flex; align-items: center; gap: 0.4rem; }
.hint i { color: var(--teal-l); font-size: 0.75rem; }

/* ═══ Aviso de error ═══════════════════════════════════════ */
.toast {
  position: absolute; z-index: 30; left: 50%; top: 18px; transform: translateX(-50%);
  display: none; align-items: flex-start; gap: 0.7rem;
  width: max-content;
  max-width: min(420px, calc(100vw - 40px));
  height: auto;                      /* nunca se estira verticalmente */
  padding: 0.6rem 2.1rem 0.6rem 0.85rem;
  background: rgba(120,30,30,0.94); border: 1px solid rgba(255,120,110,0.45);
  border-radius: 9px; font-size: 0.74rem; line-height: 1.5; color: #fff;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.toast.show { display: flex; }
.toast > i { color: #ffb3ad; margin-top: 0.12rem; font-size: 0.8rem; flex-shrink: 0; }

/* ═══ Responsive ═══════════════════════════════════════════ */
@media (max-width: 900px) {
  .vbar-title { display: none; }
  .vbar-sep { display: none; }
  .hint { display: none !important; }
}
@media (max-width: 640px) {
  .vbar { height: 54px; padding: 0 0.7rem; gap: 0.5rem; }
  .vbar-logo img { height: 24px; }
  .vbtn { height: 34px; padding: 0 0.7rem; font-size: 0.72rem; }
  .vbtn-ico { width: 34px; padding: 0; }
  .vbtn .txt { display: none; }
  .vbtn-primary .txt { display: inline; }
  .drop-box { padding: 2rem 1.3rem; }
  .drop-box h1 { font-size: 1.15rem; }
  .info {
    left: 10px; right: 10px; bottom: 10px; max-width: none; min-width: 0;
    padding: 0.8rem 0.9rem;
  }
  .info-name { margin-bottom: 0.6rem; padding-bottom: 0.5rem; font-size: 0.74rem; }
  .tools { right: 10px; bottom: auto; top: 10px; flex-direction: row; flex-wrap: wrap; justify-content: flex-end; max-width: calc(100vw - 20px); }
  /* En móvil las herramientas van arriba: el aviso baja para no encimarse */
  .toast { top: 100px; }
  .stage-mark { display: none; }
}

/* Aviso informativo, distinto del de error */
.toast.is-info {
  background: rgba(14,40,65,0.94);
  border-color: rgba(78,201,192,0.45);
}
.toast.is-info i { color: var(--teal-l); }

/* Botón para cerrar el aviso a mano */
.toast-x {
  position: absolute; top: 4px; right: 4px;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: 6px;
  color: rgba(255,255,255,0.6); font-size: 0.82rem;
  cursor: pointer; transition: all 0.18s var(--ease);
}
.toast-x:hover { background: rgba(255,255,255,0.14); color: #fff; }
