/* ============================================================================
   NOTIFICATIONS.CSS - Sistema de Toast y Confirm Dialog
   Reemplaza alert() y confirm() del navegador
   ============================================================================ */

/* ── CONTENEDOR DE TOASTS ─────────────────────────────────────────────────── */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
    width: calc(100vw - 40px);
    pointer-events: none;
}

/* ── TOAST INDIVIDUAL ─────────────────────────────────────────────────────── */
.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 1px 4px rgba(0, 0, 0, 0.1);
    background: #fff;
    border: 1px solid;
    pointer-events: all;
    cursor: default;
    animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    position: relative;
    overflow: hidden;
}

.toast.toast-out {
    animation: toastOut 0.25s ease-in both;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(120%); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(120%); }
}

/* Barra de progreso de auto-cierre */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    transform-origin: left;
    animation: toastProgress linear both;
}

@keyframes toastProgress {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* ── TIPOS DE TOAST ───────────────────────────────────────────────────────── */
.toast-success {
    border-color: #16a34a;
    background: var(--success-50, #f0fdf4);
}
.toast-success .toast-icon  { color: #16a34a; }
.toast-success .toast-progress { background: #16a34a; }

.toast-error {
    border-color: var(--critical-500, #dc2626);
    background: var(--critical-50, #fef2f2);
}
.toast-error .toast-icon  { color: var(--critical-500, #dc2626); }
.toast-error .toast-progress { background: var(--critical-500, #dc2626); }

.toast-warning {
    border-color: var(--warning-600, #d97706);
    background: var(--warning-50, #fffbeb);
}
.toast-warning .toast-icon  { color: var(--warning-600, #d97706); }
.toast-warning .toast-progress { background: var(--warning-600, #d97706); }

.toast-info {
    border-color: var(--primary-600, #2563eb);
    background: var(--primary-50, #eff6ff);
}
.toast-info .toast-icon  { color: var(--primary-600, #2563eb); }
.toast-info .toast-progress { background: var(--primary-600, #2563eb); }

/* ── TOAST PERSISTENTE (errores): no auto-cierra, se cierra con la ✕ ──────── */
.toast-persistente {
    box-shadow: 0 6px 26px rgba(220, 38, 38, 0.20), 0 1px 4px rgba(0, 0, 0, 0.10);
}
.toast-persistente .toast-close { opacity: 1; }

/* ── INTERIOR DEL TOAST ───────────────────────────────────────────────────── */
.toast-icon {
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 1px;
}

.toast-body {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--gray-900, #111827);
    margin: 0 0 2px;
    line-height: 1.3;
}

.toast-message {
    font-size: 13px;
    color: var(--gray-700, #374151);
    margin: 0;
    line-height: 1.4;
    word-break: break-word;
}

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--s500, #64748b);
    font-size: 16px;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
    transition: color 0.15s;
    margin-top: 1px;
}
.toast-close:hover { color: var(--gray-700, #374151); }

/* ── CONFIRM DIALOG ───────────────────────────────────────────────────────── */
#confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: overlayIn 0.2s ease both;
}

#confirm-overlay.overlay-out {
    animation: overlayOut 0.15s ease both;
}

@keyframes overlayIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes overlayOut { from { opacity: 1; } to { opacity: 0; } }

#confirm-dialog {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    max-width: 420px;
    width: 100%;
    overflow: hidden;
    animation: dialogIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

#confirm-overlay.overlay-out #confirm-dialog {
    animation: dialogOut 0.15s ease both;
}

@keyframes dialogIn  { from { opacity: 0; transform: scale(0.9) translateY(-10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes dialogOut { from { opacity: 1; transform: scale(1); }                   to { opacity: 0; transform: scale(0.95); } }

.confirm-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 0;
}

.confirm-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.confirm-icon svg { width: 20px; height: 20px; }
.confirm-icon-warning { background: var(--warning-100, #fef3c7); color: var(--warning-700, #b45309); }
.confirm-icon-danger  { background: var(--critical-100, #fee2e2); color: var(--critical-500, #dc2626); }
.confirm-icon-info    { background: var(--primary-100, #dbeafe); color: var(--primary-700, #1d4ed8); }
.confirm-icon-success { background: var(--success-100, #dcfce7); color: var(--success-700, #047857); }

.confirm-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900, #111827);
    margin: 0;
    line-height: 1.3;
}

.confirm-body {
    padding: 12px 20px 20px;
}

.confirm-message {
    font-size: 14px;
    color: var(--gray-600, #4b5563);
    line-height: 1.6;
    margin: 0;
    white-space: pre-line;
}

.confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 14px 20px;
    background: var(--gray-50, #f9fafb);
    border-top: 1px solid var(--gray-100, #f3f4f6);
}

.confirm-btn {
    padding: 9px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1;
}

.confirm-btn-cancel {
    background: #fff;
    color: var(--gray-700, #374151);
    border: 1px solid var(--gray-300, #d1d5db);
}
.confirm-btn-cancel:hover { background: var(--gray-100, #f3f4f6); }

.confirm-btn-ok {
    background: var(--primary-600, #2563eb);
    color: #fff;
}
.confirm-btn-ok:hover { background: var(--primary-700, #1d4ed8); }
.confirm-btn-ok.btn-danger  { background: var(--critical-500, #dc2626); }
.confirm-btn-ok.btn-danger:hover { background: var(--critical-600, #b91c1c); }
.confirm-btn-ok.btn-warning { background: var(--warning-700, #b45309); }
.confirm-btn-ok.btn-warning:hover { background: var(--warning-800, #92400e); }

@media (max-width: 480px) {
    .confirm-actions { flex-direction: column-reverse; }
    .confirm-btn { width: 100%; }
}

/* ============================================================================
   CAMPANA DE NOTIFICACIONES (topbar) — badge + panel desplegable
   ============================================================================ */
.bell-wrap { position: relative; display: inline-flex; }

/* Badge de no-leídas sobre la campana */
.bell-badge {
    position: absolute;
    top: 3px;
    right: 3px;
    min-width: 16px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--critical-500, #ef4444);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--primary-100, #dbeafe);
    pointer-events: none;
}

/* Panel desplegable anclado a la campana */
.bell-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    max-width: 90vw;
    background: #fff;
    border: 1px solid var(--s200, #e2e8f0);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .16);
    z-index: 1200;
    overflow: hidden;
}

.bell-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--s100, #f1f5f9);
}
.bell-title { font-size: 13px; font-weight: 700; color: var(--s800, #1e293b); }
.bell-markall {
    background: none;
    border: none;
    color: var(--primary-600, #2563eb);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 6px;
}
.bell-markall:hover { background: var(--s50, #f8fafc); text-decoration: underline; }

.bell-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 380px;
    overflow-y: auto;
}

.bell-empty {
    padding: 24px 14px;
    text-align: center;
    color: var(--s500, #64748b);
    font-size: 13px;
}

.bell-item {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--s100, #f1f5f9);
    cursor: pointer;
    transition: background .12s;
}
.bell-item:last-child { border-bottom: none; }
.bell-item:hover { background: var(--s50, #f8fafc); }
.bell-item:focus-visible { outline: 2px solid var(--primary-400, #60a5fa); outline-offset: -2px; }

/* Ícono coloreado por tipo */
.bell-item .bi-ic {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--s100, #f1f5f9);
    color: var(--s500, #64748b);
}
.bell-item .bi-ic svg { width: 17px; height: 17px; }
.bell-item.t-blue   .bi-ic { background: var(--primary-100, #dbeafe); color: var(--primary-600, #2563eb); }
.bell-item.t-indigo .bi-ic { background: #e0e7ff; color: #4f46e5; }
.bell-item.t-teal   .bi-ic { background: #ccfbf1; color: #0d9488; }
.bell-item.t-slate  .bi-ic { background: var(--s100, #f1f5f9); color: var(--s600, #475569); }

.bell-item .bi-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bell-item .bi-title { font-size: 13px; font-weight: 600; color: var(--s800, #1e293b); }
.bell-item .bi-desc {
    font-size: 12px;
    color: var(--s500, #64748b);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bell-item .bi-time { font-size: 11px; color: var(--s500, #64748b); margin-top: 2px; }

/* No leída: fondo distintivo + punto */
.bell-item.no-leida { background: var(--primary-50, #eff6ff); }
.bell-item.no-leida:hover { background: var(--primary-100, #dbeafe); }
.bell-item.no-leida .bi-title { color: var(--s900, #0f172a); }
.bell-item.no-leida .bi-title::after {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-left: 6px;
    border-radius: 50%;
    background: var(--primary-500, #3b82f6);
    vertical-align: middle;
}
