/* ==========================================================================
   Agenda clínica: calendario con horas (psicólogo), «Mi horario» y el selector
   de día y hora con el que reservan los pacientes. Va dentro de .adm (admin.css).
   ========================================================================== */

/* --- Pestañas Calendario / Mi horario -------------------------------------- */
.ag-tabs { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.ag-tabs .seg a { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 7px; color: var(--text-2); font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.ag-tabs .seg a:hover { color: var(--text); }
.ag-tabs .seg a[aria-current="page"] { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.ag-tabs .seg svg { width: 14px; height: 14px; }

/* --- Aviso sin horario ------------------------------------------------------ */
.ag-alert { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 16px; padding: 16px 18px; border-radius: 16px; border: 1px solid rgba(251, 191, 36, .3); background: linear-gradient(135deg, rgba(251, 191, 36, .1), rgba(251, 191, 36, .03)); }
.ag-alert > div { flex: 1 1 260px; }
.ag-alert strong { display: block; font-size: 14.5px; }
.ag-alert p { color: var(--text-2); font-size: 13px; margin-top: 2px; }

/* --- Barra de semana -------------------------------------------------------- */
.ag-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 18px 0 10px; }
.ag-bar h2 { font-family: var(--font-display); font-size: 17px; font-weight: 600; margin-right: auto; }
.ag-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 2px 0; color: var(--text-3); font-size: 12px; }
.ag-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ag-legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--c, var(--accent)); }
.ag-legend i.is-free { background: repeating-linear-gradient(135deg, rgba(52, 211, 153, .35) 0 2px, rgba(52, 211, 153, .12) 2px 5px); }
.ag-legend i.is-off { background: repeating-linear-gradient(135deg, rgba(148, 176, 255, .3) 0 2px, transparent 2px 6px); }

/* --- Calendario con horas -------------------------------------------------- */
.ag-cal { --hour: 54px; --gutter: 54px; border: 1px solid var(--line-2); border-radius: 18px; background: var(--surface); overflow: hidden; box-shadow: var(--shadow); }
.ag-cal__row { display: grid; grid-template-columns: var(--gutter) repeat(7, minmax(0, 1fr)); }
.ag-cal__head { position: sticky; top: 0; z-index: 3; background: rgba(9, 15, 34, .96); border-bottom: 1px solid var(--line-2); }
.ag-cal__dh { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 9px 4px 8px; border-left: 1px solid var(--line); color: var(--text-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; }
.ag-cal__dh b { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; font-family: var(--font-display); font-size: 17px; letter-spacing: 0; color: var(--text); }
.ag-cal__dh.is-today { color: var(--accent); }
.ag-cal__dh.is-today b { background: var(--accent); color: #031024; }
.ag-cal__dh.is-past b { color: var(--text-3); }
.ag-cal__body { position: relative; height: calc(var(--hour) * var(--rows)); }
.ag-cal__hours { position: relative; }
.ag-cal__hours span { position: absolute; right: 8px; transform: translateY(-50%); font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.ag-cal__hours span:first-child { transform: none; top: 4px !important; }
.ag-col { position: relative; border-left: 1px solid var(--line); cursor: copy;
  background-image: repeating-linear-gradient(to bottom, rgba(148, 176, 255, .08) 0 1px, transparent 1px var(--hour)); }
.ag-col.is-past { background-color: rgba(5, 10, 24, .25); }
.ag-col.is-today { background-color: rgba(0, 198, 255, .03); }
.ag-band { position: absolute; left: 0; right: 0; border-radius: 4px; pointer-events: none;
  background: repeating-linear-gradient(135deg, rgba(52, 211, 153, .10) 0 6px, rgba(52, 211, 153, .04) 6px 12px);
  box-shadow: inset 2px 0 0 rgba(52, 211, 153, .45); }
.ag-band span { position: absolute; top: 4px; left: 8px; font-size: 10.5px; font-weight: 600; color: rgba(110, 231, 183, .8); letter-spacing: .02em; }
.ag-off { position: absolute; inset: 0; display: grid; place-items: start center; padding-top: 14px; pointer-events: none;
  background: repeating-linear-gradient(135deg, rgba(148, 176, 255, .08) 0 2px, transparent 2px 9px); }
.ag-off span { padding: 4px 10px; border-radius: 999px; background: rgba(12, 20, 48, .92); border: 1px solid var(--line-2); font-size: 11.5px; color: var(--text-2); max-width: calc(100% - 12px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-now { position: absolute; left: -1px; right: 0; height: 2px; background: #ff6b8b; z-index: 2; pointer-events: none; }
.ag-now::before { content: ''; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: #ff6b8b; }
.ag-ghost { position: absolute; left: 3px; right: 3px; height: 22px; border-radius: 6px; border: 1px dashed rgba(0, 198, 255, .6); background: rgba(0, 198, 255, .08); color: var(--accent); font-size: 11px; font-weight: 600; padding: 2px 6px; pointer-events: none; display: none; z-index: 1; }
.ag-col:hover .ag-ghost.is-on { display: block; }

.ag-ev { --c: var(--accent); position: absolute; left: 3px; right: 3px; z-index: 2; display: flex; flex-direction: column; gap: 1px; min-height: 22px; padding: 4px 7px; overflow: hidden;
  border: 0; border-radius: 8px; text-align: left; cursor: pointer; font: inherit; color: var(--text);
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 30%, #0c1430), color-mix(in srgb, var(--c) 18%, #0c1430));
  box-shadow: inset 3px 0 0 var(--c), 0 6px 14px -8px rgba(0, 0, 0, .8); transition: transform .12s var(--ease), box-shadow .12s; }
.ag-ev:hover, .ag-ev:focus-visible { transform: translateY(-1px); box-shadow: inset 3px 0 0 var(--c), 0 0 0 1px var(--c), 0 10px 20px -10px rgba(0, 0, 0, .9); outline: none; z-index: 4; }
.ag-ev.is-split { right: auto; width: calc(50% - 4px); }
.ag-ev.is-split.lane-1 { left: calc(50% + 1px); }
.ag-ev b { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-ev small { font-size: 11px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.ag-ev svg { width: 11px; height: 11px; vertical-align: -1px; opacity: .8; }
.ag-ev--presencial { --c: var(--violet); }
.ag-ev--intro { --c: var(--warn); }
.ag-ev--completed { --c: var(--good); }
.ag-ev--completed b, .ag-ev--no_show b { color: var(--text-2); }
.ag-ev--no_show { --c: var(--text-3); }
.ag-ev--no_show b { text-decoration: line-through; }
.ag-ev.is-short { flex-direction: row; align-items: center; gap: 6px; padding-top: 2px; padding-bottom: 2px; }
.ag-ev.is-short b { flex: none; max-width: 60%; }
.ag-ev.is-short small { min-width: 0; }

/* Tira de días (solo móvil) */
.ag-strip { display: none; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-bottom: 10px; }
.ag-strip::-webkit-scrollbar { display: none; }
.ag-strip button { flex: 1 0 44px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; cursor: pointer; }
.ag-strip button b { font-family: var(--font-display); font-size: 17px; color: var(--text); letter-spacing: 0; }
.ag-strip button i { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.ag-strip button.has-items i { background: var(--accent); }
.ag-strip button.is-today { color: var(--accent); }
.ag-strip button[aria-selected="true"] { border-color: rgba(0, 198, 255, .6); background: var(--accent-soft); }

@media (max-width: 760px) {
  .ag-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .ag-kpis .kpi { padding: 12px 14px; }
  .ag-kpis .kpi__foot { display: none; }
  .ag-strip { display: flex; }
  .ag-cal { --gutter: 48px; --hour: 60px; }
  .ag-cal__row { grid-template-columns: var(--gutter) minmax(0, 1fr); }
  .ag-cal__head { display: none; }
  .ag-col:not(.is-active) { display: none; }
  .ag-ev b { font-size: 13.5px; }
  .ag-ev small { font-size: 12px; }
}

/* --- Tarjetas de abajo ------------------------------------------------------ */
.ag-grid2 { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); margin-top: 18px; align-items: start; }
.ag-list { list-style: none; margin: 0; padding: 0; }
.ag-list li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.ag-list li:first-child { border-top: 0; }
.ag-list .who { flex: 1; min-width: 160px; }
.ag-list .who strong { display: block; font-size: 14px; }
.ag-list .who span { color: var(--text-2); font-size: 12.5px; }
.ag-week { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ag-week li { display: flex; gap: 12px; font-size: 13px; }
.ag-week li span:first-child { width: 78px; flex: none; color: var(--text-3); text-transform: capitalize; }
.ag-week li.is-off span:last-child { color: var(--text-3); }
.ag-facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
@media (max-width: 980px) { .ag-grid2 { grid-template-columns: 1fr; } }

/* --- Diálogo de cita -------------------------------------------------------- */
.ag-form { display: grid; gap: 12px; }
.ag-form .row { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.ag-form .textarea { min-height: 64px; height: auto; padding: 10px 12px; resize: vertical; font: inherit; font-size: 13.5px; }
[data-when-mode] { display: none; }
.ag-form[data-mode="online"] [data-when-mode="online"], .ag-form[data-mode="presencial"] [data-when-mode="presencial"] { display: flex; }
.ag-suggest { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 4px; }
.ag-suggest button { flex: none; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 7px 10px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.ag-suggest button small { color: var(--text-3); font-weight: 500; font-size: 11px; text-transform: capitalize; }
.ag-suggest button.is-active, .ag-suggest button:hover { border-color: rgba(0, 198, 255, .6); background: var(--accent-soft); }
.ag-repeat { display: grid; gap: 10px; padding: 12px; border-radius: 12px; background: rgba(5, 10, 24, .45); border: 1px solid var(--line); }
.ag-repeat[hidden] { display: none; }

/* --- Mi horario ------------------------------------------------------------- */
.hr-days { display: grid; gap: 4px; }
.hr-day { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; align-items: start; padding: 12px 0; border-top: 1px solid var(--line); }
.hr-day:first-child { border-top: 0; }
.hr-day__name { display: flex; align-items: center; gap: 10px; min-height: 38px; font-weight: 600; text-transform: capitalize; }
.hr-ranges { display: flex; flex-direction: column; gap: 8px; }
.hr-range { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hr-range .input { width: 112px; }
.hr-range > span { color: var(--text-3); }
.hr-off { min-height: 38px; display: flex; align-items: center; color: var(--text-3); font-size: 13px; }
.hr-day:not(.is-on) .hr-ranges { display: none; }
.hr-day.is-on .hr-off { display: none; }
.hr-add { align-self: flex-start; background: none; border: 0; padding: 4px 0; color: var(--accent); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.hr-copy { margin-top: 12px; }
.hr-settings { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.hr-save { position: sticky; bottom: 12px; z-index: 5; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 12px 16px; border-radius: 16px; background: rgba(12, 20, 48, .95); border: 1px solid var(--line-2); box-shadow: 0 20px 40px -20px rgba(0, 0, 0, .9); backdrop-filter: blur(8px); }
.hr-save p { color: var(--text-2); font-size: 13px; }
.hr-off-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.hr-off-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 13.5px; }
.hr-feed { display: flex; gap: 8px; flex-wrap: wrap; }
.hr-feed .input { flex: 1 1 260px; font-family: var(--font-mono); font-size: 12px; }
.hr-steps { margin: 12px 0 0; padding-left: 18px; color: var(--text-2); font-size: 13px; display: grid; gap: 4px; }
@media (max-width: 640px) {
  .hr-day { grid-template-columns: 1fr; gap: 6px; }
  .hr-range .input { width: 104px; }
}

.ag-switch { position: relative; display: inline-flex; flex: none; width: 38px; height: 22px; cursor: pointer; }
.ag-switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.ag-switch span { position: absolute; inset: 0; border-radius: 999px; background: rgba(148, 176, 255, .18); transition: background .18s; }
.ag-switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #dfe7ff; transition: transform .18s var(--ease); }
.ag-switch input:checked + span { background: var(--accent); }
.ag-switch input:checked + span::after { transform: translateX(16px); background: #031024; }
.ag-switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Selector de día y hora (pacientes) ------------------------------------ */
.sp { display: grid; gap: 14px; }
.sp-days { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; padding: 2px 2px 8px; scrollbar-width: thin; }
.sp-day { flex: none; scroll-snap-align: start; width: 66px; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 10px 0 8px; border-radius: 16px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text-3); cursor: pointer; font: inherit; transition: border-color .15s, background .15s, transform .15s var(--ease); }
.sp-day:hover { border-color: var(--line-3); transform: translateY(-1px); }
.sp-day span { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
.sp-day b { font-family: var(--font-display); font-size: 22px; line-height: 1.15; color: var(--text); }
.sp-day small { font-size: 11px; }
.sp-day i { margin-top: 4px; font-style: normal; font-size: 10.5px; font-weight: 600; color: var(--good); }
.sp-day[aria-selected="true"] { border-color: rgba(0, 198, 255, .7); background: var(--accent-soft); color: #bfefff; }
.sp-day:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sp-panel[hidden] { display: none; }
.sp-panel h3 { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.sp-panel h3::first-letter { text-transform: uppercase; }
.sp-part { color: var(--text-3); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin: 12px 0 8px; }
.sp-part:first-of-type { margin-top: 0; }
.sp-times { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.sp-time { position: relative; }
.sp-time input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.sp-time span { display: flex; align-items: center; justify-content: center; height: 44px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface-2); font-weight: 600; font-size: 14.5px; font-variant-numeric: tabular-nums; transition: all .15s var(--ease); }
.sp-time:hover span { border-color: var(--line-3); }
.sp-time input:checked + span { border-color: var(--accent); background: var(--accent); color: #031024; box-shadow: 0 8px 20px -10px rgba(0, 198, 255, .8); }
.sp-time input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.sp-summary { display: grid; gap: 12px; padding: 16px; border-radius: 16px; border: 1px solid rgba(0, 198, 255, .35); background: linear-gradient(135deg, rgba(0, 198, 255, .1), rgba(124, 92, 255, .06) 60%, var(--surface)); animation: sp-in .25s var(--ease); }
.sp-summary[hidden] { display: none; }
.sp-summary__when { display: flex; gap: 12px; align-items: center; }
.sp-summary__when svg { width: 22px; height: 22px; color: var(--accent); flex: none; }
.sp-summary__when strong { display: block; font-size: 15.5px; }
.sp-summary__when strong::first-letter { text-transform: uppercase; }
.sp-summary__when span { color: var(--text-2); font-size: 13px; }
.sp-empty { padding: 18px; border-radius: 14px; background: var(--surface-2); color: var(--text-2); font-size: 13.5px; }
@keyframes sp-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .sp-summary, .sp-day, .ag-ev { animation: none; transition: none; } }

/* --- Recordatorios de cita (partials/reminders_editor.html) ------------------ */
.rm { display: grid; gap: 12px; }
.rm-rows { display: grid; gap: 8px; }
.rm-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.rm-row .select { width: auto; min-width: 170px; flex: 1 1 170px; }
.rm-ways { display: flex; gap: 6px; }
.rm-ways .chip { height: 34px; padding: 0 12px; font-size: 13px; }
.rm-nudge { animation: rm-nudge .35s; }
@keyframes rm-nudge { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.rm-add { justify-self: start; background: none; border: 0; padding: 4px 0; color: var(--accent); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.rm-add[hidden] { display: none; }
.rm-none { color: var(--text-3); font-size: 13.5px; padding: 8px 0; }
.rm-hint { color: var(--text-3); font-size: 12.5px; line-height: 1.5; }
.rm-hint b { color: var(--text-2); font-weight: 600; }
.rm-push { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 12px; background: rgba(0, 198, 255, .06); border: 1px solid rgba(0, 198, 255, .18); font-size: 13px; color: var(--text-2); }
.rm-push[hidden] { display: none; }
.rm-check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--text-2); cursor: pointer; }
.rm-check input { margin-top: 3px; accent-color: var(--accent); }
.rm-check b { color: var(--text); font-weight: 600; }
.rm-foot { display: flex; justify-content: flex-start; }
.rm-card--ask { border-color: rgba(0, 198, 255, .4); background: linear-gradient(135deg, rgba(0, 198, 255, .1), var(--surface) 60%); }
.rm-summary { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; list-style: none; cursor: pointer; }
.rm-summary::-webkit-details-marker { display: none; }
.rm-summary span { flex: 1 1 220px; color: var(--text-2); font-size: 13.5px; }
details[open] > .rm-summary .rm-change { display: none; }

/* --- ¿Cómo te piden cita tus pacientes? (Mi horario) ------------------------- */
.hr-booking { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.hr-opt { position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.hr-opt input { margin-top: 3px; accent-color: var(--accent); flex: none; }
.hr-opt span { display: grid; gap: 3px; }
.hr-opt b { font-size: 14.5px; }
.hr-opt small { color: var(--text-2); font-size: 12.5px; line-height: 1.45; }
.hr-opt:has(input:checked) { border-color: rgba(0, 198, 255, .6); background: var(--accent-soft); }
