/**
 * Custom Profile Menu - BOTBUSTER Theme
 * Matches the premium dark theme with bold red accents
 */

/* Profile Button Container */
#custom-profile-button {
    position: relative;
    display: none;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#custom-profile-button.visible {
    display: block !important;
    opacity: 1;
}

/* Profile Avatar Button */
.profile-avatar-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bb-dark-gray, #1a1a1a);
    border: 2px solid var(--bb-red-primary, #bd001b);
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--bb-font-display, 'UniformExtraCondensed', 'Impact', sans-serif);
    font-weight: var(--bb-weight-bold, 700);
    font-size: 0.875rem;
    color: var(--bb-white, #FFFFFF);
    letter-spacing: 0.05em;
    user-select: none;
    position: relative;
}

.profile-avatar-btn::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    background: var(--bb-red-primary, #bd001b);
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: -1;
}

.profile-avatar-btn:hover::before {
    opacity: 0.15;
}

.profile-avatar-btn:hover {
    border-color: var(--bb-red-hover, #d40020);
    box-shadow: 0 0 20px var(--bb-red-glow, rgba(189, 0, 27, 0.25));
    transform: scale(1.05);
}

.profile-avatar-btn:active {
    transform: scale(0.98);
}

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

/* Profile Dropdown Menu */
.profile-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    min-width: 280px;
    background: var(--bb-charcoal, #0a0a0a);
    border: 1px solid var(--bb-red-primary, #bd001b);
    border-radius: 0;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.8),
        0 0 0 1px var(--bb-red-primary, #bd001b),
        0 0 20px var(--bb-red-glow, rgba(189, 0, 27, 0.25));
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    backdrop-filter: blur(20px);
}

.profile-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Dropdown Header - User Info */
.profile-dropdown-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--bb-red-primary, #bd001b);
    background: var(--bb-black, #000000);
}

.profile-header-top {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.375rem;
    flex-wrap: wrap;
}

.profile-user-name {
    font-family: var(--bb-font-display, 'UniformExtraCondensed', 'Impact', sans-serif);
    font-size: 1.125rem;
    font-weight: var(--bb-weight-bold, 700);
    color: var(--bb-white, #FFFFFF);
    word-break: break-word;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    flex: 0 1 auto;
}

.profile-user-email {
    font-family: var(--bb-font-primary, 'CartographMono', 'Courier New', monospace);
    font-size: 0.75rem;
    color: var(--bb-gray-dark, #999999);
    word-break: break-word;
}

/* User Badge (Plan/Credits) */
.profile-user-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.5rem;
    background: var(--bb-red-light, rgba(189, 0, 27, 0.1));
    border: 1px solid var(--bb-red-primary, #bd001b);
    font-family: var(--bb-font-display, 'UniformExtraCondensed', 'Impact', sans-serif);
    font-size: 0.625rem;
    font-weight: var(--bb-weight-bold, 700);
    color: var(--bb-red-primary, #bd001b);
    letter-spacing: 0.1em;
    flex-shrink: 0;
    line-height: 1;
}

/* Dropdown Menu Items */
.profile-dropdown-menu {
    padding: 0.5rem 0;
}

.profile-menu-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    color: var(--bb-gray-light, #E5E5E5);
    text-decoration: none;
    transition: all 0.15s ease;
    cursor: pointer;
    font-family: var(--bb-font-primary, 'CartographMono', 'Courier New', monospace);
    font-size: 0.875rem;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    border-left: 3px solid transparent;
}

.profile-menu-item:hover {
    background: var(--bb-red-light, rgba(189, 0, 27, 0.1));
    border-left-color: var(--bb-red-primary, #bd001b);
    color: var(--bb-white, #FFFFFF);
}

.profile-menu-item-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bb-red-primary, #bd001b);
    flex-shrink: 0;
}

.profile-menu-item:hover .profile-menu-item-icon {
    filter: drop-shadow(0 0 8px var(--bb-red-glow, rgba(189, 0, 27, 0.25)));
}

/* Divider */
.profile-menu-divider {
    height: 1px;
    background: var(--bb-red-primary, #bd001b);
    margin: 0.5rem 0;
    opacity: 0.3;
}

/* Sign Out Button */
.profile-menu-item.sign-out {
    color: var(--bb-red-primary, #bd001b);
    font-weight: var(--bb-weight-medium, 600);
}

.profile-menu-item.sign-out:hover {
    background: var(--bb-red-primary, #bd001b);
    color: var(--bb-white, #FFFFFF);
    border-left-color: var(--bb-red-hover, #d40020);
}

.profile-menu-item.sign-out .profile-menu-item-icon {
    color: inherit;
}

/* Secured by Clerk footer (optional) */
.profile-dropdown-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--bb-red-primary, #bd001b);
    background: var(--bb-black, #000000);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--bb-font-primary, 'CartographMono', 'Courier New', monospace);
    font-size: 0.688rem;
    color: var(--bb-gray-dark, #999999);
}

.profile-dropdown-footer svg {
    width: 14px;
    height: 14px;
    opacity: 0.5;
}

/* Mobile Adjustments */
@media (max-width: 767px) {
    .profile-avatar-btn {
        width: 36px;
        height: 36px;
        font-size: 0.813rem;
    }

    .profile-dropdown {
        right: -8px;
        min-width: 260px;
    }

    .profile-dropdown-header {
        padding: 1rem 0.875rem;
    }

    .profile-user-name {
        font-size: 1rem;
    }

    .profile-user-email {
        font-size: 0.688rem;
    }

    .profile-menu-item {
        padding: 1rem 0.875rem;
        min-height: 48px; /* Touch target */
        font-size: 0.813rem;
    }
}

/* Tablet Adjustments */
@media (min-width: 768px) and (max-width: 1023px) {
    .profile-dropdown {
        min-width: 270px;
    }
}

/* Desktop Large */
@media (min-width: 1280px) {
    .profile-avatar-btn {
        width: 44px;
        height: 44px;
    }

    .profile-dropdown {
        min-width: 300px;
    }
}

/* Animation for smooth appearance */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.profile-dropdown.active {
    animation: slideDown 0.2s ease;
}

/* Accessibility: Focus states */
.profile-avatar-btn:focus {
    outline: 2px solid var(--bb-red-primary, #bd001b);
    outline-offset: 2px;
}

.profile-menu-item:focus {
    background: var(--bb-red-light, rgba(189, 0, 27, 0.1));
    border-left-color: var(--bb-red-primary, #bd001b);
    outline: none;
}

/* Accessibility: Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .profile-avatar-btn,
    .profile-dropdown,
    .profile-menu-item {
        transition: none;
    }

    .profile-dropdown.active {
        animation: none;
    }
}

/* Dark mode override (already dark, but just in case) */
@media (prefers-color-scheme: dark) {
    .profile-dropdown {
        background: var(--bb-charcoal, #0a0a0a);
        border-color: var(--bb-red-primary, #bd001b);
    }
}
