/* ─────────────────────────────────────────────────────────────────
   AirbnbCalendar — estilos del módulo de calendario multi-apartamento
   Solo modifica este archivo y calendar-airbnb.js.
   ───────────────────────────────────────────────────────────────── */

/* ── Variables ──────────────────────────────────────────────────── */
:root {
  --cal-border:        #EBEBEB;
  --cal-border-light:  #F5F5F5;
  --cal-weekend-bg:    #FAFAFA;
  --cal-today-bg:      #FFF3E0;
  --cal-today-border:  #FF9800;
  --cal-header-bg:     #FFFFFF;
  --cal-sidebar-bg:    #FFFFFF;
  --cal-text-primary:  #222222;
  --cal-text-muted:    #717171;
  --cal-row-hover:     #F7F7F7;
  --cal-bar-height:    28px;
  --cal-row-height:    52px;
  --cal-header-height: 48px;
  --cal-sidebar-width: 200px;
  --cal-font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --cal-radius:        6px;
  --cal-shadow:        0 2px 12px rgba(0,0,0,0.12);
}

/* ── Wrapper general ────────────────────────────────────────────── */
.airbnb-cal-wrapper {
  font-family: var(--cal-font);
  font-size: 13px;
  color: var(--cal-text-primary);
  background: #fff;
  border: 1px solid var(--cal-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--cal-shadow);
  user-select: none;
}

/* ── Título del mes ─────────────────────────────────────────────── */
.airbnb-cal-title {
  padding: 14px 18px 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--cal-text-primary);
  border-bottom: 1px solid var(--cal-border);
  letter-spacing: -0.2px;
}

/* ── Contenedor flex principal ──────────────────────────────────── */
.airbnb-cal {
  display: flex;
  overflow-x: auto;
  overflow-y: visible;
  /* scroll suave en móvil */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
}

.airbnb-cal::-webkit-scrollbar {
  height: 6px;
}
.airbnb-cal::-webkit-scrollbar-track {
  background: transparent;
}
.airbnb-cal::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

/* ── Sidebar (columna de nombres) ───────────────────────────────── */
.airbnb-cal-sidebar {
  width: var(--cal-sidebar-width);
  flex-shrink: 0;
  position: sticky;
  left: 0;
  background: var(--cal-sidebar-bg);
  z-index: 20;
  border-right: 2px solid var(--cal-border);
}

/* Celda vacía del header de la sidebar (alineada con el header del grid) */
.airbnb-cal-sidebar-header {
  height: var(--cal-header-height);
  border-bottom: 1px solid var(--cal-border);
  background: var(--cal-header-bg);
}

/* Nombre de apartamento */
.airbnb-cal-apt-name {
  height: var(--cal-row-height);
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--cal-text-primary);
  border-bottom: 1px solid var(--cal-border-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  transition: background 0.15s;
}

.airbnb-cal-apt-name:hover {
  background: var(--cal-row-hover);
}

/* ── Grid scrollable ────────────────────────────────────────────── */
.airbnb-cal-grid-wrapper {
  flex: 1;
  min-width: 0;
}

/* ── Cabecera de días ───────────────────────────────────────────── */
.airbnb-cal-header {
  display: grid;
  /* grid-template-columns se establece inline desde JS */
  height: var(--cal-header-height);
  border-bottom: 1px solid var(--cal-border);
  background: var(--cal-header-bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.airbnb-cal-header-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--cal-border-light);
  gap: 1px;
  cursor: default;
}

.airbnb-cal-header-cell.is-weekend {
  background: var(--cal-weekend-bg);
}

.airbnb-cal-header-cell.is-today {
  background: var(--cal-today-bg);
  border-top: 2px solid var(--cal-today-border);
}

.airbnb-cal-header-num {
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  color: var(--cal-text-primary);
}

.airbnb-cal-header-dow {
  font-size: 10px;
  font-weight: 400;
  color: var(--cal-text-muted);
  line-height: 1;
  text-transform: uppercase;
}

/* Hoy: número en naranja */
.airbnb-cal-header-cell.is-today .airbnb-cal-header-num {
  color: var(--cal-today-border);
  font-weight: 700;
}

/* ── Filas de apartamentos ──────────────────────────────────────── */
.airbnb-cal-row {
  display: grid;
  /* grid-template-columns se establece inline desde JS */
  height: var(--cal-row-height);
  position: relative;
  border-bottom: 1px solid var(--cal-border-light);
  transition: background 0.12s;
}

.airbnb-cal-row:hover {
  background: var(--cal-row-hover);
}

/* ── Celdas de día ──────────────────────────────────────────────── */
.airbnb-cal-day-cell {
  min-height: var(--cal-row-height);
  position: relative;
  border-right: 1px solid var(--cal-border-light);
  box-sizing: border-box;
  overflow: visible; /* barras se salen por la derecha */
}

.airbnb-cal-day-cell.is-weekend {
  background: var(--cal-weekend-bg);
}

.airbnb-cal-day-cell.is-today {
  background: var(--cal-today-bg);
}

/* ── Barra de reserva ───────────────────────────────────────────── */
.airbnb-cal-bar {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 2px;
  height: var(--cal-bar-height);
  /* width y border-radius se aplican inline desde JS */
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 500;
  color: #fff;
  overflow: hidden;
  white-space: nowrap;
  cursor: pointer;
  z-index: 5;
  transition: filter 0.15s, transform 0.1s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}

.airbnb-cal-bar:hover {
  filter: brightness(1.1);
  transform: translateY(calc(-50% - 1px));
  z-index: 15;
}

/* Nombre del huésped */
.airbnb-cal-bar__name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  font-size: 11px;
}

/* Importe */
.airbnb-cal-bar__amount {
  flex-shrink: 0;
  font-size: 10px;
  opacity: 0.9;
  font-weight: 500;
}

/* Badge de plataforma dentro de la barra */
.airbnb-cal-bar__platform {
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  letter-spacing: 0.3px;
  opacity: 0.95;
}

/* ── Tooltip ────────────────────────────────────────────────────── */
.airbnb-cal-tooltip {
  position: absolute;
  z-index: 9999;
  background: #fff;
  border: 1px solid var(--cal-border);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.16);
  padding: 14px 16px 12px;
  min-width: 220px;
  max-width: 280px;
  font-family: var(--cal-font);
  font-size: 12px;
  color: var(--cal-text-primary);
  animation: calTooltipIn 0.15s ease;
}

@keyframes calTooltipIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.airbnb-cal-tooltip__close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  font-size: 16px;
  line-height: 1;
  color: var(--cal-text-muted);
  cursor: pointer;
  padding: 0 2px;
}
.airbnb-cal-tooltip__close:hover {
  color: var(--cal-text-primary);
}

.airbnb-cal-tooltip__header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  padding-right: 20px;
}

.airbnb-cal-tooltip__guest {
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.airbnb-cal-tooltip__badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.3px;
}

.airbnb-cal-tooltip__apt {
  font-size: 11px;
  color: var(--cal-text-muted);
  margin-bottom: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.airbnb-cal-tooltip__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
  font-size: 12px;
}

.airbnb-cal-tooltip__row span {
  color: var(--cal-text-muted);
  white-space: nowrap;
}

.airbnb-cal-tooltip__row strong {
  font-weight: 600;
  text-align: right;
}

.airbnb-cal-tooltip__code {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--cal-border-light);
  font-size: 10px;
  color: var(--cal-text-muted);
  font-family: monospace;
  word-break: break-all;
}

/* ── Estado vacío ───────────────────────────────────────────────── */
.airbnb-cal-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--cal-text-muted);
  font-size: 13px;
}

/* ── Loader ─────────────────────────────────────────────────────── */
.airbnb-cal-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 20px;
  color: var(--cal-text-muted);
  font-size: 13px;
}

.airbnb-cal-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--cal-border);
  border-top-color: #00897B;
  border-radius: 50%;
  animation: calSpin 0.7s linear infinite;
}

@keyframes calSpin {
  to { transform: rotate(360deg); }
}

/* ── Error ──────────────────────────────────────────────────────── */
.airbnb-cal-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 20px;
  color: #B00020;
  font-size: 13px;
  text-align: center;
}

.airbnb-cal-error__retry {
  background: #B00020;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 7px 18px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.airbnb-cal-error__retry:hover {
  background: #8e001a;
}

/* ─────────────────────────────────────────────────────────────────
   Mobile (≤768px)
   ───────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {

  :root {
    --cal-sidebar-width: 120px;
    --cal-row-height:    44px;
    --cal-header-height: 38px;
    --cal-bar-height:    24px;
  }

  .airbnb-cal-apt-name {
    font-size: 11px;
    padding: 0 8px;
  }

  .airbnb-cal-header-num {
    font-size: 11px;
  }

  .airbnb-cal-header-dow {
    font-size: 9px;
  }

  .airbnb-cal-bar {
    padding: 0 5px;
    font-size: 10px;
  }

  .airbnb-cal-bar__amount,
  .airbnb-cal-bar__platform {
    display: none; /* En mobile solo inicial del nombre */
  }

  .airbnb-cal-title {
    font-size: 13px;
    padding: 10px 14px 8px;
  }

  .airbnb-cal-tooltip {
    min-width: 180px;
    max-width: 240px;
    font-size: 11px;
  }
}

/* ─────────────────────────────────────────────────────────────────
   Print
   ───────────────────────────────────────────────────────────────── */
@media print {
  .airbnb-cal-tooltip { display: none !important; }
  .airbnb-cal { overflow: visible !important; }
  .airbnb-cal-sidebar { position: static !important; }
}
