/* ============== Notificaciones • Estilos base ============== */
:root {
  --noti-radius: 14px;
  --noti-shadow: 0 8px 30px rgba(16, 24, 40, 0.12);
  --noti-shadow-sm: 0 2px 10px rgba(16, 24, 40, 0.1);
  --noti-text: #0f172a; /* fallback de color de texto */
  --noti-bg: #ffffff; /* fallback de bg            */
  --noti-accent: #22c55e; /* fallback de acento        */
}

#notificacion-widget {
  position: fixed;
  right: clamp(12px, 2vw, 24px);
  bottom: clamp(12px, 3vh, 24px);
  display: grid;
  gap: 12px;
  width: min(420px, 92vw);
  z-index: 9990;
  pointer-events: none; /* los botones internos reactivan pointer-events */
}

/* Tarjeta */
.noti-card {
  --bg: var(--noti-bg);
  --fg: var(--noti-text);
  --accent: var(--noti-accent);

  background: var(--bg);
  color: var(--fg);
  border-radius: var(--noti-radius);
  box-shadow: var(--noti-shadow);
  border: 1px solid color-mix(in oklab, var(--fg) 12%, transparent);
  overflow: clip;
  pointer-events: auto;
  animation: noti-enter 0.28s ease-out both;
}

@keyframes noti-enter {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Layout interno */
.noti-body {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  padding: 14px 14px 8px 14px;
}

.noti-icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in oklab, var(--accent) 16%, var(--bg));
  border: 1px solid color-mix(in oklab, var(--accent) 50%, transparent);
  box-shadow: var(--noti-shadow-sm);
}
.noti-icon .material-icons {
  font-size: 22px;
  color: var(--accent);
}

/* Título + contenido */
.noti-content {
  display: grid;
  gap: 4px;
}
.noti-title {
  font-weight: 700;
  line-height: 1.25;
  font-size: 15px;
}
.noti-text {
  opacity: 0.9;
  line-height: 1.45;
  font-size: 14px;
  white-space: pre-wrap;
}

/* Acciones */
.noti-actions {
  display: flex;
  gap: 8px;
  align-items: start;
}
.noti-btn {
  appearance: none;
  border: 1px solid color-mix(in oklab, var(--fg) 22%, transparent);
  background: color-mix(in oklab, var(--bg) 80%, white);
  color: var(--fg);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 10px;
  transition: transform 0.06s ease, background 0.2s ease, border-color 0.2s ease,
    opacity 0.2s ease;
  cursor: pointer;
  user-select: none;
}
.noti-btn:hover {
  transform: translateY(-1px);
  background: color-mix(in oklab, var(--bg) 75%, white);
}
.noti-btn:active {
  transform: translateY(0);
}
.noti-btn.is-accent {
  background: color-mix(in oklab, var(--accent) 16%, var(--bg));
  border-color: color-mix(in oklab, var(--accent) 72%, transparent);
}
.noti-btn.is-outline {
  background: transparent;
}

/* Pie: chips/badges opcionales */
.noti-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px 12px 66px; /* sangría para alinear con texto */
}
.noti-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--accent) 12%, var(--bg));
  border: 1px solid color-mix(in oklab, var(--accent) 60%, transparent);
  color: color-mix(in oklab, var(--accent) 85%, black);
}

/* Línea de foco/acento (decorativa) */
.noti-accentbar {
  height: 3px;
  width: 100%;
  background: linear-gradient(
    90deg,
    color-mix(in oklab, var(--accent) 78%, transparent),
    color-mix(in oklab, var(--accent) 32%, transparent) 60%,
    transparent
  );
}

/* ============== Modal invasivo mejorado ============== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: color-mix(in oklab, black 40%, transparent);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 9995;
  animation: overlayIn 0.16s ease-out both;
}
@keyframes overlayIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-notificacion {
  --bg: var(--noti-bg);
  --fg: var(--noti-text);
  --accent: var(--noti-accent);

  width: min(720px, 92vw);
  max-height: min(78vh, 760px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--bg);
  color: var(--fg);
  border-radius: calc(var(--noti-radius) + 2px);
  box-shadow: var(--noti-shadow);
  border: 1px solid color-mix(in oklab, var(--fg) 14%, transparent);
  overflow: hidden;
  animation: noti-enter 0.22s ease-out both;
}

.modal-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  padding: 18px;
  align-items: center;
  border-bottom: 1px solid color-mix(in oklab, var(--fg) 10%, transparent);
}
.modal-header .material-icons {
  color: var(--accent);
  font-size: 30px;
}
.modal-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.2px;
}
.modal-close {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: inherit;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  font-size: 22px;
}
.modal-close:hover {
  opacity: 1;
}

.modal-content-scroll {
  padding: 16px 18px;
  overflow: auto;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 12px 18px 16px;
  border-top: 1px solid color-mix(in oklab, var(--fg) 10%, transparent);
  position: sticky;
  bottom: 0;
  background: var(--bg);
}
.noti-btn.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

/* ============== Historial lateral ============== */
#history_notifications {
  display: grid;
  gap: 12px;
}
.history-card {
  --bg: var(--noti-bg);
  --fg: var(--noti-text);
  --accent: var(--noti-accent);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  background: var(--bg);
  color: var(--fg);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid color-mix(in oklab, var(--fg) 12%, transparent);
  box-shadow: var(--noti-shadow-sm);
}
.history-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: color-mix(in oklab, var(--accent) 16%, var(--bg));
  border: 1px solid color-mix(in oklab, var(--accent) 50%, transparent);
}
.history-icon .material-icons {
  font-size: 20px;
  color: var(--accent);
}
.history-content strong {
  font-size: 14px;
}
.history-content p {
  font-size: 13px;
  opacity: 0.8;
  margin-top: 4px;
}

/* ======= Pila de notificaciones internas (abajo-izquierda) ======= */
#intern-notification-container {
  position: fixed;
  right: clamp(12px, 2vw, 24px);
  bottom: clamp(12px, 3vh, 24px);
  left: auto;
  display: flex;
  flex-direction: column-reverse; /* el primer hijo queda abajo */
  align-items: flex-end; /* alinea tarjetas al borde derecho */
  gap: 12px;
  width: min(380px, 92vw);
  z-index: 2147483000; /* por encima de todo */
  pointer-events: none; /* no bloquea el fondo */
}
#intern-notification-container .noti-card {
  pointer-events: auto; /* pero los botones sí funcionan */
  width: 100%;
  animation: noti-enter-right 0.28s ease-out both;
}

/* Animación entrando desde la esquina inferior derecha */
@keyframes noti-enter-right {
  from {
    opacity: 0;
    transform: translate(10px, 10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
}
