/* Agenda (Booking). Só o que o Tailwind não expressa: a geometria da grade
   semanal e o empilhamento em camadas. Ver docs/tailwind-migration-patterns.md */

.bookings-page {
  width: 100%;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}

.bookings-page .app-form__form,
.bookings-page .app-form__panel {
  width: 100%;
  max-width: none;
}

.bookings-form {
  width: 100%;
  max-width: 1180px;
}

/* ---------- Grade semanal ---------- */

.bookings-cal-scroll {
  overflow: auto;
  max-height: 70vh;
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  background: #fff;
}

.bookings-cal {
  --bk-row-h: 1.25rem;   /* uma linha = 15 min */
  --bk-gutter: 3.5rem;   /* calha da régua de horas */
  --bk-days: 6;
  --bk-line-soft: #f1f5f9;
  --bk-line-strong: #e2e8f0;

  position: relative;
  display: grid;
  grid-template-columns: var(--bk-gutter) repeat(var(--bk-days), minmax(6.5rem, 1fr));
  /* Linha 1 é o cabeçalho dos dias e dimensiona pelo conteúdo; as linhas
     implícitas (as faixas de 15 min) têm altura fixa. */
  grid-template-rows: auto;
  grid-auto-rows: var(--bk-row-h);
}

/* z-index concentrado aqui de propósito, para não caçar `z-` espalhado no ERB. */
.bookings-cal__corner  { position: sticky; top: 0; left: 0; z-index: 40; background: #fff; }
.bookings-cal__dayhead { position: sticky; top: 0; z-index: 30; background: #fff; }
.bookings-cal__hour    { position: sticky; left: 0; z-index: 20; background: #fff; }
.bookings-cal__slot    { z-index: 0; }
.bookings-cal__block   { z-index: 5; }
.bookings-cal__event   { z-index: 10; }
.bookings-cal__now     { z-index: 15; }

.bookings-cal__corner,
.bookings-cal__dayhead {
  grid-row: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  padding: 0.5rem 0.25rem;
  border-bottom: 1px solid var(--bk-line-strong);
  border-left: 1px solid var(--bk-line-soft);
}

.bookings-cal__dayhead.is-today {
  background: #eff6ff;
  box-shadow: inset 0 -2px 0 0 #1489e5;
}

.bookings-cal__hour {
  grid-column: 1;
  padding-right: 0.5rem;
  text-align: right;
  font-size: 0.6875rem;
  line-height: 1;
  color: #94a3b8;
  border-top: 1px solid var(--bk-line-strong);
}

.bookings-cal__slot {
  border-top: 1px solid var(--bk-line-soft);
  border-left: 1px solid var(--bk-line-soft);
  transition: background-color 120ms ease;
}

/* Cada slot clicável cobre 30 min (2 linhas); a linha da hora cheia é mais forte. */
.bookings-cal__slot.is-hour { border-top-color: var(--bk-line-strong); }
.bookings-cal__slot:hover { background: #eff6ff; }
.bookings-cal__slot.is-off { background: #f8fafc; cursor: default; }
.bookings-cal__slot.is-off:hover { background: #f8fafc; }

.bookings-cal__block {
  margin: 1px;
  border-radius: 0.375rem;
  background: repeating-linear-gradient(45deg, #f1f5f9 0 6px, #e2e8f0 6px 12px);
  pointer-events: none;
}

/* ---------- Evento ---------- */

.bookings-cal__event {
  --bk-lane: 0;
  --bk-lanes: 1;

  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.0625rem;
  overflow: hidden;
  justify-self: start;
  width: calc(100% / var(--bk-lanes) - 2px);
  margin-inline-start: calc(100% / var(--bk-lanes) * var(--bk-lane));
  padding: 0.1875rem 0.375rem;
  border-radius: 0.375rem;
  border-left-width: 3px;
  border-left-style: solid;
  background: #fff;
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.08);
  font-size: 0.6875rem;
  line-height: 1.15;
  text-decoration: none;
}

.bookings-cal__event:hover { box-shadow: 0 4px 10px rgb(15 23 42 / 0.12); }

.bookings-cal__event.is-cancelled { opacity: 0.6; }
.bookings-cal__event.is-cancelled .bookings-cal__event-title { text-decoration: line-through; }

.bookings-cal__event-time { font-weight: 600; color: #64748b; }
.bookings-cal__event-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.bookings-cal__more {
  font-size: 0.625rem;
  font-weight: 600;
  color: #64748b;
}

/* ---------- Linha do "agora" ---------- */

.bookings-cal__now {
  position: absolute;
  top: var(--bk-now-top, 0);
  left: var(--bk-gutter);
  right: 0;
  height: 1px;
  background: #f43f5e;
  pointer-events: none;
}

.bookings-cal__now::before {
  content: "";
  position: absolute;
  left: -3px;
  top: -3px;
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background: #f43f5e;
}

/* ---------- Impressão ---------- */
/* A agenda do dia é impressa no balcão. */
@media print {
  .bookings-cal-scroll { overflow: visible; max-height: none; border: 0; }
  .bookings-cal { --bk-row-h: 1.5rem; }
  .bookings-cal__slot:hover { background: transparent; }
}
