/* ==========================================================================
   NOTIFICACIONES (assets/js/notifications.js)
   Campana del navbar, aviso arriba de la tabla, avisos flotantes y resaltado de tarjeta
   ========================================================================== */

/* ---------- Campana ---------- */

.notif-wrapper {
  position: relative;
}

.notif-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background-color: var(--bg-card-header);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform 0.2s ease, color 0.2s ease;
}

.notif-btn:hover {
  transform: scale(1.05);
  color: var(--text-main);
}

.notif-btn.has-unread {
  color: var(--btn-red-color);
}

.notif-btn.has-unread i {
  animation: notif-ring 2.4s ease-in-out infinite;
  transform-origin: 50% 10%;
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 10px;
  background-color: #dc3545;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 19px;
  text-align: center;
  border: 2px solid var(--bg-navbar);
  box-sizing: content-box;
}

@keyframes notif-ring {
  0%, 70%, 100% { transform: rotate(0); }
  75% { transform: rotate(14deg); }
  80% { transform: rotate(-12deg); }
  85% { transform: rotate(8deg); }
  90% { transform: rotate(-5deg); }
}

/* ---------- Panel de la campana ---------- */

.notif-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(360px, calc(100vw - 32px));
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: 0 16px 32px -8px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  z-index: 1040;
}

/* Mobile: el panel se ancla al navbar (no a la campana) y queda centrado con 16px a cada lado */
@media (max-width: 575.98px) {
  .notif-wrapper {
    position: static;
  }

  .notif-panel {
    top: calc(100% + 8px);
    left: 16px;
    right: 16px;
    width: auto;
  }
}

.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background-color: var(--bg-card-header);
  border-bottom: 1px solid var(--border-color);
  font-weight: 700;
  color: var(--text-main);
}

.notif-readall {
  border: none;
  background: none;
  padding: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--btn-green-color);
  cursor: pointer;
}

.notif-readall:hover {
  text-decoration: underline;
}

.notif-list {
  max-height: min(420px, 70vh);
  overflow-y: auto;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  width: 100%;
  padding: 0.7rem 1rem;
  border: none;
  border-bottom: 1px solid var(--border-color);
  background: none;
  text-align: left;
  color: var(--text-main);
  cursor: pointer;
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-item:hover,
.notif-item:focus-visible {
  background-color: var(--bg-card-header);
  outline: none;
}

.notif-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  margin-top: 0.4rem;
  border-radius: 50%;
  background-color: transparent;
}

.notif-item.unread .notif-dot {
  background-color: #dc3545;
}

.notif-item:not(.unread) {
  opacity: 0.7;
}

.notif-item-text,
.page-notif-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.1rem;
}

.notif-item-text strong,
.page-notif-text strong {
  font-size: 0.88rem;
  font-weight: 700;
}

.notif-item-text span,
.page-notif-text span {
  font-size: 0.82rem;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.notif-item-text small,
.page-notif-text small {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.notif-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.notif-empty i {
  font-size: 1.5rem;
}

/* ---------- Aviso arriba de la tabla ---------- */

.page-notifs:empty {
  display: none;
}

.page-notifs {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.page-notif {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: var(--card-radius);
  background-color: var(--bg-card);
  border: 1px solid var(--btn-red-border);
  border-left: 4px solid var(--btn-red-color);
  box-shadow: 0 4px 14px -6px rgba(0, 0, 0, 0.15);
}

.page-notif.is-new {
  animation: page-notif-in 0.35s ease-out;
}

.page-notif-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--btn-red-bg);
  color: var(--btn-red-color);
}

.page-notif-text {
  flex: 1;
  color: var(--text-main);
}

.page-notif-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.page-notifs-footer {
  display: flex;
  justify-content: space-between;
  padding: 0 0.25rem;
}

.page-notifs-link {
  border: none;
  background: none;
  padding: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.page-notifs-link:hover {
  color: var(--text-main);
  text-decoration: underline;
}

@keyframes page-notif-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 575.98px) {
  .page-notif {
    flex-wrap: wrap;
  }

  .page-notif-text {
    flex-basis: calc(100% - 52px);
  }

  .page-notif-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* ---------- Avisos flotantes ---------- */

.notif-toasts {
  position: fixed;
  right: 16px;
  bottom: 76px;   /* arriba del botón "volver arriba" (general.css) */
  z-index: 1090;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(340px, calc(100vw - 32px));
}

.notif-toast {
  display: flex;
  align-items: flex-start;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--btn-red-color);
  border-radius: 12px;
  box-shadow: 0 12px 28px -8px rgba(0, 0, 0, 0.3);
  animation: notif-toast-in 0.3s ease-out;
}

.notif-toast.is-leaving {
  opacity: 0;
  transform: translateX(16px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.notif-toast-body {
  flex: 1;
  display: flex;
  gap: 0.65rem;
  padding: 0.75rem 0.25rem 0.75rem 0.9rem;
  border: none;
  background: none;
  text-align: left;
  color: var(--text-main);
  cursor: pointer;
  min-width: 0;
}

.notif-toast-body > i {
  color: var(--btn-red-color);
  margin-top: 0.1rem;
}

.notif-toast-body > span {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.notif-toast-body strong {
  font-size: 0.88rem;
}

.notif-toast-body span span {
  font-size: 0.8rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notif-toast-close {
  border: none;
  background: none;
  padding: 0.6rem 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
}

.notif-toast-close:hover {
  color: var(--text-main);
}

@keyframes notif-toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Tarjeta resaltada ("Ver") ---------- */

.item-card.notif-highlight {
  outline: 3px solid var(--btn-red-color);
  outline-offset: 3px;
  animation: notif-highlight 1.1s ease-in-out 3;
}

@keyframes notif-highlight {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  50%      { box-shadow: 0 0 0 4px var(--btn-red-border), 0 0 24px var(--btn-red-bg); }
}

@media (prefers-reduced-motion: reduce) {
  .notif-btn.has-unread i,
  .page-notif.is-new,
  .notif-toast,
  .item-card.notif-highlight {
    animation: none;
  }
}

/* ---------- Notificaciones en el dispositivo (assets/js/push.js) ---------- */

.push-prompt-body {
  padding: 1.25rem 1.5rem;
}

/* Interruptor de "Mi cuenta" cuando no se puede usar (bloqueadas o navegador sin soporte) */
#push-toggle-btn.is-disabled {
  cursor: default;
}

#push-toggle-btn.is-disabled .form-switch {
  opacity: 0.4;
}
