/**
 * BSEC Account Widget Styles
 * Sleek, responsive header account widget with circular icon/avatar and floating dropdown.
 */

.bsec-account-widget {
    position: relative;
    display: inline-flex;
    box-sizing: border-box;
    vertical-align: middle;
    z-index: 99;
}

.bsec-account-widget.is-active {
    z-index: 99999;
}

/* --- Trigger Button --- */
.bsec-account-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    padding: 2px;
    margin: 0;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    font-family: inherit;
    line-height: 1;
    user-select: none;
    transition: opacity 0.18s ease;
}

.bsec-account-trigger:focus-visible {
    outline: 2px solid #1C352D;
    outline-offset: 3px;
    border-radius: 8px;
}

/* Stacked Layout: Icon Top, Text 1-Line Below (Both Logged-Out and Logged-In) */
.bsec-layout-stacked .bsec-account-trigger,
.bsec-layout-stacked .bsec-account-trigger-logged-in,
.bsec-layout-stacked .bsec-account-trigger-logged-out {
    display: inline-flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    gap: 4px !important;
}

.bsec-layout-stacked .bsec-account-label,
.bsec-layout-stacked .bsec-account-greeting-stacked {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    gap: 3px !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
}

.bsec-layout-stacked .bsec-account-greeting-prefix {
    display: inline !important;
    text-align: center !important;
    white-space: nowrap !important;
    line-height: 1.2 !important;
}

.bsec-layout-stacked .bsec-account-greeting-name-wrap {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    gap: 3px !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
}

/* Inline Layout: Icon Left, Text 2-Rows Right (Greeting on top row, Name on bottom row) */
.bsec-layout-inline .bsec-account-trigger,
.bsec-layout-inline .bsec-account-trigger-logged-in,
.bsec-layout-inline .bsec-account-trigger-logged-out {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    text-align: left !important;
    gap: 8px !important;
}

.bsec-layout-inline .bsec-account-label {
    display: inline-flex !important;
    align-items: flex-start !important;
    text-align: left !important;
}

.bsec-layout-inline .bsec-account-greeting-stacked {
    display: inline-flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: center !important;
    text-align: left !important;
    gap: 1px !important;
    line-height: 1.15 !important;
}

.bsec-layout-inline .bsec-account-greeting-prefix {
    display: block !important;
    font-size: calc(var(--bsec-aw-text-size, 12px) * 0.9) !important;
    line-height: 1.15 !important;
    opacity: 0.85 !important;
    text-align: left !important;
    white-space: nowrap !important;
}

.bsec-layout-inline .bsec-account-greeting-name-wrap {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    text-align: left !important;
    gap: 3px !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
}

/* --- Circular Icon Badge --- */
.bsec-account-badge {
    position: relative;
    width: var(--bsec-aw-size, 38px) !important;
    height: var(--bsec-aw-size, 38px) !important;
    min-width: var(--bsec-aw-size, 38px) !important;
    min-height: var(--bsec-aw-size, 38px) !important;
    border-radius: 50% !important;
    background-color: var(--bsec-aw-bg, rgba(28, 53, 45, 0.08)) !important;
    color: var(--bsec-aw-icon, #1C352D) !important;
    border: 1px solid rgba(28, 53, 45, 0.08);
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(28, 53, 45, 0.06);
    transition: background-color 0.2s ease, border-color 0.2s ease;
    flex-shrink: 0 !important;
}

/* Subtle background tint for logged-out badge only (no movement/jumping) */
.bsec-account-trigger-logged-out:hover .bsec-account-badge {
    filter: brightness(0.96);
    border-color: rgba(28, 53, 45, 0.14);
}

.bsec-account-user-icon {
    width: calc(var(--bsec-aw-size, 38px) * 0.48) !important;
    height: calc(var(--bsec-aw-size, 38px) * 0.48) !important;
    min-width: 14px;
    min-height: 14px;
    max-width: 24px;
    max-height: 24px;
    stroke: var(--bsec-aw-icon, currentColor) !important;
    color: var(--bsec-aw-icon, currentColor) !important;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    display: block;
}

/* Avatar Image & Badge (Logged In) - Zero Hover Effects */
.bsec-account-badge-avatar,
.bsec-account-trigger:hover .bsec-account-badge-avatar,
.bsec-account-trigger:active .bsec-account-badge-avatar,
.bsec-account-trigger:focus .bsec-account-badge-avatar {
    transform: none !important;
    transition: none !important;
    box-shadow: 0 0 0 1.5px #1C352D, 0 2px 6px rgba(0, 0, 0, 0.08) !important;
}

.bsec-account-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
    transform: none !important;
    transition: none !important;
}

.bsec-account-initial {
    font-size: 15px;
    font-weight: 700;
    color: var(--bsec-aw-icon, #1C352D);
    text-transform: uppercase;
    line-height: 1;
}

/* --- Label & Greeting --- */
.bsec-account-label {
    font-size: var(--bsec-aw-text-size, 12px);
    font-weight: var(--bsec-aw-text-weight, 500);
    color: var(--bsec-aw-text-color, #1C352D);
    white-space: nowrap;
    line-height: 1.2;
    transition: color 0.15s ease;
}

.bsec-account-trigger:hover .bsec-account-label {
    color: var(--bsec-aw-text-color, #12221D);
}

.bsec-account-trigger-logged-in {
    display: inline-flex;
    align-items: center;
}

.bsec-account-caret {
    display: inline-block;
    color: var(--bsec-aw-text-color, #64748b);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
}

.bsec-account-widget.is-active .bsec-account-caret {
    transform: rotate(180deg);
    color: var(--bsec-aw-text-color, #1C352D);
}

/* Greeting Label Wrap */
.bsec-account-greeting-stacked {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    line-height: 1.15;
    gap: 3px;
    white-space: nowrap;
}

.bsec-account-greeting-prefix {
    font-size: var(--bsec-aw-text-size, 12px);
    font-weight: var(--bsec-aw-text-weight, 500);
    color: var(--bsec-aw-prefix-color, #64748B);
    letter-spacing: 0.01em;
    display: inline;
    white-space: nowrap;
}

.bsec-account-greeting-name-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 3px;
    color: var(--bsec-aw-text-color, #1C352D);
    font-size: var(--bsec-aw-text-size, 12px);
    font-weight: var(--bsec-aw-text-weight, 600);
    white-space: nowrap;
}

.bsec-account-greeting-name {
    max-width: 125px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
}

.bsec-account-trigger:hover .bsec-account-greeting-name-wrap {
    color: var(--bsec-aw-text-color, #12221D);
}

/* --- Floating Dropdown Menu Card --- */
.bsec-account-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 220px;
    background-color: #FFFFFF;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 12px 30px -4px rgba(15, 23, 42, 0.12), 0 4px 6px -2px rgba(15, 23, 42, 0.04);
    z-index: 100000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-5px);
    transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1), transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.18s;
    pointer-events: none;
    box-sizing: border-box;
    text-align: left;
    overflow: hidden;
}

/* Dropdown Open State */
.bsec-account-widget.is-active .bsec-account-dropdown {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
    pointer-events: auto !important;
}

/* Dropdown Body & Items */
.bsec-account-dropdown-body {
    padding: 6px;
}

.bsec-account-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    text-decoration: none !important;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.bsec-account-dropdown-item svg {
    color: #64748b;
    transition: color 0.15s ease;
    flex-shrink: 0;
}

.bsec-account-dropdown-item:hover {
    background-color: #f1f5f9;
    color: #1C352D;
}

.bsec-account-dropdown-item:hover svg {
    color: #1C352D;
}

.bsec-account-dropdown-item.bsec-item-logout {
    color: #dc2626;
}

.bsec-account-dropdown-item.bsec-item-logout svg {
    color: #dc2626;
}

.bsec-account-dropdown-item.bsec-item-logout:hover {
    background-color: #fef2f2;
    color: #b91c1c;
}

.bsec-account-dropdown-divider {
    height: 1px;
    background-color: #f1f5f9;
    margin: 4px 6px;
}

/* Mobile & Touch Adjustments */
@media (max-width: 540px) {
    .bsec-account-dropdown {
        right: -10px;
        width: 240px;
    }

    .bsec-account-greeting-text {
        max-width: 65px;
    }
}

/* Ensure Bricks header containers hosting the widget do not clip the floating dropdown */
.brxe-container:has(.bsec-account-widget.is-active),
.brxe-block:has(.bsec-account-widget.is-active),
.brxe-section:has(.bsec-account-widget.is-active),
header:has(.bsec-account-widget.is-active) {
    overflow: visible !important;
}

