/* Clínica NOE v2 · estilos del módulo agenda (agenda, tablero, expediente, documentos InBody) */

/* ---------- Colores por estado de cita ---------- */
.st-scheduled { --st: var(--brand-500); --st-bg: var(--info-bg); }
.st-confirmed { --st: var(--ok); --st-bg: var(--ok-bg); }
.st-completed { --st: var(--muted); --st-bg: var(--surface-3); }
.st-no_show { --st: var(--warn); --st-bg: var(--warn-bg); }
.st-cancelled { --st: var(--alert); --st-bg: var(--alert-bg); }

/* ---------- Encabezado y barra ---------- */
.ag-header { margin-bottom: 14px; }
.ag-header .page-title { text-transform: none; }
.ag-toolbar { gap: 10px; }
.ag-jump { position: relative; cursor: pointer; }
.ag-jump input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.ag-jump input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
[data-body].is-loading { opacity: .55; transition: opacity 200ms; pointer-events: none; }

/* ---------- Grilla de horas ---------- */
.ag-grid { --slot: 44px; --gutter-w: 58px; overflow: clip; }
.ag-head, .ag-body { display: grid; grid-template-columns: var(--gutter-w) repeat(var(--cols), minmax(0, 1fr)); }
.ag-head { position: sticky; top: var(--topbar-h); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--border); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.ag-dayhead {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 64px; padding: 6px 4px; border: 0; border-left: 1px solid var(--border); background: none; color: var(--text-2);
}
.ag-dayhead:hover { background: var(--surface-2); }
.ag-dow { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ag-dnum { font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; line-height: 1; display: grid; place-items: center; min-width: 36px; height: 36px; border-radius: 12px; }
.ag-dayhead.is-today .ag-dnum, .ag-day.is-today .ag-dnum { background: var(--brand-600); color: #fff; }
.ag-dayhead.is-today .ag-dow { color: var(--brand-600); }
.ag-dcount { position: absolute; top: 6px; right: 6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px; background: var(--brand-50); color: var(--brand-600); font-size: .7rem; font-weight: 800; display: grid; place-items: center; }
.ag-times { display: grid; grid-auto-rows: var(--slot); }
.ag-time { position: relative; font-size: .7rem; font-weight: 700; color: var(--muted); text-align: right; padding-right: 8px; }
.ag-time:not(:empty) { transform: translateY(-.6em); }
.ag-col { position: relative; display: grid; grid-auto-rows: var(--slot); border-left: 1px solid var(--border); }
.ag-col.is-today { background: color-mix(in srgb, var(--brand-50) 45%, transparent); }
.ag-slot { display: block; width: 100%; border: 0; border-top: 1px dashed color-mix(in srgb, var(--border) 70%, transparent); background: none; padding: 0; }
.ag-slot.is-hour { border-top: 1px solid var(--border); }
button.ag-slot { cursor: copy; }
button.ag-slot:hover { background: var(--brand-50); box-shadow: inset 3px 0 0 var(--brand-400); }
button.ag-slot:focus-visible { border-radius: 0; box-shadow: inset 0 0 0 2px var(--brand-500); }

.appt {
  position: absolute; z-index: 2; overflow: hidden; display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 4px 8px 4px 10px; border: 0; border-radius: 10px; text-align: left; color: var(--text);
  background: var(--st-bg); box-shadow: inset 4px 0 0 var(--st), var(--shadow-xs);
  font-size: .78rem; line-height: 1.2; cursor: pointer; transition: transform 160ms var(--ease), box-shadow var(--dur);
}
.appt:hover { z-index: 3; transform: translateY(-1px); box-shadow: inset 4px 0 0 var(--st), var(--shadow); }
.appt-time { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; color: var(--st); font-variant-numeric: tabular-nums; white-space: nowrap; }
.appt-flag { width: 12px; height: 12px; }
.appt-name { font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appt-reason { color: var(--text-2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appt.is-short { flex-direction: row; align-items: center; gap: 6px; padding-top: 0; padding-bottom: 0; }
.appt.st-cancelled { opacity: .62; }
.appt.st-cancelled .appt-name { text-decoration: line-through; }
.ag-now { position: absolute; left: 0; right: 0; z-index: 4; height: 2px; background: var(--alert); pointer-events: none; }
.ag-now::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--alert); }

/* ---------- Leyenda ---------- */
.ag-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 14px; font-size: .8rem; color: var(--muted); font-weight: 600; }
.ag-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.ag-swatch { width: 14px; height: 14px; border-radius: 4px; background: var(--st-bg); box-shadow: inset 3px 0 0 var(--st); }

/* ---------- Lista por día (celular) ---------- */
.ag-day { padding: 14px 16px 10px; }
.ag-day-head { display: flex; align-items: center; gap: 10px; }
.ag-day-title { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 0; color: inherit; text-align: left; min-height: 44px; }
.ag-day-title .ag-dow { font-size: .95rem; text-transform: none; letter-spacing: 0; color: var(--text); }
.ag-day-list { margin-top: 6px; }
.ag-day-empty { padding: 8px 0 6px; }
.ag-row { position: relative; padding-left: 16px; }
.ag-row::before { content: ""; position: absolute; left: 2px; top: 14px; bottom: 14px; width: 4px; border-radius: 4px; background: var(--st); }
.ag-row.st-cancelled .list-item-title { text-decoration: line-through; color: var(--muted); }
.ag-row-time { display: flex; flex-direction: column; min-width: 64px; }
.ag-gap { min-height: 48px; color: var(--muted); border-style: dashed !important; }
button.ag-gap:hover { color: var(--brand-600); }
.ag-row .chip { flex: none; }
@media (max-width: 420px) { .ag-row .chip { display: none; } }

/* ---------- Mes ---------- */
.ag-month { overflow: clip; }
.ag-month-head, .ag-month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.ag-month-head > div { padding: 10px 6px; text-align: center; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-bottom: 1px solid var(--border); }
.ag-mcell {
  position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 4px; min-height: 108px; min-width: 0;
  padding: 6px; border: 0; border-left: 1px solid var(--border); border-top: 1px solid var(--border); background: none; text-align: left; color: inherit;
}
.ag-mcell:nth-child(7n + 1) { border-left: 0; }
.ag-mcell:nth-child(-n + 7) { border-top: 0; }
.ag-mcell:hover { background: var(--surface-2); }
.ag-mcell.is-out { background: var(--surface-2); color: var(--muted); }
.ag-mnum { font-weight: 800; font-size: .85rem; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; }
.ag-mcell.is-today .ag-mnum { background: var(--brand-600); color: #fff; }
.ag-mitems { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ag-mpill { display: block; padding: 2px 6px; border-radius: 6px; font-size: .7rem; font-weight: 700; background: var(--st-bg); box-shadow: inset 3px 0 0 var(--st); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-mdots { display: none; }
@media (max-width: 767px) {
  .ag-mcell { min-height: 64px; align-items: center; padding: 6px 2px; }
  .ag-mitems { display: none; }
  .ag-mdots { display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 99px; background: var(--brand-50); color: var(--brand-600); font-size: .72rem; font-weight: 800; }
  .ag-toolbar .segmented { width: 100%; }
  .ag-toolbar .segmented button { flex: 1; justify-content: center; }
  .ag-toolbar > .spacer { display: none; }
}

/* ---------- Formulario y detalle de cita ---------- */
.ag-results { display: flex; flex-direction: column; margin-top: 8px; max-height: 300px; overflow-y: auto; }
.ag-results .list-item { margin: 0; width: 100%; }
.ag-results-note { padding: 8px 12px; font-size: .85rem; color: var(--muted); }
.ag-picked { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px; border: 1.5px solid var(--border); background: var(--surface-2); }
.ag-detail-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.ag-detail-time .num { font-family: var(--font-display); font-size: 2rem; font-weight: 600; line-height: 1; }
.ag-status-actions, .ag-detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ag-detail-actions .btn { flex: 1 1 220px; }
.ag-st { min-height: 44px; }
.ag-st[aria-pressed="true"] { --btn-bg: var(--st-bg); --btn-fg: var(--st); --btn-bd: var(--st); }
.ag-st-confirmed { --st: var(--ok); --st-bg: var(--ok-bg); }
.ag-st-completed { --st: var(--text-2); --st-bg: var(--surface-3); }
.ag-st-no_show { --st: var(--warn); --st-bg: var(--warn-bg); }
.ag-st-cancelled { --st: var(--alert); --st-bg: var(--alert-bg); }
.appt-detail .modal-footer { align-items: center; }

/* ---------- Tablero ---------- */
.dash-appt-time { display: flex; flex-direction: column; align-items: center; min-width: 58px; padding: 6px 4px; border-radius: 12px; background: var(--st-bg, var(--surface-3)); color: var(--st, var(--text)); font-weight: 800; font-variant-numeric: tabular-nums; font-size: .9rem; }
.dash-appt-time small { font-size: .68rem; font-weight: 700; opacity: .8; }
.dash-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.fu-badge { flex: none; }
.dash-list-scroll { max-height: 440px; overflow-y: auto; margin: 0 -12px; padding: 0 12px; }
@media (max-width: 560px) {
  .dash-row { flex-wrap: wrap; }
  .dash-row .dash-actions { width: 100%; justify-content: flex-start; padding-left: 62px; }
}

/* ---------- Expediente: citas y documentos ---------- */
.next-appt { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 18px 20px; border-radius: var(--radius); background: linear-gradient(120deg, var(--brand-50), var(--surface)); border: 1px solid var(--brand-200); }
[data-theme="dark"] .next-appt { border-color: var(--border-strong); }
.next-appt-date { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; }
.doc-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.doc-filter { min-height: 44px; }
.doc-filter[aria-pressed="true"] { --btn-bg: var(--brand-600); --btn-fg: #fff; --btn-bd: transparent; }
.doc-cat { position: absolute; left: 8px; top: 8px; z-index: 1; height: 24px; padding: 0 8px; font-size: .7rem; box-shadow: var(--shadow-xs); }
.doc-cat-edit { all: unset; cursor: pointer; }
.doc-cat-edit:focus-visible { box-shadow: var(--ring); border-radius: 999px; }
.inbody-panel { padding: 18px 20px; border-radius: var(--radius); background: var(--gold-100); border: 1px solid transparent; }
.inbody-list .list-item { margin: 0; }
.inbody-list .list-item + .list-item { border-color: color-mix(in srgb, var(--gold-500) 30%, transparent); }
.inbody-date { display: flex; flex-direction: column; align-items: center; min-width: 58px; padding: 6px 4px; border-radius: 12px; background: var(--surface); line-height: 1.1; }
.inbody-date strong { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; }
.inbody-date small { font-size: .7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.cat-select { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
