/**
 * Salish Mushrooms - Profile Menu Styles
 *
 * Modern user profile dropdown menu for header navigation.
 * Provides a clean, accessible profile circle with dropdown menu.
 */

/* ===================================================================
 * Profile Menu Container & Menu Item Integration
 * ================================================================ */

/* Make the menu item contain the profile menu properly */
.menu-item.salish-profile-menu-item {
    position: relative;
    display: flex;
    align-items: center;
}

.menu-item.salish-profile-menu-item > a {
    display: none; /* Hide default link styling */
}

.salish-profile-menu-container {
    display: flex;
    align-items: center;
    height: 100%;
    margin-left: 0;
}

/* ===================================================================
 * Logged Out State - Login Button
 * ================================================================ */

.salish-login-button-wrapper {
    display: flex;
    align-items: center;
}

.salish-login-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 20px;
    background: var(--global-palette1, #2b6cb0);
    color: #ffffff !important;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.salish-login-button:hover {
    background: var(--global-palette2, #2c5282);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(43, 108, 176, 0.3);
}

.salish-login-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(43, 108, 176, 0.3);
}

/* ===================================================================
 * Logged In State - Profile Circle
 * ================================================================ */

.salish-profile-circle-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.salish-profile-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--global-palette1, #2b6cb0) 0%, var(--global-palette2, #2c5282) 100%);
    color: #ffffff;
    border: 2px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    outline: none;
}

.salish-profile-circle:hover {
    border-color: var(--global-palette1, #2b6cb0);
    box-shadow: 0 4px 12px rgba(43, 108, 176, 0.3);
    transform: scale(1.05);
}

.salish-profile-circle:focus {
    border-color: var(--global-palette1, #2b6cb0);
    box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.2);
}

.salish-profile-circle[aria-expanded="true"] {
    border-color: var(--global-palette1, #2b6cb0);
    box-shadow: 0 4px 12px rgba(43, 108, 176, 0.3);
}

.salish-profile-initials {
    user-select: none;
    pointer-events: none;
}

/* ===================================================================
 * Profile Dropdown Menu
 * ================================================================ */

.salish-profile-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    min-width: 260px;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.salish-profile-dropdown[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Dropdown arrow pointer */
.salish-profile-dropdown::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 14px;
    width: 12px;
    height: 12px;
    background: #ffffff;
    transform: rotate(45deg);
    box-shadow: -2px -2px 5px rgba(0, 0, 0, 0.05);
}

/* ===================================================================
 * Dropdown Header - User Info
 * ================================================================ */

.salish-profile-dropdown-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
}

.salish-profile-name {
    font-weight: 600;
    font-size: 15px;
    color: #1a202c;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.salish-profile-email {
    font-size: 13px;
    color: #718096;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.salish-profile-membership {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.salish-profile-membership.pro {
    background: linear-gradient(135deg, #f6ad55 0%, #ed8936 100%);
    color: #ffffff;
}

.salish-profile-membership.free {
    background: #e2e8f0;
    color: #4a5568;
}

/* ===================================================================
 * Dropdown Menu Items
 * ================================================================ */

.salish-profile-menu-items {
    list-style: none;
    margin: 0;
    padding: 8px 0;
}

.salish-profile-menu-items li {
    margin: 0;
    padding: 0;
}

.salish-profile-menu-items li.separator {
    height: 1px;
    background: #e2e8f0;
    margin: 8px 0;
}

.salish-profile-menu-items a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: #4a5568 !important;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.15s ease;
}

.salish-profile-menu-items a:hover {
    background: #f7fafc;
    color: var(--global-palette1, #2b6cb0) !important;
}

.salish-profile-menu-items a svg {
    margin-right: 12px;
    flex-shrink: 0;
}

.salish-profile-menu-items a.upgrade-link {
    color: #ed8936 !important;
    font-weight: 600;
}

.salish-profile-menu-items a.upgrade-link:hover {
    background: #fffaf0;
    color: #dd6b20 !important;
}

.salish-profile-menu-items a.salish-logout-link {
    color: #e53e3e !important;
}

.salish-profile-menu-items a.salish-logout-link:hover {
    background: #fff5f5;
    color: #c53030 !important;
}

/* ===================================================================
 * Mobile Responsive Styles
 * ================================================================ */

@media (max-width: 1024px) {
    .salish-profile-menu-container {
        margin-left: 12px;
    }

    .salish-login-button {
        padding: 6px 16px;
        font-size: 13px;
    }

    .salish-profile-circle {
        width: 36px;
        height: 36px;
        font-size: 13px;
    }

    .salish-profile-dropdown {
        min-width: 240px;
    }
}

@media (max-width: 768px) {
    .salish-profile-menu-container {
        margin-left: 8px;
    }

    .salish-profile-dropdown {
        min-width: 220px;
        right: -10px;
    }

    .salish-profile-dropdown::before {
        right: 22px;
    }
}

/* ===================================================================
 * Tablet & Mobile - Header Integration
 * ================================================================ */

/* Adjust positioning in Kadence mobile header */
#mobile-header .salish-profile-menu-container {
    margin-left: 0;
    margin-right: 15px;
}

/* Kadence mobile menu - ensure profile menu is visible */
.mobile-drawer-inner .salish-profile-menu-container,
.drawer-inner .salish-profile-menu-container {
    display: block;
    width: 100%;
    margin: 0;
    padding: 15px 20px;
    border-top: 1px solid #e2e8f0;
}

/* Mobile drawer - profile circle takes full width */
.mobile-drawer-inner .salish-profile-circle-wrapper,
.drawer-inner .salish-profile-circle-wrapper {
    display: block;
    width: 100%;
}

/* Mobile drawer - make profile circle inline with menu items */
.mobile-drawer-inner .salish-profile-circle,
.drawer-inner .salish-profile-circle {
    display: inline-flex;
    margin-bottom: 10px;
}

/* Mobile drawer - dropdown appears below (not floating) */
.mobile-drawer-inner .salish-profile-dropdown,
.drawer-inner .salish-profile-dropdown {
    position: relative;
    top: 0;
    right: 0;
    box-shadow: none;
    border: 1px solid #e2e8f0;
    margin-top: 10px;
}

/* Mobile drawer - hide dropdown arrow */
.mobile-drawer-inner .salish-profile-dropdown::before,
.drawer-inner .salish-profile-dropdown::before {
    display: none;
}

/* Mobile drawer - login button full width */
.mobile-drawer-inner .salish-login-button,
.drawer-inner .salish-login-button {
    width: 100%;
    justify-content: center;
    padding: 12px 20px;
}

/* Ensure dropdown stays within viewport on mobile */
@media (max-width: 480px) {
    .salish-profile-dropdown {
        right: -10px;
        min-width: 200px;
    }

    .salish-profile-dropdown-header {
        padding: 12px 16px;
    }

    .salish-profile-menu-items a {
        padding: 10px 16px;
        font-size: 13px;
    }
}

/* ===================================================================
 * Accessibility & Focus States
 * ================================================================ */

.salish-profile-circle:focus-visible {
    outline: 2px solid var(--global-palette1, #2b6cb0);
    outline-offset: 2px;
}

.salish-profile-menu-items a:focus-visible {
    outline: 2px solid var(--global-palette1, #2b6cb0);
    outline-offset: -2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .salish-profile-circle,
    .salish-profile-dropdown,
    .salish-profile-menu-items a {
        transition: none;
    }
}

/* ===================================================================
 * Loading State (for AJAX logout)
 * ================================================================ */

.salish-logout-link.loading {
    opacity: 0.6;
    pointer-events: none;
}

.salish-logout-link.loading::after {
    content: '...';
    animation: logout-loading 1s infinite;
}

@keyframes logout-loading {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* ===================================================================
 * Dark Mode Support (optional)
 * ================================================================ */

@media (prefers-color-scheme: dark) {
    .salish-profile-dropdown {
        background: #2d3748;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    }

    .salish-profile-dropdown::before {
        background: #2d3748;
    }

    .salish-profile-dropdown-header {
        border-bottom-color: #4a5568;
    }

    .salish-profile-name {
        color: #f7fafc;
    }

    .salish-profile-email {
        color: #cbd5e0;
    }

    .salish-profile-menu-items li.separator {
        background: #4a5568;
    }

    .salish-profile-menu-items a {
        color: #e2e8f0 !important;
    }

    .salish-profile-menu-items a:hover {
        background: #4a5568;
    }
}
