/* ============================================================================
   AGENDAR CITA DESDE EL CHAT (js/citas/agendar-desde-chat.js)
   Computadora: se abre a la derecha del chat. Celular: pantalla completa.
   ============================================================================ */
#ag-modal { display: none; position: fixed; inset: 0; z-index: 10050; pointer-events: none;
    align-items: center; justify-content: flex-start; padding-left: calc(50vw + 12px); padding-right: 20px; }
#ag-modal.abierto { display: flex; }
#ag-modal .ag-card { pointer-events: auto; width: 100%; max-width: 640px; height: 86vh; max-height: 820px; background: #fff;
    border-radius: 16px; box-shadow: 0 12px 36px rgba(0,0,0,.3); display: flex; flex-direction: column; overflow: hidden;
    color: #0f172a; font-size: 14px; }
.ag-hd { display: flex; align-items: center; gap: 10px; padding: 14px 16px 8px; }
.ag-tit { flex: 1; min-width: 0; }
.ag-tit h3 { margin: 0; font-size: 16px; font-weight: 800; }
.ag-tit small { display: block; font-size: 12px; color: #64748b; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-x { width: 32px; height: 32px; border-radius: 50%; border: none; background: #f1f5f9; color: #475569; font-size: 20px; cursor: pointer; flex: none; line-height: 1; }
.ag-pasos { display: flex; gap: 6px; padding: 0 16px 8px; }
.ag-pasos i { flex: 1; height: 4px; border-radius: 2px; background: #e2e8f0; }
.ag-pasos i.on { background: #d81b60; }

/* Paso 1 */
.ag-uno { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.ag-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 14px 8px; }
.ag-nav b { font-size: 14px; text-transform: capitalize; }
.ag-nav button, .ag-chips button, .ag-libres button { border: 1px solid #e2e8f0; background: #fff; color: #334155; border-radius: 999px;
    padding: 5px 11px; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: inherit; display: inline-flex; align-items: center; gap: 5px; }
.ag-chips { display: flex; gap: 6px; padding: 0 14px 8px; overflow-x: auto; scrollbar-width: none; flex: none; }
.ag-chips::-webkit-scrollbar { display: none; }
.ag-chips button { flex: none; }
.ag-chips button.on { background: #0f172a; color: #fff; border-color: #0f172a; }
.ag-chips i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.ag-tira { display: flex; gap: 6px; padding: 2px 12px 10px; overflow-x: auto; scrollbar-width: none; flex: none; }
.ag-tira::-webkit-scrollbar { display: none; }
.ag-tira button { flex: none; width: 50px; border-radius: 12px; border: 1px solid #e2e8f0; background: #fff; padding: 5px 0 4px; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; color: #334155; font-family: inherit; }
.ag-tira span { font-size: 10.5px; font-weight: 700; text-transform: uppercase; color: #64748b; }
.ag-tira b { font-size: 17px; line-height: 1.2; }
.ag-tira em { display: flex; gap: 2px; height: 5px; margin-top: 2px; }
.ag-tira em i { width: 5px; height: 5px; border-radius: 50%; background: #94a3b8; }
.ag-tira button.on { background: #d81b60; border-color: #d81b60; color: #fff; }
.ag-tira button.on span { color: #fde2ec; } .ag-tira button.on em i { background: #fff; }
.ag-tira button.sab:not(.on) { opacity: .6; }
.ag-cabcols { display: grid; grid-template-columns: 52px repeat(3, 1fr); border-bottom: 1px solid #eef2f7; position: sticky; top: 0; z-index: 4; background: #fff; }
.ag-cabcols div { text-align: center; font-size: 12.5px; font-weight: 700; padding: 6px 0; text-transform: capitalize; color: #334155; }
.ag-cabcols div.hoy { color: #d81b60; }
.ag-scroll { flex: 1; overflow-y: auto; min-height: 0; border-top: 1px solid #eef2f7; -webkit-overflow-scrolling: touch; }
.ag-rejilla { display: flex; }
.ag-horas { width: 52px; flex: none; }
.ag-h { font-size: 11px; color: #94a3b8; text-align: right; padding: 2px 8px 0 0; box-sizing: border-box; }
.ag-cols { flex: 1; display: flex; }
.ag-col { flex: 1; position: relative; border-left: 1px solid #f1f5f9; cursor: pointer;
    background-image: linear-gradient(#eef2f7 1px, transparent 1px), linear-gradient(#f8fafc 1px, transparent 1px);
    background-size: 100% 80px, 100% 40px; }
.ag-col:hover { background-color: #fdf2f8; }
.ag-col.pasado { background-color: #f8fafc; cursor: not-allowed; }
.ag-col.sab { background-color: #fafafa; }
.ag-fuera { position: absolute; left: 0; right: 0; pointer-events: none;
    background: repeating-linear-gradient(45deg, rgba(241,245,249,.9), rgba(241,245,249,.9) 6px, rgba(226,232,240,.9) 6px, rgba(226,232,240,.9) 12px); }
.ag-ev { position: absolute; border-radius: 8px; border-left: 4px solid; padding: 3px 6px; font-size: 11.5px; line-height: 1.25; overflow: hidden;
    box-sizing: border-box; cursor: default; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.ag-ev b { display: block; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-ev span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
.ag-ev.tenue { opacity: .4; }
.ag-ahora { position: absolute; left: 0; right: 0; height: 2px; background: #ef4444; pointer-events: none; z-index: 2; }
.ag-ahora::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: #ef4444; }
.ag-pie { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 8px 14px; border-top: 1px solid #eef2f7; font-size: 11.5px; color: #64748b; flex: none; }
.ag-pie span { display: inline-flex; align-items: center; gap: 5px; }
.ag-pie i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.ag-pie i.raya { background: repeating-linear-gradient(45deg, #f1f5f9, #f1f5f9 2px, #cbd5e1 2px, #cbd5e1 4px); }
.ag-pie .der { margin-left: auto; }

/* Paso 2 */
.ag-dos { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.ag-form { flex: 1; overflow-y: auto; padding: 4px 16px 12px; display: flex; flex-direction: column; gap: 6px; }
.ag-sel { display: flex; align-items: center; gap: 10px; background: #fdf2f8; border: 1px solid #fbcfe8; border-radius: 14px; padding: 10px 12px; margin-bottom: 4px; }
.ag-sel.mal { background: #fef2f2; border-color: #fecaca; }
.ag-ic { width: 38px; height: 38px; border-radius: 10px; background: #d81b60; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; flex: none; }
.ag-sel.mal .ag-ic { background: #dc2626; }
.ag-sel b { display: block; font-size: 14.5px; }
.ag-sel span { font-size: 12px; color: #64748b; }
.ag-link { margin-left: auto; border: none; background: none; color: #d81b60; font-weight: 700; font-size: 13px; cursor: pointer; font-family: inherit; }
.ag-aviso { border-radius: 12px; padding: 9px 11px; font-size: 12.5px; line-height: 1.4; }
.ag-aviso.rojo { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.ag-aviso.ambar { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.ag-aviso.azul { background: #f0f9ff; border: 1px solid #bae6fd; color: #075985; }
.ag-libres { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ag-lb { font-size: 11px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: .3px; margin-top: 6px; }
.ag-in { width: 100%; box-sizing: border-box; border: 1px solid #e2e8f0; border-radius: 10px; padding: 9px 12px; font-size: 14px; font-family: inherit; color: #0f172a; background: #fff; outline: none; }
.ag-in:focus { border-color: #d81b60; }
textarea.ag-in { resize: vertical; min-height: 54px; }
.ag-fila { display: flex; gap: 8px; }
.ag-fila .ag-tel { width: 42%; flex: none; }
.ag-ops { display: flex; gap: 6px; flex-wrap: wrap; }
.ag-ops button { flex: 1; min-width: 70px; padding: 8px 6px; border-radius: 10px; border: 1px solid #e2e8f0; background: #fff; color: #334155; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; }
.ag-ops button.on { background: #0f172a; color: #fff; border-color: #0f172a; }
.ag-chk { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #334155; margin-top: 8px; cursor: pointer; }
.ag-chk input { width: 18px; height: 18px; accent-color: #d81b60; }
.ag-botones { display: flex; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid #eef2f7; flex: none; }
.ag-b { flex: 1; padding: 12px 0; border-radius: 12px; border: none; font-weight: 700; font-size: 14px; cursor: pointer; font-family: inherit; }
.ag-b.gris { background: #f1f5f9; color: #334155; flex: .55; }
.ag-b.rosa { background: #d81b60; color: #fff; }
.ag-b.rojo { background: #fff; color: #dc2626; border: 1.5px solid #dc2626; }
.ag-b:disabled { opacity: .6; cursor: wait; }

/* Abierto desde el calendario de citas: centrado con fondo */
#ag-modal.ag-centro { padding: 16px; justify-content: center; background: rgba(15,23,42,.35); pointer-events: auto; }

/* Tablet: centrado */
@media (max-width: 991px) {
    #ag-modal { padding: 16px; justify-content: center; background: rgba(15,23,42,.35); pointer-events: auto; }
}
/* Celular: pantalla completa */
@media (max-width: 767px) {
    #ag-modal, #ag-modal.ag-centro { padding: 0; align-items: stretch; background: #fff; }
    #ag-modal .ag-card { max-width: none; height: var(--chat-vv-h, 100dvh); max-height: none; border-radius: 0; box-shadow: none;
        margin-top: var(--chat-vv-top, 0px); padding-bottom: env(safe-area-inset-bottom); }
    .ag-in { font-size: 16px; }   /* evita el zoom del iPhone */
}
