/*
 * Enhanced User Profile Dropdown
 * This file contains improved styles for the user profile dropdown
 * to create a more elegant, user-friendly experience
 */

:root {
  --accent-color: #fd5631;
  --accent-hover-color: #ff3a40;
  --dark-bg: #1f1b2c;
  --darker-bg: #18151f;
  --light-text: rgba(255, 255, 255, 0.9);
  --medium-text: rgba(255, 255, 255, 0.7);
  --border-color: rgba(255, 255, 255, 0.1);
  --hover-bg: rgba(253, 86, 49, 0.15);
  --danger-color: #dc3545;
  --danger-hover: rgba(220, 53, 69, 0.15);
  --transition-fast: 0.2s;
  --transition-medium: 0.3s;
  --box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  --box-shadow-hover: 0 12px 28px rgba(0, 0, 0, 0.25);
}

/* Main dropdown container */
.custom-dropdown {
  width: 320px;
  padding: 0;
  background: linear-gradient(145deg, #211d2e, #1a1724);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--box-shadow);
  overflow: hidden;
  animation: dropdownFadeIn var(--transition-fast) ease-out;
  transform-origin: top right;
  z-index: 1030; /* Ensure it's above other elements */
}

/* Base dropdown styles - Click-only version */
.dropdown-menu.custom-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.95);
  transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
  z-index: 1030; /* Ensure it's above other elements */
}

/* Show dropdown when .show class is applied */
.dropdown-menu.custom-dropdown.show {
  display: block;
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Fix for dropdown positioning */
.nav-item.dropdown {
  position: relative;
}

/* Ensure dropdown toggle has a pointer cursor */
.nav-link.dropdown-toggle {
  cursor: pointer;
}

/* Add a subtle active state for the dropdown toggle */
.nav-item.dropdown.show .nav-link.dropdown-toggle {
  background-color: rgba(255, 255, 255, 0.05);
}

/* Animation keyframes */
@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Entrance animation */
.custom-dropdown.animate-entrance {
  animation: dropdownEntrance 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

@keyframes dropdownEntrance {
  from {
    opacity: 0;
    transform: translateY(-15px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Exit animation */
.custom-dropdown.animate-exit {
  animation: dropdownExit 0.2s ease-in forwards;
}

@keyframes dropdownExit {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }
}

/* Profile section with improved layout */
.profile-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  background: linear-gradient(to bottom, rgba(31, 27, 44, 0.95), rgba(31, 27, 44, 0.85));
  border-bottom: none;
  position: relative;
  overflow: hidden;
}

/* Profile header with user info always visible */
.profile-header {
  width: 100%;
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: var(--darker-bg);
  border-bottom: 1px solid var(--border-color);
}

.profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--border-color);
  background-color: #2a2438;
  flex-shrink: 0;
  position: relative;
  transition: transform var(--transition-medium) ease, border-color var(--transition-medium) ease;
}

.profile-avatar:hover {
  transform: scale(1.05);
  border-color: var(--accent-color);
}

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

.profile-avatar .fa-user-circle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  color: #6c757d;
}

.profile-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.profile-info #userName {
  font-size: 1rem;
  font-weight: 600;
  color: var(--light-text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-info #userEmail {
  font-size: 0.8rem;
  color: var(--medium-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Remove the old profile box */
.profile-box {
  display: none;
}

/* Dropdown menu items with improved layout */
.dropdown-menu-items {
  display: flex;
  flex-direction: column;
  padding: 10px;
  gap: 5px;
  background-color: transparent;
  border-top: none;
  position: relative;
}

/* Remove the column divider */
.dropdown-menu-items::after {
  display: none;
}

/* Create sections for menu items */
.dropdown-section {
  margin-bottom: 8px;
  position: relative;
}

.dropdown-section:not(:last-child)::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 10%;
  width: 80%;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border-color), transparent);
}

/* Style for dropdown items */
.custom-dropdown .dropdown-item {
  padding: 10px 12px;
  font-size: 0.9rem;
  border-radius: 8px;
  color: var(--light-text);
  transition: all 0.2s ease;
  margin: 2px 0;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

/* Active/focus state for dropdown items */
.custom-dropdown .dropdown-item:active,
.custom-dropdown .dropdown-item:focus {
  outline: none;
  background-color: rgba(253, 86, 49, 0.1);
  color: var(--accent-color);
  transform: translateX(4px);
}

/* Focus styles for keyboard navigation */
.custom-dropdown .dropdown-item:focus-visible {
  box-shadow: 0 0 0 2px var(--accent-color);
}

/* Position elements above the background */
.custom-dropdown .dropdown-item i,
.custom-dropdown .dropdown-item div,
.custom-dropdown .dropdown-item span,
.custom-dropdown .dropdown-item .badge {
  position: relative;
  z-index: 1;
}

/* Icon styles */
.custom-dropdown .dropdown-item i {
  margin-right: 10px;
  font-size: 16px;
  width: 20px;
  text-align: center;
  color: var(--accent-color);
  transition: transform 0.2s ease;
}

/* Icon animation on active/focus */
.custom-dropdown .dropdown-item:active i,
.custom-dropdown .dropdown-item:focus i {
  transform: translateX(2px);
}

/* Style for the logout item */
.custom-dropdown .dropdown-item.text-danger {
  color: var(--danger-color) !important;
}

.custom-dropdown .dropdown-item.text-danger:active,
.custom-dropdown .dropdown-item.text-danger:focus {
  background-color: var(--danger-hover);
}

.custom-dropdown .dropdown-item.text-danger i {
  color: var(--danger-color);
}

/* Badge styling */
.custom-dropdown .badge {
  transition: all 0.2s ease;
  background-color: var(--accent-color);
}

.custom-dropdown .dropdown-item:active .badge,
.custom-dropdown .dropdown-item:focus .badge {
  transform: scale(1.1);
}

/* Mobile optimizations */
@media (max-width: 576px) {
  .custom-dropdown {
    width: 280px;
    max-width: calc(100vw - 20px);
  }

  .profile-header {
    padding: 12px;
  }

  .profile-avatar {
    width: 40px;
    height: 40px;
  }

  .dropdown-menu-items {
    padding: 8px;
  }

  .custom-dropdown .dropdown-item {
    padding: 8px 10px;
    font-size: 0.85rem;
  }
}

@media (max-width: 375px) {
  .custom-dropdown {
    width: 250px;
  }

  .profile-avatar {
    width: 36px;
    height: 36px;
  }

  .profile-info #userName {
    font-size: 0.9rem;
  }

  .profile-info #userEmail {
    font-size: 0.75rem;
  }
}
