/* TradiusPro Journal Account Switcher Menu */
.tp-user-menu {
    --tp-surface: #152035;
    --tp-text: #e7edf7;
    --tp-muted: #9baac0;
    --tp-border: #33435c;
    --tp-hover: #22334e;
    --tp-field: #101a2d;
    color: var(--tp-text);
    background: var(--tp-surface);
    border: 1px solid var(--tp-border);
    font-family: Inter, system-ui, sans-serif;
    box-sizing: border-box;
}

[data-site-theme="light"] .tp-user-menu {
    --tp-surface: #fff;
    --tp-text: #1e293b;
    --tp-muted: #64748b;
    --tp-border: #dbe3ee;
    --tp-hover: #eff5ff;
    --tp-field: #f8fafc;
}

#journal-account-switcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#journal-account-switcher[hidden] {
    display: none !important;
}

.tp-account-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    padding: 0.25rem;
    font-size: 1.25rem;
    color: #94a3b8;
    cursor: pointer;
    border-radius: 0.375rem;
    transition: color 0.15s ease, transform 0.15s ease;
    line-height: 1;
}

.tp-account-trigger:hover,
.tp-account-trigger[aria-expanded="true"] {
    color: #60a5fa;
}

.tp-account-trigger:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: 2px;
}

#journal-account-dropdown.tp-user-menu {
    position: fixed;
    z-index: 10000;
    min-width: 280px;
    max-width: min(340px, calc(100vw - 24px));
    padding: 7px;
    border-radius: 14px;
    box-shadow: 0 16px 44px rgba(2, 6, 23, 0.35);
    overflow: auto;
    opacity: 0;
    transform: translateY(-5px);
    transition: opacity .15s ease, transform .15s ease;
    visibility: visible;
}

#journal-account-dropdown.tp-user-menu[hidden] {
    display: none;
}

#journal-account-dropdown.tp-user-menu.is-open {
    opacity: 1;
    transform: translateY(0);
}

.tp-account-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tp-account-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 38px;
    padding: 9px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--tp-text);
    font: 500 14px/1.4 Inter, system-ui, sans-serif;
    text-align: left;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
    box-sizing: border-box;
}

.tp-account-item:hover {
    background: var(--tp-hover);
}

.tp-account-item.is-active {
    background: rgba(96, 165, 250, 0.12);
    color: #60a5fa;
    font-weight: 600;
}

.tp-account-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tp-account-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(96, 165, 250, 0.2);
    color: #60a5fa;
    margin-left: 8px;
    flex-shrink: 0;
}

.tp-account-manage {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 38px;
    padding: 8px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--tp-muted);
    font: 500 13px/1.4 Inter, system-ui, sans-serif;
    text-decoration: none;
    text-align: left;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.tp-account-manage:hover {
    background: var(--tp-hover);
    color: var(--tp-text);
}

.tp-menu-divider {
    height: 1px;
    background: var(--tp-border, #33435c);
    margin: 6px 8px;
}

.tp-menu-status {
    font-size: 12px;
    color: #ef7070;
    padding: 0 10px;
    margin: 4px 0 0;
}

.tp-menu-status:empty {
    display: none;
}

/* Mobile Navigation Menu Switch Account Item */
.tp-nav-account-btn {
    display: none;
}

@media (max-width: 640px) {
    /* Hide the standalone switcher on mobile to prevent overlapping with TradiusPro logo */
    #journal-account-switcher {
        display: none !important;
    }

    #user-info-box .flex-col:has(#journal-account-switcher) {
        display: none !important;
    }

    /* Show Switch account button in user avatar menu on mobile */
    .tp-nav-account-btn {
        display: flex !important;
    }
}

/* Trading Account Pop-up Modal Dialog */
.tp-account-dialog {
    width: min(420px, calc(100vw - 32px));
    max-height: calc(100dvh - 48px);
    margin: auto;
    padding: 22px;
    border-radius: 18px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.65);
    overflow: hidden;
    box-sizing: border-box;
}

.tp-account-dialog::backdrop {
    background: rgba(2, 6, 23, 0.75);
    backdrop-filter: blur(4px);
}

.tp-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
}

.tp-dialog-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 650;
    color: var(--tp-text);
}

.tp-dialog-close {
    border: 0;
    background: transparent;
    color: var(--tp-muted);
    font-size: 24px !important;
    line-height: 1 !important;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: color 0.15s ease;
}

.tp-dialog-close:hover {
    color: var(--tp-text);
}

.tp-dialog-accounts {
    max-height: 320px;
    overflow-y: auto;
    margin: 12px 0;
    padding-right: 4px;
}

.tp-dialog-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--tp-border);
}

.tp-dialog-cancel-btn {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--tp-border);
    background: transparent;
    color: var(--tp-text);
    font: 500 13px/1.4 Inter, system-ui, sans-serif;
    cursor: pointer;
    transition: background 0.15s ease;
}

.tp-dialog-cancel-btn:hover {
    background: var(--tp-hover);
}
