/**
 * NorthPathOS · Agenda grid CSS (ticket 853, batch 5e)
 *
 * Week/day hourly grid chrome, lanes, cards and shading. Every color here is
 * a var(--agenda-*) token from lib/agenda-tokens.css (batch 5d) or an
 * existing generic app token (--text/--surface-2/--border-color/etc, already
 * used across the rest of the admin UI) -- NO hex literal anywhere in this
 * file (enforced by a dedicated test, same idiom as
 * admin/tests/agenda-tokens.test.mjs). Layout math (pixel positions/heights)
 * is computed in admin/modules/agenda-grid.js and applied as inline
 * style="top:...;height:..." -- this file only supplies color/border/shape.
 */

.ag-page {
  /* ticket 853 5f: reserve the floating chat / quick-action buttons' strip
     (fixed at right 20px, about 54px wide) so they never cover grid lanes,
     cards or the bottom cards. */
  padding-right: 80px;
}
@media (max-width: 480px) { .ag-page { padding-right: 64px; } }

/* ticket 853 5f toolbar: row 1 = nav left, view dropdown + actions right;
   row 2 = the three filters directly under the nav. */
.ag-toolbar {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-top: .75rem;
  margin-bottom: .5rem;
}
.ag-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}
.ag-toolbar-row1 { justify-content: space-between; }
.ag-toolbar-actions {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
  margin-left: auto;
}
.ag-view-select { width: auto; min-width: 7.5rem; }
.ag-nav, .ag-filters {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}
.ag-toolbar-row2 { justify-content: flex-start; }
.ag-filter { min-width: 150px; flex: 0 1 220px; }
.ag-view-on { font-weight: 700; background: var(--agenda-accent-soft); }
.ag-own-scope-label {
  font-size: .82rem;
  font-weight: 600;
  padding: .35rem .7rem;
  border-radius: 6px;
  background: var(--surface-2, transparent);
}
.ag-notice {
  padding: .5rem .75rem;
  border-radius: 6px;
  border: 1px solid var(--agenda-grid-border);
  background: var(--agenda-accent-soft);
  color: var(--agenda-accent-text);
  font-size: .85rem;
  font-weight: 600;
}

/* Grid: fills the available width (sidebar open or collapsed, any window
   size); scrolls horizontally only when the lanes' minimum widths no
   longer fit. No gap under the toolbar, no blank block under the grid. */
.ag-grid-scroll {
  margin-top: 0;
  overflow-x: auto;
  border: 1px solid var(--agenda-grid-border);
  border-radius: 8px;
  background: var(--agenda-grid-bg);
}
.ag-grid-body {
  display: flex;
  position: relative;
  width: 100%;
  min-width: max-content;
}

.ag-time-col {
  position: relative;
  flex: 0 0 72px; /* room for 12h labels ('12:00 p. m.') */
  width: 72px;
  border-right: 1px solid var(--agenda-grid-border);
}
.ag-time-head { padding: 0; }
.ag-time-body {
  position: relative;
  z-index: 3;
}
.ag-hour-label {
  position: absolute;
  right: 6px;
  transform: translateY(-50%);
  font-size: .68rem;
  line-height: 1;
  color: var(--text-muted, var(--g500, inherit));
  white-space: nowrap;
}

.ag-day-cols {
  display: flex;
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
.ag-day-view { flex-direction: column; }

.ag-day-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--agenda-grid-border);
}
.ag-day-today .ag-day-head { background: var(--agenda-today-tint); }

.ag-day-head {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 .4rem;
  font-size: .78rem;
  font-weight: 700;
  border-bottom: 1px solid var(--agenda-grid-border);
}
.ag-lane-heads {
  display: flex;
  height: 28px;
  border-bottom: 1px solid var(--agenda-grid-border);
}
.ag-lane-head {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .68rem;
  font-weight: 700;
  border-right: 1px solid var(--agenda-grid-border);
}
.ag-doctor-col-head {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: 0 .5rem;
  font-size: .78rem;
  font-weight: 600;
  border-right: 1px solid var(--agenda-grid-border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ag-doctor-strip {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.ag-day-body {
  position: relative;
}
.ag-lanes-row {
  display: flex;
  position: absolute;
  width: 100%;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}
.ag-lane {
  position: relative;
  border-right: 1px solid var(--agenda-grid-border);
  cursor: pointer;
}
.ag-lane-empty { cursor: pointer; }
.ag-lane-empty-label {
  padding: 1.5rem 1rem;
  font-size: .85rem;
  color: var(--text-muted, var(--g500, inherit));
}

.ag-hour-line, .ag-halfhour-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 1px solid var(--agenda-hour-line);
  pointer-events: none;
}
.ag-halfhour-line { border-top: 1px dashed var(--agenda-halfhour-line); }

.ag-today-tint {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  background: var(--agenda-today-tint);
  pointer-events: none;
}

.ag-now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 2px solid var(--agenda-now-line);
  z-index: 5;
  pointer-events: none;
}

.ag-offhours {
  position: absolute;
  left: 0;
  right: 0;
  background: var(--agenda-offhours-bg);
  pointer-events: none;
}
.ag-blocked {
  position: absolute;
  left: 0;
  right: 0;
  background: var(--agenda-blocked-bg);
  background-image: repeating-linear-gradient(
    45deg,
    var(--agenda-blocked-stripe),
    var(--agenda-blocked-stripe) 4px,
    transparent 4px,
    transparent 9px
  );
  pointer-events: none;
}

.ag-card {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: 4px;
  border: 1px solid;
  border-left-width: 4px;
  padding: 2px 4px;
  font-size: .68rem;
  line-height: 1.15;
  overflow: hidden;
  cursor: grab;
  z-index: 2;
  user-select: none;
  touch-action: none; /* issue 853 drag fix: a touch drag moves the card, not the page */
}
.ag-card-dragging { opacity: .45; cursor: grabbing; }
.ag-card-pending { opacity: .7; }
.ag-card-cancelled { cursor: pointer; }

/* issue 853 drag fix: snapped ghost in the target lane + floating label near the pointer. */
.ag-drag-ghost {
  position: absolute;
  left: 2px;
  right: 2px;
  border: 2px dashed var(--agenda-accent);
  border-radius: 4px;
  background: var(--agenda-accent-soft);
  color: var(--agenda-accent-text);
  font-size: .68rem;
  font-weight: 700;
  padding: 1px 3px;
  overflow: hidden;
  pointer-events: none;
  z-index: 6;
}
.ag-drag-preview {
  position: fixed;
  max-width: 240px;
  padding: .3rem .55rem;
  border-radius: 6px;
  border: 1px solid var(--agenda-grid-border);
  background: var(--agenda-grid-bg);
  color: var(--agenda-accent-text);
  font-size: .75rem;
  font-weight: 600;
  box-shadow: 0 4px 14px var(--shadow, transparent);
  pointer-events: none;
  z-index: 50;
}
.ag-drag-preview-out { color: var(--agenda-card-cancelled-text); }
.ag-card:focus-visible { outline: 2px solid var(--agenda-accent); }
.ag-card-time { font-weight: 700; }
.ag-card-patient { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ag-card-presencial {
  background: var(--agenda-card-presencial-bg);
  border-color: var(--agenda-card-presencial-border);
  color: var(--agenda-card-presencial-text);
}
.ag-card-teleconsulta {
  background: var(--agenda-card-teleconsulta-bg);
  border-color: var(--agenda-card-teleconsulta-border);
  color: var(--agenda-card-teleconsulta-text);
}
.ag-card-cancelled {
  background: var(--agenda-card-cancelled-bg);
  border-color: var(--agenda-card-cancelled-border);
  color: var(--agenda-card-cancelled-text);
  text-decoration: line-through;
}

.ag-resize-handle {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 5px;
  cursor: ns-resize;
}

.ag-more-lanes {
  border: none;
  background: var(--agenda-accent-soft);
  color: var(--agenda-accent-text);
  border-radius: 4px;
  font-size: .68rem;
  font-weight: 700;
  padding: .1rem .4rem;
  cursor: pointer;
}
.ag-less-lanes { background: transparent; }

.ag-create-results {
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--agenda-grid-border);
  border-radius: 6px;
  margin-top: .3rem;
}
.ag-create-result {
  padding: .35rem .5rem;
  font-size: .8rem;
  cursor: pointer;
}
.ag-create-result:hover { background: var(--agenda-accent-soft); }

.ag-detail-card {
  /* issue 853 drag fix: anchored next to the clicked card; left/top set by showDetailCard(). */
  position: fixed;
  left: 0;
  top: 0;
  width: 280px;
  max-width: calc(100vw - 16px);
  background: var(--agenda-grid-bg);
  border: 1px solid var(--agenda-grid-border);
  border-radius: 8px;
  padding: .85rem;
  box-shadow: 0 4px 18px var(--shadow, transparent);
  z-index: 40;
}
.ag-detail-row { font-size: .82rem; margin-bottom: .3rem; }
.ag-detail-actions {
  display: flex;
  gap: .4rem;
  justify-content: flex-end;
  margin-top: .5rem;
}

/* ticket 853 5f: form error line (no hex fallback). */
.ag-form-err { color: var(--red, var(--agenda-card-cancelled-text)); font-size: .8rem; margin-top: .4rem; }
.ag-create-when {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: .5rem;
}
.ag-block-allday { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; margin: .35rem 0; }

/* ticket 853 5f legend: doctor colour keys (token swatches), tags, and the
   card kinds the grid draws. */
.ag-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.25rem;
  margin-top: .6rem;
  padding: .5rem .75rem;
  border-radius: 6px;
  background: var(--surface-2, transparent);
  font-size: .75rem;
}
.ag-legend-group { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .75rem; }
.ag-legend-label { font-weight: 700; color: var(--text-muted, var(--g500, inherit)); }
.ag-legend-item { display: inline-flex; align-items: center; gap: .35rem; }
.ag-legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid var(--agenda-grid-border);
  text-decoration: none;
}
.ag-legend-blocked {
  background: var(--agenda-blocked-bg);
  background-image: repeating-linear-gradient(
    45deg,
    var(--agenda-blocked-stripe),
    var(--agenda-blocked-stripe) 2px,
    transparent 2px,
    transparent 5px
  );
}
.ag-legend-tag {
  padding: .1rem .5rem;
  border-radius: 99px;
  border: 1px solid var(--agenda-grid-border);
}

/* ticket 853 5f bottom cards (honest "no disponible" states). */
.ag-bottom-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: .75rem;
  margin-top: .75rem;
}
.ag-bottom-card { margin: 0; }
.ag-bottom-card .section-card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }

/* ticket 853 5f item 2: 12h/24h segmented toggle + hours toggle in row 2. */
.ag-seg {
  display: inline-flex;
  border: 1px solid var(--agenda-grid-border);
  border-radius: 6px;
  overflow: hidden;
}
.ag-seg-btn { border-radius: 0; padding: .3rem .6rem; font-size: .8rem; }
.ag-seg-on { font-weight: 700; background: var(--agenda-accent-soft); color: var(--agenda-accent-text); }

/* ticket 853 5f items 4 and 9: grid + collapsible day panel, full width. */
.ag-main {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  width: 100%;
}
.ag-grid-wrap {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.ag-hours-more {
  display: block;
  width: 100%;
  border: 1px dashed var(--agenda-grid-border);
  background: var(--agenda-accent-soft);
  color: var(--agenda-accent-text);
  font-size: .75rem;
  font-weight: 700;
  padding: .2rem;
  cursor: pointer;
}
.ag-hours-more-top { border-radius: 8px 8px 0 0; border-bottom: 0; }
.ag-hours-more-bottom { border-radius: 0 0 8px 8px; border-top: 0; }
@keyframes ag-hours-reveal {
  from { opacity: .35; transform: scaleY(.97); }
  to { opacity: 1; transform: scaleY(1); }
}
.ag-hours-anim { animation: ag-hours-reveal .22s ease-out; transform-origin: top; }
@media (prefers-reduced-motion: reduce) { .ag-hours-anim { animation: none; } }

.ag-day-panel {
  flex: 0 0 17rem;
  max-width: 17rem;
  border: 1px solid var(--agenda-grid-border);
  border-radius: 8px;
  background: var(--agenda-grid-bg);
  overflow: hidden;
}
.ag-day-panel-collapsed { flex: 0 0 auto; max-width: 2.5rem; }
.ag-day-panel-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .4rem;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--agenda-grid-border);
  background: transparent;
  color: inherit;
  font-weight: 700;
  font-size: .82rem;
  padding: .6rem .75rem;
  cursor: pointer;
  text-align: left;
}
.ag-day-panel-collapsed .ag-day-panel-toggle {
  writing-mode: vertical-rl;
  border-bottom: 0;
  padding: .75rem .5rem;
  min-height: 12rem;
}
.ag-day-panel-list { list-style: none; margin: 0; padding: .4rem 0; max-height: 70vh; overflow-y: auto; }
.ag-day-panel-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .1rem .5rem;
  padding: .35rem .75rem;
  font-size: .8rem;
  border-bottom: 1px solid var(--agenda-grid-border);
}
.ag-day-panel-time { font-weight: 700; white-space: nowrap; }
.ag-day-panel-type { font-size: .72rem; color: var(--text-muted, var(--g500, inherit)); }
.ag-day-panel-title { grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-day-panel-empty { padding: .75rem; font-size: .8rem; }
.ag-day-col .ag-day-head { cursor: pointer; }
@media (max-width: 900px) {
  .ag-main { flex-direction: column; }
  .ag-day-panel, .ag-day-panel-collapsed { flex: 1 1 auto; max-width: none; width: 100%; }
  .ag-day-panel-collapsed .ag-day-panel-toggle { writing-mode: horizontal-tb; min-height: 0; }
}

/* ticket 853 5f item 3: legend kind swatches (same app tokens the month
   dots use; no hex). */
.ag-legend-cita { background: var(--purple, var(--agenda-accent)); }
.ag-legend-tarea { background: var(--accent, var(--agenda-accent)); }
.ag-legend-consulta { background: var(--success, var(--agenda-accent-soft)); }

/* ticket 853 5f item 5: Enlace de Reserva row. */
.ag-booking-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.ag-booking-url { flex: 1 1 14rem; min-width: 0; font-size: .78rem; }
