/**
 * Brand Platform User Menu — Styles
 *
 * Matches Brand Platform's UserMenu component design:
 * - 36×36px circular avatar with #0D8ABC background
 * - 224px dropdown with shadow and rounded corners
 * - Role badge pills (Admin=purple, Creator=blue, Viewer=gray)
 * - Dark mode support for Blocksy + prefers-color-scheme
 */

/* ==========================================================================
   Menu Item Container
   ========================================================================== */

.bp-user-menu-item {
    position: relative;
    display: flex;
    align-items: center;
}

.bp-user-menu {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* ==========================================================================
   Loading Skeleton (shown before JS hydrates)
   ========================================================================== */

.bp-avatar-skeleton {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #e5e5e5;
    animation: bpum-pulse 1.5s ease-in-out infinite;
}

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

/* ==========================================================================
   Login Button (logged-out state)
   ========================================================================== */

.bp-login-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 150ms ease;
}

.bp-login-button:hover,
.bp-login-button:focus-visible {
    background-color: rgba(0, 0, 0, 0.06);
    text-decoration: none;
    color: inherit;
}

.bp-login-button svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ==========================================================================
   Avatar Trigger (logged-in state)
   ========================================================================== */

.bp-avatar-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    transition: opacity 150ms ease;
}

.bp-avatar-trigger:hover {
    opacity: 0.85;
}

.bp-avatar-trigger:focus-visible {
    outline: 2px solid #0D8ABC;
    outline-offset: 2px;
}

.bp-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #0D8ABC;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    user-select: none;
    overflow: hidden;
}

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

.bp-user-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 9999;
    width: 224px;
    padding: 4px;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    background-color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 150ms ease, transform 150ms ease;
}

.bp-user-dropdown[aria-hidden="false"] {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ==========================================================================
   Dropdown Header (name + email)
   ========================================================================== */

.bp-dropdown-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 8px 6px;
}

.bp-name-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.bp-badges-row {
    display: flex;
    gap: 4px;
    margin-top: 2px;
}

.bp-header-divider {
    width: 70%;
    border: none;
    border-top: 1px solid #e5e5e5;
    margin: 4px 0 2px;
}

.bp-user-name {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    color: #171717;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bp-user-email {
    font-size: 12px;
    line-height: 1.2;
    color: #737373;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.bp-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 8px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #171717;
    font-size: 14px;
    line-height: 1.4;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 100ms ease;
}

.bp-dropdown-item:hover,
.bp-dropdown-item:focus-visible {
    background-color: #f5f5f5;
    text-decoration: none;
    color: #171717;
}

.bp-dropdown-item:focus-visible {
    outline: 2px solid #0D8ABC;
    outline-offset: -2px;
}

.bp-dropdown-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.7;
}

/* Logout item — destructive red */
.bp-dropdown-item.bp-logout {
    color: #dc2626;
}

.bp-dropdown-item.bp-logout:hover,
.bp-dropdown-item.bp-logout:focus-visible {
    background-color: #fef2f2;
    color: #dc2626;
}

.bp-dropdown-item.bp-logout svg {
    opacity: 1;
}

/* ==========================================================================
   Divider
   ========================================================================== */

.bp-dropdown-divider {
    height: 1px;
    margin: 4px -4px;
    background-color: #e5e5e5;
}

/* ==========================================================================
   Role Badge
   ========================================================================== */

.bp-role-display {
    cursor: default;
    padding: 6px 8px;
}

.bp-role-display:hover {
    background: transparent;
}

.bp-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

/* Admin — purple */
.bp-badge-administrator {
    background-color: #7c3aed;
    color: #fff;
}

/* Creator/Editor — blue */
.bp-badge-editor {
    background-color: #0D8ABC;
    color: #fff;
}

/* Viewer/Subscriber — gray */
.bp-badge-subscriber {
    background-color: #e5e5e5;
    color: #525252;
}

/* Fallback for other roles */
.bp-badge-default {
    background-color: #e5e5e5;
    color: #525252;
}

/* Local account — orange/amber */
.bp-badge-local {
    background-color: #f59e0b;
    color: #fff;
}

/* ==========================================================================
   Dark Mode
   Supports Blocksy [data-theme="dark"] and prefers-color-scheme
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .bp-avatar-skeleton {
        background-color: #333;
    }

    :root:not([data-theme="light"]) .bp-login-button:hover,
    :root:not([data-theme="light"]) .bp-login-button:focus-visible {
        background-color: rgba(255, 255, 255, 0.1);
    }

    :root:not([data-theme="light"]) .bp-user-dropdown {
        background-color: #1c1c1c;
        border-color: #333;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    }

    :root:not([data-theme="light"]) .bp-user-name {
        color: #f5f5f5;
    }

    :root:not([data-theme="light"]) .bp-user-email {
        color: #a3a3a3;
    }

    :root:not([data-theme="light"]) .bp-dropdown-item {
        color: #f5f5f5;
    }

    :root:not([data-theme="light"]) .bp-dropdown-item:hover,
    :root:not([data-theme="light"]) .bp-dropdown-item:focus-visible {
        background-color: #2a2a2a;
        color: #f5f5f5;
    }

    :root:not([data-theme="light"]) .bp-dropdown-item.bp-logout:hover,
    :root:not([data-theme="light"]) .bp-dropdown-item.bp-logout:focus-visible {
        background-color: #2a1515;
    }

    :root:not([data-theme="light"]) .bp-dropdown-divider {
        background-color: #333;
    }

    :root:not([data-theme="light"]) .bp-header-divider {
        border-top-color: #333;
    }

    :root:not([data-theme="light"]) .bp-badge-subscriber,
    :root:not([data-theme="light"]) .bp-badge-default {
        background-color: #333;
        color: #a3a3a3;
    }
}

/* Blocksy explicit dark mode */
[data-theme="dark"] .bp-avatar-skeleton {
    background-color: #333;
}

[data-theme="dark"] .bp-login-button:hover,
[data-theme="dark"] .bp-login-button:focus-visible {
    background-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .bp-user-dropdown {
    background-color: #1c1c1c;
    border-color: #333;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .bp-user-name {
    color: #f5f5f5;
}

[data-theme="dark"] .bp-user-email {
    color: #a3a3a3;
}

[data-theme="dark"] .bp-dropdown-item {
    color: #f5f5f5;
}

[data-theme="dark"] .bp-dropdown-item:hover,
[data-theme="dark"] .bp-dropdown-item:focus-visible {
    background-color: #2a2a2a;
    color: #f5f5f5;
}

[data-theme="dark"] .bp-dropdown-item.bp-logout:hover,
[data-theme="dark"] .bp-dropdown-item.bp-logout:focus-visible {
    background-color: #2a1515;
}

[data-theme="dark"] .bp-dropdown-divider {
    background-color: #333;
}

[data-theme="dark"] .bp-header-divider {
    border-top-color: #333;
}

[data-theme="dark"] .bp-badge-subscriber,
[data-theme="dark"] .bp-badge-default {
    background-color: #333;
    color: #a3a3a3;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .bp-user-dropdown {
        position: fixed;
        top: auto;
        right: 8px;
        left: 8px;
        bottom: 8px;
        width: auto;
        max-width: 400px;
        margin: 0 auto;
    }

    .bp-user-dropdown[aria-hidden="false"] {
        transform: translateY(0);
    }
}
