/* ===== LAANTICLASE — AVISOS Y VENTANAS PROPIAS =====
   Toasts (mostrarToast) y ventanas de confirmacion/aviso (uiConfirm, uiAlert, uiPrompt).
   Reemplazan a confirm() y alert() del navegador para que todo el sistema hable igual.
   Usa la paleta de app.css: tinta, cafe, arena. */

/* ---------- TOASTS ---------- */
.lac-toasts {
  position: fixed; z-index: 900;
  right: 20px; bottom: 20px;
  display: flex; flex-direction: column; gap: 10px;
  width: 340px; max-width: calc(100vw - 32px);
  pointer-events: none;
}
.lac-toast {
  pointer-events: auto;
  position: relative; overflow: hidden;
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--white, #fff);
  border: 1px solid var(--gray-100, #e6e6e6);
  border-radius: 14px;
  padding: 12px 12px 12px 16px;
  box-shadow: 0 10px 30px rgba(31,29,25,.14);
  animation: lacToastIn .22s cubic-bezier(.2,.8,.3,1);
}
.lac-toast::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--lac-tono, var(--gray-400));
}
.lac-toast.saliendo { animation: lacToastOut .18s ease forwards; }

.lac-toast-icono {
  width: 28px; height: 28px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 9px; font-size: 16px;
  background: var(--lac-tono-suave, var(--gray-50)); color: var(--lac-tono, var(--gray-500));
}
.lac-toast-cuerpo { flex: 1; min-width: 0; padding-top: 2px; }
.lac-toast-titulo {
  font-size: 13px; font-weight: 600; color: var(--gray-900, #111111);
  line-height: 1.35; word-break: break-word;
}
.lac-toast-detalle {
  font-size: 12px; color: var(--gray-500, #5a5a5a); margin-top: 2px; line-height: 1.4;
}
.lac-toast-cerrar {
  background: none; border: none; cursor: pointer; padding: 2px; margin: -2px -2px 0 0;
  color: var(--gray-400, #8a8a8a); font-size: 16px; line-height: 1; flex-shrink: 0;
  border-radius: 6px;
}
.lac-toast-cerrar:hover { background: var(--gray-50, #f5f5f5); color: var(--gray-900, #111111); }
.lac-toast-barra {
  position: absolute; left: 0; bottom: 0; height: 2px; width: 100%;
  background: var(--lac-tono, var(--gray-400)); opacity: .35;
  transform-origin: left center;
  animation: lacToastBarra linear forwards;
}

.lac-toast.tipo-ok    { --lac-tono: var(--ok, #3f6b3a);    --lac-tono-suave: var(--ok-light, #e3efe1); }
.lac-toast.tipo-error { --lac-tono: var(--error, #9c4f3f); --lac-tono-suave: var(--error-light, #f7e9e4); }
.lac-toast.tipo-warn  { --lac-tono: var(--warn, #9a6b1f);  --lac-tono-suave: var(--warn-light, #f7ecd6); }
.lac-toast.tipo-info  { --lac-tono: var(--cafe, #333333);  --lac-tono-suave: var(--cafe-light, #efefef); }

@keyframes lacToastIn  { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes lacToastOut { to { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes lacToastBarra { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* En el celular los avisos bajan desde arriba: abajo esta el menu de pestanas. */
@media (max-width: 700px) {
  .lac-toasts {
    left: 12px; right: 12px; width: auto;
    top: calc(12px + env(safe-area-inset-top, 0px)); bottom: auto;
    flex-direction: column-reverse;
  }
  @keyframes lacToastIn  { from { opacity: 0; transform: translateY(-10px) scale(.98); } to { opacity: 1; transform: none; } }
  @keyframes lacToastOut { to { opacity: 0; transform: translateY(-6px) scale(.98); } }
}

/* ---------- VENTANAS (confirmar / avisar / pedir un dato) ---------- */
.lac-modal-fondo {
  position: fixed; inset: 0; z-index: 950;
  background: rgba(31,29,25,.55);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: lacFondoIn .16s ease;
}
.lac-modal-fondo.saliendo { animation: lacFondoOut .16s ease forwards; }

.lac-modal {
  background: var(--white, #fff);
  border-radius: 18px;
  width: 100%; max-width: 420px;
  padding: 22px 22px 18px;
  box-shadow: 0 24px 60px rgba(31,29,25,.3);
  animation: lacModalIn .2s cubic-bezier(.2,.8,.3,1);
}
.lac-modal-fondo.saliendo .lac-modal { animation: lacModalOut .16s ease forwards; }

.lac-modal-icono {
  width: 44px; height: 44px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; margin-bottom: 14px;
  background: var(--lac-tono-suave, var(--arena-light, #f5f5f5));
  color: var(--lac-tono, var(--verde, #111));
}
.lac-modal-titulo {
  font-size: 17px; font-weight: 600; color: var(--gray-900, #111111);
  letter-spacing: -.2px; line-height: 1.3;
}
.lac-modal-texto {
  font-size: 13.5px; color: var(--gray-500, #5a5a5a);
  line-height: 1.55; margin-top: 7px; word-break: break-word;
}
.lac-modal-campo {
  width: 100%; height: 44px; margin-top: 14px;
  border: 1.5px solid var(--gray-100, #e6e6e6); border-radius: var(--radius-md, 12px);
  padding: 0 12px; font-family: var(--font, sans-serif); font-size: 14px;
  color: var(--gray-900, #111111); background: var(--white, #fff);
}
.lac-modal-campo:focus { border-color: var(--verde, #111); outline: none; }
.lac-modal-acciones {
  display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px;
}
.lac-modal-acciones .btn { min-width: 104px; }
/* Dentro de la ventana el botón sí va lleno: es la confirmación final. */
.lac-modal .btn-peligro { background: var(--error, #9c4f3f); color: #fff; box-shadow: none; }
.lac-modal .btn-peligro:hover { background: var(--error, #9c4f3f); opacity: .9; color: #fff; }

.lac-modal.tono-peligro { --lac-tono: var(--error, #9c4f3f); --lac-tono-suave: var(--error-light, #f7e9e4); }
.lac-modal.tono-warn    { --lac-tono: var(--warn, #9a6b1f);  --lac-tono-suave: var(--warn-light, #f7ecd6); }
.lac-modal.tono-ok      { --lac-tono: var(--ok, #3f6b3a);    --lac-tono-suave: var(--ok-light, #e3efe1); }
.lac-modal.tono-info    { --lac-tono: var(--cafe, #333333);  --lac-tono-suave: var(--cafe-light, #efefef); }

@keyframes lacFondoIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes lacFondoOut { to { opacity: 0; } }
@keyframes lacModalIn  { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes lacModalOut { to { opacity: 0; transform: translateY(8px) scale(.98); } }

/* En el celular la ventana sube como hoja desde abajo. */
@media (max-width: 700px) {
  .lac-modal-fondo { align-items: flex-end; padding: 0; }
  .lac-modal {
    max-width: none; border-radius: 24px 24px 0 0;
    padding: 22px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  }
  .lac-modal-acciones { flex-direction: column-reverse; gap: 8px; }
  .lac-modal-acciones .btn { width: 100%; height: 46px; font-size: 14px; }
  @keyframes lacModalIn  { from { opacity: 0; transform: translateY(100%); } to { opacity: 1; transform: none; } }
  @keyframes lacModalOut { to { opacity: 0; transform: translateY(100%); } }
}

/* ---------- CAMPO DE FECHA + CALENDARIO PROPIO ---------- */
.campo-fecha { position: relative; }
/* El input real sigue ahí (es el que se envía), pero no se ve. */
.campo-fecha-real {
  position: absolute; opacity: 0; pointer-events: none;
  width: 1px; height: 1px; padding: 0; border: 0;
}
.campo-fecha-boton {
  position: relative; width: 100%; height: 40px; padding: 0 10px 0 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--gray-100, #e6e6e6); border-radius: var(--radius-md, 12px);
  background: var(--white, #fff); color: var(--gray-900, #111111);
  font-family: var(--font, sans-serif); font-size: 14px; cursor: pointer;
  transition: border-color .15s;
}
.campo-fecha-boton:hover { border-color: var(--gray-200, #d0d0d0); }
.campo-fecha-boton > i {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 18px; color: var(--gray-400, #8a8a8a);
}
/* La fecha va al centro del campo y nunca se parte en dos lineas. */
.campo-fecha-texto {
  text-align: center; white-space: nowrap;
  font-variant-numeric: tabular-nums; letter-spacing: .01em;
}
.campo-fecha-texto.vacio { color: var(--gray-400, #8a8a8a); }

.cal-fondo { position: fixed; inset: 0; z-index: 940; background: transparent; }
.cal {
  position: fixed; width: 288px;
  background: var(--white, #fff); border: 1px solid var(--gray-100, #e6e6e6);
  border-radius: 16px; padding: 12px;
  box-shadow: 0 18px 44px rgba(31,29,25,.2);
  animation: lacToastIn .16s ease;
}
.cal-cabecera { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.cal-mes {
  flex: 1; text-align: center; font-size: 13.5px; font-weight: 600;
  color: var(--gray-900, #111111); text-transform: capitalize;
}
.cal-nav {
  width: 30px; height: 30px; border: none; border-radius: 9px; cursor: pointer;
  background: var(--gray-50, #f5f5f5); color: var(--gray-500, #5a5a5a);
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.cal-nav:hover { background: var(--gray-100, #e6e6e6); color: var(--gray-900, #111111); }

.cal-dias { display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 4px; }
.cal-dias span {
  text-align: center; font-size: 10px; font-weight: 700; color: var(--gray-400, #8a8a8a);
  text-transform: uppercase; letter-spacing: .06em;
}
.cal-grilla { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dia {
  height: 34px; border: none; background: none; cursor: pointer;
  border-radius: 10px; font-family: var(--font, sans-serif); font-size: 13px;
  color: var(--gray-900, #111111); font-variant-numeric: tabular-nums;
}
.cal-dia:hover { background: var(--gray-50, #f5f5f5); }
.cal-dia.fuera { color: var(--gray-200, #d0d0d0); }
.cal-dia.hoy { box-shadow: inset 0 0 0 1.5px var(--gray-200, #d0d0d0); font-weight: 600; }
.cal-dia.elegido, .cal-dia.elegido:hover {
  background: var(--verde, #111111); color: #fff; font-weight: 600; box-shadow: none;
}

.cal-pie {
  display: flex; gap: 8px; margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--gray-100, #e6e6e6);
}
.cal-accion {
  flex: 1; height: 32px; border: none; border-radius: 9px; cursor: pointer;
  background: var(--gray-50, #f5f5f5); color: var(--gray-500, #5a5a5a);
  font-family: var(--font, sans-serif); font-size: 12px; font-weight: 600;
}
.cal-accion:hover { background: var(--gray-100, #e6e6e6); color: var(--gray-900, #111111); }

@media (max-width: 700px) {
  .cal-fondo {
    background: rgba(31,29,25,.55);
    -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
    display: flex; align-items: flex-end;
  }
  .cal {
    position: relative; inset: auto; width: 100%;
    border-radius: 24px 24px 0 0; border: none;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    animation: lacModalIn .2s cubic-bezier(.2,.8,.3,1);
  }
  .cal-dia { height: 42px; font-size: 14px; }
}
