:root {
    --zsp-header-height: 72px;
    --zsp-header-text: #111827;
    --zsp-header-text-muted: #475467;
    --zsp-header-border: #d8e0ea;
    --zsp-header-surface: #ffffff;
    --zsp-header-surface-hover: #f8fafc;
    --zsp-header-active-bg: #eef2f7;
    --zsp-header-shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --zsp-header-shadow-md: 0 12px 28px rgba(15, 23, 42, .14);
}

body.zsp-has-plugin-header {
    --zsp-adminbar-offset: 0px;
    --zsp-header-offset-total: calc(var(--zsp-header-height) + var(--zsp-adminbar-offset));
    padding-top: var(--zsp-header-offset-total);
}

body.admin-bar.zsp-has-plugin-header {
    --zsp-adminbar-offset: 32px;
}

@media (max-width: 782px) {
    body.admin-bar.zsp-has-plugin-header {
        --zsp-adminbar-offset: 46px;
    }
}

.zsp-header {
    position: fixed;
    top: var(--zsp-adminbar-offset, 0px);
    left: 0;
    right: 0;
    z-index: 99998;
    height: var(--zsp-header-height);
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid #dbe5f4;
    backdrop-filter: blur(10px);
    display: block !important;
    box-sizing: border-box !important;
}

.zsp-header__inner {
    max-width: 1320px;
    height: 100%;
    margin: 0 auto;
    padding: 0 22px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-sizing: border-box !important;
    visibility: visible !important;
    opacity: 1 !important;
    justify-content: flex-end;
}

.zsp-header__brand {
    text-decoration: none;
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    flex-shrink: 0;
    visibility: visible !important;
    opacity: 1 !important;
}

.zsp-header__brand-main {
    color: #071022;
    font-weight: 800;
    font-size: 22px;
    letter-spacing: -0.02em;
}

.zsp-header__brand-sub {
    color: #0d63f3;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.zsp-header__menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    margin-left: 0;
    border: 1px solid #d7e3f5;
    background: #fff;
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
}

.zsp-header__menu-toggle span {
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: #1b2a44;
    display: block;
}

.zsp-header__menu-toggle .screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.zsp-header__nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    visibility: visible !important;
    opacity: 1 !important;
}

.zsp-header__nav-link {
    color: var(--zsp-header-text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    padding: 11px 13px;
    border-radius: 10px;
    transition: color 0.18s ease, background-color 0.18s ease;
    display: inline-flex !important;
    align-items: center !important;
    box-sizing: border-box !important;
    opacity: 1 !important;
}

.zsp-header__nav-link:hover {
    color: var(--zsp-header-text);
    background: #f6f8fb;
}

.zsp-header__nav-link.is-active {
    color: var(--zsp-header-text);
    background: var(--zsp-header-active-bg);
}

.zsp-header__actions {
    margin-left: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    visibility: visible !important;
    opacity: 1 !important;
}

.zsp-header__btn {
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    border-radius: 10px;
    padding: 10px 14px;
    line-height: 1;
    transition: all 0.18s ease;
}

.zsp-header__btn--ghost {
    color: #334a68;
    border: 1px solid #d2e0f4;
    background: #fff;
}

.zsp-header__btn--ghost:hover {
    border-color: #0d63f3;
    color: #0d63f3;
}

.zsp-header__btn--solid {
    color: #fff;
    border: 1px solid #0d63f3;
    background: linear-gradient(135deg, #0d63f3 0%, #1a8eff 100%);
}

.zsp-header__btn--solid:hover {
    box-shadow: 0 8px 18px rgba(13, 99, 243, 0.25);
}

.zsp-header__user {
    position: relative;
}

.zsp-header__user-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--zsp-header-border);
    background: var(--zsp-header-surface);
    box-shadow: var(--zsp-header-shadow-sm);
    border-radius: 999px;
    padding: 6px 10px 6px 6px;
    cursor: pointer;
    display: inline-flex !important;
    box-sizing: border-box !important;
    visibility: visible !important;
    opacity: 1 !important;
    transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

/* High-specificity guard to neutralize any stale/third-party gradient overrides */
.zsp-header .zsp-header__actions .zsp-header__user .zsp-header__user-toggle {
    background: var(--zsp-header-surface) !important;
    border: 1px solid var(--zsp-header-border) !important;
    box-shadow: var(--zsp-header-shadow-sm) !important;
}

.zsp-header__user-toggle:hover {
    background: var(--zsp-header-surface-hover);
    border-color: #cbd5e1;
}

.zsp-header__user-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, .22), var(--zsp-header-shadow-sm);
}

.zsp-header__avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #e5e7eb;
}

.zsp-header__user-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--zsp-header-text);
}

.zsp-header__dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    min-width: 140px;
    background: var(--zsp-header-surface);
    border: 1px solid var(--zsp-header-border);
    border-radius: 12px;
    box-shadow: var(--zsp-header-shadow-md);
    overflow: hidden;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: all 0.16s ease;
}

.zsp-header__user.is-open .zsp-header__dropdown {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.zsp-header__dropdown-item {
    display: block;
    width: 100%;
    padding: 11px 12px;
    text-decoration: none;
    color: var(--zsp-header-text);
    font-size: 13px;
    font-weight: 600;
}

.zsp-header__dropdown-item:hover {
    background: #f8fafc;
    color: var(--zsp-header-text);
}

.zsp-header__backdrop {
    display: none;
}

/* Align existing plugin page wrappers to the unified header offset */
.zsp-has-plugin-header .dashboard-wrapper {
    margin-top: 0 !important;
    min-height: calc(100vh - var(--zsp-header-offset-total));
}

.zsp-has-plugin-header .zsp-inbox-wrapper,
.zsp-has-plugin-header .agency-inbox-wrapper {
    height: calc(100vh - var(--zsp-header-offset-total));
}

/* Inbox pages use their own viewport layout rules. Use explicit offsets to
   avoid admin-bar inheritance glitches that cause top white gaps/cut composer. */
body.zsp-has-plugin-header.zsp-inbox-page,
body.zsp-has-plugin-header.zsp-agency-inbox-page,
body.zsp-has-plugin-header.zsp-plugin-page-inbox {
    padding-top: 0 !important;
}

body.zsp-has-plugin-header.zsp-inbox-page .zsp-inbox-wrapper,
body.zsp-has-plugin-header.zsp-agency-inbox-page .agency-inbox-wrapper,
body.zsp-has-plugin-header.zsp-plugin-page-inbox .agency-inbox-wrapper,
body.zsp-has-plugin-header.zsp-plugin-page-inbox .zsp-inbox-wrapper {
    margin-top: var(--zsp-header-runtime-offset, var(--zsp-header-offset-total)) !important;
    height: calc(100dvh - var(--zsp-header-runtime-offset, var(--zsp-header-offset-total))) !important;
    min-height: calc(100dvh - var(--zsp-header-runtime-offset, var(--zsp-header-offset-total))) !important;
}

body.admin-bar.zsp-has-plugin-header.zsp-inbox-page .zsp-inbox-wrapper,
body.admin-bar.zsp-has-plugin-header.zsp-agency-inbox-page .agency-inbox-wrapper {
    margin-top: var(--zsp-header-runtime-offset, var(--zsp-header-offset-total)) !important;
    height: calc(100dvh - var(--zsp-header-runtime-offset, var(--zsp-header-offset-total))) !important;
    min-height: calc(100dvh - var(--zsp-header-runtime-offset, var(--zsp-header-offset-total))) !important;
}

@media (max-width: 782px) {
    body.admin-bar.zsp-has-plugin-header.zsp-inbox-page .zsp-inbox-wrapper,
    body.admin-bar.zsp-has-plugin-header.zsp-agency-inbox-page .agency-inbox-wrapper {
        margin-top: var(--zsp-header-runtime-offset, var(--zsp-header-offset-total)) !important;
        height: calc(100dvh - var(--zsp-header-runtime-offset, var(--zsp-header-offset-total))) !important;
        min-height: calc(100dvh - var(--zsp-header-runtime-offset, var(--zsp-header-offset-total))) !important;
    }
}

.zsp-has-plugin-header.seomp-order-page-body {
    padding-top: var(--zsp-header-offset-total) !important;
}

@media (max-width: 980px) {
    .zsp-header__menu-toggle {
        display: inline-flex;
        margin-left: auto;
    }

    .zsp-header__nav {
        position: fixed;
        top: calc(var(--zsp-header-offset-total));
        left: 12px;
        right: 12px;
        border-radius: 14px;
        border: 1px solid #d7e3f5;
        background: #fff;
        box-shadow: 0 18px 36px rgba(9, 26, 52, 0.2);
        padding: 10px;
        display: none;
        flex-direction: column;
        align-items: stretch;
        margin-left: 0;
        z-index: 99999;
    }

    .zsp-header.is-menu-open .zsp-header__nav {
        display: flex;
    }

    .zsp-header__nav-link {
        border-radius: 10px;
        padding: 12px;
    }

    .zsp-header__backdrop {
        position: fixed;
        inset: calc(var(--zsp-header-offset-total)) 0 0 0;
        background: rgba(8, 18, 36, 0.38);
        z-index: 99997;
        display: none;
    }

    .zsp-header.is-menu-open .zsp-header__backdrop {
        display: block;
    }

    .zsp-header__actions {
        margin-left: 10px;
    }

    .zsp-header__user-name {
        display: none;
    }
}

@media (max-width: 640px) {
    .zsp-header__inner {
        padding: 0 12px;
    }

    .zsp-header__brand-main {
        font-size: 19px;
    }

    .zsp-header__brand-sub {
        font-size: 12px;
    }

    .zsp-header__btn {
        padding: 9px 11px;
    }
}
