/* ===================================
   WhispeeAi - Profile Dropdown Enhancements
   Advanced animations and effects for user menu
   =================================== */

/* Staggered animation for dropdown items when opening */
.user-menu.active .dropdown-item {
    animation: dropdown-item-appear 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) backwards;
}

.user-menu.active .dropdown-item:nth-child(1) { animation-delay: 0.1s; }
.user-menu.active .dropdown-item:nth-child(2) { animation-delay: 0.15s; }
.user-menu.active .dropdown-item:nth-child(3) { animation-delay: 0.2s; }
.user-menu.active .dropdown-item:nth-child(4) { animation-delay: 0.25s; }
.user-menu.active .dropdown-item:nth-child(5) { animation-delay: 0.3s; }

@keyframes dropdown-item-appear {
    0% {
        opacity: 0;
        transform: translateX(-20px) scale(0.9);
    }
    50% {
        transform: translateX(5px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* Dropdown header entrance animation */
.user-menu.active .dropdown-header {
    animation: header-slide-in 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes header-slide-in {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Floating particles effect in dropdown */
.user-dropdown::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(102, 126, 234, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 90% 80%, rgba(240, 147, 251, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(118, 75, 162, 0.05) 0%, transparent 50%);
    background-size: 200% 200%;
    animation: particles-move 15s ease-in-out infinite;
    pointer-events: none;
    border-radius: 20px;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.user-menu.active .user-dropdown::after {
    opacity: 1;
}

@keyframes particles-move {
    0%, 100% {
        background-position: 0% 0%, 100% 100%, 50% 50%;
    }
    50% {
        background-position: 100% 100%, 0% 0%, 25% 75%;
    }
}

/* Enhanced divider with animation */
.dropdown-divider {
    position: relative;
    overflow: hidden;
}

.dropdown-divider::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent,
        rgba(102, 126, 234, 0.5),
        transparent);
    animation: divider-shine 3s infinite;
}

@keyframes divider-shine {
    0% { left: -100%; }
    50%, 100% { left: 100%; }
}

/* Tooltip effect on hover */
.dropdown-item {
    position: relative;
}

.dropdown-item::before {
    content: attr(data-tooltip);
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    transition: opacity 0.3s ease;
}

/* Icon bounce on hover */
@keyframes icon-bounce {
    0%, 100% { transform: scale(1.2) rotate(10deg) translateY(0); }
    50% { transform: scale(1.2) rotate(10deg) translateY(-3px); }
}

.dropdown-item:hover i {
    animation: icon-bounce 0.6s ease;
}

/* Glow effect on active dropdown */
.user-menu.active .user-dropdown {
    animation: dropdown-glow 3s ease-in-out infinite;
}

@keyframes dropdown-glow {
    0%, 100% {
        box-shadow: 
            0 20px 60px rgba(102, 126, 234, 0.25),
            0 8px 16px rgba(0, 0, 0, 0.1),
            0 0 0 1px rgba(102, 126, 234, 0.15),
            inset 0 1px 0 rgba(255, 255, 255, 0.9);
    }
    50% {
        box-shadow: 
            0 20px 70px rgba(102, 126, 234, 0.35),
            0 10px 20px rgba(0, 0, 0, 0.15),
            0 0 0 1px rgba(240, 147, 251, 0.25),
            0 0 40px rgba(240, 147, 251, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 1);
    }
}

/* Smooth close animation */
.user-dropdown {
    animation-fill-mode: forwards;
}

.user-menu:not(.active) .user-dropdown {
    animation: dropdown-close 0.3s ease-out forwards;
}

@keyframes dropdown-close {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1) rotateX(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(-10px) scale(0.95) rotateX(-5deg);
    }
}

/* User name typing effect */
.user-menu.active .user-name {
    animation: text-shimmer 4s ease-in-out infinite;
}

@keyframes text-shimmer {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

/* Hover lift effect for dropdown header */
.dropdown-header {
    transition: transform 0.3s ease;
}

.dropdown-header:hover {
    transform: translateY(-2px);
}

/* Interactive background on item hover */
.dropdown-item {
    background-size: 200% 100%;
    background-position: right;
}

.dropdown-item:hover {
    background-position: left;
}

/* Enhanced focus states for accessibility */
.dropdown-item:focus,
.dropdown-item:focus-visible {
    outline: 2px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
    background: linear-gradient(90deg, 
        rgba(102, 126, 234, 0.15), 
        rgba(240, 147, 251, 0.1),
        rgba(240, 147, 251, 0.05));
}

/* Micro-interaction: Icon rotation variants */
.dropdown-item:nth-child(odd):hover i {
    transform: scale(1.2) rotate(-10deg);
}

.dropdown-item:nth-child(even):hover i {
    transform: scale(1.2) rotate(10deg);
}

/* Subtle pulsing effect on avatar in header */
.dropdown-header .avatar-circle {
    animation: avatar-pulse-header 3s ease-in-out infinite;
}

/* Arrow indicator for dropdown */
.user-dropdown::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid rgba(102, 126, 234, 0.2);
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.user-menu.active .user-dropdown::before {
    opacity: 1;
    animation: arrow-bounce 1s ease-in-out infinite;
}

@keyframes arrow-bounce {
    0%, 100% { top: -8px; }
    50% { top: -10px; }
}

/* Logout button special styling */
.dropdown-item:last-child {
    margin-top: 0.5rem;
    border-top: 1px solid rgba(102, 126, 234, 0.1);
    padding-top: 1.25rem;
}

.dropdown-item:last-child:hover {
    background: linear-gradient(90deg, 
        rgba(239, 68, 68, 0.1), 
        rgba(239, 68, 68, 0.05));
    color: #ef4444;
}

.dropdown-item:last-child:hover i {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

/* Smooth transitions for all interactive elements */
.user-dropdown * {
    transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Performance optimizations */
.user-dropdown,
.dropdown-item,
.dropdown-header,
.avatar-circle {
    will-change: transform, opacity;
}

/* Prevent text selection in dropdown */
.user-dropdown {
    user-select: none;
    -webkit-user-select: none;
}

/* Mobile-specific enhancements */
@media (max-width: 768px) {
    /* Fullscreen overlay effect on mobile */
    .user-menu.active::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.3);
        backdrop-filter: blur(4px);
        z-index: 999;
        animation: overlay-fade-in 0.3s ease;
    }
    
    @keyframes overlay-fade-in {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    
    .user-dropdown {
        box-shadow: 
            0 25px 70px rgba(102, 126, 234, 0.35),
            0 15px 30px rgba(0, 0, 0, 0.2),
            0 0 0 1px rgba(102, 126, 234, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 1);
    }
    
    /* Touch-friendly item spacing */
    .dropdown-item {
        min-height: 48px;
    }
    
    /* Enhanced tap feedback */
    .dropdown-item:active {
        transform: scale(0.95);
        background: linear-gradient(90deg, 
            rgba(102, 126, 234, 0.2), 
            rgba(240, 147, 251, 0.15));
    }
}

/* Tablet adjustments */
@media (max-width: 1024px) and (min-width: 769px) {
    .user-dropdown {
        min-width: 270px;
    }
}

/* Print styles - hide dropdown */
@media print {
    .user-dropdown {
        display: none !important;
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .user-dropdown,
    .dropdown-item,
    .dropdown-header,
    .avatar-circle {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .user-dropdown {
        border: 2px solid currentColor;
    }
    
    .dropdown-item:hover {
        outline: 2px solid currentColor;
    }
}

/* ===================================
   Chevron rotation on open
   =================================== */
.user-menu.active .user-avatar-btn .fa-chevron-down {
    transform: rotate(180deg);
}

/* Logout item — keep red on hover */
#logoutBtn.dropdown-item:hover {
    color: #ef4444 !important;
    background: linear-gradient(90deg, rgba(239,68,68,0.1), rgba(239,68,68,0.05));
}
#logoutBtn.dropdown-item:hover i {
    color: white !important;
}
#logoutBtn.dropdown-item:hover i::after {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}
#logoutBtn.dropdown-item:hover::before {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

/* Credits badge subtle pulse on open */
.user-menu.active #dropdownCreditsDisplay {
    animation: credits-pop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) 0.35s both;
}
@keyframes credits-pop {
    0% { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
