/* Agenda estilo Google Calendar (agenda.js). Usa los colores del sistema de diseno del panel
   (estilo.css) y funciona igual en modo oscuro. El color de cada cita viene de su etiqueta en
   --c, y el texto en --t (blanco o casi negro, el que cumple AA sobre ese color). */

.ag {
  --ag-defecto: #5F0A3C; --ag-defecto-t: #FFFFFF;
  --ag-linea: var(--borde); --ag-ahora: #D93025;
  display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 18px; align-items: start;
}
:root[data-tema="oscuro"] .ag { --ag-defecto: #D98FBB; --ag-defecto-t: #1B1216; --ag-ahora: #F28B82; }

/* ---------- barra de la vista ---------- */
.ag-barra { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 12px; }
.ag-flechas { display: flex; gap: 2px; }
.ag-titulo { margin: 0 auto 0 4px; font-size: 19px; font-weight: 600; min-width: 0; }
.ag-titulo::first-letter { text-transform: uppercase; }
.ag-vistas { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--borde); border-radius: 999px; background: var(--superficie); }
.ag-vista-btn {
  min-height: 34px; padding: 6px 14px; border: 0; border-radius: 999px; background: none;
  color: var(--texto-2); font: inherit; font-size: 13.5px; cursor: pointer;
}
.ag-vista-btn:hover { color: var(--texto); background: var(--superficie-2); }
.ag-vista-btn[aria-pressed="true"] { background: var(--uva); color: #fff; }
:root[data-tema="oscuro"] .ag-vista-btn[aria-pressed="true"] { background: var(--verde); color: #1C1620; }
.ag-vista-btn:focus-visible, .ag button:focus-visible, .ag-lado input:focus-visible + .ag-muestra { outline: 2px solid var(--verde); outline-offset: 2px; }
.ag-aviso { margin-bottom: 12px; }
.ag-solo-movil { display: none; }
.ag-i { width: 14px; height: 14px; }

/* ---------- lado: mini calendario y leyenda ---------- */
.ag-lado { position: sticky; top: 84px; display: grid; gap: 16px; }
.ag-mini, .ag-leyenda { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--r); padding: 12px; }
.ag-mini-cabeza { display: flex; align-items: center; gap: 2px; margin-bottom: 6px; }
.ag-mini-cabeza strong { flex: 1; font-size: 14px; }
.ag-mini-dias { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.ag-mini-sem { font-size: 11px; color: var(--texto-3); padding: 2px 0; }
.ag-mini-dia {
  aspect-ratio: 1; min-width: 0; border: 0; border-radius: 50%; background: none; color: var(--texto);
  font: inherit; font-size: 12.5px; cursor: pointer; font-variant-numeric: tabular-nums;
}
.ag-mini-dia:hover { background: var(--superficie-2); }
.ag-mini-dia.fuera { color: var(--texto-3); }
.ag-mini-dia.en-rango { background: color-mix(in srgb, var(--verde) 22%, transparent); }
.ag-mini-dia.hoy { background: var(--uva); color: #fff; font-weight: 700; }
:root[data-tema="oscuro"] .ag-mini-dia.hoy { background: var(--verde); color: #1C1620; }
.ag-mini-dia.elegido:not(.hoy) { box-shadow: inset 0 0 0 2px var(--uva); }
:root[data-tema="oscuro"] .ag-mini-dia.elegido:not(.hoy) { box-shadow: inset 0 0 0 2px var(--verde); }
.ag-leyenda-cabeza { display: flex; align-items: center; margin-bottom: 4px; }
.ag-leyenda-cabeza strong { flex: 1; font-size: 14px; }
.ag-leyenda-lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.ag-leyenda-fila { display: flex; align-items: center; gap: 9px; min-height: 36px; padding: 4px 6px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.ag-leyenda-fila:hover { background: var(--superficie-2); }
.ag-leyenda-fila input { width: 17px; height: 17px; accent-color: var(--uva); flex: none; margin: 0; }
.ag-muestra { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.ag-muestra.sin-color { background: var(--ag-defecto); }

/* ---------- rejilla de franjas (dia y semana) ---------- */
.ag-rejilla {
  position: relative; overflow: auto; max-height: calc(100dvh - 210px); min-height: 420px;
  background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--r);
  overscroll-behavior: contain;
}
.ag-cabeza, .ag-horas-cuerpo { display: grid; grid-template-columns: 58px repeat(var(--dias), minmax(0, 1fr)); }
.ag-cabeza { position: sticky; top: 0; z-index: 4; background: var(--superficie); border-bottom: 1px solid var(--ag-linea); }
.ag-esquina { font-size: 10.5px; color: var(--texto-3); display: grid; place-items: end center; padding-bottom: 6px; }
.ag-dia-cab {
  display: grid; justify-items: center; gap: 2px; padding: 8px 2px; border: 0; background: none; cursor: pointer;
  color: var(--texto-2); font: inherit; border-left: 1px solid var(--ag-linea);
}
.ag-dia-cab:hover .ag-dia-num { background: var(--superficie-2); }
.ag-dia-nombre { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.ag-dia-num { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-size: 19px; color: var(--texto); font-variant-numeric: tabular-nums; }
.ag-dia-cab.hoy .ag-dia-nombre { color: var(--uva); font-weight: 700; }
.ag-dia-cab.hoy .ag-dia-num { background: var(--uva); color: #fff; }
:root[data-tema="oscuro"] .ag-dia-cab.hoy .ag-dia-nombre { color: var(--verde); }
:root[data-tema="oscuro"] .ag-dia-cab.hoy .ag-dia-num { background: var(--verde); color: #1C1620; }
.ag-horas-cuerpo { position: relative; height: calc(24 * var(--hora)); }
.ag-horas { position: relative; }
.ag-horas span { position: absolute; right: 8px; transform: translateY(-50%); font-size: 10.5px; color: var(--texto-3); font-variant-numeric: tabular-nums; }
.ag-col {
  position: relative; border-left: 1px solid var(--ag-linea); cursor: cell;
  background-image: linear-gradient(to bottom, var(--ag-linea) 1px, transparent 1px),
                    linear-gradient(to bottom, color-mix(in srgb, var(--ag-linea) 45%, transparent) 1px, transparent 1px);
  background-size: 100% var(--hora), 100% calc(var(--hora) / 2);
  background-position: 0 0, 0 calc(var(--hora) / 2);
}
.ag-col.hoy { background-color: color-mix(in srgb, var(--verde) 7%, transparent); }
.ag-ahora { position: absolute; left: 0; right: 0; height: 2px; background: var(--ag-ahora); z-index: 3; pointer-events: none; }
.ag-ahora::before { content: ""; position: absolute; left: -6px; top: -5px; width: 12px; height: 12px; border-radius: 50%; background: var(--ag-ahora); }

/* Una cita: bloque del color de su etiqueta */
.ag-cita {
  position: absolute; z-index: 2; display: flex; flex-direction: column; gap: 1px; overflow: hidden;
  padding: 4px 7px; border: 1px solid color-mix(in srgb, var(--superficie) 70%, transparent); border-radius: 7px;
  background: var(--c, var(--ag-defecto)); color: var(--t, var(--ag-defecto-t));
  text-align: left; font: inherit; font-size: 12.5px; line-height: 1.25; cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
  transition: box-shadow .15s, transform .15s, opacity .15s;
}
.ag-cita.sin-color { background: var(--ag-defecto); color: var(--ag-defecto-t); }
.ag-cita:hover { box-shadow: 0 6px 16px -6px rgba(0,0,0,.35); z-index: 3; }
.ag-cita:focus-visible { outline: 2px solid var(--texto); outline-offset: 2px; z-index: 4; }
.ag-cita-nombre { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-cita-hora { display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; }
.ag-cita .ag-i { width: 12px; height: 12px; stroke-width: 2; }
.ag-cita-estado { font-size: 11px; font-weight: 700; opacity: .92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-cita-tiempo { overflow: hidden; text-overflow: ellipsis; }
/* Cita corta (menos de 40 px): una sola linea, nombre y hora de inicio */
.ag-cita.corta { flex-direction: row; align-items: center; gap: 5px; padding: 1px 6px; }
.ag-cita.corta .ag-cita-nombre { flex: 0 1 auto; min-width: 0; }
.ag-cita.corta .ag-cita-hora { flex: 0 0 auto; font-weight: 400; }
/* Por confirmar: borde punteado; cancelada: gris, tachada y detras */
.ag-cita.propuesta { border: 2px dashed color-mix(in srgb, var(--t, #fff) 70%, transparent); }
.ag-cita.cancelada, .ag-chip.cancelada {
  background: var(--superficie-2); color: var(--texto-2); border: 1px solid var(--borde); box-shadow: none;
  text-decoration: line-through; z-index: 1;
}
.ag-estirar { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; cursor: ns-resize; }
.ag-estirar::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 18px; height: 3px; margin-left: -9px; border-radius: 2px; background: currentColor; opacity: 0; transition: opacity .15s; }
.ag-cita:hover .ag-estirar::after { opacity: .6; }
.ag-cita.arrastrando { z-index: 6; opacity: .92; box-shadow: 0 18px 36px -14px rgba(0,0,0,.45); transform: scale(1.02); cursor: grabbing; }
.ag-cita.guardando { opacity: .6; }
body.ag-arrastrando, body.ag-arrastrando * { user-select: none !important; cursor: grabbing !important; }

/* ---------- mes ---------- */
.ag-mes {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(108px, auto);
  background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--r); overflow: hidden;
}
.ag-mes-sem { grid-row: 1; min-height: 0; padding: 8px 0 4px; text-align: center; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--texto-3); border-bottom: 1px solid var(--ag-linea); }
.ag-mes > .ag-mes-sem { height: auto; }
.ag-mes { grid-template-rows: auto; }
.ag-mes-dia { display: flex; flex-direction: column; gap: 3px; padding: 4px 5px 6px; min-width: 0; border-right: 1px solid var(--ag-linea); border-bottom: 1px solid var(--ag-linea); cursor: cell; }
.ag-mes-dia:nth-child(7n) { border-right: 0; }
.ag-mes-dia.fuera { background: color-mix(in srgb, var(--superficie-2) 60%, transparent); }
.ag-mes-dia.fuera .ag-mes-num { color: var(--texto-3); }
.ag-mes-num { align-self: center; display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 50%; background: none; color: var(--texto); font: inherit; font-size: 13px; cursor: pointer; font-variant-numeric: tabular-nums; }
.ag-mes-num:hover { background: var(--superficie-2); }
.ag-mes-dia.hoy .ag-mes-num { background: var(--uva); color: #fff; font-weight: 700; }
:root[data-tema="oscuro"] .ag-mes-dia.hoy .ag-mes-num { background: var(--verde); color: #1C1620; }
.ag-chip {
  display: flex; gap: 5px; align-items: center; min-width: 0; padding: 2px 6px; border: 0; border-radius: 5px;
  background: var(--c, var(--ag-defecto)); color: var(--t, var(--ag-defecto-t)); font: inherit; font-size: 12px; text-align: left; cursor: pointer;
}
.ag-chip.sin-color { background: var(--ag-defecto); color: var(--ag-defecto-t); }
.ag-chip-hora { font-variant-numeric: tabular-nums; opacity: .92; }
.ag-chip-nombre { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.ag-mas { align-self: flex-start; border: 0; background: none; padding: 2px 6px; border-radius: 5px; color: var(--texto-2); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.ag-mas:hover { background: var(--superficie-2); color: var(--texto); }

/* ---------- lista ---------- */
.ag-lista { display: grid; gap: 10px; }
.ag-lista-dia { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 10px; align-items: start; background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--r); padding: 12px; }
.ag-lista-fecha { display: grid; justify-items: center; gap: 2px; color: var(--texto-2); }
.ag-lista-dia.hoy .ag-dia-num { background: var(--uva); color: #fff; }
:root[data-tema="oscuro"] .ag-lista-dia.hoy .ag-dia-num { background: var(--verde); color: #1C1620; }
.ag-lista-citas { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ag-lista-fila { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 10px; background: var(--superficie-2); }
.ag-lista-fila .ag-muestra { width: 6px; height: 38px; border-radius: 3px; }
.ag-lista-abrir { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; padding: 0; border: 0; background: none; text-align: left; color: var(--texto); font: inherit; cursor: pointer; }
.ag-lista-hora { font-size: 12.5px; color: var(--texto-2); font-variant-numeric: tabular-nums; }
.ag-lista-nombre { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-lista-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; min-width: 0; font-size: 12px; color: var(--texto-3); }
.ag-lista-fila.cancelada .ag-lista-nombre { text-decoration: line-through; color: var(--texto-2); }

/* ---------- etiquetas: gestion, paleta y formulario ---------- */
.ag-rotulo { display: block; font-size: 13px; font-weight: 500; color: var(--texto-2); margin-bottom: 5px; }
.ag-ayuda { margin: 0 0 14px; font-size: 13.5px; color: var(--texto-2); line-height: 1.5; }
.ag-etiquetas-lista { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 6px; }
.ag-etiquetas-lista li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--borde); border-radius: 10px; }
.ag-etiquetas-n { flex: 1; font-size: 12.5px; color: var(--texto-3); }
.ag-etiqueta { display: inline-flex; align-items: center; min-height: 26px; padding: 3px 11px; border-radius: 999px; background: var(--c); color: var(--t); font-size: 13px; font-weight: 700; }
.ag-etiqueta-form { padding-top: 14px; border-top: 1px solid var(--borde); }
.ag-paleta { display: grid; grid-template-columns: repeat(6, 38px); gap: 8px; }
.ag-color {
  width: 38px; height: 38px; border-radius: 50%; border: 2px solid transparent; background: var(--c); cursor: pointer;
  position: relative; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.ag-color[aria-checked="true"] { border-color: var(--superficie); box-shadow: 0 0 0 2px var(--texto); }
.ag-color[aria-checked="true"]::after {
  content: ""; position: absolute; left: 12px; top: 8px; width: 8px; height: 14px;
  border: solid var(--t); border-width: 0 3px 3px 0; transform: rotate(45deg);
}
.ag-color:focus-visible { outline: 3px solid var(--verde); outline-offset: 3px; }
.ag-previa { margin: 12px 0; min-height: 28px; }
.ag-etiqueta-botones { display: flex; gap: 9px; justify-content: flex-end; }
.ag-gestionar { margin-top: 6px; padding: 6px 8px; font-size: 13px; }
.ag-check { display: flex; gap: 9px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.ag-confirmar p { margin: 0 0 10px; line-height: 1.5; }
.ag-antes { color: var(--texto-3); text-decoration: line-through; }

/* ---------- tableta y celular ---------- */
@media (max-width: 1100px) {
  .ag { grid-template-columns: minmax(0, 1fr); }
  .ag-lado { position: static; display: none; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ag-lado.abierto { display: grid; }
  .ag-solo-movil { display: inline-flex; }
  .ag-principal { grid-row: 1; }
}
@media (max-width: 700px) {
  .ag-lado { grid-template-columns: minmax(0, 1fr); }
  .ag-titulo { order: -1; width: 100%; margin: 0 0 2px; font-size: 17px; }
  .ag-vistas { order: 5; width: 100%; justify-content: space-between; }
  .ag-vista-btn { flex: 1; padding: 6px 4px; }
  .ag-rejilla { max-height: calc(100dvh - 250px); }
  .ag-cabeza, .ag-horas-cuerpo { grid-template-columns: 44px repeat(var(--dias), minmax(0, 1fr)); }
  .ag-horas span { right: 4px; font-size: 10px; }
  .ag-mes { grid-auto-rows: minmax(76px, auto); }
  .ag-chip-hora { display: none; }
  .ag-chip { font-size: 11px; padding: 2px 4px; }
  .ag-paleta { grid-template-columns: repeat(6, 36px); }
}

/* Horas ocupadas del Google Calendar de la psicologa (Maity 5, etapa 2). No son citas: no se
   abren, no se mueven y quedan DEBAJO de las citas (z-index 1). Rayado gris para que se lea de
   un vistazo que esa hora no esta libre, sin competir con los colores de las etiquetas. */
.ag-ocupado {
  position: absolute; z-index: 1; left: 2px; right: 2px; overflow: hidden;
  padding: 3px 7px; border-radius: 7px; pointer-events: none;
  border: 1px dashed color-mix(in srgb, var(--texto-3) 55%, transparent);
  background: repeating-linear-gradient(135deg,
    color-mix(in srgb, var(--texto-3) 12%, transparent) 0 6px,
    transparent 6px 12px);
  color: var(--texto-2); font-size: 12px; line-height: 1.25;
}
.ag-ocupado.corta { padding: 0 7px; font-size: 10.5px; line-height: 15px; }
.ag-ocupado-txt {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-style: italic;
}
/* Lo que en Google esta marcado como "disponible": se ve, pero no bloquea. Mas tenue y sin rayado,
   para que se note la diferencia de un vistazo (el porque va en el title y en el aria-label). */
.ag-ocupado.libre { background: none; border-style: dotted; opacity: .72; }
/* Lo del Google Calendar en la vista de lista (la del telefono): se mezcla con las citas por hora,
   pero se lee distinto, porque no es una cita y no se puede abrir. */
.ag-lista-fila.ocupado .ag-lista-nombre { font-style: italic; color: var(--texto-2); font-weight: 500; }
.ag-lista-fila.ocupado .ag-lista-abrir { cursor: default; background: none; }
.ag-lista-fila.ocupado.libre { opacity: .75; }
.ag-muestra.ocupado {
  background: repeating-linear-gradient(135deg,
    var(--texto-3) 0 3px, transparent 3px 6px);
}

/* El color que Maity le puso al evento en su Google Calendar (--oc). Va de franja y de tinte, no
   de fondo del texto: la paleta de Google tiene tonos sobre los que el texto no se leeria, y
   ademas una cita del sistema no se puede confundir con un bloque de Google. Quien no es dueño
   del calendario no recibe el color: ese bloque se queda gris y sin nombre. */
.ag-ocupado.propio {
  /* El texto va en el tono mas fuerte: sobre el tinte de un color oscuro de la paleta (arandano)
     el color apagado se quedaba en 4,27 y AA pide 4,5. */
  color: var(--texto);
  border-color: color-mix(in srgb, var(--oc) 70%, transparent);
  border-left: 3px solid var(--oc);
  background: repeating-linear-gradient(135deg,
    color-mix(in srgb, var(--oc) 15%, transparent) 0 6px,
    transparent 6px 12px);
}
.ag-ocupado.propio.libre { background: none; }
.ag-muestra.ocupado.propio {
  background: repeating-linear-gradient(135deg, var(--oc) 0 3px, transparent 3px 6px);
}

/* Tarjeta "Hoy" del tablero: el día completo, las citas del sistema y lo del Google Calendar en
   la misma lista. Lo de Google no se abre, va en cursiva y con la franja de su color; para quien
   no conectó el calendario llega sin color y sin título, y se queda gris. */
.hoy-fila {
  display: flex; gap: 11px; align-items: center;
  padding: 9px; border-radius: 10px; background: var(--superficie-2);
}
.hoy-hora { font-variant-numeric: tabular-nums; min-width: 44px; }
.hoy-ocupado {
  background: none;
  border: 1px dashed color-mix(in srgb, var(--texto-3) 45%, transparent);
  border-left: 3px solid var(--oc, var(--texto-3));
}
.hoy-ocupado .hoy-ocupado-txt { font-style: italic; color: var(--texto-2); }
.hoy-ocupado.propio { border-color: color-mix(in srgb, var(--oc) 60%, transparent); border-left-color: var(--oc); }

/* Formulario de cita: qué pasa a la hora elegida y qué horas quedan libres ese día. */
.ag-hora-aviso {
  display: flex; gap: 7px; align-items: center; margin-top: 6px;
  font-size: 12.5px; line-height: 1.4;
}
.ag-hora-aviso.bien { color: var(--verde); }
.ag-hora-aviso.mal { color: var(--coral); }
.ag-libres { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 7px; }
.ag-libres-rotulo { font-size: 12px; color: var(--texto-3); }
.btn.ag-libre { padding: 3px 9px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.ag-ver-todas {
  margin-top: 6px; padding: 0; border: none; background: none; cursor: pointer;
  font: inherit; font-size: 12.5px; color: var(--uva); text-decoration: underline;
}
.ag-ver-todas:hover { color: var(--texto); }
