/**
 * 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: all 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: all 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: all 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: all 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 */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.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; }

/* Dropdown pull-to-refresh */
.dropdown-ptr {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  height: 0;
  transition: height 0.2s ease-out;
  color: var(--text-muted, #9ca3af);
  font-size: 0.8125rem;
  border-bottom: 1px solid var(--card-border, rgba(168,85,247,0.10));
}
.dropdown-ptr .ptr-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color, rgba(168,85,247,0.3));
  border-top-color: var(--color-primary, #a855f7);
  border-radius: 50%;
  margin-right: 0.4rem;
}
.dropdown-ptr .ptr-spinner.spinning {
  animation: ptrSpin 0.6s linear infinite;
}
.dropdown-ptr .ptr-arrow {
  display: inline-block;
  margin-right: 0.4rem;
  transition: transform 0.2s ease;
}
.dropdown-ptr.pull-ready .ptr-arrow {
  transform: rotate(180deg);
}
@keyframes ptrSpin {
  to { transform: rotate(360deg); }
}

@keyframes skeletonFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes skeletonPulse {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 0.8; }
}

/* ── 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;
}
