/* =====================================================================
   MiesApp — COMPONENTES
   Cada pieza reutilizable de la UI: botones, formularios, cards, listas,
   pills, tabs, chat, overlays. Mismo rol visual = misma clase.
   Los constructores de estas piezas viven en js/ui.js (nada de estilos
   inline en el JS: si algo necesita estilo, se le hace una clase acá).
   ===================================================================== */

/* ---- Botones ---- */
.appbtn {
  width: 100%;
  min-height: 50px;
  border-radius: var(--rad);
  border: none;
  background: var(--acento, var(--primary));   /* usa el color de marca */
  color: #ffffff;
  font-size: 15.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.appbtn:active   { transform: scale(.98); }
.appbtn:disabled { opacity: .5; }

.ghostbtn {
  width: 100%;
  min-height: 46px;
  border-radius: var(--rad);
  border: 1px solid var(--border2);
  background: none;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.ghostbtn:active { transform: scale(.98); }

.dangerbtn {
  width: 100%;
  min-height: 46px;
  border-radius: var(--rad);
  border: 1px solid var(--badbg);
  background: var(--badbg);
  color: var(--bad);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.bigopt {
  width: 100%;
  min-height: 54px;
  border-radius: var(--rad);
  border: 1px solid var(--border2);
  background: var(--bg);
  font-size: 15px;
  cursor: pointer;
  color: var(--text);
  text-align: left;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 8px;
  font-family: inherit;
  font-weight: 500;
}
.bigopt:active     { transform: scale(.98); background: var(--surf); }
.bigopt .debe      { margin-left: auto; font-size: 12px; color: var(--bad); }

/* ---- Formularios ---- */
.fld { margin: 0 0 14px; }
.fld label { display: block; font-size: 13px; color: var(--sec); margin: 0 0 6px; font-weight: 500; }

.seg { display: flex; gap: 6px; }
.seg button, .chip {
  height: 46px;
  border-radius: var(--rad-sm);
  border: 1px solid var(--border2);
  background: none;
  font-size: 14px;
  cursor: pointer;
  color: var(--sec);
  font-family: inherit;
  font-weight: 500;
}
.seg button { flex: 1; }
.chip { flex: 1; min-width: 0; }
.seg button.sel, .chip.sel { background: var(--primary); color: var(--onprimary); border-color: var(--primary); }

/* ---- Bloques de datos (clave/valor, hint) ---- */
.kv { display: flex; justify-content: space-between; font-size: 13.5px; }
.kv + .kv { margin-top: 5px; }
.kv .k { color: var(--sec); }
.kv .v { font-weight: 600; text-align: right; }
.hint { background: var(--accbg); color: var(--acc); padding: 12px; border-radius: var(--rad-sm); font-size: 13.5px; line-height: 1.4; margin-bottom: 14px; font-weight: 500; }

/* ---- Cards ---- */
.card { background: var(--surf); border-radius: var(--rad-lg); padding: 13px 16px; margin-bottom: 10px; }

/* ---- Pills / estados ---- */
.pill { font-size: 11.5px; padding: 4px 9px; border-radius: var(--rad-pill); flex-shrink: 0; font-weight: 600; }
.p-bad { background: var(--badbg); color: var(--bad); }
.p-ok  { background: var(--okbg);  color: var(--ok); }
.p-neu { background: var(--surf);  color: var(--sec); }
.p-acc { background: var(--accbg); color: var(--acc); }
.p-warn{ background: #fbeeca;      color: #9a6c07; }   /* Cargo parcial (ámbar) */

/* Colores de texto sueltos. Reemplazan a los `elemento.style.color = …`
   que el JS de FlorApp escribía a mano (ej. el color del CC en la ficha):
   ahora se togglea una clase, nunca un estilo inline. */
.t-ok  { color: var(--ok); }
.t-bad { color: var(--bad); }
.t-sec { color: var(--sec); }
.t-warn{ color: #e0a11b; }   /* igual que .ic-warn, para que icono y label matcheen */
/* Estados del login (Enviando…, Verificando…, etc.): en azul mies, no verde. */
.auth-msg.t-ok { color: var(--mies); }

/* ---- Avatar ---- */
.avat {
  width: 40px;
  height: 40px;
  border-radius: var(--rad-round);
  background-color: color-mix(in srgb, var(--acento) 15%, transparent);
  color: var(--acento);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: bold;
  flex-shrink: 0;
}

/* ---- Fila de paciente (lista) ---- */
.prow { display: flex; align-items: center; gap: 12px; padding: 13px 2px; border-bottom: 1px solid var(--border); cursor: pointer; }
.prow .pinfo { flex: 1; min-width: 0; }
.prow .pname { margin: 0; font-size: 14.5px; font-weight: 600; }
.prow .psub  { margin: 0; font-size: 12.5px; color: var(--muted); }

/* ---- Fila de sesión (agenda / home) ---- */
.sesrow { display: grid; grid-template-columns: 84px 48px 1fr auto; align-items: center; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--rad); margin: 0 0 8px; cursor: pointer; font-size: 14px; }
.sesrow .sdate { color: var(--muted); font-size: 13px; }
.sesrow .shora { color: var(--sec);   font-size: 13px; }
.sesrow .spac  { font-weight: 600; }
.past { opacity: .65; }

/* ---- Fila de movimiento (cuenta corriente) ---- */
.mrow { display: flex; align-items: center; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--border); font-size: 13.5px; cursor: pointer; }
.mrow.last  { border-bottom: none; }
.mrow .mdate { color: var(--muted); flex: 0 0 auto; width: max-content; white-space: nowrap; }
.mrow .mmain { flex: 1; }
.mrow .mname { font-weight: 600; }
.mrow .msub  { font-size: 12px; color: var(--muted); }
.mrow .mamt  { font-weight: 600; }

/* ---- Tabs ---- */
.tabbar { display: flex; gap: 6px; background: var(--surf); border-radius: var(--rad); padding: 4px; margin-bottom: 10px; }
.tab { flex: 1; height: 42px; border-radius: var(--rad-xs); border: none; background: none; font-size: 14px; cursor: pointer; color: var(--sec); font-family: inherit; font-weight: 500; }
.tab.sel { background: var(--bg); color: var(--text); font-weight: 600; box-shadow: var(--sh-tab); }

/* ---- Home: card de acceso (hc3) ---- */
.hc3 { border: 1px solid var(--border); border-radius: var(--rad-lg); background: var(--bg); padding: 18px 6px; text-align: center; cursor: pointer; }
.hc3:active { transform: scale(.97); background: var(--surf); }
.hc3 .ic { font-size: 19px; line-height: 1; display: flex; justify-content: center; color: var(--sec); }
.hc3 p   { margin: 8px 0 0; font-size: 12.5px; font-weight: 600; }

/* ---- Iconos de línea (inline SVG, ver js/icons.js) ---- */
/* El grosor de línea se define acá una sola vez para toda la app. */
.ico { width: 1.3em; height: 1.3em; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.18em; flex-shrink: 0; }
/* Botón de avisos (campana) en la cabecera: relleno azul mies, icono blanco. */
.bk.bell-btn { background: var(--mies); border-color: var(--mies); color: #fff; }
.ic-ok   { color: var(--ok); }
.ic-bad  { color: var(--bad); }
.ic-warn { color: #e0a11b; }
.ic-mut  { color: var(--sec); }

/* ---- Notificaciones: botones de acción dentro de una burbuja ---- */
/* ---- Notificaciones: fila full-width formato notificación ---- */
.noti { display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 14px 2px; border-bottom: 1px solid var(--border); }
.noti-ico { flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%; background: var(--accbg); color: var(--acento); display: flex; align-items: center; justify-content: center; margin-top: 1px; }
.noti-ico .ico { width: 18px; height: 18px; }
.noti-body { flex: 1; min-width: 0; }
.noti-texto { font-size: 14px; line-height: 1.45; white-space: pre-wrap; color: var(--text); }
.noti-time { font-size: 11px; color: var(--muted); margin-top: 6px; }
.noti-check { flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%; border: none; background: none; padding: 0; margin-top: 1px; color: var(--border2); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.noti-check .ico { width: 24px; height: 24px; }
.noti-check:active { background: var(--surf); }
.noti-check:disabled { cursor: default; }
/* Marcada como leída: toda la fila en gris. */
.noti-leida { opacity: .5; }
.noti-leida .noti-ico { background: var(--surf); color: var(--sec); }
.noti-leida .noti-check { color: var(--sec); }

.notif-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 11px; }
.notif-actions button { flex: 1 1 auto; min-height: 38px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--border2); background: var(--bg); font-size: 12.5px; font-weight: 600; color: var(--text); font-family: inherit; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.notif-actions button:active { transform: scale(.96); background: var(--surf); }

/* ---- Chat (pantalla Notificaciones) ----
   Las notificaciones automáticas y la charla son lo mismo: burbujas del bot
   a la izquierda, las de la profesional a la derecha. */
.chat-msg { display: flex; margin-bottom: 9px; }
.chat-msg.is-flor { justify-content: flex-end; }
.chat-msg.is-bot  { justify-content: flex-start; }
.chat-bub {
  max-width: 80%;
  padding: 9px 12px 6px;
  border-radius: 16px;          /* radio propio de la burbuja */
  font-size: 14px;
  line-height: 1.42;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.chat-msg.is-bot  .chat-bub { background: var(--surf);  border-bottom-left-radius: 5px; }
.chat-msg.is-flor .chat-bub { background: var(--acento); color: #fff; border-bottom-right-radius: 5px; }
.chat-texto { white-space: pre-wrap; }
.chat-bub .notif-actions { margin-top: 8px; }
.chat-pie  { display: flex; align-items: center; justify-content: flex-end; gap: 7px; margin-top: 3px; }
.chat-time { font-size: 10.5px; opacity: .6; }
.chat-msg.is-flor .chat-time { color: #fff; }

/* Barra de escritura */
.chat-form { display: flex; gap: 8px; align-items: center; }
.chat-form input {
  flex: 1; min-width: 0; height: 48px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: 24px;    /* óvalo propio */
  background: var(--surf); color: var(--text);
  font-size: 16px;
  font-family: inherit;
}
.chat-form input:focus { outline: none; border-color: var(--acento); }
/* Más específico que .appbtn (que impone width:100% y min-height:50px y
   dejaba el botón ovalado en vez de redondo). */
.chat-form .chat-send {
  width: 48px; height: 48px; min-height: 48px; flex: 0 0 48px; padding: 0;
  border-radius: var(--rad-round); font-size: 17px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}

/* "Escribiendo…" — el asistente tarda unos segundos en contestar */
.chat-typing { display: flex; gap: 4px; align-items: center; padding: 13px 14px; }
.chat-typing i { width: 7px; height: 7px; border-radius: var(--rad-round); background: var(--muted); display: block; animation: chatdot 1.3s infinite; }
.chat-typing i:nth-child(2) { animation-delay: .18s; }
.chat-typing i:nth-child(3) { animation-delay: .36s; }

/* ---- Overlays globales ---- */
#toast {
  display: none; position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom));
  background: var(--primary); color: var(--onprimary);
  border-radius: var(--rad); padding: 13px 20px; font-size: 14px;
  text-align: center; z-index: var(--z-toast); max-width: 90%;
  box-shadow: var(--sh-toast);
}
/* Variante error: fondo rojo, texto a la izquierda y botón "Reportar". */
#toast.is-error { align-items: center; gap: 12px; text-align: left; background: var(--bad); }
#toast .toast-txt { flex: 1; min-width: 0; }
#toast .toast-rep { flex-shrink: 0; background: #fff; color: var(--bad); border-radius: var(--rad-sm); padding: 6px 13px; font-weight: 700; font-size: 13px; text-decoration: none; white-space: nowrap; }
#toast .toast-rep:active { transform: scale(.96); }

#loader { display: none; position: fixed; inset: 0; background: rgba(255, 255, 255, .75); z-index: var(--z-loader); align-items: center; justify-content: center; }
.spin { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: var(--rad-round); animation: sp .8s linear infinite; }

.vacio { margin: 10px 0 12px; text-align: center; }
