/**
 * Navbar Dropdown Styles
 * Dropdown menus for notifications, messages, etc.
 */

.navbar-dropdown {
  position: fixed;
  width: 360px;
  max-height: 480px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--z-dropdown);
  opacity: 0;
  transform: translateY(-15px) scaleY(0.95);
  transform-origin: top center;
  transition: opacity 0.25s ease-out, transform 0.25s ease-out;
  pointer-events: none;
}

.navbar-dropdown:not(.hidden) {
  opacity: 1;
  transform: translateY(0) scaleY(1);
  pointer-events: auto;
}

/* Dropdown Header */
.dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-4);
  border-bottom: 1px solid var(--card-border);
  background: var(--bg-secondary);
}

.dropdown-header h3 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.dropdown-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: var(--text-lg);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast) var(--ease-in-out), background-color var(--transition-fast) var(--ease-in-out), border-color var(--transition-fast) var(--ease-in-out), box-shadow var(--transition-fast) var(--ease-in-out), opacity var(--transition-fast) var(--ease-in-out), transform var(--transition-fast) var(--ease-in-out), filter var(--transition-fast) var(--ease-in-out);
}

.dropdown-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Dropdown Content */
.dropdown-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.dropdown-content::-webkit-scrollbar {
  width: 6px;
}

.dropdown-content::-webkit-scrollbar-track {
  background: transparent;
}

.dropdown-content::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-full);
}

.dropdown-content::-webkit-scrollbar-thumb:hover {
  background: var(--border-color-dark);
}

/* Empty State */
.dropdown-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-12) var(--spacing-6);
  gap: var(--spacing-4);
  color: var(--text-muted);
}

.dropdown-empty i {
  opacity: 0.5;
}

.dropdown-empty p {
  font-size: var(--text-base);
  text-align: center;
}

/* Dropdown Items */
.dropdown-item {
  display: flex;
  gap: var(--spacing-3);
  padding: var(--spacing-4);
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: color var(--transition-fast) var(--ease-in-out), background-color var(--transition-fast) var(--ease-in-out), border-color var(--transition-fast) var(--ease-in-out), box-shadow var(--transition-fast) var(--ease-in-out), opacity var(--transition-fast) var(--ease-in-out), transform var(--transition-fast) var(--ease-in-out), filter var(--transition-fast) var(--ease-in-out);
  position: relative;
}

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

.dropdown-item:hover {
  background: var(--bg-hover);
}

.dropdown-item.unread {
  background: rgba(168, 85, 247, 0.06);
  animation: stateHighlightFlash 0.6s ease-out;
}

.dropdown-item.unread::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--color-primary);
}

/* Item Icon */
.item-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(168, 85, 247, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
  font-size: var(--text-lg);
}

/* Item Avatar */
.item-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.item-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item-avatar i {
  font-size: var(--text-2xl);
  color: var(--text-muted);
}

.item-avatar.online::after {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  background: var(--color-success);
  border: 2px solid var(--card-bg);
  border-radius: 50%;
  animation: pulse-online 3s ease-in-out infinite;
}

/* pulse-online keyframes (shared animation for online status indicators) */
@keyframes pulse-online {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* Item Content */
.item-content {
  flex: 1;
  min-width: 0;
}

.item-title {
  color: var(--text-primary);
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-base);
  margin-bottom: var(--spacing-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-text {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: var(--line-height-normal);
  margin-bottom: var(--spacing-1);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-time {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

/* Dropdown Footer */
.dropdown-footer {
  display: flex;
  gap: var(--spacing-2);
  padding: var(--spacing-3);
  border-top: 1px solid var(--card-border);
  background: var(--bg-secondary);
}

.dropdown-action-btn {
  flex: 1;
  padding: var(--spacing-2) var(--spacing-3);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: color var(--transition-fast) var(--ease-in-out), background-color var(--transition-fast) var(--ease-in-out), border-color var(--transition-fast) var(--ease-in-out), box-shadow var(--transition-fast) var(--ease-in-out), opacity var(--transition-fast) var(--ease-in-out), transform var(--transition-fast) var(--ease-in-out), filter var(--transition-fast) var(--ease-in-out);
}

.dropdown-action-btn:hover {
  background: var(--bg-hover);
  border-color: var(--color-primary);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

/* Badge Styles */
.badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--color-danger);
  color: white;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-bold);
  padding: var(--spacing-1) var(--spacing-2);
  border-radius: var(--radius-full);
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1;
  pointer-events: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  animation: stateBadgePop 0.4s ease-out;
}

.badge.hidden {
  display: none;
}

/* Icon Button Styles */
.icon-btn {
  position: relative;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: var(--text-xl);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast) var(--ease-in-out), background-color var(--transition-fast) var(--ease-in-out), border-color var(--transition-fast) var(--ease-in-out), box-shadow var(--transition-fast) var(--ease-in-out), opacity var(--transition-fast) var(--ease-in-out), transform var(--transition-fast) var(--ease-in-out), filter var(--transition-fast) var(--ease-in-out);
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.icon-btn:active {
  animation: stateBounceClick 0.25s ease-out;
}

.icon-btn.active {
  background: var(--color-primary);
  color: white;
  animation: stateShadowPulse 0.5s ease-out;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .navbar-dropdown {
    width: calc(100vw - 20px);
    max-width: 360px;
    right: 10px !important;
  }
  
  .dropdown-item {
    padding: var(--spacing-3);
  }
  
  .item-icon,
  .item-avatar {
    width: 36px;
    height: 36px;
  }
  
  .item-icon {
    font-size: var(--text-base);
  }
}

@media (max-width: 480px) {
  .navbar-dropdown {
    max-height: 70vh;
  }
  
  .dropdown-footer {
    flex-direction: column;
  }
  
  .dropdown-action-btn {
    width: 100%;
  }
}

/* Animations */


.badge {
  animation: pulse 2s ease-in-out infinite;
}

/* Dropdown skeleton placeholders */
.dropdown-skeleton { padding: 0.5rem; }
.dropdown-skeleton-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius-lg, 10px);
  opacity: 0;
  animation: skeletonFadeIn 0.35s ease-out forwards;
}
.skeleton-avatar-sm {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg-tertiary, rgba(255,255,255,0.06));
  flex-shrink: 0;
  animation: skeletonPulse 1.8s ease-in-out infinite;
}
.skeleton-text-group { flex: 1; display: flex; flex-direction: column; gap: 0.4rem; }
.skeleton-line {
  height: 10px;
  border-radius: 4px;
  background: var(--bg-tertiary, rgba(255,255,255,0.06));
  animation: skeletonPulse 1.8s ease-in-out infinite;
}
.skeleton-line-title { width: 65%; }
.skeleton-line-sub   { width: 40%; height: 8px; }

/* Pull-to-refresh: css/pull-to-refresh.css (shared component). */
@keyframes ptrSpin {
  to { transform: rotate(360deg); }
}


/* ── ConversationCard inside the messages dropdown ──────────────────────────
   Override messenger.css defaults so the cards fit the narrow dropdown panel.
   border-radius:0 keeps the flat list look; border-bottom separates rows.     */
.dropdown-content .messenger-conv-item {
  border-radius: 0;
  border-bottom: 1px solid var(--border-color);
  padding: 0.55rem 0.85rem;
}

.dropdown-content .messenger-conv-item:last-child {
  border-bottom: none;
}

/* Keep unread accent bar consistent with other dropdown item types */
.dropdown-content .messenger-conv-item.unread::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--color-primary);
}

/* Constrain preview text so it doesn't overflow the panel */
.dropdown-content .messenger-conv-preview {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  display: block;
}

/* ── Account chip: avatar + @username, opens the account menu ───────── */
.header-actions .navbar-account-chip {
  width: auto;
  min-width: 40px;
  gap: 8px;
  padding: 3px 10px 3px 3px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border, rgba(127, 127, 160, 0.25));
  background: var(--bg-secondary, rgba(127, 127, 160, 0.08));
  position: relative;
}
.navbar-account-chip:hover { background: var(--bg-hover, rgba(168, 85, 247, 0.12)); }
.navbar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
}
.navbar-username {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary, inherit);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.navbar-username:empty { display: none; }
.navbar-account-caret { font-size: 0.65rem; opacity: 0.6; }
.navbar-account-chip .badge-dot.online {
  position: absolute; left: 26px; bottom: 3px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--color-success, #10b981);
  border: 2px solid var(--bg-primary, #fff);
}
@media (max-width: 640px) {
  .navbar-username, .navbar-account-caret { display: none; }
  .header-actions .navbar-account-chip { padding: 3px; }
}

/* ── Dropdown items: avatar with a type badge ─────────────────────────── */
.navbar-dropdown .item-avatar { position: relative; flex: none; }
.navbar-dropdown .item-icon { position: relative; overflow: visible; }  /* holds the stack-count bubble */
/* The badges sit on the avatar's edge: round the image, not the box, so they are not clipped. */
.navbar-dropdown .item-avatar { overflow: visible; }
.navbar-dropdown .item-avatar .item-avatar-img { border-radius: 50%; }
.navbar-dropdown .item-avatar .item-type-badge i { font-size: 9px; color: #fff; }
.navbar-dropdown .item-type-badge {
  position: absolute; right: -4px; bottom: -4px;
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: #fff;
  background: var(--color-primary, #a855f7);
  border: 2px solid var(--bg-primary, #fff);
}
.navbar-dropdown .dropdown-item.unread { background: var(--bg-unread, rgba(168, 85, 247, 0.08)); }
.navbar-dropdown .dropdown-item.unread .item-title { font-weight: 700; }
.navbar-dropdown .dropdown-item.unread::after {
  content: ''; flex: none; align-self: center;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--color-primary, #a855f7); margin-left: 8px;
}
/* A theme rule paints every div opaque; inside an item that hid the row's
   unread tint behind light "bars" under the title, text and time. */
.navbar-dropdown .dropdown-item .item-content,
.navbar-dropdown .dropdown-item .item-content *,
.navbar-dropdown .dropdown-item .item-avatar { background: transparent; }
