/* ── Header ── */
.app-header { position: sticky; top: 0; z-index: 100; }
.app-header h1 { font-size: 1.05rem; }
.header-right { display: flex; align-items: center; gap: .5rem; }
.btn-volver {
  background: rgba(255,255,255,.18); border: none; color: white;
  border-radius: 8px; padding: .28rem .65rem; font-size: .78rem;
  cursor: pointer; text-decoration: none;
}

/* ── Tabs principales ── */
.tabs-main {
  display: flex; background: white; border-bottom: 2px solid #eceff1;
  position: sticky; top: 64px; z-index: 90;
}
.tab-main {
  flex: 1; padding: .78rem .3rem; border: none; background: none; cursor: pointer;
  font-size: .82rem; color: var(--suave); font-weight: 600;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
  transition: color .2s, border-color .2s; white-space: nowrap;
}
.tab-main.active { color: var(--azul2); border-bottom-color: var(--azul2); }

/* sections controlled by Alpine x-show */

/* ── Mapa ── */
#mainMap { width: 100%; height: 56vh; }
.mapa-toolbar {
  background: white; padding: .6rem 1rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid #eceff1; position: sticky; top: 110px; z-index: 80;
}
.mapa-count { font-size: .84rem; color: var(--suave); }
.btn-gps-mapa {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .4rem .9rem; background: var(--azul2); color: white;
  border: none; border-radius: 20px; font-size: .82rem; font-weight: 600; cursor: pointer;
}
.mapa-leyenda {
  background: white; border-top: 1px solid #eceff1; padding: .55rem 1rem;
  display: flex; gap: 1rem; flex-wrap: wrap; font-size: .75rem; color: var(--suave);
}
.leyenda-item { display: flex; align-items: center; gap: .3rem; }
.leyenda-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ── Sección interna ── */
.section-toolbar {
  background: white; padding: .7rem 1rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid #eceff1;
}
.section-toolbar h2 { font-size: .95rem; font-weight: 700; color: var(--azul); }
.btn-agregar {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .45rem 1rem; background: var(--azul); color: white;
  border: none; border-radius: 8px; font-size: .85rem; font-weight: 700;
  cursor: pointer; transition: background .2s;
}
.btn-agregar:hover { background: var(--azul2); }

.section-body { padding: 1rem 1rem 5rem; max-width: 560px; margin: 0 auto; box-sizing: border-box; }

/* ── Formulario ── */
.form-panel {
  background: white; border-radius: 14px;
  box-shadow: 0 2px 16px rgba(0,0,0,.10);
  padding: 1.2rem 1rem; margin-bottom: 1rem;
  border-left: 4px solid var(--azul2);
  /* evita solapamiento con controles sticky superiores */
  position: relative; z-index: 1;
}
.form-panel h3 { font-size: 1rem; font-weight: 700; color: var(--azul); margin-bottom: 1rem; }

.field-group { margin-bottom: 1.1rem; }
.field-group label { display: block; font-size: .86rem; font-weight: 600; color: var(--texto); margin-bottom: .4rem; }
.opc { color: var(--suave); font-weight: 400; font-size: .76rem; margin-left: .25rem; }

input[type="text"],
input[type="tel"],
input[type="number"],
select,
textarea {
  width: 100%; border: 1.5px solid var(--borde); border-radius: 8px;
  padding: .7rem .9rem; font-size: .95rem; color: var(--texto);
  font-family: inherit; outline: none; transition: border-color .2s; background: white;
  -moz-appearance: textfield;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
input:focus, select:focus, textarea:focus { border-color: var(--azul2); }
textarea { resize: vertical; min-height: 75px; }
select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='%236b7a8d' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .75rem center;
}

/* ── Días disponibles ── */
.dias-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; }
.dia-opt { cursor: pointer; text-align: center; }
.dia-opt input[type="checkbox"] { display: none; }
.dia-pill {
  display: block; padding: .45rem .3rem; border-radius: 8px; font-size: .78rem;
  font-weight: 600; border: 1.5px solid var(--borde); color: var(--suave);
  transition: all .15s; background: white;
}
.dia-opt input:checked + .dia-pill { background: var(--azul); color: white; border-color: var(--azul); }

/* ── Mapa mini ── */
.mapa-mini-wrap {
  border: 1.5px solid var(--borde); border-radius: 10px; overflow: hidden;
  position: relative; margin-bottom: .5rem;
  /* evita que el mapa Leaflet se solape con headers sticky */
  isolation: isolate;
}
#mapaMini { width: 100%; height: 220px; }
/* forzar que controles de Leaflet queden dentro del contexto de apilamiento */
#mapaMini .leaflet-top,
#mapaMini .leaflet-bottom { z-index: 400; }
.mapa-mini-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,.5); color: white; font-size: .72rem;
  text-align: center; padding: .35rem; pointer-events: none;
  z-index: 5;
}
.btn-gps-mini {
  display: flex; align-items: center; justify-content: center; gap: .4rem;
  width: 100%; padding: .65rem 1.1rem; background: var(--azul); color: white;
  border: none; border-radius: 8px; font-size: .9rem; font-weight: 600;
  cursor: pointer; margin-bottom: .5rem;
}
.btn-gps-mini:disabled { opacity: .6; cursor: not-allowed; }
.coords-txt { font-size: .76rem; color: var(--suave); min-height: 1.1em; }

.territorio-nota {
  font-size: .8rem;
  color: #37474f;
  background: #f3f7ff;
  border: 1px solid #d7e3ff;
  border-radius: 8px;
  padding: .6rem .7rem;
  margin: -.2rem 0 .9rem;
}

/* ── Fotos ── */
.fotos-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; margin-bottom: .6rem; }
.foto-wrap { position: relative; border-radius: 8px; overflow: hidden; aspect-ratio: 1; }
.foto-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.btn-del-foto {
  position: absolute; top: 3px; right: 3px;
  background: rgba(0,0,0,.55); color: white; border: none;
  border-radius: 50%; width: 24px; height: 24px; font-size: .7rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.btn-del-foto:hover { background: rgba(198,40,40,.85); }
.foto-add-btns { display: flex; gap: .5rem; flex-wrap: wrap; }
.btn-foto-add {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .55rem 1rem; border-radius: 8px; font-size: .88rem; font-weight: 600;
  cursor: pointer; border: none; position: relative; overflow: hidden;
}
.btn-foto-add input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.btn-foto-camara  { background: var(--azul2); color: white; }
.btn-foto-galeria { background: #eceff1; color: #37474f; }

.form-btns { display: flex; gap: .6rem; }
.btn-save {
  flex: 1; padding: .8rem; background: var(--azul); color: white;
  border: none; border-radius: 9px; font-size: .95rem; font-weight: 700;
  cursor: pointer; transition: background .2s;
}
.btn-save:hover { background: var(--azul2); }
.btn-save:disabled { opacity: .6; cursor: not-allowed; }
.btn-cancel {
  padding: .8rem 1.2rem; background: #eceff1; color: var(--texto);
  border: none; border-radius: 9px; font-size: .95rem; font-weight: 600;
  cursor: pointer; transition: background .2s;
}
.btn-cancel:hover { background: var(--borde); }

/* Banners inline */
.banner-ok  { background: #e8f5e9; border: 1px solid #a5d6a7; color: #1b5e20; }
.banner-err { background: #fce4ec; border: 1px solid #f48fb1; color: #880e4f; }

/* ── Cards encuentros ── */
.enc-card {
  background: white; border-radius: 14px;
  box-shadow: 0 1px 8px rgba(0,0,0,.08); margin-bottom: .9rem; overflow: hidden;
}
.enc-fotos { display: flex; gap: 2px; overflow-x: auto; background: #eceff1; scrollbar-width: none; }
.enc-fotos::-webkit-scrollbar { display: none; }
.enc-fotos img { height: 150px; min-width: 210px; object-fit: cover; cursor: pointer; flex-shrink: 0; transition: opacity .2s; }
.enc-fotos img:hover { opacity: .88; }
.enc-fotos.una img { width: 100%; min-width: 0; }
.enc-body { padding: .9rem 1rem; }
.enc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.enc-nombre { font-size: 1rem; font-weight: 700; color: var(--azul); }
.enc-dir { font-size: .85rem; color: var(--suave); margin-bottom: .45rem; }
.enc-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .5rem; }
.chip { font-size: .76rem; background: var(--gris); border-radius: 20px; padding: .18rem .55rem; color: var(--suave); }
.acceso-badge { font-size: .75rem; font-weight: 700; border-radius: 20px; padding: .2rem .6rem; flex-shrink: 0; }
.enc-notas { font-size: .83rem; color: var(--suave); border-top: 1px solid #eceff1; padding-top: .5rem; }
.enc-fecha { font-size: .7rem; color: #b0bec5; margin-top: .4rem; }
.card-actions { display: flex; gap: .4rem; margin-top: .7rem; }
.btn-edit { flex: 1; padding: .5rem; background: #e8f0fe; color: var(--azul2); border: none; border-radius: 7px; font-size: .85rem; font-weight: 600; cursor: pointer; }
.btn-edit:hover { background: #c5d8fc; }
.btn-map  { padding: .5rem .8rem; background: #e8f5e9; color: var(--verde); border: none; border-radius: 7px; font-size: .85rem; font-weight: 600; cursor: pointer; }
.btn-map:hover { background: #c8e6c9; }
.btn-del  { padding: .5rem .8rem; background: #fce4ec; color: var(--rojo); border: none; border-radius: 7px; font-size: .85rem; font-weight: 600; cursor: pointer; }
.btn-del:hover { background: #f8bbd0; }

/* ── Cards conductores ── */
.cond-card {
  background: white; border-radius: 14px;
  box-shadow: 0 1px 8px rgba(0,0,0,.08); margin-bottom: .9rem; padding: 1rem 1.1rem;
}
.cond-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: .5rem; gap: .5rem; }
.cond-nombre { font-size: 1rem; font-weight: 700; color: var(--azul); }
.cond-vehiculo-badge { font-size: .75rem; font-weight: 700; border-radius: 20px; padding: .2rem .65rem; background: #e3f2fd; color: #1565c0; flex-shrink: 0; white-space: nowrap; }
.cond-tel { font-size: .9rem; margin-bottom: .4rem; }
.cond-tel a { color: var(--azul2); text-decoration: none; font-weight: 600; }
.cond-tel a:hover { text-decoration: underline; }
.cond-info { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .45rem; }
.cond-chip-cap  { background: #fff3e0; color: var(--naranja); border-radius: 20px; padding: .18rem .55rem; font-size: .76rem; font-weight: 600; }
.cond-chip-zona { background: #e8f5e9; color: var(--verde);   border-radius: 20px; padding: .18rem .55rem; font-size: .76rem; font-weight: 600; }
.dias-badges { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .4rem; }
.dia-badge { font-size: .72rem; background: #e8f0fe; color: var(--azul2); border-radius: 6px; padding: .15rem .45rem; font-weight: 600; }
.cond-notas { font-size: .82rem; color: var(--suave); border-top: 1px solid #eceff1; padding-top: .45rem; }
.cond-fecha { font-size: .7rem; color: #b0bec5; margin-top: .4rem; }

/* ── Popup Leaflet ── */
.popup-enc { min-width: 190px; }
.popup-enc h4 { color: var(--azul); margin-bottom: .3rem; font-size: .92rem; }
.popup-enc p  { font-size: .8rem; color: var(--suave); margin-bottom: .18rem; }
.popup-enc img { width: 100%; height: 100px; object-fit: cover; border-radius: 6px; margin-top: .4rem; }
