/* =========================================================================
   Estructura compartida entre las secciones de "Mapa de Potencialidades"
   (Mapa, Listado, y las que se vayan agregando): menu lateral, header con
   estadisticas, sidebars de filtros/insights, barra de productos.
   Cada pagina agrega SUS propios estilos para su contenido central.
   ========================================================================= */
html, body { height: 100%; margin: 0; overflow: hidden; }
body { font-family: 'Inter', 'Segoe UI', sans-serif; color: var(--mp-ink); background: var(--mp-bg); }

.mpx-app { height: 100%; display: flex; }
.mpx-shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mpx-body { flex: 1; display: flex; min-height: 0; }

/* Columna de navegacion (secciones del sistema, no del contenido en si) */
.mpx-nav {
  flex: none; width: 64px; z-index: 1020; display: flex; flex-direction: column; align-items: center;
  gap: .3rem; padding: .8rem 0; background: var(--mp-green);
}
.mpx-nav-item {
  width: 46px; height: 46px; border-radius: .8rem; border: none; background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem;
  color: rgba(255,255,255,.72); font-size: 1.1rem; text-decoration: none; cursor: pointer;
}
.mpx-nav-item span { font-size: .56rem; font-weight: 600; letter-spacing: .01em; }
.mpx-nav-item:hover { background: rgba(255,255,255,.12); color: #fff; }
.mpx-nav-item.is-active { background: var(--mp-white); color: var(--mp-green); }
.mpx-nav-item.is-disabled { color: rgba(255,255,255,.38); cursor: not-allowed; }
.mpx-nav-item.is-disabled:hover { background: transparent; color: rgba(255,255,255,.38); }
.mpx-nav-spacer { flex: 1; min-height: .5rem; }
.mpx-nav form { width: 100%; display: flex; justify-content: center; }

/* ---------------------------------------------------------------------
   Header
   --------------------------------------------------------------------- */
.mpx-header {
  flex: none; z-index: 1010; display: flex; align-items: center; gap: 1.25rem;
  padding: .55rem 1.25rem; background: var(--mp-white);
  box-shadow: 0 2px 12px rgba(0,0,0,.06); flex-wrap: wrap;
}
.mpx-brand { display: flex; align-items: center; gap: .65rem; flex: none; }
.mpx-brand img { height: 36px; }
.mpx-brand-title { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 1.02rem; color: var(--mp-ink); line-height: 1.2; }
.mpx-brand-subtitle { font-size: .72rem; color: var(--mp-ink-soft); }

.mpx-stats { display: flex; gap: .6rem; flex: 1; flex-wrap: wrap; justify-content: center; }
.mpx-stat {
  display: flex; align-items: center; gap: .55rem; background: var(--mp-bg);
  border-radius: .8rem; padding: .4rem .85rem; min-width: 118px;
}
.mpx-stat i { font-size: 1.05rem; color: var(--mp-green); }
.mpx-stat-value { display: block; font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 1.02rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.mpx-stat-label { display: block; font-size: .66rem; color: var(--mp-ink-soft); text-transform: uppercase; letter-spacing: .04em; }

.mpx-header-actions { display: flex; gap: .4rem; flex: none; }
.mpx-icon-btn {
  width: 38px; height: 38px; border-radius: .7rem; border: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--mp-bg); color: var(--mp-green); font-size: 1.05rem;
  text-decoration: none; cursor: pointer;
}
.mpx-icon-btn:hover { background: var(--mp-green); color: #fff; }
.mpx-toggle-sidebar { display: none; }

.mpx-icon-sol { display: none; }
:root[data-theme="dark"] .mpx-icon-luna { display: none; }
:root[data-theme="dark"] .mpx-icon-sol { display: inline-block; }

/* ---------------------------------------------------------------------
   Sidebars
   --------------------------------------------------------------------- */
.mpx-sidebar {
  flex: none; width: 280px; background: var(--mp-white); overflow-y: auto;
  padding: 1rem 1.1rem 1.5rem; font-size: .84rem;
}
.mpx-sidebar-left { border-right: 1px solid var(--mp-line); }
/* Fuera del flujo en todos los anchos: el mapa se queda con el espacio y el
   panel entra deslizandose desde la derecha al tirar de la pestana. */
.mpx-sidebar-right {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 1050;
  width: 300px; border-left: 1px solid var(--mp-line);
  box-shadow: var(--mp-shadow);
  transform: translateX(100%); transition: transform .22s ease;
}
.mpx-sidebar-right.is-open { transform: translateX(0); }

/* Pestana para abrir el panel. Va fuera del aside porque el aside tiene
   overflow-y:auto y recortaria cualquier hijo que sobresalga. */
.mpx-asa {
  position: fixed; right: 0; top: 50%; z-index: 1051;
  transform: translateY(-50%); transition: right .22s ease;
  display: flex; flex-direction: column; align-items: center; gap: .45rem;
  width: 34px; padding: .95rem .2rem;
  border: 1px solid var(--mp-line); border-right: 0; border-radius: 9px 0 0 9px;
  background: var(--mp-white); color: var(--mp-green);
  box-shadow: var(--mp-shadow); cursor: pointer;
}
.mpx-asa:hover { background: var(--mp-green); color: #fff; }
.mpx-asa span {
  writing-mode: vertical-rl; text-transform: uppercase;
  font-size: .64rem; font-weight: 700; letter-spacing: .09em;
}
.mpx-asa i { transition: transform .22s ease; }
body.mpx-panel-abierto .mpx-asa { right: 300px; }
body.mpx-panel-abierto .mpx-asa i { transform: rotate(180deg); }

/* Cae encima de la tarjeta verde del destacado: va en blanco translucido, un
   gris sobre ese degradado no se lee. */
.mpx-cerrar-panel {
  position: absolute; top: 1.35rem; right: 1.45rem; z-index: 2;
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%;
  background: rgba(255,255,255,.18); color: #fff; cursor: pointer; font-size: .72rem;
}
.mpx-cerrar-panel:hover { background: rgba(255,255,255,.34); color: #fff; }
.mpx-label {
  display: block; font-family: 'Poppins', sans-serif; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--mp-green); margin: 1.1rem 0 .55rem;
}
.mpx-sidebar > .mpx-label:first-child { margin-top: 0; }
.mpx-sidebar label.mpx-check { display: flex; align-items: center; gap: .5rem; margin-bottom: .45rem; cursor: pointer; }
.mpx-dot {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: .62rem;
}
.mpx-count { margin-left: auto; color: var(--mp-ink-soft); font-variant-numeric: tabular-nums; }
.mpx-total { margin-top: .9rem; padding-top: .7rem; border-top: 1px solid var(--mp-line); font-weight: 600; }

/* Avance de carga: se oculta solo al terminar (ver MapaShell.progreso). */
.mpx-progreso { margin-top: .6rem; }
.mpx-progreso[hidden] { display: none; }
.mpx-progreso-barra { height: 5px; border-radius: 3px; background: var(--mp-line); overflow: hidden; }
.mpx-progreso-barra span { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--mp-green, #176B3A); transition: width .18s linear; }
.mpx-progreso-texto { margin-top: .3rem; font-size: .74rem; color: var(--mp-ink-soft); font-variant-numeric: tabular-nums; }

/* Un solo formato para "no hay dato" en todas las pantallas. */
.mpx-sin-dato { font-style: italic; color: var(--mp-ink-soft); opacity: .85; font-weight: 400; }

/* Aviso de que el resumen corresponde a una seleccion filtrada. */
.mpx-seleccion-aviso {
  margin: -.2rem 0 .5rem; padding: .25rem .5rem; border-radius: 5px;
  background: var(--mp-line); color: var(--mp-ink-soft);
  font-size: .72rem; font-variant-numeric: tabular-nums;
}

/* Registro incompleto: mismo punto, atenuado y con borde punteado. */
.mpx-dot-incompleto { opacity: .55; border: 1px dashed currentColor; }
.mpx-limpiar { font-size: .8rem; color: var(--mp-green); text-decoration: none; }
.mpx-limpiar:hover { text-decoration: underline; }

/* Tarjeta "potencial destacado": siempre verde oscuro, en los dos temas —
   por eso su texto es blanco literal, no el token --mp-white (que en modo
   oscuro pasa a ser un color de superficie oscura, no blanco). */
.mpx-highlight {
  border-radius: var(--mp-radius); padding: 1rem 1.1rem; padding-right: 2.6rem; color: #fff;
  background: linear-gradient(150deg, var(--mp-green) 0%, #0f4d2a 100%);
  box-shadow: var(--mp-shadow);
}
.mpx-highlight .mpx-eyebrow { color: rgba(255,255,255,.85); font-size: .66rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; }
.mpx-highlight h5 {
  font-family: 'Poppins', sans-serif; font-weight: 700; margin: .3rem 0; font-size: 1.1rem; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.mpx-highlight p { margin: 0; font-size: .78rem; color: rgba(255,255,255,.85); }

.mpx-resumen { list-style: none; margin: 0; padding: 0; }
.mpx-resumen li { display: flex; justify-content: space-between; padding: .4rem 0; border-bottom: 1px dashed var(--mp-line); }
.mpx-resumen li:last-child { border-bottom: none; }
.mpx-resumen span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; }

.mpx-recientes { list-style: none; margin: 0; padding: 0; }
.mpx-recientes li { display: flex; gap: .55rem; padding: .5rem 0; border-bottom: 1px dashed var(--mp-line); }
.mpx-recientes li:last-child { border-bottom: none; }
.mpx-recientes .emoji { font-size: 1.1rem; }
.mpx-recientes .nombre { font-weight: 600; font-size: .78rem; line-height: 1.25; }
.mpx-recientes .detalle { font-size: .7rem; color: var(--mp-ink-soft); }

/* ---------------------------------------------------------------------
   Barra inferior: explorar por producto
   --------------------------------------------------------------------- */
.mpx-footer {
  flex: none; display: flex; align-items: center; gap: .8rem; padding: .6rem 1.25rem;
  background: var(--mp-white); border-top: 1px solid var(--mp-line); overflow-x: auto;
}
.mpx-footer-label { flex: none; font-size: .74rem; font-weight: 700; color: var(--mp-ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.mpx-chip {
  flex: none; display: inline-flex; align-items: center; gap: .4rem;
  border: 1.5px solid var(--mp-line); background: var(--mp-white); color: var(--mp-ink);
  font-weight: 600; font-size: .82rem; padding: .4rem .9rem; border-radius: 999px;
  cursor: pointer; transition: background-color .18s ease, color .18s ease, border-color .18s ease;
}
.mpx-chip:hover { border-color: var(--mp-green-light); }
.mpx-chip.is-active { background: var(--mp-green); border-color: var(--mp-green); color: #fff; }

/* ---------------------------------------------------------------------
   Tema oscuro: controles de Bootstrap no usan nuestros tokens por defecto
   (fondo/borde propios), asi que hay que pisarlos explicitamente aca.
   --------------------------------------------------------------------- */
:root[data-theme="dark"] .form-select,
:root[data-theme="dark"] .form-control {
  background-color: var(--mp-white);
  color: var(--mp-ink);
  border-color: var(--mp-line);
}
:root[data-theme="dark"] .form-select:focus,
:root[data-theme="dark"] .form-control:focus {
  background-color: var(--mp-white);
  color: var(--mp-ink);
}
:root[data-theme="dark"] .form-control::placeholder { color: var(--mp-ink-soft); }
:root[data-theme="dark"] .form-select:disabled { color: var(--mp-ink-soft); }

/* ---------------------------------------------------------------------
   Responsive: sidebars pasan a paneles deslizables
   --------------------------------------------------------------------- */
@media (max-width: 1199.98px) {
  /* El panel ya es deslizable en todos los anchos; aqui solo se suma el boton
     de la cabecera, que en pantallas chicas es mas comodo que la pestana. */
  .mpx-toggle-sidebar.mpx-toggle-right { display: inline-flex; }
}
@media (max-width: 767.98px) {
  .mpx-sidebar-left { position: fixed; top: 0; left: 0; bottom: 0; z-index: 1050; box-shadow: var(--mp-shadow); transform: translateX(-100%); transition: transform .22s ease; }
  .mpx-sidebar-left.is-open { transform: translateX(0); }
  .mpx-toggle-sidebar.mpx-toggle-left { display: inline-flex; }
  .mpx-stats { display: none; }
  .mpx-donut-card { display: none; }
  .mpx-asa { display: none; }
  .mpx-sidebar-right { width: min(300px, 88vw); }
  .mpx-nav { width: 52px; }
  .mpx-nav-item span { display: none; }
}
