/*
   historial.css — Sección Historial de Alojamientos + Vehículos en el camping
*/

/* ──────────────────────────────────────────────────────────
   CONTENEDOR PRINCIPAL
────────────────────────────────────────────────────────── */
.hal-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ──────────────────────────────────────────────────────────
   BARRA DE FILTROS
────────────────────────────────────────────────────────── */
.hal-filters {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: .5rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.hal-filters-left {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  flex-wrap: wrap;
}
.hal-field-f {
  position: relative;
  width: 120px;
}
.hal-field-tipo {
  position: relative;
  width: 170px;
}
.hal-inp-f,
.hal-sel-tipo {
  width: 100%;
  height: 42px;
  padding: 0 .625rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-m);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: .875rem;
  font-family: inherit;
  text-transform: uppercase;
  outline: none;
}
.hal-inp-f:focus,
.hal-sel-tipo:focus {
  border-color: var(--color-primary);
}
.hal-btn-primary {
  height: 42px;
  padding: 0 1rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-m);
  font-size: .875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .35rem;
  white-space: nowrap;
  transition: opacity .15s;
}
.hal-btn-primary:hover { opacity: .88; }
.hal-btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.hal-btn-veh {
  height: 42px;
  padding: 0 .875rem;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-m);
  color: var(--color-text-secondary);
  font-size: .8rem;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .35rem;
  white-space: nowrap;
  transition: border-color .15s, color .15s;
}
.hal-btn-veh:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.hal-btn-veh:disabled { opacity: .55; cursor: not-allowed; }
.hal-filters-right {
  display: flex;
  align-items: flex-end;
  gap: .4rem;
}
.hal-btn-print {
  height: 42px;
  width: 42px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-m);
  color: var(--color-text-secondary);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, color .15s;
}
.hal-btn-print:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* ──────────────────────────────────────────────────────────
   BARRA DE ESTADÍSTICAS
────────────────────────────────────────────────────────── */
.hal-stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.hal-stat {
  padding: .6rem 1rem;
  border-right: 1px solid var(--color-border);
  text-align: center;
}
.hal-stat:last-child { border-right: none; }
.hal-stat-v {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-text);
}
.hal-stat-l {
  font-size: .7rem;
  color: var(--color-text-secondary);
  margin-top: 1px;
}

/* ──────────────────────────────────────────────────────────
   PANELES PRINCIPALES
────────────────────────────────────────────────────────── */
.hal-main {
  flex: 1;
  overflow: hidden;
  display: flex;
}
.hal-init-hint,
.hal-loading {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  color: var(--color-text-secondary);
  font-size: .9rem;
  text-align: center;
  padding: 2.5rem;
}
.hal-init-hint i { font-size: 2.5rem; opacity: .3; }
.hal-loading i { font-size: 1.75rem; opacity: .6; }
.hal-init-hint p { max-width: 280px; line-height: 1.5; }

/* ──────────────────────────────────────────────────────────
   PANEL IZQUIERDO — LISTA DE ALOJAMIENTOS
────────────────────────────────────────────────────────── */
.hal-left {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
}
.hal-item {
  padding: .625rem .875rem;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
  transition: background .12s;
}
.hal-item:hover { background: rgba(0,0,0,.04); }
[data-theme="dark"] .hal-item:hover { background: rgba(255,255,255,.05); }
.hal-item--active {
  background: rgba(34,197,94,.1);
  border-left: 3px solid var(--color-primary);
  padding-left: calc(.875rem - 3px);
}
[data-theme="dark"] .hal-item--active { background: rgba(34,197,94,.15); }
.hal-item-info {
  display: flex;
  align-items: baseline;
  gap: .4rem;
  margin-bottom: .3rem;
}
.hal-item-nombre {
  font-weight: 500;
  font-size: .875rem;
  color: var(--color-text);
}
.hal-item-tipo {
  font-size: .68rem;
  color: var(--color-text-secondary);
}
.hal-item-bar-row {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-bottom: .25rem;
}
.hal-item-bar-bg {
  flex: 1;
  height: 5px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
}
.hal-item-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .3s;
}
.hal-item-pct {
  font-size: .72rem;
  font-weight: 700;
  width: 32px;
  text-align: right;
  flex-shrink: 0;
}
.hal-item-meta {
  font-size: .68rem;
  color: var(--color-text-secondary);
}

/* ──────────────────────────────────────────────────────────
   PANEL DERECHO — DETALLE
────────────────────────────────────────────────────────── */
.hal-right {
  flex: 1;
  overflow-y: auto;
}
.hal-right-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  height: 100%;
  color: var(--color-text-secondary);
  font-size: .85rem;
  text-align: center;
  padding: 2rem;
}
.hal-right-hint i { font-size: 2rem; opacity: .25; }

/* Detalle */
.hal-det {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.hal-det-head {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.hal-det-nombre {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
}
.hal-det-tipo {
  font-size: .7rem;
  font-weight: 500;
  padding: .2rem .5rem;
  border-radius: 999px;
  background: var(--color-border);
  color: var(--color-text-secondary);
}
.hal-det-toggle,
.hal-det-print {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-m);
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: .375rem .625rem;
  font-size: .85rem;
  display: flex;
  align-items: center;
  gap: .3rem;
  transition: border-color .15s, color .15s;
}
.hal-det-toggle { margin-left: auto; }
.hal-det-toggle:hover,
.hal-det-print:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.hal-btn-back {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-m);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: .95rem;
  transition: border-color .15s, color .15s;
}
.hal-btn-back:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* Stats del detalle */
.hal-det-stats {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.hal-det-stat {
  flex: 1;
  padding: .75rem 1rem;
  text-align: center;
  border-right: 1px solid var(--color-border);
}
.hal-det-stat:last-child { border-right: none; }
.hal-det-stat-v {
  font-size: 1.25rem;
  font-weight: 700;
}
.hal-det-stat-l {
  font-size: .68rem;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

/* Tabla del detalle */
.hal-det-table-wrap {
  flex: 1;
  overflow-y: auto;
}
.hal-det-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.hal-det-table thead th {
  padding: .625rem 1rem;
  text-align: left;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: var(--color-surface);
}
.hal-det-table .hal-det-n,
.hal-det-table .hal-det-fac { text-align: center; }
.hal-det-row:hover { background: rgba(0,0,0,.03); }
[data-theme="dark"] .hal-det-row:hover { background: rgba(255,255,255,.04); }
.hal-det-td {
  padding: .5rem 1rem;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
}
.hal-det-cli {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hal-det-empty {
  text-align: center;
  padding: 2rem;
  color: var(--color-text-secondary);
  font-size: .875rem;
}
.hal-tag-activa {
  font-size: .72rem;
  font-weight: 500;
  color: var(--color-primary);
  background: rgba(34,197,94,.12);
  padding: .15rem .4rem;
  border-radius: 4px;
}

/* Puntos factura */
.hal-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid var(--color-border);
  background: transparent;
  vertical-align: middle;
}
.hal-dot--ok {
  background: var(--color-primary);
  border-color: var(--color-primary);
}
.hal-det-leyenda {
  padding: .5rem 1rem;
  font-size: .72rem;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: .4rem;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

/* ──────────────────────────────────────────────────────────
   CALENDARIO DE OCUPACIÓN (detalle de alojamiento)
────────────────────────────────────────────────────────── */
.hal-cal-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem 1.25rem;
}
.hal-cal-year {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  font-size: .8rem;
  font-weight: 700;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .75rem;
}
.hal-cal-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: .9rem;
  transition: background .15s, color .15s, border-color .15s;
}
.hal-cal-nav:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}
.hal-cal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 1rem;
}
.hal-cal-mes {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-m);
  padding: .5rem .5rem .625rem;
}
.hal-cal-mes-nombre {
  font-size: .78rem;
  font-weight: 700;
  color: var(--color-text);
  text-align: center;
  margin-bottom: .4rem;
}
.hal-cal-dow,
.hal-cal-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.hal-cal-dow {
  margin-bottom: 2px;
}
.hal-cal-dow span {
  font-size: .6rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-align: center;
}
.hal-cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .68rem;
  border-radius: 4px;
  color: var(--color-text-secondary);
}
.hal-cal-day--empty {
  visibility: hidden;
}
.hal-cal-day--pas {
  background: #ef4444;
  color: #fff;
  font-weight: 500;
}
.hal-cal-day--fut {
  background: #f59e0b;
  color: #fff;
  font-weight: 500;
}
.hal-cal-day--abi {
  background: #3b82f6;
  color: #fff;
  font-weight: 500;
}
.hal-cal-day--today {
  outline: 2px solid var(--color-primary);
  outline-offset: -1px;
}
/* Claves de la leyenda del calendario */
.hal-cal-key {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  vertical-align: middle;
}
.hal-cal-key--pas { background: #ef4444; }
.hal-cal-key--fut { background: #f59e0b; }
.hal-cal-key--abi { background: #3b82f6; }

/* ──────────────────────────────────────────────────────────
   MODAL VEHÍCULOS EN EL CAMPING
────────────────────────────────────────────────────────── */
.hal-veh-ov {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  padding: 1rem;
}
.hal-veh-modal {
  background: var(--color-surface);
  border-radius: var(--radius-l);
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  width: 100%;
  max-width: 760px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.hal-veh-hd {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.hal-veh-titulo { font-size: 1rem; font-weight: 700; color: var(--color-text); }
.hal-veh-sub { font-size: .75rem; color: var(--color-text-secondary); }
.hal-veh-evacuacion {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .375rem .75rem;
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.35);
  border-radius: var(--radius-m);
  color: #dc2626;
  cursor: pointer;
  font-size: .78rem;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: .02em;
  transition: background .15s, border-color .15s;
  flex-shrink: 0;
}
.hal-veh-evacuacion:hover {
  background: rgba(239,68,68,.15);
  border-color: rgba(239,68,68,.6);
}
[data-theme="dark"] .hal-veh-evacuacion {
  background: rgba(239,68,68,.12);
  border-color: rgba(239,68,68,.4);
  color: #f87171;
}
.hal-veh-print,
.hal-veh-close {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-m);
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: .375rem .5rem;
  font-size: .875rem;
  display: flex;
  align-items: center;
  transition: border-color .15s, color .15s;
}
.hal-veh-print:hover { border-color: var(--color-primary); color: var(--color-primary); }
.hal-veh-close:hover { border-color: var(--color-error); color: var(--color-error); }
.hal-veh-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
}
.hal-veh-aviso {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  padding: .625rem .875rem;
  background: rgba(245,158,11,.08);
  border: 1px solid rgba(245,158,11,.25);
  border-radius: var(--radius-m);
  font-size: .78rem;
  color: var(--color-text-secondary);
  margin-bottom: .875rem;
  line-height: 1.4;
}
.hal-veh-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.hal-veh-table thead th {
  padding: .5rem .75rem;
  text-align: left;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-secondary);
  border-bottom: 2px solid var(--color-border);
}
.hal-veh-td {
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
}
.hal-veh-mat { font-weight: 700; font-size: .9rem; letter-spacing: .03em; }
.hal-veh-tr--alt { background: rgba(0,0,0,.025); }
[data-theme="dark"] .hal-veh-tr--alt { background: rgba(255,255,255,.03); }
.hal-veh-empty {
  text-align: center;
  padding: 2rem;
  color: var(--color-text-secondary);
  font-size: .875rem;
}

/* ──────────────────────────────────────────────────────────
   RESPONSIVE
────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  /* Ocultar botón de header en móvil (acceso vía menú) */
  #dbhHistorialBtn { display: none; }

  /* Barra de filtros: columna, items se estiran */
  .hal-filters {
    flex-direction: column;
    align-items: stretch;
    padding: .625rem .75rem;
    gap: .5rem;
  }

  /* Filtros izquierda: grid 2 columnas para alinear campos */
  .hal-filters-left {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .4rem;
    align-items: end;
  }

  /* Desde y Hasta: ocupan 1 columna cada uno */
  .hal-field-f {
    width: auto;
  }

  /* Tipo: ocupa toda la fila */
  .hal-field-tipo {
    grid-column: 1 / -1;
    width: auto;
  }

  /* Botón Consultar: ocupa toda la fila */
  .hal-btn-primary {
    grid-column: 1 / -1;
    justify-content: center;
  }

  /* Botones derecha: fila completa, lado a lado */
  .hal-filters-right {
    display: flex;
    gap: .4rem;
  }
  .hal-btn-veh {
    flex: 1;
    justify-content: center;
  }
  .hal-btn-print {
    flex-shrink: 0;
  }

  /* Stats bar: 2x2 */
  .hal-stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }
  .hal-stat { padding: .5rem .75rem; }
  .hal-stat-v { font-size: .95rem; }

  /* Botón volver: visible en móvil */
  .hal-btn-back { display: flex; }

  /* Paneles: apilados verticalmente */
  .hal-main { flex-direction: column; }

  /* Lista izquierda: ocupa todo por defecto */
  .hal-left {
    width: 100%;
    flex: 1;
    border-right: none;
    border-bottom: none;
  }

  /* Panel detalle: oculto hasta que se seleccione un alojamiento */
  .hal-right { display: none; }

  /* Cuando hay detalle seleccionado: ocultar lista, mostrar detalle */
  .hal-main--showing-detail .hal-left { display: none; }
  .hal-main--showing-detail .hal-right {
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 100%;
  }

  /* Stats del detalle: scroll horizontal */
  .hal-det-stats {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }
  .hal-det-stat {
    min-width: 90px;
    flex-shrink: 0;
    padding: .6rem .75rem;
  }
  .hal-det-stat-v { font-size: 1rem; }

  /* Tabla del detalle: scroll horizontal */
  .hal-det-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .hal-det-table {
    min-width: 500px;
    font-size: .8rem;
  }
  .hal-det-td { padding: .45rem .75rem; white-space: nowrap; }
  .hal-det-cli { max-width: 130px; }

  /* Calendario: 2 mini-meses por fila en móvil */
  .hal-cal-wrap { padding: .75rem; }
  .hal-cal-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: .625rem;
  }

  /* Modal vehículos: tabla scrollable */
  .hal-veh-modal { max-height: 90vh; }
  .hal-veh-body {
    padding: .75rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .hal-veh-table { min-width: 380px; font-size: .8rem; }
  .hal-veh-td { padding: .45rem .625rem; }
}

@media (max-width: 480px) {
  .hal-stat-v { font-size: .875rem; }
  .hal-stat-l { font-size: .65rem; }
  .hal-det-stat { min-width: 80px; }
  /* Ocultar texto de botones para ganar espacio */
  .hal-btn-veh-txt { display: none; }
  .hal-veh-evacuacion span { display: none; }
}
