/* ============================================================
   localizador.css — Sección "Sucursales" integrada al Cotizador
   Adopta la identidad visual del Cotizador (azul AT&T, glass,
   sombras suaves). Todo va scoped a #v-sucursales para no afectar
   al resto de la app. Aditivo: no modifica estilos existentes.
   ============================================================ */

#v-sucursales {
  --loc-brand: #009FDB;
  --loc-brand-strong: #0A73B8;
  --loc-navy: #061F5C;
  --loc-surface: #ffffff;
  --loc-surface-2: #f3f6fb;
  --loc-surface-3: #e9eef6;
  --loc-text: #0f1830;
  --loc-text-2: #55617a;
  --loc-text-3: #8b95ab;
  --loc-border: rgba(6, 31, 92, 0.10);
  --loc-border-strong: rgba(6, 31, 92, 0.18);
  --loc-brand-soft: rgba(0, 159, 219, 0.10);
  --loc-brand-ring: rgba(0, 159, 219, 0.30);
  --loc-glass: rgba(255, 255, 255, 0.82);
  --loc-radius: 16px;
  --loc-shadow: 0 10px 30px rgba(6, 31, 92, 0.12);
  --loc-shadow-sm: 0 2px 10px rgba(6, 31, 92, 0.08);
}

/* ---------------- Layout ---------------- */
#v-sucursales .loc-layout {
  display: grid;
  grid-template-columns: minmax(320px, 380px) 1fr;
  gap: 16px;
  height: min(64vh, 620px);
  min-height: 420px;
}
#v-sucursales .loc-panel {
  background: var(--loc-surface);
  border: 1px solid var(--loc-border);
  border-radius: var(--loc-radius);
  box-shadow: var(--loc-shadow-sm);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  min-height: 0;
}
#v-sucursales .loc-map-wrap {
  position: relative;
  border-radius: var(--loc-radius);
  overflow: hidden;
  border: 1px solid var(--loc-border);
  box-shadow: var(--loc-shadow-sm);
  min-height: 0;
}
#v-sucursales .loc-map { position: absolute; inset: 0; width: 100%; height: 100%; background: var(--loc-surface-3); }

/* ---------------- Buscador ---------------- */
#v-sucursales .loc-search { display: flex; flex-direction: column; gap: 10px; }
#v-sucursales .loc-search__label { font-size: 13px; font-weight: 500; color: var(--loc-text-2); }
#v-sucursales .search__field { position: relative; display: flex; align-items: center; }
#v-sucursales .search__field svg { position: absolute; left: 13px; width: 18px; height: 18px; stroke: var(--loc-text-3); }
#v-sucursales #searchInput {
  width: 100%; height: 46px; padding: 0 14px 0 40px; font-size: 14px;
  color: var(--loc-text); background: var(--loc-surface-2);
  border: 1px solid var(--loc-border); border-radius: var(--loc-radius);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
#v-sucursales #searchInput::placeholder { color: var(--loc-text-3); }
#v-sucursales #searchInput:focus { outline: none; background: #fff; border-color: var(--loc-brand); box-shadow: 0 0 0 4px var(--loc-brand-soft); }

#v-sucursales #useLocationBtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 16px; width: 100%; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--loc-brand-strong);
  background: var(--loc-brand-soft); border: 1px solid var(--loc-brand-ring);
  border-radius: var(--loc-radius); transition: background .15s, border-color .15s;
}
#v-sucursales #useLocationBtn:hover { background: rgba(0,159,219,0.16); }
#v-sucursales #useLocationBtn svg { width: 18px; height: 18px; fill: var(--loc-brand); }

/* ---------------- Dropdown de búsqueda ---------------- */
#v-sucursales .search-results {
  margin-top: 8px; background: #fff; border: 1px solid var(--loc-border);
  border-radius: var(--loc-radius); box-shadow: var(--loc-shadow);
  overflow: hidden; max-height: 320px; overflow-y: auto;
}
#v-sucursales .sr-loading { padding: 12px 16px; font-size: 13px; color: var(--loc-text-3); }
#v-sucursales .sr-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 16px; background: transparent; border: none; cursor: pointer;
  border-bottom: 1px solid var(--loc-border);
}
#v-sucursales .sr-item:last-child { border-bottom: none; }
#v-sucursales .sr-item:hover, #v-sucursales .sr-item.is-active { background: var(--loc-surface-2); }
#v-sucursales .sr-ico { flex: 0 0 auto; width: 22px; text-align: center; font-size: 15px; color: var(--loc-text-3); }
#v-sucursales .sr-ico--branch { color: var(--loc-brand); font-size: 17px; }
#v-sucursales .sr-text { display: flex; flex-direction: column; min-width: 0; }
#v-sucursales .sr-title { font-size: 14px; font-weight: 500; color: var(--loc-text); }
#v-sucursales .sr-sub { font-size: 12px; color: var(--loc-text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#v-sucursales .sr-tag { display: inline-block; font-size: 11px; font-weight: 500; color: var(--loc-text-3); background: var(--loc-surface-3); border-radius: 999px; padding: 1px 7px; margin-left: 4px; }

#v-sucursales .search-status { margin: 8px 0 0; font-size: 12px; padding: 8px 12px; border-radius: 10px; }
#v-sucursales .search-status.is-warn { color: var(--loc-brand-strong); background: var(--loc-brand-soft); border: 1px solid var(--loc-brand-ring); }
#v-sucursales .search-status.is-info { color: var(--loc-text-2); background: var(--loc-surface-2); border: 1px solid var(--loc-border); }

/* ---------------- Resultados / cercanas ---------------- */
#v-sucursales .loc-results { display: flex; flex-direction: column; gap: 12px; }
#v-sucursales .results__title { margin: 0; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--loc-text-3); }
#v-sucursales .empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 5px;
  padding: 16px 14px; background: var(--loc-surface-2); border: 1px dashed var(--loc-border-strong); border-radius: 12px;
}
#v-sucursales .empty__icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--loc-brand-soft); margin-bottom: 2px; }
#v-sucursales .empty__icon svg { width: 16px; height: 16px; fill: var(--loc-brand); }
#v-sucursales .empty__title { margin: 0; font-size: 13px; font-weight: 600; color: var(--loc-text); }
#v-sucursales .empty__text { margin: 0; font-size: 12px; line-height: 1.4; color: var(--loc-text-2); max-width: 28ch; }
#v-sucursales .results__list { display: flex; flex-direction: column; gap: 10px; }

#v-sucursales .near {
  display: flex; flex-direction: column; gap: 4px; width: 100%; text-align: left; position: relative;
  padding: 12px 14px; background: var(--loc-surface-2); border: 1px solid var(--loc-border);
  border-radius: var(--loc-radius); cursor: pointer; transition: border-color .15s, background .15s;
}
#v-sucursales .near:hover { border-color: var(--loc-brand-ring); background: #fff; }
#v-sucursales .near.is-selected { border-color: var(--loc-brand); box-shadow: 0 0 0 3px var(--loc-brand-soft); }
#v-sucursales .near__badge { align-self: flex-start; font-size: 11px; font-weight: 600; color: #fff; background: linear-gradient(150deg, var(--loc-brand), var(--loc-brand-strong)); padding: 2px 9px; border-radius: 999px; margin-bottom: 2px; }
#v-sucursales .near__name { font-size: 14px; font-weight: 600; color: var(--loc-text); }
#v-sucursales .near__meta { font-size: 12px; color: var(--loc-text-3); }
#v-sucursales .near__foot { display: flex; align-items: center; justify-content: space-between; margin-top: 2px; }
#v-sucursales .near__dist { font-size: 13px; font-weight: 600; color: var(--loc-brand-strong); }
#v-sucursales .near__cta { font-size: 12px; font-weight: 500; color: var(--loc-text-2); }

/* ---------------- Detalle en el panel (escritorio) ---------------- */
/* En escritorio, al seleccionar una sucursal el detalle se muestra DENTRO del
   panel (no flota sobre el mapa → nunca se corta). En móvil se usa el sheet. */
#v-sucursales .loc-detail { display: none; }
#v-sucursales .loc-panel.is-detail .loc-search,
#v-sucursales .loc-panel.is-detail #loc-results { display: none !important; }
#v-sucursales .loc-panel.is-detail .loc-detail { display: block; }
#v-sucursales .loc-detail__back {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: 6px; cursor: pointer;
  padding: 7px 12px; border: 1px solid var(--loc-border); border-radius: 999px;
  background: var(--loc-surface-2); color: var(--loc-text-2); font-size: 12px; font-weight: 500;
}
#v-sucursales .loc-detail__back:hover { background: var(--loc-surface-3); color: var(--loc-text); }
@media (max-width: 900px) { #v-sucursales .loc-detail { display: none !important; } }

/* ---------------- Popup / sheet de sucursal ---------------- */
#v-sucursales .branch-popup .maplibregl-popup-content {
  padding: 0; background: var(--loc-glass); backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px); border: 1px solid rgba(255,255,255,.6);
  border-radius: 18px; box-shadow: var(--loc-shadow); overflow: hidden;
}
/* La tarjeta interna hace scroll si el contenido (ruta+transportes) es alto, para
   que NO se corte contra los bordes del mapa. El botón × es hermano y queda fijo. */
#v-sucursales .branch-popup .branch-card { max-height: min(62vh, 400px); overflow-y: auto; overflow-x: hidden; }
#v-sucursales .branch-popup .branch-card__head { padding-right: 26px; } /* deja hueco para la × */
#v-sucursales .branch-popup .maplibregl-popup-close-button { width: 26px; height: 26px; font-size: 18px; color: var(--loc-text-2); border-radius: 50%; margin: 4px; z-index: 2; }
#v-sucursales .branch-popup .maplibregl-popup-close-button:hover { background: var(--loc-surface-3); color: var(--loc-text); }
#v-sucursales .branch-popup.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--loc-glass); }
#v-sucursales .branch-popup.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--loc-glass); }
#v-sucursales .branch-popup.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--loc-glass); }
#v-sucursales .branch-popup.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--loc-glass); }

.branch-sheet { display: none; }
@media (max-width: 900px) {
  #v-sucursales ~ .branch-sheet, .branch-sheet {
    display: flex; flex-direction: column; position: fixed; left: 10px; right: 10px;
    /* Se ancla ARRIBA de la barra de navegación inferior para NO quedar tapada. */
    bottom: calc(var(--nav-h, 72px) + env(safe-area-inset-bottom, 0px) + 10px);
    z-index: 65; max-height: 62vh;
    background: var(--loc-glass, rgba(255,255,255,.9)); backdrop-filter: saturate(160%) blur(18px);
    -webkit-backdrop-filter: saturate(160%) blur(18px); border: 1px solid rgba(255,255,255,.6);
    border-radius: 22px; box-shadow: 0 12px 40px rgba(6,31,92,.28);
    padding: 6px 16px 14px; transform: translateY(calc(100% + 90px)); transition: transform .35s cubic-bezier(.16,1,.3,1);
  }
  .branch-sheet.is-open { transform: translateY(0); }
  .branch-sheet__bar { flex: 0 0 auto; width: 44px; height: 5px; margin: 6px auto 4px; border-radius: 999px; background: rgba(6,31,92,.18); }
  .branch-sheet__close { position: absolute; top: 10px; right: 12px; width: 32px; height: 32px; border: none; border-radius: 50%; background: #e9eef6; color: #55617a; font-size: 20px; cursor: pointer; z-index: 2; }
  .branch-sheet__content { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .branch-sheet .branch-card__head { padding-right: 34px; } /* deja hueco para la × */
}

/* Contenido de la tarjeta (común) */
.branch-card { padding: 18px; }
.branch-sheet .branch-card { padding: 10px 4px 0; }
.branch-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.branch-card__name { margin: 0; font-size: 16px; font-weight: 600; color: #0f1830; line-height: 1.2; }
.branch-card__badge { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 500; color: #0A73B8; background: rgba(0,159,219,.10); border: 1px solid rgba(0,159,219,.30); padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.branch-card__badge .dot { width: 6px; height: 6px; border-radius: 50%; background: #009FDB; }
.branch-card__meta { margin: 0 0 12px; font-size: 13px; color: #8b95ab; }
.branch-card__rows { display: flex; flex-direction: column; gap: 8px; }
.bc-row { display: flex; align-items: flex-start; gap: 8px; }
.bc-row__ico { flex: 0 0 auto; width: 16px; height: 16px; margin-top: 2px; }
.bc-row__ico svg { width: 16px; height: 16px; fill: #8b95ab; }
.bc-row__txt { font-size: 13px; color: #55617a; line-height: 1.45; }
.branch-card__note { margin: 12px 0; font-size: 13px; color: #55617a; background: #f3f6fb; border: 1px solid rgba(6,31,92,.10); border-radius: 10px; padding: 10px 12px; }

/* Cómo llegar / transporte / ruta */
.branch-dir { margin-top: 16px; padding-top: 12px; border-top: 1px solid rgba(6,31,92,.10); }
.branch-dir__dist { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.branch-dir__km { font-size: 16px; font-weight: 600; color: #0f1830; }
.branch-dir__hint { font-size: 12px; color: #8b95ab; }
.modes { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.mode { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border: 1px solid rgba(6,31,92,.10); border-radius: 999px; background: #f3f6fb; color: #55617a; cursor: pointer; font-size: 12px; font-weight: 500; transition: all .15s; }
.mode:hover { border-color: rgba(6,31,92,.18); }
.mode.is-active { background: rgba(0,159,219,.10); border-color: #009FDB; color: #0A73B8; }
.mode__ico { font-size: 14px; line-height: 1; }
.route-info { min-height: 20px; margin-bottom: 12px; }
.route-info__big { font-size: 16px; font-weight: 600; color: #0f1830; }
.route-info__sub { font-size: 12px; color: #8b95ab; display: block; }
.route-info__loading { font-size: 13px; color: #8b95ab; }
.route-info__error { font-size: 13px; color: #0A73B8; }
.gmaps-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 100%; height: 42px;
  border-radius: 12px; font-size: 13px; font-weight: 600; text-decoration: none; cursor: pointer; border: 1px solid transparent;
}
.gmaps-btn.btn--primary { background: linear-gradient(150deg, #009FDB, #0A73B8); color: #fff; }
.gmaps-btn.btn--ghost { background: #fff; border-color: rgba(6,31,92,.14); color: #0f1830; }
.branch-card__actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }

/* Botón "Ver todas / Ver menos" de la lista de cercanas */
#v-sucursales .results__toggle {
  width: 100%; padding: 9px; margin-top: 2px; cursor: pointer;
  border: 1px dashed var(--loc-border-strong); border-radius: 12px; background: transparent;
  color: var(--loc-brand-strong); font-size: 13px; font-weight: 500; transition: background .15s;
}
#v-sucursales .results__toggle:hover { background: var(--loc-brand-soft); }

/* Marcador del usuario (punto azul con halo) — distinto del pin AT&T */
.user-marker { position: relative; width: 20px; height: 20px; }
.user-marker__dot { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); width: 14px; height: 14px; border-radius: 50%; background: #1a73e8; border: 2.5px solid #fff; box-shadow: 0 1px 4px rgba(6,31,92,.4); z-index: 2; }
.user-marker__halo { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); width: 20px; height: 20px; border-radius: 50%; background: rgba(26,115,232,.28); z-index: 1; animation: locUserPulse 2s ease-out infinite; }
@keyframes locUserPulse { 0% { width: 18px; height: 18px; opacity: .6; } 100% { width: 46px; height: 46px; opacity: 0; } }

/* Marcador AT&T (icono symbol de MapLibre; sombra por CSS del contenedor) */
#v-sucursales .marker--branch { cursor: pointer; }

/* Atribución visible */
#v-sucursales .maplibregl-ctrl-attrib { font-size: 11px; }

/* ---------------- Responsive: apilar en móvil ---------------- */
@media (max-width: 900px) {
  #v-sucursales .loc-layout { grid-template-columns: 1fr; height: auto; }
  /* En móvil el MAPA va primero (se ven los pines al abrir); la búsqueda y la lista
     compacta quedan debajo, para que no "empujen" el mapa fuera de la vista. */
  #v-sucursales .loc-map-wrap { height: 46vh; min-height: 300px; order: -1; }
  #v-sucursales .loc-panel { order: 0; }
  #v-sucursales .view-head p { display: none; } /* subtítulo redundante con el placeholder */
}

/* ============================================================
   Administrar sucursales (panel admin) — clases sucadm-*
   El modal vive a nivel de body, por eso NO va scoped a #v-sucursales.
   ============================================================ */
.sucadm-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.sucadm-search {
  flex: 1; min-width: 220px; height: 42px; padding: 0 14px; font-size: 14px;
  border: 1px solid rgba(6,31,92,.14); border-radius: 12px; background: #f7f9fc; color: #0f1830;
}
.sucadm-search:focus { outline: none; border-color: #009FDB; box-shadow: 0 0 0 4px rgba(0,159,219,.12); background:#fff; }
.sucadm-count { font-size: 12px; color: #8b95ab; margin-bottom: 8px; }
.admin-tabla-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid rgba(6,31,92,.10); }
.sucadm-tabla { width: 100%; }
.sucadm-acc { display: flex; gap: 6px; flex-wrap: wrap; }
.sucadm-warn { font-size: 10px; font-weight: 600; color: #b06a00; background: rgba(255,170,0,.14); border-radius: 999px; padding: 1px 7px; margin-left: 4px; }

/* Modal de formulario (más ancho, con scroll interno para no desbordar). */
.sucadm-card {
  max-width: 780px; width: min(92vw, 780px);
  max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.sucadm-form__cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.sucadm-pinlabel { font-size: 13px; font-weight: 500; color: #55617a; margin-bottom: 6px; }
.sucadm-pinlabel small { display: block; font-weight: 400; color: #8b95ab; font-size: 11px; }
.sucadm-pinmap { height: 240px; border-radius: 12px; overflow: hidden; border: 1px solid rgba(6,31,92,.12); background: #eef2f8; }
.sucadm-coords { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.sucadm-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: #0f1830; margin-top: 4px; }
.sucadm-msg { margin-top: 10px; font-size: 13px; color: #c0392b; background: rgba(192,57,43,.08); border: 1px solid rgba(192,57,43,.22); border-radius: 10px; padding: 8px 12px; }
.sucadm-confirm { font-size: 14px; color: #55617a; margin: 6px 0 4px; }
.abtn--danger { background: #c0392b !important; color: #fff !important; border-color: #c0392b !important; }

/* Marcador (pin) del editor admin — diseño propio simple, azul */
.sucadm-pin { width: 22px; height: 30px; cursor: grab; filter: drop-shadow(0 3px 4px rgba(6,31,92,.35)); }
.sucadm-pin::before {
  content: ""; position: absolute; left: 50%; top: 0; transform: translateX(-50%) rotate(45deg);
  width: 20px; height: 20px; background: #009FDB; border: 2px solid #fff;
  border-radius: 50% 50% 50% 0; box-sizing: border-box;
}
.sucadm-pin::after {
  content: ""; position: absolute; left: 50%; top: 6px; transform: translateX(-50%);
  width: 7px; height: 7px; background: #fff; border-radius: 50%;
}

@media (max-width: 720px) {
  .sucadm-form__cols { grid-template-columns: 1fr; }
}

/* Aviso discreto (una línea) cuando hay ubicación pero sin cercanas */
#v-sucursales .loc-results__hint { margin: 0; font-size: 13px; color: var(--loc-text-2); background: var(--loc-surface-2); border: 1px solid var(--loc-border); border-radius: 12px; padding: 10px 12px; }

/* Ícono de la pestaña "Sucursales" (pin de ubicación) — antes salía un cuadro
   porque no tenía definida la variable --ic. Se define en las dos barras. */
.side-nav .tab[data-vista="sucursales"],
.rd-on .rd-left .tab[data-vista="sucursales"] {
  --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 21s6.5-6 6.5-11.2A6.5 6.5 0 0 0 5.5 9.8C5.5 15 12 21 12 21Z'/%3E%3Ccircle cx='12' cy='9.5' r='2.4'/%3E%3C/svg%3E");
}

/* El atributo [hidden] debe ocultar aunque el elemento tenga display propio. */
#v-sucursales .loc-results[hidden] { display: none !important; }
