/* ═══════════════════════════════════════════════════════════════
   SURIAPP — assets/css/notifications.css
   Sistema de Notificaciones v2.0 — Standalone
   Requiere: variables CSS de dashboard.css (:root)
   ═══════════════════════════════════════════════════════════════ */

/* ──────────────────────────────────────────────────────────────
   1. KEYFRAMES
   ────────────────────────────────────────────────────────────── */
@keyframes notif-bell-shake {
  0%,100% { transform: rotate(0deg)   }
  15%     { transform: rotate(-20deg) }
  30%     { transform: rotate(16deg)  }
  45%     { transform: rotate(-10deg) }
  60%     { transform: rotate(7deg)   }
  75%     { transform: rotate(-4deg)  }
  90%     { transform: rotate(2deg)   }
}
@keyframes notif-badge-pop {
  0%   { transform: scale(0) rotate(-15deg); opacity: 0  }
  65%  { transform: scale(1.35) rotate(4deg)              }
  100% { transform: scale(1) rotate(0);     opacity: 1  }
}
@keyframes notif-badge-pulse {
  0%,100% { box-shadow: 0 0 0 0   rgba(239, 68, 68, .6)  }
  50%     { box-shadow: 0 0 0 5px rgba(239, 68, 68, 0)   }
}
@keyframes notif-panel-desktop-in {
  from { opacity: 0; transform: translateY(-10px) scale(.97) }
  to   { opacity: 1; transform: translateY(0)     scale(1)   }
}
@keyframes notif-panel-mobile-in {
  from { opacity: .7; transform: translateY(100%) }
  to   { opacity: 1;  transform: translateY(0)    }
}
@keyframes notif-item-appear {
  from { opacity: 0; transform: translateY(-5px) }
  to   { opacity: 1; transform: translateY(0)    }
}
@keyframes notif-toast-enter {
  from { opacity: 0; transform: translateX(110%) scale(.96) }
  to   { opacity: 1; transform: translateX(0)    scale(1)   }
}
@keyframes notif-toast-exit {
  from { opacity: 1; transform: translateX(0)    scale(1)   }
  to   { opacity: 0; transform: translateX(110%) scale(.96) }
}
@keyframes notif-spin {
  to { transform: rotate(360deg) }
}

/* ──────────────────────────────────────────────────────────────
   2. BELL TRIGGER (navbar icon)
   ────────────────────────────────────────────────────────────── */
.notif-trigger {
  position: relative;
  overflow: visible !important;   /* permite que el badge sobresalga */
  cursor: pointer;
}

/* Bell shake al recibir notificación */
.notif-trigger.notif-trigger--shake #notif-bell-icon {
  animation: notif-bell-shake .65s cubic-bezier(.36,.07,.19,.97) both;
}

/* ── Badge contador ──────────────────────────────────────────── */
.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 10px;
  background: #ef4444;
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  border: 2px solid var(--dark1, #141628);
  display: none;                  /* JS lo muestra cuando hay no leídas */
  box-sizing: border-box;
  pointer-events: none;
  z-index: 10;
  animation: notif-badge-pop .3s cubic-bezier(.34,1.6,.64,1),
             notif-badge-pulse 2.8s ease-in-out 1s infinite;
}
.notif-badge.notif-badge--visible {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ──────────────────────────────────────────────────────────────
   3. BACKDROP (overlay móvil y clic-fuera desktop)
   ────────────────────────────────────────────────────────────── */
.notif-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1039;
  background: transparent;
  pointer-events: none;
}
.notif-backdrop.notif-backdrop--visible {
  display: block;
  pointer-events: auto;
}
@media (max-width: 767px) {
  .notif-backdrop.notif-backdrop--visible {
    background: rgba(0, 0, 0, .5);
  }
}

/* ──────────────────────────────────────────────────────────────
   4. PANEL PRINCIPAL
   ────────────────────────────────────────────────────────────── */
.notif-panel {
  display: none;
  position: fixed;
  z-index: 1040;
  background: var(--dark2, #1A1D30);
  border: 1px solid var(--border2, rgba(255,255,255,.12));
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .55),
              0 4px 16px  rgba(0, 0, 0, .35),
              inset 0 1px 0 rgba(255,255,255,.06);
  overflow: hidden;
  flex-direction: column;
  width: 360px;
  max-height: 520px;
}

/* Estado visible — JS añade esta clase */
.notif-panel.notif-panel--open {
  display: flex;
  animation: notif-panel-desktop-in .22s cubic-bezier(.34,1.2,.64,1);
}

/* ──────────────────────────────────────────────────────────────
   5. DRAG HANDLE (solo mobile)
   ────────────────────────────────────────────────────────────── */
.notif-handle {
  display: none;
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border2, rgba(255,255,255,.12));
  margin: 10px auto 4px;
  flex-shrink: 0;
}

/* ──────────────────────────────────────────────────────────────
   6. HEADER
   ────────────────────────────────────────────────────────────── */
.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border, rgba(255,255,255,.07));
  flex-shrink: 0;
}
.notif-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.notif-header-icon {
  color: var(--violet, #7B3FE4);
  font-size: 1rem;
  line-height: 1;
}
.notif-header-title {
  font-size: .88rem;
  font-weight: 700;
  color: var(--text1, #F1F5F9);
  font-family: 'Syne', sans-serif;
}
.notif-header-total {
  display: none;
  background: var(--dark4, #272B42);
  color: var(--text2, #94A3B8);
  font-size: .68rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  line-height: 1.5;
}
.notif-header-total.notif-header-total--visible {
  display: inline-block;
}
.notif-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Botones de acción en header ─────────────────────────────── */
.notif-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(255,255,255,.07));
  background: var(--dark3, #20233A);
  color: var(--text3, #475569);
  cursor: pointer;
  font-size: .82rem;
  transition: background .15s, color .15s, border-color .15s, transform .1s;
}
.notif-action-btn:hover {
  background: var(--dark4, #272B42);
  color: var(--text1, #F1F5F9);
  border-color: var(--border2, rgba(255,255,255,.12));
}
.notif-action-btn:active { transform: scale(.93); }

/* Botón eliminar todo */
.notif-action-btn--clear:hover {
  color: #f87171 !important;
  border-color: rgba(248, 113, 113, .3) !important;
  background: rgba(248, 113, 113, .08) !important;
}

/* Botón leer todo — oculto si no hay no leídas */
.notif-action-btn--readall {
  display: none;
}
.notif-action-btn--readall.notif-action-btn--visible {
  display: flex;
}
.notif-action-btn--readall:hover {
  color: var(--violet2, #9B5FFF) !important;
  border-color: rgba(123, 63, 228, .35) !important;
  background: rgba(123, 63, 228, .1) !important;
}

/* ──────────────────────────────────────────────────────────────
   7. TABS
   ────────────────────────────────────────────────────────────── */
.notif-tabs {
  display: flex;
  padding: 0 14px;
  border-bottom: 1px solid var(--border, rgba(255,255,255,.07));
  flex-shrink: 0;
  gap: 2px;
}
.notif-tab {
  position: relative;
  padding: 8px 12px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text3, #475569);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: -1px;
}
.notif-tab:hover { color: var(--text2, #94A3B8); }
.notif-tab.notif-tab--active {
  color: var(--violet2, #9B5FFF);
  border-bottom-color: var(--violet, #7B3FE4);
}

/* Pill de no leídas dentro del tab */
.notif-tab-pill {
  display: none;
  background: var(--violet, #7B3FE4);
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 10px;
}
.notif-tab-pill.notif-tab-pill--visible { display: inline-block; }

/* ──────────────────────────────────────────────────────────────
   8. LISTA DE NOTIFICACIONES
   ────────────────────────────────────────────────────────────── */
.notif-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0;
  min-height: 80px;
}
.notif-list::-webkit-scrollbar       { width: 3px; }
.notif-list::-webkit-scrollbar-track { background: transparent; }
.notif-list::-webkit-scrollbar-thumb {
  background: var(--border2, rgba(255,255,255,.12));
  border-radius: 2px;
}

/* ── Estado vacío ───────────────────────────────────────────── */
.notif-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  color: var(--text3, #475569);
  text-align: center;
  gap: 10px;
}
.notif-empty i {
  font-size: 2.2rem;
  opacity: .3;
}
.notif-empty p {
  margin: 0;
  font-size: .82rem;
  color: var(--text3, #475569);
}

/* ── Estado cargando ────────────────────────────────────────── */
.notif-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px 20px;
  color: var(--text3, #475569);
  font-size: .8rem;
}
.notif-loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border2, rgba(255,255,255,.12));
  border-top-color: var(--violet, #7B3FE4);
  border-radius: 50%;
  animation: notif-spin .7s linear infinite;
}

/* ──────────────────────────────────────────────────────────────
   9. ITEM DE NOTIFICACIÓN
   ────────────────────────────────────────────────────────────── */
.notif-item {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: start;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid transparent;
  transition: background .15s;
  animation: notif-item-appear .18s ease both;
  position: relative;
  cursor: default;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover {
  background: rgba(255, 255, 255, .04);
}

/* No leída: fondo suave + borde izquierdo de color */
.notif-item.notif-item--unread {
  background: rgba(123, 63, 228, .05);
  border-left: 3px solid var(--violet, #7B3FE4);
  padding-left: 11px;
}
.notif-item.notif-item--unread:hover {
  background: rgba(123, 63, 228, .09);
}

/* Clickable (tiene enlace) */
.notif-item.notif-item--clickable { cursor: pointer; }

/* ── Ícono de tipo ───────────────────────────────────────────── */
.notif-item-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Contenido ──────────────────────────────────────────────── */
.notif-item-body { min-width: 0; }

.notif-item-title {
  font-size: .81rem;
  font-weight: 600;
  color: var(--text1, #F1F5F9);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notif-item-desc {
  font-size: .73rem;
  color: var(--text2, #94A3B8);
  line-height: 1.4;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.notif-item.notif-item--unread .notif-item-desc {
  color: var(--text2, #94A3B8);
}

.notif-item-time {
  font-size: .67rem;
  color: var(--text3, #475569);
  display: flex;
  align-items: center;
  gap: 3px;
  opacity: .8;
}
.notif-item-time i { font-size: .6rem; }

/* ── Acciones del item (botón eliminar) ─────────────────────── */
.notif-item-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Dot no leída */
.notif-item-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--violet2, #9B5FFF);
  flex-shrink: 0;
  margin-top: 5px;
}

/* Botón eliminar item — visible solo en hover */
.notif-item-delete {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--text3, #475569);
  font-size: .7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .15s, background .15s, color .15s;
  padding: 0;
}
.notif-item:hover .notif-item-delete { opacity: 1; }
.notif-item-delete:hover {
  background: rgba(248, 113, 113, .15);
  color: #f87171;
}

/* ──────────────────────────────────────────────────────────────
   10. FOOTER DEL PANEL
   ────────────────────────────────────────────────────────────── */
.notif-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--border, rgba(255,255,255,.07));
  flex-shrink: 0;
}
.notif-footer-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(255,255,255,.07));
  background: transparent;
  color: var(--text3, #475569);
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.notif-footer-btn:hover {
  background: rgba(123, 63, 228, .1);
  border-color: rgba(123, 63, 228, .3);
  color: var(--violet2, #9B5FFF);
}

/* ──────────────────────────────────────────────────────────────
   11. TOASTS
   ────────────────────────────────────────────────────────────── */
.notif-toasts {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1050;
  display: flex;
  flex-direction: column-reverse; /* nuevo toast abajo, los viejos suben */
  align-items: stretch;
  gap: 10px;
  width: 320px;
  pointer-events: none;
  /* Evitar que el stack crezca fuera de pantalla */
  max-height: calc(100dvh - 80px);
  overflow: hidden;
}

.notif-toast {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 38px 12px 12px;
  border-radius: 12px;
  background: var(--dark2, #1A1D30);
  border: 1px solid var(--border2, rgba(255,255,255,.12));
  box-shadow: 0 8px 32px rgba(0, 0, 0, .5),
              inset 0 1px 0 rgba(255,255,255,.06);
  pointer-events: auto;
  overflow: hidden;
  cursor: default;
  animation: notif-toast-enter .28s cubic-bezier(.34,1.2,.64,1) both;
}

/* Barra de color izquierda */
.notif-toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--toast-color, var(--violet, #7B3FE4));
  border-radius: 12px 0 0 12px;
}

.notif-toast-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  flex-shrink: 0;
}
.notif-toast-body { flex: 1; min-width: 0; }
.notif-toast-title {
  font-size: .8rem;
  font-weight: 700;
  color: var(--text1, #F1F5F9);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notif-toast-desc {
  font-size: .72rem;
  color: var(--text2, #94A3B8);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Botón cerrar toast */
.notif-toast-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--text3, #475569);
  font-size: .8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
  padding: 0;
}
.notif-toast-close:hover {
  background: var(--dark4, #272B42);
  color: var(--text1, #F1F5F9);
}

/* Barra de progreso toast */
.notif-toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--toast-color, var(--violet, #7B3FE4));
  opacity: .4;
  width: 100%;
  transition: width linear;
  border-radius: 0 0 0 12px;
}

/* Animación de salida (clase JS) */
.notif-toast.notif-toast--exiting {
  animation: notif-toast-exit .22s ease forwards;
}

/* ──────────────────────────────────────────────────────────────
   12. LIGHT THEME OVERRIDES
   ────────────────────────────────────────────────────────────── */
[data-theme="light"] .notif-panel {
  background: #fff;
  border-color: rgba(0, 0, 0, .1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .18);
}
[data-theme="light"] .notif-badge {
  border-color: #fff;
}
[data-theme="light"] .notif-item:hover {
  background: rgba(0, 0, 0, .04);
}
[data-theme="light"] .notif-item.notif-item--unread {
  background: rgba(123, 63, 228, .06);
}
[data-theme="light"] .notif-item.notif-item--unread:hover {
  background: rgba(123, 63, 228, .1);
}
[data-theme="light"] .notif-action-btn {
  background: #F0F4F8;
  border-color: rgba(0, 0, 0, .1);
  color: #475569;
}
[data-theme="light"] .notif-toast {
  background: #fff;
  border-color: rgba(0, 0, 0, .1);
}

/* ──────────────────────────────────────────────────────────────
   13. RESPONSIVE — MOBILE BOTTOM SHEET (≤ 767px)
   ────────────────────────────────────────────────────────────── */
@media (max-width: 767px) {

  .notif-handle { display: block; }

  /* Panel se convierte en bottom sheet */
  .notif-panel.notif-panel--open {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    max-height: 82dvh !important;
    border-radius: 20px 20px 0 0 !important;
    border-bottom: none !important;
    box-sizing: border-box !important;
    padding-bottom: env(safe-area-inset-bottom, 0) !important;
    animation: notif-panel-mobile-in .3s cubic-bezier(.34,1.05,.64,1) !important;
  }

  /* Lista sin altura máxima fija en mobile */
  .notif-panel.notif-panel--open .notif-list {
    max-height: none;
    flex: 1;
  }

  /* Toasts: todo el ancho en mobile */
  .notif-toasts {
    right: 10px;
    left: 10px;
    bottom: 16px;
    width: auto;
    flex-direction: column-reverse;
  }
}

/* ──────────────────────────────────────────────────────────────
   14. PANTALLAS MUY PEQUEÑAS (≤ 360px)
   ────────────────────────────────────────────────────────────── */
@media (max-width: 360px) {
  .notif-panel.notif-panel--open {
    max-height: 88dvh !important;
  }
  .notif-item {
    padding: 9px 10px;
    gap: 8px;
  }
  .notif-item-icon {
    width: 30px;
    height: 30px;
    font-size: .82rem;
  }
}