/* ============================================================
   style-agenda.css — Your Body Talks  (v2 — pro rewrite)
   Layout: sidebar fijo + vista de día tipo Google Calendar
   Drag & drop, resize, tooltip de acciones, responsive.
   Sin height fija en section.agenda.
   #app.light-theme para overrides de modo claro.
============================================================ */

/* ─── Reset parcial dentro del scope ─── */
section.agenda *,
section.agenda *::before,
section.agenda *::after { box-sizing: border-box; color: var(--text); }

/* ─── Fuente elegante via Google Fonts ─── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&display=swap');

/* ─── Shell principal ─── */
section.agenda {
  display: grid;
  grid-template-columns: 1fr;   /* el shell interno maneja el grid */
  margin: 18px 0;
  padding: 0 20px;
  font-family: 'DM Sans', var(--font-sans, system-ui), sans-serif;
}

/* Shell = sidebar + main-content */
.agenda-shell {
  display: grid;
  grid-template-columns: 230px 1fr;
  grid-template-rows: auto 1fr;
  height: calc(100vh - 100px);
  min-height: 540px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow);
}

/* ─── Sidebar ─── */
.ag-sidebar {
  grid-row: 1 / -1;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, var(--card), var(--card-2));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ag-sb-brand {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.ag-sb-brand .logo {
  width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0;
  background:
    radial-gradient(circle at 30% 30%, var(--accent), transparent 60%),
    radial-gradient(circle at 70% 70%, var(--purple), transparent 60%),
    var(--accent);
}

.ag-sb-brand h1 {
  margin: 0; font-size: 15px; font-weight: 600;
  color: var(--text); letter-spacing: .2px; line-height: 1.2;
}

/* Mini calendario */
.ag-mini-cal {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.ag-mc-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}

.ag-mc-header strong {
  font-size: 13px; font-weight: 600; color: var(--text);
  text-transform: capitalize; letter-spacing: .3px;
}

.ag-mc-nav {
  background: none; border: 1px solid var(--border);
  color: var(--text); border-radius: 8px;
  width: 26px; height: 26px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; transition: background .15s; 
}
.ag-mc-nav:hover { background: var(--card-2); }

.ag-mc-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.ag-mc-day {
  font-size: 11px; text-align: center; padding: 4px 2px;
  border-radius: 6px; cursor: pointer; color: var(--muted);
  transition: background .12s, color .12s;
  user-select: none;
}
.ag-mc-day.hd { font-weight: 600; color: var(--muted); cursor: default; font-size: 10px; }
.ag-mc-day:hover:not(.hd):not(.ag-mc-today) { background: rgba(79,140,255,.1); color: var(--text); }
.ag-mc-today { background: var(--accent); color: #fff; font-weight: 600; }
.ag-mc-sel:not(.ag-mc-today) { background: rgba(79,140,255,.18); color: var(--accent); font-weight: 600; }
.ag-mc-has-appt::after {
  content: ''; display: block; width: 4px; height: 4px;
  border-radius: 50%; background: var(--purple);
  margin: 1px auto 0;
}

/* Lista de pacientes del día */
.ag-patient-list {
  flex: 1; overflow-y: auto; padding: 10px 14px;
}

.ag-pl-label {
  font-size: 10px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .08em;
  margin-bottom: 8px;
}

.ag-patient-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 10px; cursor: pointer;
  transition: background .12s;
}
.ag-patient-chip:hover { background: rgba(255,255,255,.06); }
#app.light-theme .ag-patient-chip:hover { background: rgba(0,0,0,.05); }

.ag-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
  overflow: hidden;
}
.ag-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ag-avatar.has-img { background: transparent !important; color: transparent; }

.ag-patient-chip .ag-pc-info { flex: 1; min-width: 0; }
.ag-pc-name { font-size: 12px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-pc-time { font-size: 11px; color: var(--muted); }

/* Scrollbar sidebar */
.ag-patient-list::-webkit-scrollbar { width: 4px; }
.ag-patient-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ─── Top bar ─── */
.ag-topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--card), var(--card-2));
  flex-shrink: 0;
}

.ag-nav-btns { display: flex; gap: 4px; }

.ag-btn {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border);
  color: var(--text); padding: 7px 12px;
  border-radius: 10px; cursor: pointer;
  font-family: inherit; font-size: 13px;
  transition: transform .1s, box-shadow .15s;
  white-space: nowrap; min-height: 36px;
}
.ag-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.18); }
.ag-btn:active { transform: translateY(0); }

.ag-btn-primary {
  background: var(--grad-1); color: #fff;
  font-weight: 600; border: none;
}

.ag-day-title {
  flex: 1; font-size: 16px; font-weight: 600;
  color: var(--text); text-transform: capitalize;
}

.ag-view-tabs {
  display: flex; gap: 2px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 3px;
}
#app.light-theme .ag-view-tabs { background: rgba(0,0,0,.04); }

.ag-view-tab {
  background: none; border: none;
  padding: 5px 12px; border-radius: 8px;
  font-size: 12px; font-weight: 500; cursor: pointer;
  color: var(--muted); font-family: inherit;
  transition: background .12s, color .12s;
}
.ag-view-tab.active {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}

.ag-search {
  padding: 7px 12px; border-radius: 10px;
  background: var(--card-2); border: 1px solid var(--border);
  color: var(--text); font-family: inherit; font-size: 13px;
  width: 180px; min-height: 36px;
}
.ag-search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ─── Stats bar ─── */
.ag-stats {
  display: flex; gap: 8px; align-items: center;
  padding: 8px 16px; border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.02);
  flex-shrink: 0; flex-wrap: wrap;
}
#app.light-theme .ag-stats { background: rgba(0,0,0,.02); }

.ag-chip {
  font-size: 12px; padding: 4px 10px;
  border-radius: 999px; border: 1px solid var(--border);
  color: var(--muted); font-weight: 500;
}
.ag-chip.neutral { border-color: rgba(255,255,255,.14); background: rgba(255,255,255,.05); }
.ag-chip.ok      { border-color: rgba(80,220,140,.4);  background: rgba(80,220,140,.1); color: #50dc8c; }
.ag-chip.warn    { border-color: rgba(80,180,255,.4);  background: rgba(80,180,255,.1); color: #50b4ff; }
.ag-chip.danger  { border-color: rgba(255,90,90,.4);   background: rgba(255,90,90,.08); color: #ff5a5a; }

/* ─── Day grid ─── */
:root {
  --hour-h: 64px;
  --lane-hour-line: rgba(255,255,255,.07);
  --lane-half-line: rgba(255,255,255,.03);
}
#app.light-theme {
  --lane-hour-line: rgba(0,0,0,.09);
  --lane-half-line: rgba(0,0,0,.05);
}

.ag-main {
  display: flex; flex-direction: column; overflow: hidden;
}

.ag-grid-area {
  flex: 1; display: grid;
  grid-template-columns: 60px 1fr;
  overflow-y: auto; overflow-x: hidden;
  position: relative;
}

.ag-time-col {
  border-right: 1px solid var(--border);
  background: rgba(255,255,255,.015);
  position: sticky; left: 0; z-index: 2;
}
#app.light-theme .ag-time-col { background: rgba(0,0,0,.015); }

.ag-hour-label {
  height: var(--hour-h);
  display: flex; align-items: flex-start;
  justify-content: flex-end;
  padding: 8px 8px 0 0;
  font-size: 11px; color: var(--muted);
  user-select: none; white-space: nowrap;
}

.ag-lane-wrap {
  position: relative; flex: 1;
}

.ag-lane {
  position: relative; width: 100%;
}

.ag-h-line {
  position: absolute; left: 0; right: 0; height: 1px;
  background: var(--lane-hour-line);
  pointer-events: none;
}

.ag-hf-line {
  position: absolute; left: 0; right: 0; height: 1px;
  background: var(--lane-half-line);
  pointer-events: none;
}

.ag-now-line {
  position: absolute; left: 0; right: 0; height: 2px;
  background: rgba(255,90,90,.9);
  pointer-events: none; z-index: 10;
}
.ag-now-dot {
  position: absolute; left: -5px; top: -4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: rgba(255,90,90,.9);
}

/* Click-to-create ghost */
.ag-ghost-create {
  position: absolute; left: 10px; right: 10px;
  border-radius: 10px; pointer-events: none; z-index: 3;
  border: 1.5px dashed rgba(79,140,255,.6);
  background: rgba(79,140,255,.08);
  display: none;
}

/* Drop ghost */
.ag-ghost-drop {
  position: absolute; left: 10px; right: 10px;
  border-radius: 10px; pointer-events: none; z-index: 4;
  border: 1.5px dashed var(--purple);
  background: rgba(167,139,250,.09);
  display: none;
}

/* ─── Appointment blocks ─── */
.ag-appt-block {
  position: absolute; left: 10px; right: 10px;
  border-radius: 10px; padding: 7px 10px;
  cursor: grab; user-select: none;
  border-left: 3px solid transparent;
  transition: box-shadow .12s, transform .12s, opacity .12s;
  z-index: 5; overflow: hidden;
}
.ag-appt-block:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,.22);
  transform: translateY(-1px);
}
.ag-appt-block:active { cursor: grabbing; }
.ag-appt-block.is-dragging {
  opacity: .8; transform: scale(1.015);
  box-shadow: 0 12px 32px rgba(0,0,0,.28);
  cursor: grabbing; z-index: 100;
}

/* Estado colores */
.ag-appt-block[data-estado="agendada"] {
  background: rgba(79,140,255,.13);
  border-left-color: rgba(79,140,255,.85);
}
/* retrocompat con datos viejos */
.ag-appt-block[data-estado="programada"],
.ag-appt-block[data-estado="confirmada"] {
  background: rgba(79,140,255,.13);
  border-left-color: rgba(79,140,255,.85);
}
.ag-appt-block[data-estado="atendida"] {
  background: rgba(80,220,140,.12);
  border-left-color: rgba(80,220,140,.85);
}
.ag-appt-block[data-estado="cancelada"] {
  background: rgba(255,90,90,.09);
  border-left-color: rgba(255,90,90,.7);
  opacity: .65; text-decoration: line-through;
}

/* Light mode overrides */
#app.light-theme .ag-appt-block[data-estado="agendada"]   { background: rgba(79,140,255,.11); }
#app.light-theme .ag-appt-block[data-estado="programada"],
#app.light-theme .ag-appt-block[data-estado="confirmada"] { background: rgba(79,140,255,.11); }
#app.light-theme .ag-appt-block[data-estado="atendida"]   { background: rgba(80,220,140,.13); }
#app.light-theme .ag-appt-block[data-estado="cancelada"]  { background: rgba(255,90,90,.09); }

.ag-ab-row { display: flex; align-items: center; gap: 6px; }
.ag-ab-avatar {
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; flex-shrink: 0;
  overflow: hidden;
}
.ag-ab-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ag-ab-avatar.has-img { background: transparent !important; color: transparent; }
.ag-ab-name {
  font-size: 12px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ag-ab-meta {
  font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}
.ag-ab-paid {
  display: inline-block; font-size: 10px;
  padding: 1px 6px; border-radius: 999px; margin-left: 4px;
  border: 1px solid rgba(255,215,0,.3); background: rgba(255,215,0,.1);
  color: #ffd700;
}

/* Resize handle */
.ag-resize-handle {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 10px; cursor: s-resize;
  display: flex; align-items: center; justify-content: center;
  border-radius: 0 0 10px 10px;
}
.ag-resize-handle::after {
  content: ''; width: 28px; height: 2px;
  border-radius: 1px; background: currentColor; opacity: .35;
}
[data-estado="programada"] .ag-resize-handle { color: rgba(167,139,250,.9); }
[data-estado="confirmada"] .ag-resize-handle { color: rgba(79,140,255,.9); }
[data-estado="atendida"]   .ag-resize-handle { color: rgba(80,220,140,.9); }

/* ─── Tooltip de acciones ─── */
.ag-tooltip {
  position: fixed; z-index: 9999;
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,.28);
  padding: 12px 14px;
  min-width: 200px; max-width: 240px;
  pointer-events: none; /* activado solo al hover */
  display: none; opacity: 0;
  transition: opacity .1s;
}
.ag-tooltip.visible {
  display: block; opacity: 1; pointer-events: auto;
}

.ag-tt-name  { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.ag-tt-time  { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.ag-tt-srv   { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.ag-tt-notas { font-size: 11px; color: var(--muted); font-style: italic; margin-bottom: 8px; }

.ag-tt-badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; margin-left: 6px;
  vertical-align: middle;
}
.ag-tt-badge.agendada,
.ag-tt-badge.programada,
.ag-tt-badge.confirmada { background: rgba(79,140,255,.18); color: #4f8cff; }
.ag-tt-badge.atendida   { background: rgba(80,220,140,.18); color: #50dc8c; }
.ag-tt-badge.cancelada  { background: rgba(255,90,90,.15); color: #ff5a5a; }

.ag-tt-divider { height: 1px; background: var(--border); margin: 8px 0; }

.ag-tt-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ag-tt-btn {
  flex: 1 1 auto; padding: 5px 8px;
  border-radius: 8px; border: 1px solid var(--border);
  background: rgba(255,255,255,.04); color: var(--text);
  font-size: 11px; cursor: pointer; font-family: inherit;
  transition: background .12s; min-width: 0;
  text-align: center;
}
.ag-tt-btn:hover { background: rgba(255,255,255,.1); }
#app.light-theme .ag-tt-btn:hover { background: rgba(0,0,0,.07); }
.ag-tt-btn.danger { border-color: rgba(255,90,90,.4); color: #ff5a5a; }
.ag-tt-btn.danger:hover { background: rgba(255,90,90,.1); }
.ag-tt-btn.ok { border-color: rgba(80,220,140,.4); color: #50dc8c; }

/* ─── Modal (idéntico al original, ajustado para la nueva shell) ─── */
.ag-modal {
  position: fixed; inset: 0; display: none; place-items: center;
  background: rgba(0,0,0,.55); z-index: 1000;
  backdrop-filter: blur(4px);
}
.ag-modal.active { display: grid; }

.ag-dialog {
  width: min(1000px, 94vw); max-height: 88vh; overflow: hidden;
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(0,0,0,.4);
}

.ag-dialog header {
  position: sticky; top: 0; z-index: 2;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--card), var(--card-2));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}

.ag-dlg-title { display: grid; gap: 2px; }
.ag-dlg-title h3 { margin: 0; font-size: 18px; font-weight: 600; color: var(--text); }
.ag-dlg-title .sub { font-size: 12px; color: var(--muted); }

.ag-dlg-x {
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--border); background: rgba(255,255,255,.04);
  color: var(--text); cursor: pointer; display: grid; place-items: center;
  font-size: 16px;
}
.ag-dlg-x:hover { box-shadow: 0 4px 12px rgba(0,0,0,.2); }
#app.light-theme .ag-dlg-x { background: rgba(0,0,0,.04); }

.ag-dialog .ag-body {
  padding: 16px; display: grid; grid-template-columns: 1fr 1fr;
  gap: 14px; max-height: 70vh; overflow: auto;
}

.ag-form-section {
  border: 1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.03);
  border-radius: 14px; padding: 12px;
}
#app.light-theme .ag-form-section { border-color: rgba(0,0,0,.08); background: rgba(0,0,0,.03); }

.ag-form-section .ag-sec-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px;
}
.ag-sec-head strong { color: var(--text); font-size: 13px; letter-spacing: .3px; }
.ag-sec-head span   { font-size: 12px; color: var(--muted); }

.ag-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.ag-dialog label {
  font-size: 12px; color: var(--muted); display: block;
  margin-bottom: 4px; font-weight: 600;
}

.ag-dialog input,
.ag-dialog select,
.ag-dialog textarea {
  width: 100%; padding: 10px 12px; border-radius: 12px;
  background: linear-gradient(180deg, var(--card-2), rgba(0,0,0,.02));
  color: var(--text); border: 1px solid var(--border);
  font-family: inherit; font-size: 13px; min-height: 44px;
}
.ag-dialog textarea { min-height: 80px; resize: vertical; }
.ag-dialog input:focus,
.ag-dialog select:focus,
.ag-dialog textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(79,140,255,.2);
}

.ag-dialog select,
.ag-dialog option { color: var(--text); background-color: var(--card-2); }

.ag-dialog footer {
  position: sticky; bottom: 0; z-index: 2;
  padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
  background: linear-gradient(0deg, var(--card), var(--card-2));
  flex-wrap: wrap;
}

.ag-appt-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-right: auto; }

.ag-btn-danger { background: rgba(255,90,90,.15); border: 1px solid rgba(255,90,90,.4); color: #ff5a5a; }
.ag-btn-warn   { background: rgba(255,170,0,.1); border: 1px solid rgba(255,170,0,.4); color: #ffaa00; }
.ag-btn-ok     { background: rgba(80,220,140,.1); border: 1px solid rgba(80,220,140,.4); color: #50dc8c; }

/* ─── Rate banner ─── */
.rate-banner {
  position: fixed; bottom: 20px; right: 20px; z-index: 9998;
  background: linear-gradient(135deg, var(--card), var(--card-2));
  border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 16px; font-size: 13px; color: var(--muted);
  box-shadow: 0 8px 24px rgba(0,0,0,.2); text-align: center;
}

/* ─── color-scheme sync ─── */
section.agenda { color-scheme: dark; }
#app.light-theme section.agenda { color-scheme: light; }

/* ─── Responsive ─── */
/* REEMPLAZAR el bloque @media (max-width: 900px) */
@media (max-width: 900px) {
  .agenda-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }
  .ag-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    grid-row: auto;
    max-height: none;
    flex-direction: column;
  }
  .ag-sb-brand { width: 100%; }
  .ag-mini-cal { border-bottom: 1px solid var(--border); }
  /* Ocultar lista de pacientes en mobile — accesible vía el grid */
  .ag-patient-list { display: none; }
  .ag-grid-area { height: 65vh; min-height: 420px; }
  .ag-dialog .ag-body { grid-template-columns: 1fr; }
  .ag-grid-2 { grid-template-columns: 1fr; }
  /* Topbar: wrap limpio */
  .ag-topbar { flex-wrap: wrap; gap: 6px; padding: 8px 12px; }
  .ag-day-title { width: 100%; order: -1; font-size: 14px; }
  .ag-view-tabs { order: 1; }
  .ag-search { width: 100%; order: 2; }
  #addApptBtn { order: 3; width: 100%; }
}

@media (max-width: 600px) {
  section.agenda { padding: 0 6px; margin: 6px 0; }
  .agenda-shell { border-radius: 12px; }
  .ag-topbar { gap: 5px; padding: 8px 10px; }
  .ag-search { width: 100%; }
  .ag-day-title { font-size: 13px; }
  .ag-stats { padding: 6px 10px; gap: 5px; }
  .ag-stats .ag-chip { font-size: 11px; padding: 3px 8px; }
  .ag-appt-block { left: 4px !important; right: 4px !important; padding: 5px 8px; }
  #modal { padding: 6px; }
  #modal .dialog { border-radius: 14px; max-height: 98vh; }
  #modal .dialog header { padding: 12px 14px 10px; }
  #modal .form-section { padding: 10px; }
  #modal .grid-2 { grid-template-columns: 1fr; }
  #modal .dialog footer { flex-direction: column-reverse; gap: 6px; }
  #modal .appt-actions { margin-right: 0; width: 100%; }
  #modal .appt-actions .btn,
  #modal .appt-actions button { flex: 1; min-width: 0; font-size: 11px; padding: 7px 8px; }
  #modal button[type="submit"] { width: 100%; }
}

/* ─── Accesibilidad ─── */
.ag-sr {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

section.agenda button:focus-visible,
section.agenda input:focus-visible,
section.agenda select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(79,140,255,.18);
}

@media (prefers-reduced-motion: reduce) {
  section.agenda *, section.agenda *::before, section.agenda *::after {
    transition: none !important; animation: none !important;
  }
}

body.modal-open { overflow: hidden; }

/* ============================================================
   MODAL v2 — diseño completo para #modal existente en el PHP
   Reemplaza las clases section.agenda .modal / .dialog del CSS viejo.
   Usa las mismas variables CSS del sistema (--card, --border, etc.)
============================================================ */

/* ── Overlay ── */
#modal {
  position: fixed; inset: 0;
  display: none; place-items: center;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  z-index: 1000;
  padding: 16px;
  transition: background .28s ease, backdrop-filter .28s ease;
}
#modal.active {
  display: grid;
  background: rgba(0, 0, 0, .58);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: modalOverlayIn .28s ease both;
}
#modal .dialog {
  animation: modalDialogIn .36s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes modalOverlayIn {
  from { background: rgba(0,0,0,0); backdrop-filter: blur(0px); -webkit-backdrop-filter: blur(0px); }
  to   { background: rgba(0,0,0,.58); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
}
@keyframes modalDialogIn {
  from { opacity: 0; transform: translateY(14px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  #modal, #modal.active, #modal .dialog { animation: none !important; transition: none !important; }
}

/* ── Dialog ── */
#modal .dialog {
  width: min(880px, 100%);
  max-height: 92vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, var(--card) 0%, var(--card-2) 100%);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,.06) inset,
    0 32px 80px rgba(0,0,0,.45);
    overflow: auto;
}
#app.light-theme #modal .dialog {
  box-shadow:
    0 0 0 1px rgba(0,0,0,.06) inset,
    0 24px 60px rgba(0,0,0,.18);
}

/* ── Header ── */
#modal .dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--card) 0%, transparent 100%);
  flex-shrink: 0;
}

#modal .dlg-title { display: flex; flex-direction: column; gap: 3px; }

#modal .dlg-title h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .15px;
  font-family: 'DM Sans', var(--font-sans, system-ui), sans-serif;
}

#modal .dlg-title .sub {
  font-size: 12px;
  color: var(--muted);
}

/* Botón ✕ */
#modal .dlg-x {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.05);
  color: var(--text);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 15px;
  flex-shrink: 0;
  transition: background .12s, box-shadow .12s;
}
#modal .dlg-x:hover {
  background: rgba(255,255,255,.1);
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
#app.light-theme #modal .dlg-x {
  background: rgba(0,0,0,.04);
}
#app.light-theme #modal .dlg-x:hover {
  background: rgba(0,0,0,.08);
}

/* ── Body scrollable ── */
#modal .dialog .body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px;
  display: grid;
  gap: 12px;
}
#modal .dialog .body::-webkit-scrollbar { width: 5px; }
#modal .dialog .body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Secciones del form ── */
#modal .form-section {
  border: 1px solid rgba(255,255,255,.07);
  background: rgba(255,255,255,.025);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#app.light-theme #modal .form-section {
  border-color: rgba(0,0,0,.08);
  background: rgba(0,0,0,.025);
}

#modal .sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  margin-bottom: 2px;
}
#app.light-theme #modal .sec-head { border-bottom-color: rgba(0,0,0,.08); }

#modal .sec-head strong {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .4px;
  text-transform: uppercase;
}
#modal .sec-head span {
  font-size: 11px;
  color: var(--muted);
}

/* ── Grid 2 columnas dentro de sección ── */
#modal .grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ── Labels ── */
#modal label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  display: block;
  margin-bottom: 5px;
  letter-spacing: .3px;
  text-transform: uppercase;
  font-family: 'DM Sans', var(--font-sans, system-ui), sans-serif;
}

/* ── Inputs, selects, textarea ── */
#modal input,
#modal select,
#modal textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'DM Sans', var(--font-sans, system-ui), sans-serif;
  font-size: 13px;
  min-height: 42px;
  transition: border-color .12s, box-shadow .12s;
  appearance: none;
  -webkit-appearance: none;
}
#app.light-theme #modal input,
#app.light-theme #modal select,
#app.light-theme #modal textarea {
  background: rgba(0,0,0,.03);
}

#modal input:focus,
#modal select:focus,
#modal textarea:focus {
  outline: none;
  border-color: rgba(79,140,255,.55);
  box-shadow: 0 0 0 3px rgba(79,140,255,.15);
}

#modal input:disabled,
#modal select:disabled,
#modal textarea:disabled {
  opacity: .45;
  cursor: not-allowed;
}

#modal input[type="date"],
#modal input[type="time"] {
  color-scheme: dark;
}
#app.light-theme #modal input[type="date"],
#app.light-theme #modal input[type="time"] {
  color-scheme: light;
}

#modal textarea {
  min-height: 76px;
  resize: vertical;
}

/* Select: flecha custom */
#modal select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}
#modal select,
#modal option { color: var(--text); background-color: var(--card-2); }

/* ── Input search con estilo ID ── */
#modal .input-id,
#modal .input-nombre-paciente {
  font-variant-numeric: tabular-nums;
}

/* ── Footer ── */
#modal .dialog footer {
  flex-shrink: 0;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
  background: linear-gradient(0deg, var(--card) 0%, transparent 100%);
  flex-wrap: wrap;
}

/* Grupo de acciones rápidas (izquierda del footer) */
#modal .appt-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-right: auto;
}

/* Botones base del modal */
#modal .btn,
#modal button:not([type="submit"]):not(.dlg-x) {
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.05);
  color: var(--text);
  font-family: 'DM Sans', var(--font-sans, system-ui), sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, box-shadow .12s, transform .1s;
  min-height: 40px;
}
#modal .btn:hover,
#modal button:not([type="submit"]):not(.dlg-x):hover {
  background: rgba(255,255,255,.1);
  box-shadow: 0 3px 10px rgba(0,0,0,.18);
  transform: translateY(-1px);
}
#modal .btn:active,
#modal button:not([type="submit"]):not(.dlg-x):active {
  transform: translateY(0);
}
#app.light-theme #modal .btn,
#app.light-theme #modal button:not([type="submit"]):not(.dlg-x) {
  background: rgba(0,0,0,.04);
}
#app.light-theme #modal .btn:hover,
#app.light-theme #modal button:not([type="submit"]):not(.dlg-x):hover {
  background: rgba(0,0,0,.08);
}

/* Botón Guardar / Actualizar */
#modal button[type="submit"],
#modal .btn-primary {
  padding: 9px 18px;
  border-radius: 10px;
  border: none;
  background: var(--grad-1, linear-gradient(135deg,#4f8cff,#a78bfa));
  color: #fff;
  font-family: 'DM Sans', var(--font-sans, system-ui), sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
  transition: opacity .12s, transform .1s, box-shadow .15s;
  box-shadow: 0 4px 16px rgba(79,140,255,.3);
}
#modal button[type="submit"]:hover,
#modal .btn-primary:hover {
  opacity: .9;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(79,140,255,.4);
}
#modal button[type="submit"]:active { transform: translateY(0); }
#modal button[type="submit"]:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* Variantes de color */
#modal .btn.danger,
#modal button#btnApptDelete {
  border-color: rgba(255,90,90,.4);
  color: #ff6b6b;
  background: rgba(255,90,90,.08);
}
#modal .btn.danger:hover,
#modal button#btnApptDelete:hover { background: rgba(255,90,90,.15); }

#modal .btn.warn,
#modal button#btnApptCancel {
  border-color: rgba(255,170,0,.4);
  color: #ffaa00;
  background: rgba(255,170,0,.07);
}
#modal .btn.warn:hover,
#modal button#btnApptCancel:hover { background: rgba(255,170,0,.14); }

#modal .btn.btn-ok,
#modal button#btnConfirmarPagoCita {
  border-color: rgba(80,220,140,.4);
  color: #50dc8c;
  background: rgba(80,220,140,.07);
}
#modal .btn.btn-ok:hover,
#modal button#btnConfirmarPagoCita:hover { background: rgba(80,220,140,.14); }

#modal button#btnApptConfirm {
  border-color: rgba(79,140,255,.4);
  color: #4f8cff;
  background: rgba(79,140,255,.07);
}
#modal button#btnApptConfirm:hover { background: rgba(79,140,255,.14); }

#modal button#btnApptAtendida {
  border-color: rgba(80,220,140,.4);
  color: #50dc8c;
  background: rgba(80,220,140,.07);
}
#modal button#btnApptAtendida:hover { background: rgba(80,220,140,.14); }

/* ── Responsive modal ── */
@media (max-width: 700px) {
  #modal .dialog .body {
    grid-template-columns: 1fr;
    padding: 12px 14px;
  }
  #modal .grid-2 { grid-template-columns: 1fr; }
  #modal .dialog footer { flex-direction: column-reverse; }
  #modal .appt-actions { margin-right: 0; width: 100%; justify-content: stretch; }
  #modal .appt-actions .btn,
  #modal .appt-actions button { flex: 1; }
  #modal button[type="submit"] { width: 100%; }
  #modal .dlg-title h3 { font-size: 15px; }
}

@media (max-width: 480px) {
  #modal { padding: 8px; }
  #modal .dialog { border-radius: 16px; }
  #modal .dialog header { padding: 14px 14px 12px; }
  #modal .form-section { padding: 12px; }
}

/* ============================================================
   VISTA SEMANA — estilos adicionales
============================================================ */

/* Bloques en semana: más compactos */
.ag-appt-block.ag-appt-week {
  left: 3px;
  right: 3px;
  border-radius: 7px;
  padding: 4px 6px;
}

.ag-appt-block.ag-appt-week.is-dragging {
  opacity: 0.2 !important;
  pointer-events: none;
  transform: none !important;
  box-shadow: none !important;
}
.ag-appt-block.ag-appt-week .ag-ab-name { font-size: 11px; }
.ag-appt-block.ag-appt-week .ag-ab-meta { font-size: 10px; margin-top: 1px; }

/* Columnas del grid de semana */
.ag-lane-wrap [data-iso] {
  transition: background .1s;
}
.ag-lane-wrap [data-iso]:hover {
  background: rgba(79,140,255,.03);
}
#app.light-theme .ag-lane-wrap [data-iso]:hover {
  background: rgba(79,140,255,.04);
}

/* Header de días en semana — sticky dentro del scroll area */
.ag-week-header-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  border-right: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}
.ag-week-header-cell:hover { background: rgba(255,255,255,.04); }
#app.light-theme .ag-week-header-cell:hover { background: rgba(0,0,0,.04); }

/* En semana el agGridArea necesita overflow correcto */
.ag-grid-area.week-mode {
  overflow-y: auto;
  overflow-x: hidden;
}

/* Responsive semana — en móvil colapsa a 3 días */
@media (max-width: 720px) {
  /* El grid semana horizontal hace scroll */
  .ag-lane-wrap > div > div:last-child {
    overflow-x: auto;
  }
}