/* =====================================================================
   estilos.css — Plataforma de Reportes Ciudadanos de Emergencias, Tacna
   FASE 1: demo visual. Bootstrap 5 hace la base; aquí va lo propio.
   Criterio: limpio, didáctico, mobile-first y con los colores de la
   leyenda de tipos de incidente siempre coherentes.
   ===================================================================== */

:root {
  /* Colores por tipo de incidente (los mismos que js/config.js) */
  --c-inundacion: #1d4ed8;
  --c-desague:    #8b5a2b;
  --c-tuberia:    #38bdf8;
  --c-huaico:     #dc2626;
  --c-calle:      #f59e0b;

  /* Identidad de la plataforma (colores corporativos de Fuerza Tacna) */
  --marca:        var(--ft-vino);
  --marca-claro:  var(--ft-dorado);
  --tinta:        #0f172a;
  --tinta-suave:  #475569;
  --linea:        #e2e8f0;
  --fondo:        #f1f5f9;
  --panel:        #ffffff;

  --alto-navbar:  60px;
  --radio:        14px;
  --sombra:       0 6px 24px rgba(15, 23, 42, .10);

  /* Colores corporativos de Fuerza Tacna (yovotopormiguelito.creala.online) */
  --ft-vino:      #5C1622;
  --ft-dorado:    #F0A500;
  --ft-crema:     #F4F2F0;
  /* Variante clara del vino para degradés, sin perder contraste con texto blanco */
  --ft-vino-claro: color-mix(in srgb, var(--ft-vino) 65%, white);
}

/* ------------------------------- Base ------------------------------ */
html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--tinta);
  background: var(--fondo);
  overscroll-behavior-y: none;
}

.texto-suave { color: var(--tinta-suave); }

/* ------------------------------ Navbar ----------------------------- */
.navbar-plataforma {
  height: var(--alto-navbar);
  background: linear-gradient(100deg, var(--marca) 0%, var(--ft-vino-claro) 100%);
  box-shadow: 0 2px 12px rgba(92, 22, 34, .35);
  z-index: 1035;
}

.navbar-plataforma .navbar-brand {
  font-weight: 700;
  letter-spacing: .2px;
  display: flex;
  align-items: center;
  gap: .55rem;
  color: #fff;
}

.marca-icono {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 10px;
  font-size: 1.05rem;
}

.marca-sub {
  font-size: .70rem;
  font-weight: 500;
  opacity: .85;
  display: block;
  line-height: 1;
  margin-top: 2px;
}

/* Punto latiendo = "el mapa está vivo" */
.pulso-vivo {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 0 rgba(74, 222, 128, .8);
  animation: latido 1.9s infinite;
}
@keyframes latido {
  70%  { box-shadow: 0 0 0 9px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0  rgba(74, 222, 128, 0); }
}

/* ---------------------- Estructura del dashboard ------------------- */
.area-trabajo {
  display: flex;
  height: calc(100vh - var(--alto-navbar));
  height: calc(100dvh - var(--alto-navbar));
}

.panel-lateral {
  width: 380px;
  flex: 0 0 380px;
  background: var(--panel);
  border-right: 1px solid var(--linea);
  overflow-y: auto;
  padding: 1rem;
}

.zona-mapa {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

#mapa, #mapaReporte {
  width: 100%;
  height: 100%;
  background: #dfe6ec;
}

/* ------------------------ Tarjetas del panel ----------------------- */
.tarjeta {
  background: var(--panel);
  border: 1px solid var(--linea);
  border-radius: var(--radio);
  padding: .9rem 1rem;
  margin-bottom: .85rem;
}

.titulo-bloque {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--tinta-suave);
  margin-bottom: .6rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}

/* ---------------------- Estadísticas (KPI) ------------------------- */
.grid-kpi {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .6rem;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--linea);
  border-radius: var(--radio);
  padding: .75rem .85rem;
  position: relative;
  overflow: hidden;
}

.kpi::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--marca-claro);
}

.kpi.kpi-critico::after { background: var(--c-huaico); }
.kpi.kpi-ok::after      { background: #16a34a; }
.kpi.kpi-espera::after  { background: var(--c-calle); }

.kpi-numero {
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -.02em;
}

.kpi-texto {
  font-size: .74rem;
  color: var(--tinta-suave);
  line-height: 1.25;
}

/* --------------------- Filtros por tipo (chips) -------------------- */
.chips-tipo {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.chip-tipo {
  border: 1.5px solid var(--linea);
  background: #fff;
  border-radius: 999px;
  padding: .34rem .7rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--tinta-suave);
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  cursor: pointer;
  transition: all .15s ease;
  line-height: 1.2;
}

.chip-tipo:hover { border-color: #cbd5e1; background: #f8fafc; }

.chip-tipo .conteo {
  font-size: .7rem;
  background: #eef2f6;
  border-radius: 999px;
  padding: 0 .38rem;
  font-weight: 700;
}

/* Chip activo: toma el color de su tipo (coherente con la leyenda) */
.chip-tipo.activo {
  color: #fff;
  border-color: transparent;
  background: var(--color-tipo, var(--marca));
}
.chip-tipo.activo .conteo {
  background: rgba(255, 255, 255, .25);
  color: #fff;
}

/* ------------------------------ Leyenda ---------------------------- */
.leyenda-item {
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  padding: .3rem 0;
  font-size: .82rem;
}

.leyenda-pin {
  width: 26px; height: 26px;
  flex: 0 0 26px;
  border-radius: 50% 50% 50% 6px;
  transform: rotate(45deg);
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, .22);
}
.leyenda-pin span { transform: rotate(-45deg); font-size: .8rem; }

.leyenda-texto strong { display: block; font-size: .82rem; }
.leyenda-texto small  { color: var(--tinta-suave); font-size: .72rem; }

/* ------------------- Lista de reportes recientes ------------------- */
.lista-reportes { display: flex; flex-direction: column; gap: .5rem; }

.item-reporte {
  display: flex;
  gap: .6rem;
  align-items: center;
  border: 1px solid var(--linea);
  border-left: 4px solid var(--color-tipo, var(--marca));
  border-radius: 10px;
  padding: .5rem .6rem;
  background: #fff;
  cursor: pointer;
  transition: box-shadow .15s ease, transform .15s ease;
  text-align: left;
  width: 100%;
}

.item-reporte:hover {
  box-shadow: var(--sombra);
  transform: translateY(-1px);
}

.item-reporte img {
  width: 46px; height: 46px;
  object-fit: cover;
  border-radius: 8px;
  flex: 0 0 46px;
}

.item-reporte .info { min-width: 0; flex: 1 1 auto; }
.item-reporte .info strong {
  display: block;
  font-size: .82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-reporte .info small {
  color: var(--tinta-suave);
  font-size: .72rem;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-reporte.recien-llegado {
  animation: entrada 2.6s ease;
}
@keyframes entrada {
  0%   { background: #ecfdf5; box-shadow: 0 0 0 3px rgba(16, 185, 129, .35); }
  100% { background: #fff; }
}

/* ------------------------- Badges de estado ------------------------ */
.badge-estado {
  font-size: .68rem;
  font-weight: 700;
  padding: .22rem .5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.estado-nuevo    { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.estado-revision { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.estado-atendido { background: #dcfce7; color: #166534; border-color: #bbf7d0; }

.badge-gravedad {
  font-size: .68rem;
  font-weight: 700;
  padding: .22rem .5rem;
  border-radius: 999px;
}
.gravedad-baja  { background: #ecfdf5; color: #047857; }
.gravedad-media { background: #fffbeb; color: #b45309; }
.gravedad-alta  { background: #fef2f2; color: #b91c1c; }

/* --------------------- InfoWindow del marcador --------------------- */
.gm-style .gm-style-iw-c { padding: 0 !important; border-radius: 14px !important; }
.gm-style .gm-style-iw-d { overflow: hidden !important; padding: 0 !important; }

.ficha {
  width: 290px;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

.ficha-cabecera {
  padding: .6rem .8rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: .45rem;
  font-weight: 700;
  font-size: .88rem;
}

.ficha-foto {
  width: 100%;
  height: 148px;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
  background: #e2e8f0;
}

.ficha-cuerpo { padding: .7rem .8rem .85rem; }

.ficha-comentario {
  font-size: .85rem;
  line-height: 1.4;
  margin-bottom: .6rem;
  color: var(--tinta);
}

.ficha-dato {
  display: flex;
  gap: .45rem;
  font-size: .76rem;
  color: var(--tinta-suave);
  padding: .13rem 0;
  align-items: flex-start;
}
.ficha-dato .etiqueta { flex: 0 0 20px; text-align: center; }

.ficha-coords {
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  font-size: .72rem;
}

.ficha-privacidad {
  margin-top: .55rem;
  font-size: .68rem;
  color: #64748b;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: .35rem .5rem;
  line-height: 1.3;
}

.ficha-miniaturas { display: flex; gap: .3rem; padding: .35rem .8rem 0; }
.ficha-miniaturas img {
  width: 42px; height: 42px;
  border-radius: 6px;
  object-fit: cover;
  cursor: zoom-in;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, .2);
}

/* --------------------- Controles sobre el mapa --------------------- */
.control-mapa {
  position: absolute;
  z-index: 5;
}

.aviso-tiempo-real {
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, .92);
  color: #fff;
  border-radius: 999px;
  padding: .45rem .9rem;
  font-size: .8rem;
  font-weight: 600;
  box-shadow: var(--sombra);
  display: flex;
  align-items: center;
  gap: .45rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
}
.aviso-tiempo-real.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

.boton-reportar-flotante {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1030;
  border-radius: 999px;
  padding: .8rem 1.3rem;
  font-weight: 700;
  box-shadow: 0 10px 26px rgba(220, 38, 38, .38);
}

/* Aviso cuando falta la API key de Google Maps */
.aviso-sin-key {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: repeating-linear-gradient(45deg, #eef2f6, #eef2f6 12px, #e6ebf1 12px, #e6ebf1 24px);
  z-index: 6;
}
.aviso-sin-key .caja {
  background: #fff;
  border: 1px solid var(--linea);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  max-width: 460px;
  padding: 1.4rem 1.5rem;
}
.aviso-sin-key code {
  background: #f1f5f9;
  padding: .1rem .35rem;
  border-radius: 5px;
  color: #b91c1c;
}

/* ---------------------- Formulario ciudadano ----------------------- */
.pagina-formulario { background: var(--fondo); }

.cabecera-form {
  background: linear-gradient(100deg, var(--marca) 0%, var(--ft-vino-claro) 100%);
  color: #fff;
  padding: 1.3rem 0 2.6rem;
}

.tarjeta-form {
  background: #fff;
  border: 1px solid var(--linea);
  border-radius: 18px;
  box-shadow: var(--sombra);
  margin-top: -1.6rem;
}

.paso {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-weight: 700;
  font-size: .95rem;
  margin-bottom: .8rem;
}
.paso .numero {
  width: 27px; height: 27px;
  flex: 0 0 27px;
  border-radius: 50%;
  background: var(--marca-claro);
  color: var(--ft-vino);
  display: grid;
  place-items: center;
  font-size: .82rem;
}

.form-label { font-weight: 600; font-size: .87rem; }
.form-text  { font-size: .76rem; }

.form-control:focus, .form-select:focus {
  border-color: var(--marca-claro);
  box-shadow: 0 0 0 .2rem rgba(240, 165, 0, .25);
}

/* Selector visual de tipo de incidente */
.opciones-tipo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .5rem;
}

.opcion-tipo input { position: absolute; opacity: 0; pointer-events: none; }

.opcion-tipo label {
  display: flex;
  align-items: center;
  gap: .5rem;
  border: 2px solid var(--linea);
  border-radius: 12px;
  padding: .6rem .65rem;
  cursor: pointer;
  font-size: .84rem;
  font-weight: 600;
  height: 100%;
  transition: all .15s ease;
  background: #fff;
}
.opcion-tipo label .icono { font-size: 1.3rem; line-height: 1; }
.opcion-tipo label:hover { border-color: #cbd5e1; }

.opcion-tipo input:checked + label {
  border-color: var(--color-tipo);
  background: color-mix(in srgb, var(--color-tipo) 10%, #fff);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-tipo) 22%, transparent);
}
.opcion-tipo input:focus-visible + label { outline: 2px solid var(--marca-claro); outline-offset: 2px; }

/* Selector de gravedad */
.opciones-gravedad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.opciones-gravedad input { position: absolute; opacity: 0; pointer-events: none; }
.opciones-gravedad label {
  border: 2px solid var(--linea);
  border-radius: 12px;
  padding: .55rem .4rem;
  text-align: center;
  cursor: pointer;
  font-weight: 700;
  font-size: .82rem;
  background: #fff;
  display: block;
}
.opciones-gravedad label small { display: block; font-weight: 500; font-size: .68rem; color: var(--tinta-suave); }
.opciones-gravedad input:checked + label.g-baja  { border-color: #16a34a; background: #f0fdf4; }
.opciones-gravedad input:checked + label.g-media { border-color: #f59e0b; background: #fffbeb; }
.opciones-gravedad input:checked + label.g-alta  { border-color: #dc2626; background: #fef2f2; }

/* Mapa del formulario */
.caja-mapa-form {
  height: 300px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--linea);
  position: relative;
}

.pista-arrastrar {
  position: absolute;
  bottom: 10px; left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, .88);
  color: #fff;
  font-size: .74rem;
  padding: .32rem .7rem;
  border-radius: 999px;
  z-index: 3;
  white-space: nowrap;
}

/* Vista previa de fotos */
.previa-fotos { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.previa-fotos figure {
  position: relative;
  margin: 0;
  width: 86px; height: 86px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--linea);
}
.previa-fotos img { width: 100%; height: 100%; object-fit: cover; }
.previa-fotos button {
  position: absolute;
  top: 3px; right: 3px;
  width: 21px; height: 21px;
  border: none;
  border-radius: 50%;
  background: rgba(15, 23, 42, .75);
  color: #fff;
  font-size: .75rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
}

/* Aviso legal de privacidad */
.caja-privacidad {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 12px;
  padding: .8rem .9rem;
  font-size: .8rem;
  line-height: 1.45;
}
.caja-privacidad .titulo { font-weight: 700; display: flex; align-items: center; gap: .4rem; margin-bottom: .25rem; }

/* Destinatarios del informe */
.entidad {
  display: flex;
  gap: .6rem;
  align-items: flex-start;
  font-size: .78rem;
  padding: .4rem 0;
  border-bottom: 1px dashed var(--linea);
}
.entidad:last-child { border-bottom: none; }
.entidad .escudo {
  width: 30px; height: 30px;
  flex: 0 0 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #eef4f8;
  border: 1px solid var(--linea);
}

/* ----------------------------- Responsive -------------------------- */
@media (max-width: 991.98px) {
  .area-trabajo { display: block; height: auto; }

  .panel-lateral {
    width: 100%;
    flex: none;
    border-right: none;
    border-bottom: 1px solid var(--linea);
    overflow: visible;
    padding: .85rem;
  }

  .zona-mapa {
    height: 62vh;
    height: 62dvh;
    position: relative;
  }

  /* En celular el mapa va primero: es lo que el vecino quiere ver */
  .orden-mapa-primero { display: flex; flex-direction: column; }
  .orden-mapa-primero .zona-mapa    { order: 1; }
  .orden-mapa-primero .panel-lateral { order: 2; }

  .ficha { width: 240px; }
  .ficha-foto { height: 128px; }
}

@media (max-width: 575.98px) {
  .grid-kpi { grid-template-columns: repeat(2, 1fr); }
  .kpi-numero { font-size: 1.4rem; }
  .boton-reportar-flotante { right: 12px; bottom: 12px; padding: .7rem 1.05rem; }
  .caja-mapa-form { height: 260px; }
}

/* --------- Crédito discreto del partido (pie de página / panel) ---------- */
.pie-partido {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .7rem;
  color: var(--tinta-suave);
  line-height: 1.3;
}

.pie-partido-ft {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--ft-vino);
  color: var(--ft-dorado);
  font-weight: 800;
  font-size: .68rem;
  letter-spacing: .02em;
}

.pie-partido a {
  color: var(--ft-vino);
  font-weight: 700;
  text-decoration: none;
}
.pie-partido a:hover { text-decoration: underline; color: var(--ft-dorado); }

/* Como <footer> en páginas de scroll normal (formulario, admin) */
footer.pie-partido {
  flex-direction: column;
  gap: .35rem;
  padding: .9rem 1rem;
  background: var(--ft-crema);
  border-top: 1px solid var(--linea);
}

footer.pie-partido .pie-partido-linea {
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* Crédito del desarrollador, más discreto que el del partido */
.pie-dev {
  font-size: .66rem;
  color: var(--tinta-suave);
  opacity: .85;
}
.pie-dev a {
  color: var(--tinta-suave);
  text-decoration: underline;
}
.pie-dev a:hover { color: var(--ft-vino); }
