/**
 * Menus contextuels (mini-popovers) du tableau de bord.
 *
 * Réutilise les classes existantes .chat-unread-popover-* (déjà créées en JS par
 * showAnnoncesNotificationPopover et le popover du clavardage) pour un look unifié :
 * pilule blanche, ombre douce, petite flèche pointant vers l'icône cliquée.
 */

.chat-unread-popover-wrap {
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
}

.chat-unread-popover-backdrop {
  position: absolute;
  inset: 0;
  background: transparent;
  pointer-events: auto;
}

.chat-unread-popover {
  position: absolute;
  pointer-events: auto;
  min-width: 240px;
  max-width: min(320px, calc(100vw - 16px));
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow:
    0 12px 32px rgba(15, 23, 42, 0.18),
    0 4px 10px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  font-family: inherit;
  color: #111827;
  animation: chat-unread-popover-in 140ms cubic-bezier(0.16, 1, 0.3, 1) both;
  transform-origin: top right;
}

/* Petite flèche en haut à droite, qui pointe vers l'icône cloche/bulle. */
.chat-unread-popover::before {
  content: '';
  position: absolute;
  top: -7px;
  right: 16px;
  width: 14px;
  height: 14px;
  background: #ffffff;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  border-left: 1px solid rgba(15, 23, 42, 0.08);
  transform: rotate(45deg);
  border-top-left-radius: 3px;
}

@keyframes chat-unread-popover-in {
  0% {
    opacity: 0;
    transform: translateY(-6px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chat-unread-popover-title {
  padding: 12px 14px 8px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #6b7280;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.chat-unread-popover-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  max-height: min(60vh, 360px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.chat-unread-popover-item {
  display: block;
  padding: 10px 14px;
  font-size: 0.88rem;
  line-height: 1.35;
  color: #1f2937;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.chat-unread-popover-item + .chat-unread-popover-item {
  border-top: 1px solid rgba(15, 23, 42, 0.05);
}

.chat-unread-popover-item:hover {
  background: rgba(201, 162, 39, 0.07);
  border-left-color: #c9a227;
}

.chat-unread-popover-item:active {
  background: rgba(201, 162, 39, 0.14);
}

.chat-unread-popover-empty {
  cursor: default;
  color: #6b7280;
  font-style: italic;
  text-align: center;
  padding: 18px 14px;
}

.chat-unread-popover-empty:hover {
  background: transparent;
  border-left-color: transparent;
}

.chat-unread-popover-item.chat-unread-popover-more {
  font-size: 0.78rem;
  color: #6b7280;
  font-style: italic;
  text-align: center;
}

/* Pied de menu : actions globales (ex. « Liste complète », « Ouvrir le clavardage »). */
.annonces-notif-popover-foot {
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #fafbfc;
}

.annonces-notif-popover-link-btn {
  display: block;
  width: 100%;
  padding: 9px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffffff;
  background: linear-gradient(180deg, #d4a017 0%, #b8860b 100%);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  text-decoration: none;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 2px rgba(184, 134, 11, 0.3);
  transition: transform 100ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.annonces-notif-popover-link-btn:hover {
  filter: brightness(1.05);
  box-shadow: 0 2px 6px rgba(184, 134, 11, 0.35);
}

.annonces-notif-popover-link-btn:active {
  transform: translateY(1px);
}

.annonces-notif-popover-kind {
  font-weight: 700;
  color: #b8860b;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.annonces-notif-popover-date {
  color: #9ca3af;
  font-weight: 400;
  font-size: 0.78rem;
}

/* Avatar / source dans la liste de messages chat (premier badge en début de ligne). */
.chat-unread-popover-source {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-right: 8px;
  border-radius: 50%;
  background: linear-gradient(180deg, #f3f4f6 0%, #e5e7eb 100%);
  color: #4b5563;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  vertical-align: middle;
}

.chat-unread-popover-item--message {
  display: flex;
  align-items: flex-start;
  gap: 0;
}

.chat-unread-popover-item--message .chat-unread-popover-msg-body {
  flex: 1;
  min-width: 0;
}

.chat-unread-popover-msg-from {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: #111827;
  margin-bottom: 2px;
}

.chat-unread-popover-msg-preview {
  display: block;
  font-size: 0.8rem;
  color: #4b5563;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Thème nuit. */
#app-container.app-theme-night .chat-unread-popover {
  background: #1f2937;
  border-color: rgba(255, 255, 255, 0.06);
  color: #e5e7eb;
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.55),
    0 4px 10px rgba(0, 0, 0, 0.3);
}

#app-container.app-theme-night .chat-unread-popover::before {
  background: #1f2937;
  border-color: rgba(255, 255, 255, 0.06);
}

#app-container.app-theme-night .chat-unread-popover-title {
  color: #9ca3af;
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

#app-container.app-theme-night .chat-unread-popover-item {
  color: #e5e7eb;
}

#app-container.app-theme-night .chat-unread-popover-item + .chat-unread-popover-item {
  border-top-color: rgba(255, 255, 255, 0.05);
}

#app-container.app-theme-night .chat-unread-popover-item:hover {
  background: rgba(212, 160, 23, 0.16);
}

#app-container.app-theme-night .chat-unread-popover-empty {
  color: #9ca3af;
}

#app-container.app-theme-night .annonces-notif-popover-foot {
  background: #111827;
  border-top-color: rgba(255, 255, 255, 0.06);
}

#app-container.app-theme-night .chat-unread-popover-msg-from {
  color: #f3f4f6;
}

#app-container.app-theme-night .chat-unread-popover-msg-preview {
  color: #cbd5e1;
}

/* Tableau de bord — « indisponible temporairement » : même look que le menu contextuel des notes
   (.chat-unread-popover + .note-item-popover, titre bandeau doré défini dans pages/note.css). */
.dashboard-feature-unavail-wrap {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(12px + env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px))
    calc(12px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  box-sizing: border-box;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.dashboard-feature-unavail-wrap.dashboard-feature-unavail-wrap--open {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
}
.dashboard-feature-unavail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}
.dashboard-feature-unavail-wrap .dashboard-feature-unavail-popover.chat-unread-popover {
  position: relative;
  margin: auto;
  left: auto;
  right: auto;
  top: auto;
  transform-origin: center center;
  min-width: min(280px, calc(100vw - 24px));
  max-width: min(340px, calc(100vw - 24px));
  z-index: 1;
  pointer-events: auto;
}
.dashboard-feature-unavail-wrap .dashboard-feature-unavail-popover.chat-unread-popover::before {
  content: none !important;
  display: none !important;
}
.dashboard-feature-unavail-wrap .note-item-popover .chat-unread-popover-title {
  padding-right: 44px;
}
.dashboard-feature-unavail-body {
  margin: 0;
  padding: 14px 16px 8px;
  font-size: 0.9rem;
  line-height: 1.45;
  color: #374151;
}
.dashboard-feature-unavail-close {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  color: #111827;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.dashboard-feature-unavail-close:hover {
  background: rgba(0, 0, 0, 0.06);
}
.dashboard-feature-unavail-close:active {
  background: rgba(0, 0, 0, 0.1);
}
#app-container:has(.dashboard-feature-unavail-wrap--open) #dashboard-screen .dashboard-content {
  overflow: hidden !important;
  touch-action: none;
}
#app-container.app-theme-night .dashboard-feature-unavail-body {
  color: #d1d5db;
}
