/**
 * Reduce flash of wrong placeholder avatar / notification counts on refresh.
 * Requires: early <script> in <head> that adds .kwick-logged-in when kwick_token exists,
 * and api-client.js adding .kwick-header-ui-ready / .kwick-notifications-ready.
 */

html.kwick-logged-in .header-profile-user,
html.kwick-logged-in #page-header-user-dropdown .user-name-text {
    opacity: 0;
    transition: opacity 0.15s ease;
}

html.kwick-logged-in.kwick-header-ui-ready .header-profile-user,
html.kwick-logged-in.kwick-header-ui-ready #page-header-user-dropdown .user-name-text {
    opacity: 1;
}

html.kwick-logged-in #page-header-notifications-dropdown .topbar-badge,
html.kwick-logged-in #page-header-notifications-dropdown > .badge {
    visibility: hidden !important;
}

html.kwick-logged-in.kwick-notifications-ready #page-header-notifications-dropdown .topbar-badge:not(.d-none),
html.kwick-logged-in.kwick-notifications-ready #page-header-notifications-dropdown > .badge:not(.d-none) {
    visibility: visible !important;
}

html.kwick-logged-in #notificationDropdown .dropdown-head .dropdown-tabs .badge {
    visibility: hidden !important;
}

html.kwick-logged-in.kwick-notifications-ready #notificationDropdown .dropdown-head .dropdown-tabs .badge:not(.d-none) {
    visibility: visible !important;
}

/**
 * Hide main page body until API-driven content is applied (no dummy template flash).
 * Set on <html>: data-kwick-async-main="1" and call KwickApi.releaseAsyncPageContent() when ready.
 */
html.kwick-logged-in.kwick-page-await-data:not(.kwick-page-data-ready) .main-content .page-content > .container-fluid {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

html.kwick-logged-in.kwick-page-data-ready .main-content .page-content > .container-fluid,
html.kwick-logged-in:not(.kwick-page-await-data) .main-content .page-content > .container-fluid,
html:not(.kwick-logged-in) .main-content .page-content > .container-fluid {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.18s ease;
}

/* Remove top-right quick action icons globally (portal grid, fullscreen, dark mode). */
#page-topbar .topbar-head-dropdown.header-item:not(#notificationDropdown) {
    display: none !important;
}

#page-topbar .header-item.d-none.d-sm-flex {
    display: none !important;
}
