/* ============================================================================
   NewFox — diálogos y toasts propios (avisos de la casa)
   ----------------------------------------------------------------------------
   Hoja AUTOCONTENIDA para assets/js/nf-dialog.js. Se carga en TODAS las
   pantallas desde includes/footer.php, así que no puede tocar nada que no sea
   suyo:

     - Los tokens se declaran en los propios contenedores (.nf-dialog-backdrop,
       .nf-toast-wrap), NUNCA en :root, para no pisar los tokens --rv- y --nf-
       que cada pantalla trae de includes/estilos_nf.php o de newfox-ui.css.
     - Los botones van bajo .nf-dialog (.nf-dialog .nf-btn), no sueltos: en una
       pantalla que ya cargue newfox-ui.css el resultado es el mismo, y en una
       que no, el diálogo se ve igual de bien.
     - Todo lleva prefijo nf-dialog- / nf-toast-.

   El diálogo se abre a menudo ENCIMA de otro modal (parte, reserva, ficha), así
   que su z-index queda por encima del más alto de la casa (s2hr-backdrop, 10020).
   Paleta y radios: docs/GUIA-ESTETICA.md.
   ========================================================================== */

.nf-dialog-backdrop,
.nf-toast-wrap {
    --nfd-primary: #2E86AB;
    --nfd-primary-dark: #236B8E;
    --nfd-text: #1C2634;
    --nfd-secondary: #4A5866;
    --nfd-muted: #5F6E7C;
    --nfd-border: #E8EBEE;
    --nfd-ok: #227952;        --nfd-ok-tint: #EAF6F0;
    --nfd-warn: #9A6B00;      --nfd-warn-tint: #FFF4DB;
    --nfd-danger: #C03A3A;    --nfd-danger-tint: #FDEDED;
    --nfd-info: #0E6E8C;      --nfd-info-tint: #E0F3F8;
    --nfd-font: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --nfd-radius: 14px;
    --nfd-radius-sm: 8px;
}

/* ==== Diálogo ==== */
.nf-dialog-backdrop {
    position: fixed; inset: 0; background: rgba(16,30,46,0.55);
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 10050; padding: 16px; animation: nfdFade 0.18s ease;
}
.nf-dialog {
    background: #fff; border: 1px solid var(--nfd-border); border-radius: var(--nfd-radius);
    width: 440px; max-width: 100%; max-height: 92vh; overflow-y: auto;
    box-shadow: 0 24px 70px rgba(16,30,46,0.4);
    font-family: var(--nfd-font); color: var(--nfd-text);
    animation: nfdPopIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: left;
}
.nf-dialog-body { padding: 22px 22px 6px; }
.nf-dialog-ico {
    width: 42px; height: 42px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.05rem; margin-bottom: 12px;
}
.nf-dialog-ico.ok { background: var(--nfd-ok-tint); color: var(--nfd-ok); }
.nf-dialog-ico.warn { background: var(--nfd-warn-tint); color: var(--nfd-warn); }
.nf-dialog-ico.danger { background: var(--nfd-danger-tint); color: var(--nfd-danger); }
.nf-dialog-ico.info { background: var(--nfd-info-tint); color: var(--nfd-info); }
.nf-dialog-title {
    font-size: 1rem; font-weight: 700; margin: 0 0 6px;
    color: var(--nfd-text); line-height: 1.35;
}
/* pre-line: los mensajes vienen del código con \n, y esos saltos son los que
   separaban párrafos en el alert() nativo. */
.nf-dialog-msg {
    font-size: 0.85rem; color: var(--nfd-secondary); line-height: 1.55;
    margin: 0; white-space: pre-line; overflow-wrap: anywhere;
}
.nf-dialog-msg + .nf-dialog-msg { margin-top: 8px; }
.nf-dialog-input {
    width: 100%; margin-top: 12px; padding: 9px 12px;
    border: 1px solid var(--nfd-border); border-radius: var(--nfd-radius-sm);
    font-family: inherit; font-size: 0.88rem; color: var(--nfd-text); outline: none;
    background: #fff;
    transition: border 0.15s, box-shadow 0.15s;
}
.nf-dialog-input:focus { border-color: var(--nfd-primary); box-shadow: 0 0 0 3px rgba(46,134,171,0.12); }
textarea.nf-dialog-input.multi { min-height: 92px; resize: vertical; line-height: 1.45; font-family: inherit; }
.nf-dialog-hint { font-size: 0.74rem; color: var(--nfd-muted); margin-top: 6px; }
/* Diálogo de dos campos (ver `opts.campo` en nf-dialog.js): cada casilla con
   su etiqueta, porque con dos cajas seguidas y ninguna nombrada no se sabe
   qué va en cuál. */
.nf-dialog-lbl { display: block; text-align: left; font-size: 0.78rem; font-weight: 600;
    color: var(--nfd-text); margin: 13px 0 5px; }
.nf-dialog-hint-campo { margin-bottom: 4px; }
.nf-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px 20px; flex-wrap: wrap; }

/* Botones del diálogo: mismos valores que .nf-btn de newfox-ui.css, pero
   acotados al diálogo para que esta hoja se pueda cargar en cualquier pantalla. */
.nf-dialog .nf-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 13px; border-radius: var(--nfd-radius-sm);
    font-size: 0.8rem; font-weight: 600; line-height: 1.4;
    border: 1px solid transparent; cursor: pointer;
    transition: all 0.15s; text-decoration: none; font-family: inherit;
}
.nf-dialog .nf-btn:focus-visible { outline: 2px solid var(--nfd-primary); outline-offset: 2px; }
.nf-dialog .nf-btn-primary { background: var(--nfd-primary); color: #fff; border-color: var(--nfd-primary); }
.nf-dialog .nf-btn-primary:hover { background: var(--nfd-primary-dark); color: #fff; }
.nf-dialog .nf-btn-outline { background: #fff; color: var(--nfd-secondary); border-color: var(--nfd-border); }
.nf-dialog .nf-btn-outline:hover { background: #F4F5F7; border-color: #D5DADE; color: var(--nfd-text); }
.nf-dialog .nf-btn-danger { background: var(--nfd-danger); color: #fff; border-color: var(--nfd-danger); }
.nf-dialog .nf-btn-danger:hover { background: #A83232; color: #fff; }

/* Opciones apiladas (nfDialog.choose) */
.nf-dialog-opts { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.nf-dialog-opts .nf-btn { width: 100%; justify-content: flex-start; padding: 11px 14px; font-size: 0.85rem; }

/* ==== Toasts ==== */
.nf-toast-wrap {
    position: fixed; bottom: 18px; right: 18px; z-index: 10060;
    display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
    pointer-events: none;
}
.nf-toast {
    display: flex; align-items: center; gap: 10px;
    background: #fff; border: 1px solid var(--nfd-border); border-radius: 10px;
    padding: 11px 16px; box-shadow: 0 10px 30px rgba(16,30,46,0.14);
    font-family: var(--nfd-font); font-size: 0.85rem; color: var(--nfd-text);
    max-width: 380px; pointer-events: auto; cursor: pointer;
    animation: nfdToastIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
.nf-toast.out { animation: nfdToastOut 0.22s ease forwards; }
.nf-toast i { flex-shrink: 0; }
.nf-toast.ok i { color: var(--nfd-ok); }
.nf-toast.error i { color: var(--nfd-danger); }
.nf-toast.info i { color: var(--nfd-info); }
.nf-toast.error { border-color: #F5C6C6; }

@keyframes nfdFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes nfdPopIn { from { transform: translateY(12px) scale(0.985); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes nfdToastIn { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes nfdToastOut { to { transform: translateY(8px); opacity: 0; } }

@media (max-width: 480px) {
    .nf-dialog-actions { flex-direction: column-reverse; }
    .nf-dialog-actions .nf-btn { width: 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
    .nf-dialog-backdrop, .nf-dialog, .nf-toast { animation: none !important; }
    .nf-dialog .nf-btn { transition: none !important; }
}
