/* En vistas que no requieren shell (login), ocultar nav y dejar el view a pantalla completa */
body.no-shell #topnav,
body.no-shell #mbn { display: none !important; }
body.no-shell { padding-bottom: 0 !important; }

/* ── Top PC nav (sticky horizontal) ─────────────────────────────────────── */
#topnav {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 0 var(--space-sm);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: none;
}
#topnav::-webkit-scrollbar { display: none; }

.tn-item,
.tn-drop-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: 10px var(--space-sm);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-muted);
  text-decoration: none;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}
.tn-drop { flex-shrink: 0; }
.tn-act  { flex-shrink: 0; }
.tn-item:hover,
.tn-drop-btn:hover { color: var(--color-text); }
.tn-item.tn-active,
.tn-drop.open .tn-drop-btn {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}
.tn-ic { font-size: 1rem; line-height: 1; }
.tn-caret { font-size: 0.7rem; margin-left: 2px; opacity: 0.8; }

.tn-drop { position: relative; display: inline-flex; }
.tn-drop-menu {
  position: fixed;
  min-width: 220px;
  max-height: 80vh;
  overflow-y: auto;
  padding: var(--space-2xs);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: calc(var(--z-nav) + 10);
}
.tn-drop.open .tn-drop-menu { display: block; }
.tn-drop-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 8px 12px;
  font-size: var(--font-size-sm);
  color: var(--color-text);
  text-decoration: none;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.tn-drop-item:hover { background: var(--color-surface-alt); color: var(--color-primary); }

.tn-spacer { flex: 1; min-width: 8px; }

.tn-act {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: 6px 12px;
  margin: 6px 2px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
}
.tn-act:hover  { background: var(--color-border); }
.tn-act:active { transform: scale(0.96); }
#tn-theme { font-size: 1rem; padding: 6px 10px; }
.tn-ot  { background: var(--color-primary); color: var(--color-primary-text); border-color: transparent; }
.tn-ot:hover  { background: var(--color-primary-hover); }
.tn-pto { background: var(--color-info); color: #fff; border-color: transparent; }
.tn-pto:hover { filter: brightness(1.08); }

/* ── Mobile bottom nav (estilo hub) ─────────────────────────────────────── */
#mbn {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: var(--z-nav);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.mbn-a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 4px 4px 3px;
  font-size: 0.6rem;
  font-weight: var(--font-weight-bold);
  color: var(--color-text-muted);
  text-decoration: none;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.1;
}
.mbn-a.mbn-active,
.mbn-a:active { color: var(--color-primary); }
.mbn-a .mi {
  font-size: 1.05rem;
  line-height: 1;
}
.mbn-a.mbn-plus .mi {
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-style: normal;
  color: #fff;
}
.mbn-ot  .mi { background: var(--color-primary); }
.mbn-pto .mi { background: var(--color-info); }

#mbn-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-modal) - 5);
  background: rgba(0, 0, 0, 0.65);
}
#mbn-overlay.open {
  display: flex;
  align-items: flex-end;
}
#mbn-chat {
  width: 100%;
  height: 88vh;
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#mbn-overlay.open #mbn-chat { animation: mbn-up 0.25s ease-out; }
@keyframes mbn-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
#mbn-chat-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
}
#mbn-chat-hdr button {
  background: none;
  border: 0;
  color: var(--color-text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 2px 8px;
}
#mbn-chat iframe { flex: 1; width: 100%; border: 0; }

/* ── Responsivo: bottom nav solo en móvil, top siempre visible ──────────── */
@media (max-width: 900px) {
  #mbn {
    display: flex;
    flex-direction: row;
    align-items: center;
    height: calc(48px + env(safe-area-inset-bottom, 0));
  }
  body { padding-bottom: calc(48px + env(safe-area-inset-bottom, 0)) !important; }
  /* Apretar el top nav para pantalla pequeña */
  .tn-item .tn-lb,
  .tn-drop-btn .tn-lb { display: none; }
  .tn-act { padding: 6px 10px; font-size: var(--font-size-xs); }
  /* +OT y +Presupuesto ya están en el bottom nav móvil → ocultar arriba */
  #tn-ot, #tn-pto { display: none; }
}
