/* ════════════════════════════════════════════════════════════════
   ESTILOS — Mapa de menciones ciudadanas (CDMX / Edomex)
════════════════════════════════════════════════════════════════ */
/* ══════════════════════════════════════════════════════════════
   RESET + BASE
══════════════════════════════════════════════════════════════ */
*{box-sizing:border-box;margin:0;padding:0}
body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;background:#f5f5f2;color:#1a1a1a;font-size:13px;height:100vh;height:100dvh;overflow:hidden;-webkit-text-size-adjust:100%}

/* ══════════════════════════════════════════════════════════════
   CABECERA
══════════════════════════════════════════════════════════════ */
#header{background:#fff;border-bottom:1px solid #e0e0dc;padding:8px 16px;display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:6px;flex-shrink:0}
#header-left h1{font-size:13px;font-weight:600;color:#1a1a1a}
#header-left p{font-size:10px;color:#888;margin-top:1px}
#header-right{display:flex;gap:6px;flex-wrap:wrap}

/* ══════════════════════════════════════════════════════════════
   BARRA DE HERRAMIENTAS
══════════════════════════════════════════════════════════════ */
#toolbar{background:#fff;border-bottom:1px solid #e0e0dc;padding:6px 16px;display:flex;flex-wrap:wrap;gap:4px;align-items:center;flex-shrink:0}
#toolbar-section{display:flex;align-items:center;gap:4px;flex-wrap:wrap}
.tl{font-size:9px;color:#bbb;text-transform:uppercase;letter-spacing:.4px;margin-right:2px;white-space:nowrap}
.sep{width:1px;height:16px;background:#e0e0dc;margin:0 4px}
.bf{font-size:10px;padding:2px 8px;border-radius:20px;cursor:pointer;border:1px solid;font-family:inherit;background:#fff;white-space:nowrap;transition:all .15s}
.bf:hover{opacity:.75}
.bf.off{opacity:.28}
.bf.active{font-weight:600}

/* buscador */
#search-wrap{position:relative;display:flex;align-items:center}
#search{font-size:10px;padding:3px 8px 3px 24px;border:1px solid #ddd;border-radius:20px;width:160px;font-family:inherit;outline:none}
#search:focus{border-color:#378add;box-shadow:0 0 0 2px rgba(55,138,221,.15)}
#search-icon{position:absolute;left:7px;font-size:11px;color:#aaa;pointer-events:none}
#search-count{font-size:9px;color:#999;white-space:nowrap}

/* ══════════════════════════════════════════════════════════════
   LAYOUT PRINCIPAL
══════════════════════════════════════════════════════════════ */
#layout{display:flex;height:calc(100vh - 88px);height:calc(100dvh - 88px)}
#map{flex:1;min-width:0}

/* ══════════════════════════════════════════════════════════════
   PANEL LATERAL
══════════════════════════════════════════════════════════════ */
#sidebar{width:290px;flex-shrink:0;background:#fff;border-left:1px solid #e0e0dc;overflow-y:auto;display:flex;flex-direction:column}
.panel-sec{padding:10px 13px;border-bottom:1px solid #eee}
.panel-sec h2{font-size:9px;font-weight:600;color:#bbb;text-transform:uppercase;letter-spacing:.5px;margin-bottom:7px}

/* stats */
.stat-row{display:flex;justify-content:space-between;align-items:center;padding:2px 0}
.stat-row span:first-child{display:flex;align-items:center;gap:5px;color:#555}
.dot{width:8px;height:8px;border-radius:50%;display:inline-block;flex-shrink:0}

/* ficha detalle */
#detail-content{color:#bbb;font-size:11px;line-height:1.5}
#detail-content.has-data{color:#1a1a1a}
.ficha-dir{font-size:12px;font-weight:600;line-height:1.35;margin-bottom:3px}
.ficha-col{font-size:10px;color:#888;margin-bottom:7px}
.badge{display:inline-block;font-size:9px;font-weight:600;padding:2px 7px;border-radius:20px;margin:2px 2px 2px 0;border:1px solid}
.ficha-idx{font-size:10px;color:#888;margin:5px 0 3px}
.idx-bar{height:4px;background:#eee;border-radius:2px;margin-bottom:7px}
.idx-fill{height:4px;border-radius:2px}
.ficha-section{font-size:10px;margin-top:7px;padding-top:7px;border-top:1px solid #eee;line-height:1.6;color:#444}
.ficha-section strong{color:#1a1a1a;font-weight:600}
.ficha-adv{font-size:9px;color:#aaa;font-style:italic;line-height:1.5;margin-top:7px;padding-top:6px;border-top:1px solid #eee}
.ficha-label{font-size:9px;text-transform:uppercase;letter-spacing:.3px;color:#bbb;font-weight:600;display:block;margin-bottom:1px}
.ficha-val{font-size:10px;color:#333;margin-bottom:4px;display:block}
/* botones ficha */
.ficha-btns{display:flex;flex-wrap:wrap;gap:4px;margin-top:8px}
.fbtn{font-size:9px;padding:3px 8px;border:1px solid #ddd;border-radius:4px;cursor:pointer;background:#fafafa;font-family:inherit;color:#555}
.fbtn:hover{background:#f0f0f0}

/* etiquetas zona */
.e-cdmx{background:#dbeafe;color:#1e40af;border-color:#93c5fd}
.e-edomex{background:#dcfce7;color:#14532d;border-color:#86efac}
.e-toluca{background:#fef9c3;color:#713f12;border-color:#fde047}

/* metodología desplegable */
#metodo-toggle{cursor:pointer;font-size:10px;color:#555;background:#fafafa;border:1px solid #eee;padding:4px 10px;border-radius:4px;font-family:inherit;text-align:left;width:100%}
#metodo-toggle:hover{background:#f0f0f0}
#metodo-body{font-size:10px;color:#444;line-height:1.7;display:none;padding-top:8px}
#metodo-body dt{font-weight:600;color:#1a1a1a;margin-top:6px}
#metodo-body dd{margin-left:10px;color:#555}

/* clúster tags */
.ctag{display:inline-block;font-size:9px;background:#fff3cd;color:#856404;border:1px solid #ffc107;border-radius:3px;padding:2px 5px;margin:2px 2px 2px 0;cursor:pointer}
.ctag:hover{background:#fde68a}
.ctag.active-cluster{background:#d97706;color:#fff;border-color:#d97706}

/* tabla */
#tabla-panel{display:none;flex-direction:column;position:absolute;bottom:0;left:0;right:290px;height:240px;background:#fff;border-top:2px solid #ddd;z-index:1000;overflow:hidden}
#tabla-panel.visible{display:flex}
#tabla-header{padding:7px 12px;background:#f8f8f8;border-bottom:1px solid #eee;display:flex;align-items:center;justify-content:space-between}
#tabla-header h3{font-size:11px;font-weight:600}
#tabla-toggle{font-size:9px;padding:2px 8px;border:1px solid #ddd;border-radius:4px;cursor:pointer;background:#fff;font-family:inherit}
#tabla-wrap{overflow:auto;flex:1}
table{width:100%;border-collapse:collapse;font-size:10px}
thead{position:sticky;top:0;background:#f8f8f8}
th{padding:5px 8px;text-align:left;border-bottom:1px solid #ddd;font-weight:600;white-space:nowrap;cursor:pointer;color:#555}
th:hover{background:#f0f0f0}
td{padding:4px 8px;border-bottom:1px solid #f0f0f0;vertical-align:top}
tr:hover td{background:#fafafa}
.t-ver-btn{font-size:9px;padding:1px 6px;border:1px solid #378add;border-radius:3px;cursor:pointer;color:#378add;background:#fff;font-family:inherit}
.t-ver-btn:hover{background:#dbeafe}

/* botones header */
.hbtn{font-size:10px;padding:4px 10px;border:1px solid #ddd;border-radius:4px;cursor:pointer;background:#fff;font-family:inherit;color:#444;white-space:nowrap}
.hbtn:hover{background:#f0f0f0}
.hbtn.active{background:#1a1a1a;color:#fff;border-color:#1a1a1a}

/* recorrido narrativo */
#recorrido-panel{display:none;position:absolute;top:90px;left:16px;z-index:2000;background:#fff;border:1px solid #ddd;border-radius:8px;padding:12px 14px;width:240px;box-shadow:0 4px 16px rgba(0,0,0,.12)}
#recorrido-panel h3{font-size:11px;font-weight:600;margin-bottom:8px;color:#1a1a1a}
#recorrido-panel.visible{display:block}
.rec-item{font-size:10px;padding:5px 8px;margin-bottom:4px;border:1px solid #eee;border-radius:4px;cursor:pointer;line-height:1.4}
.rec-item:hover{background:#f0f7ff;border-color:#378add}
.rec-item strong{display:block;color:#1a1a1a;font-weight:600}
.rec-item span{color:#888}
#recorrido-close{font-size:9px;color:#aaa;cursor:pointer;float:right;margin-top:-18px}

/* notificación toast */
#toast{position:fixed;bottom:20px;left:50%;transform:translateX(-50%);background:#1a1a1a;color:#fff;font-size:11px;padding:7px 16px;border-radius:20px;opacity:0;pointer-events:none;transition:opacity .3s;z-index:9999}
#toast.show{opacity:1}

/* responsive side */
@media(max-width:700px){
  #sidebar{width:100%;position:absolute;bottom:0;left:0;right:0;max-height:45vh;z-index:1000}
  #layout{flex-direction:column}
  #tabla-panel{right:0}
}

/* ══ MODAL BIENVENIDA / FORMULARIO ══ */
.overlay{position:fixed;inset:0;background:rgba(0,0,0,.55);z-index:9000;display:flex;align-items:center;justify-content:center;padding:16px}
.overlay.hidden{display:none}
.modal{background:#fff;border-radius:12px;max-width:560px;width:100%;max-height:90vh;display:flex;flex-direction:column;box-shadow:0 8px 40px rgba(0,0,0,.18)}
.modal-header{padding:18px 20px 14px;border-bottom:1px solid #eee;display:flex;align-items:flex-start;justify-content:space-between;flex-shrink:0}
.modal-header h2{font-size:15px;font-weight:600;line-height:1.35;color:#1a1a1a}
.modal-header p{font-size:11px;color:#888;margin-top:3px}
.modal-close{background:none;border:none;font-size:20px;cursor:pointer;color:#aaa;line-height:1;padding:0 0 0 12px;flex-shrink:0}
.modal-close:hover{color:#555}
.modal-body{overflow-y:auto;padding:16px 20px;flex:1}
.modal-footer{padding:12px 20px;border-top:1px solid #eee;display:flex;gap:8px;justify-content:flex-end;flex-shrink:0;flex-wrap:wrap}

/* Pasos del formulario */
.step-indicator{display:flex;gap:0;margin-bottom:16px}
.step-dot{flex:1;height:3px;background:#eee;border-radius:2px;transition:background .3s}
.step-dot.done{background:#10b981}
.step-dot.active{background:#378add}
.step-label{display:flex;justify-content:space-between;margin-bottom:12px}
.step-label span{font-size:9px;color:#aaa;text-align:center;flex:1}
.step-label span.active{color:#378add;font-weight:600}

/* Campos formulario */
.fgroup{margin-bottom:12px}
.fgroup label{display:block;font-size:10px;font-weight:600;color:#555;margin-bottom:4px;text-transform:uppercase;letter-spacing:.3px}
.fgroup input,.fgroup select,.fgroup textarea{width:100%;font-size:12px;padding:7px 10px;border:1px solid #ddd;border-radius:6px;font-family:inherit;outline:none;background:#fff}
.fgroup input:focus,.fgroup select:focus,.fgroup textarea:focus{border-color:#378add;box-shadow:0 0 0 2px rgba(55,138,221,.12)}
.fgroup textarea{resize:vertical;min-height:60px}
.fgroup .hint{font-size:10px;color:#aaa;margin-top:3px;line-height:1.4}
.fgroup .warn{font-size:10px;color:#b45309;background:#fef9c3;border:1px solid #fde047;border-radius:4px;padding:5px 8px;margin-top:4px;line-height:1.5}

/* Radio/check grupos */
.check-row{display:flex;align-items:center;gap:7px;padding:4px 0;font-size:11px;color:#333;cursor:pointer}
.check-row input{width:auto;cursor:pointer}
.radio-group{display:flex;flex-wrap:wrap;gap:8px;margin-top:4px}
.radio-pill{display:flex;align-items:center;gap:5px;padding:4px 10px;border:1px solid #ddd;border-radius:20px;font-size:10px;cursor:pointer;transition:all .15s}
.radio-pill input{display:none}
.radio-pill.selected{background:#dbeafe;border-color:#378add;color:#1e40af;font-weight:600}

/* Confirmación */
.confirm-screen{text-align:center;padding:20px 10px}
.confirm-icon{font-size:40px;margin-bottom:12px}
.confirm-screen h3{font-size:16px;font-weight:600;margin-bottom:8px}
.confirm-screen p{font-size:12px;color:#666;line-height:1.6;max-width:360px;margin:0 auto 16px}

/* Botones principales */
.btn-primary{font-size:11px;padding:8px 18px;background:#1a1a1a;color:#fff;border:none;border-radius:6px;cursor:pointer;font-family:inherit;font-weight:500}
.btn-primary:hover{background:#333}
.btn-secondary{font-size:11px;padding:8px 18px;background:#fff;color:#555;border:1px solid #ddd;border-radius:6px;cursor:pointer;font-family:inherit}
.btn-secondary:hover{background:#f5f5f5}
.btn-green{background:#059669;color:#fff;font-size:11px;padding:8px 18px;border:none;border-radius:6px;cursor:pointer;font-family:inherit}
.btn-green:hover{background:#047857}

/* Barra móvil */
#mobile-bar{display:none;position:fixed;bottom:0;left:0;right:0;height:54px;background:#fff;border-top:1px solid #e0e0dc;z-index:3000;flex-direction:row;justify-content:space-around;align-items:center}
.mob-btn{display:flex;flex-direction:column;align-items:center;gap:2px;font-size:9px;color:#555;background:none;border:none;cursor:pointer;padding:4px 8px;font-family:inherit;flex:1}
.mob-btn .mob-icon{font-size:18px;line-height:1}
.mob-btn.active{color:#378add}
@media(max-width:700px){
  #mobile-bar{display:flex}
  #layout{height:calc(100vh - 142px);height:calc(100dvh - 142px)}
  #sidebar{position:fixed;bottom:54px;left:0;right:0;max-height:50vh;z-index:2000;transform:translateY(100%);transition:transform .3s;display:flex}
  #sidebar.mob-open{transform:translateY(0)}
  #tabla-panel{bottom:54px;right:0}
  #toolbar{overflow-x:auto;flex-wrap:nowrap;padding:5px 10px}
}

/* Leyenda flotante */
#legend-float{position:absolute;bottom:28px;left:12px;z-index:800;background:rgba(255,255,255,.97);border:1px solid #e0e0dc;border-radius:8px;padding:10px 12px;font-size:10px;min-width:200px;box-shadow:0 2px 10px rgba(0,0,0,.1)}
#legend-float h4{font-size:9px;font-weight:600;color:#bbb;text-transform:uppercase;letter-spacing:.4px;margin-bottom:7px}
.leg-row{display:flex;align-items:center;gap:7px;padding:2px 0;color:#444}
.leg-dot{width:10px;height:10px;border-radius:50%;flex-shrink:0;border:1.5px solid rgba(0,0,0,.2)}
.leg-ring{width:10px;height:10px;border-radius:50%;flex-shrink:0;border:2px solid currentColor;background:transparent}
#legend-toggle{position:absolute;bottom:28px;left:12px;z-index:801;background:#fff;border:1px solid #ddd;border-radius:20px;padding:3px 10px;font-size:10px;cursor:pointer;display:none}

/* Guía rápida */
#guia-panel{display:none;position:absolute;top:0;right:0;bottom:0;width:300px;background:#fff;border-left:1px solid #e0e0dc;z-index:900;overflow-y:auto;flex-direction:column}
#guia-panel.visible{display:flex}
.guia-item{display:flex;gap:10px;padding:10px 14px;border-bottom:1px solid #f0f0f0;align-items:flex-start}
.guia-num{width:22px;height:22px;border-radius:50%;background:#1a1a1a;color:#fff;font-size:10px;font-weight:600;display:flex;align-items:center;justify-content:center;flex-shrink:0;margin-top:1px}
.guia-text{font-size:11px;color:#333;line-height:1.55}
.guia-text strong{display:block;font-size:10px;font-weight:600;color:#1a1a1a;margin-bottom:2px}

/* Botón reportar en header */
#btn-reportar-header{background:#1a1a1a;color:#fff;font-size:11px;padding:5px 14px;border:none;border-radius:20px;cursor:pointer;font-family:inherit;font-weight:500;white-space:nowrap}
#btn-reportar-header:hover{background:#333}

/* Exportar */
.export-row{display:flex;gap:6px;flex-wrap:wrap;padding:8px 0}

/* Toast mejorado */
#toast{position:fixed;bottom:70px;left:50%;transform:translateX(-50%);background:#1a1a1a;color:#fff;font-size:11px;padding:8px 18px;border-radius:20px;opacity:0;pointer-events:none;transition:opacity .3s;z-index:9999;white-space:nowrap}
#toast.show{opacity:1}


/* ════════════════════════════════════════════════════════════════
   MEJORAS RESPONSIVE (móvil y tablet)
   Se cargan al final para sobrescribir lo anterior.
════════════════════════════════════════════════════════════════ */

/* Tablet / móvil grande */
@media(max-width:760px){
  /* Cabecera compacta: una sola fila con scroll horizontal */
  #header{flex-wrap:nowrap;gap:8px;padding:8px 12px;align-items:center}
  #header-left{min-width:0;flex:1}
  #header-left h1{font-size:12px;line-height:1.25;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  #header-left p{display:none}
  #header-right{flex-wrap:nowrap;overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:none;padding-bottom:2px}
  #header-right::-webkit-scrollbar{display:none}
  /* El botón "Reportar" del header se duplica en la barra inferior */
  #btn-reportar-header{display:none}

  /* Barra de filtros con scroll horizontal y targets más cómodos */
  #toolbar{padding:6px 10px;gap:6px}
  .bf{font-size:12px;padding:6px 12px;min-height:32px;display:inline-flex;align-items:center}
  .hbtn{font-size:12px;padding:8px 12px;min-height:34px}

  /* Buscador flexible (no ancho fijo) */
  #search{width:42vw;min-width:130px;font-size:16px;padding:8px 10px 8px 28px}
  #search-icon{font-size:13px;left:9px}
}

/* Móvil */
@media(max-width:700px){
  /* Inputs a 16px evita el auto-zoom de iOS al enfocar */
  .fgroup input,.fgroup select,.fgroup textarea{font-size:16px;padding:9px 11px}

  /* Botones del formulario y modales: más alto para el dedo */
  .btn-primary,.btn-secondary,.btn-green{padding:11px 18px;font-size:13px}
  .radio-pill{padding:7px 12px;font-size:12px;min-height:34px}
  .check-row{padding:7px 0;font-size:13px}

  /* Modales ocupan casi toda la pantalla con bordes redondeados arriba */
  .overlay{padding:0;align-items:flex-end}
  .modal{max-width:100%;max-height:92dvh;border-radius:14px 14px 0 0}
  .modal-header h2{font-size:15px}

  /* Leyenda: por encima de la barra inferior y más compacta */
  #legend-float{bottom:calc(54px + 10px);left:8px;right:auto;min-width:0;max-width:62vw;font-size:9px;padding:8px 10px}
  #legend-float h4{margin-bottom:5px}

  /* Ficha lateral y tabla más legibles al tacto */
  .fbtn{padding:7px 10px;font-size:11px}
  .t-ver-btn{padding:4px 10px;font-size:11px}
  td,th{padding:7px 8px;font-size:11px}

  /* Recorrido narrativo: ancho adaptado y separado de los bordes */
  #recorrido-panel{left:8px;right:8px;width:auto;top:auto;bottom:calc(54px + 10px)}
  .rec-item{padding:9px 10px;font-size:12px}

  /* Menú de exportación pegado a la derecha sin salirse */
  #export-menu{right:0;left:auto;max-width:90vw}

  /* Barra inferior: targets cómodos */
  .mob-btn{padding:6px 4px;min-height:50px}
  .mob-btn .mob-icon{font-size:20px}
}

/* Móvil pequeño */
@media(max-width:380px){
  #header-left h1{font-size:11px}
  .bf{padding:6px 10px}
  #search{width:38vw;min-width:110px}
  #legend-float{max-width:70vw}
}

/* Respeta el área segura de dispositivos con notch */
@supports(padding:max(0px)){
  #mobile-bar{height:auto;min-height:54px;padding-bottom:env(safe-area-inset-bottom)}
}

/* ════════════════════════════════════════════════════════════════
   v2 — UI MÓVIL COLAPSABLE (filtros, leyenda y ficha como hojas)
════════════════════════════════════════════════════════════════ */

/* Controles auxiliares: ocultos en escritorio */
#legend-show{display:none}
#sidebar-close{display:none}
/* En escritorio la leyenda se puede ocultar con su botón (clase) */
body.leyenda-oculta #legend-float{display:none}

@media(max-width:700px){
  /* ---- El mapa ocupa todo el alto disponible (layout flexible) ---- */
  body{display:flex;flex-direction:column}
  #header{flex:0 0 auto}
  #layout{height:auto;flex:1 1 auto;min-height:0;padding-bottom:54px}
  #map{flex:1 1 auto;height:auto;min-height:0}

  /* ---- Barra de filtros: oculta; se abre como hoja inferior ---- */
  #toolbar{
    display:none;
    position:fixed;left:0;right:0;bottom:54px;z-index:2600;
    max-height:60dvh;overflow-y:auto;
    flex-wrap:wrap;align-items:flex-start;
    background:#fff;border-top:2px solid #ddd;
    box-shadow:0 -6px 20px rgba(0,0,0,.16);
    padding:14px 14px calc(14px + env(safe-area-inset-bottom));
    gap:10px;
  }
  body.ver-filtros #toolbar{display:flex}
  #toolbar #toolbar-section{flex:1 1 100%}
  #toolbar .sep{display:none}
  #toolbar #search-wrap{flex:1 1 100%}
  #search{width:100%}
  .bf{font-size:13px;padding:7px 13px;min-height:36px}

  /* ---- Leyenda: oculta por defecto; botón flotante para mostrarla ---- */
  #legend-float{display:none;left:10px;bottom:calc(54px + 58px);max-width:80vw}
  body.ver-leyenda #legend-float{display:block}
  #legend-show{
    display:block;position:fixed;left:10px;bottom:calc(54px + 12px);z-index:1200;
    background:#fff;border:1px solid #ddd;border-radius:22px;
    padding:8px 14px;font-size:12px;font-family:inherit;color:#333;cursor:pointer;
    box-shadow:0 2px 10px rgba(0,0,0,.18)
  }
  body.ver-leyenda #legend-show{display:none}

  /* ---- Ficha (panel lateral) como hoja inferior, con asa de cerrar ---- */
  #sidebar{max-height:64dvh}
  #sidebar-close{
    display:block;position:sticky;top:0;z-index:5;
    width:100%;border:none;border-bottom:1px solid #eee;
    background:#fff;color:#888;font-family:inherit;font-size:13px;
    padding:12px;cursor:pointer;text-align:center
  }
}
