/*
 * SEOPress admin header — React rewrite.
 *
 * Replaces the legacy markup formerly echoed by seopress_admin_header().
 * Mounted on every SEOPress admin page by ModuleAdminHeader.
 *
 * Selectors are anchored on `#seopress-admin-header-root` so the higher
 * ID specificity beats the legacy `.seopress-styles *` cascade without
 * resorting to `!important`.
 *
 * Tokens are shared with the dashboard stylesheet (see dashboard.css
 * `:root` block). When the header is loaded outside the dashboard page,
 * these tokens fall back to the values defined inline below.
 */

#seopress-admin-header-root {
    --seopress-header-color-text: #1d2327;
    --seopress-header-color-text-muted: #595d62; /* AAA against #fff */
    --seopress-header-color-border: #dcdcde;
    --seopress-header-color-soft: rgba(var(--wp-admin-theme-color--rgb), 0.08);
    --seopress-header-space-1: 4px;
    --seopress-header-space-2: 8px;
    --seopress-header-space-3: 12px;
    --seopress-header-space-4: 16px;
    --seopress-header-space-5: 24px;
    --seopress-header-radius: 4px;
    --seopress-header-transition: 0.15s ease-in-out;

    background: #fff;
    border-bottom: 1px solid var(--seopress-header-color-border);
}

/* ---------- Top banner promotion ---------- */

.seopress-promo-banner {
    display: flex;
    align-items: center;
    gap: var(--seopress-header-space-3);
    padding: 10px var(--seopress-header-space-5);
    font-size: 13px;
    line-height: 1.4;
    background: var(--wp-admin-theme-color);
    color: #fff;
}

.seopress-promo-banner__content {
    display: flex;
    align-items: center;
    gap: var(--seopress-header-space-2);
    flex: 1 1 auto;
    flex-wrap: wrap;
}

.seopress-promo-banner__icon.dashicons {
    width: 18px;
    height: 18px;
    font-size: 18px;
    color: inherit;
}

.seopress-promo-banner__title {
    font-weight: 600;
}

.seopress-promo-banner__body {
    opacity: 0.95;
}

.seopress-promo-banner__cta {
    display: inline-block;
    padding: 6px 14px;
    border-radius: var(--seopress-header-radius);
    font-weight: 600;
    text-decoration: none;
    transition: opacity var(--seopress-header-transition);
}

/* Banner button style variants, data-driven so React only ships values. */
.seopress-promo-banner__cta[data-button-style="primary"],
.seopress-promo-banner__cta:not([data-button-style]) {
    background: #fff;
    color: var(--wp-admin-theme-color);
    border: 0;
}

.seopress-promo-banner__cta[data-button-style="secondary"] {
    background: transparent;
    color: #fff;
    border: 2px solid #fff;
}

.seopress-promo-banner__cta[data-button-style="link"] {
    background: transparent;
    color: #fff;
    border: 0;
    padding: 6px 0;
    text-decoration: underline;
}

.seopress-promo-banner__cta:hover,
.seopress-promo-banner__cta:focus-visible {
    opacity: 0.92;
}

.seopress-promo-banner__dismiss.components-button.has-icon {
    flex: 0 0 auto;
    color: #fff;
}

.seopress-promo-banner__dismiss.components-button.has-icon:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* ---------- Header bar ---------- */

.seopress-admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--seopress-header-space-4);
    min-height: 68px;
    padding: 14px var(--seopress-header-space-5);
    box-sizing: border-box;
}

/* ---------- Breadcrumb ---------- */

.seopress-admin-header__breadcrumb ol {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: var(--seopress-header-space-2);
    flex-wrap: wrap;
}

.seopress-admin-header__breadcrumb li {
    color: var(--seopress-header-color-text-muted);
    font-size: 13px;
    line-height: 1.4;
}

.seopress-admin-header__breadcrumb li[aria-current="page"] {
    color: var(--seopress-header-color-text);
    font-weight: 600;
}

/* `aria-hidden="true"` is not needed here: CSS-generated content via
   `::before` is universally ignored by modern screen readers (Safari/Chrome
   VoiceOver, JAWS, NVDA). #8c8f94 = 4.6:1 on #fff (WCAG AA, AAA needs 7:1). */
.seopress-admin-header__breadcrumb li + li::before {
    content: "/";
    margin-right: var(--seopress-header-space-2);
    color: #8c8f94;
}

.seopress-admin-header__breadcrumb a {
    color: var(--wp-admin-theme-color);
    text-decoration: none;
    font-weight: 600;
}

.seopress-admin-header__breadcrumb a:hover,
.seopress-admin-header__breadcrumb a:focus-visible {
    text-decoration: underline;
}

/* ---------- Activity panel triggers ---------- */

.seopress-admin-header__actions {
    display: flex;
    align-items: center;
    gap: var(--seopress-header-space-1);
    flex: 0 0 auto;
}

#seopress-admin-header-root .seopress-admin-header__action.components-button.has-icon {
    min-width: 36px;
    height: 36px;
    padding: 6px;
    color: var(--seopress-header-color-text);
    background: transparent;
    border: 0;
    border-radius: var(--seopress-header-radius);
    cursor: pointer;
}

#seopress-admin-header-root .seopress-admin-header__action.components-button.has-icon:hover {
    background: var(--seopress-header-color-soft);
    color: var(--wp-admin-theme-color);
}

#seopress-admin-header-root .seopress-admin-header__action.is-active.components-button.has-icon {
    color: var(--wp-admin-theme-color);
    background: var(--seopress-header-color-soft);
}

/* ---------- Notifications badge ---------- */

.seopress-admin-header__action--notifications.components-button {
    position: relative;
    overflow: visible;
}

.seopress-admin-header__badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    box-sizing: border-box;
    border-radius: 999px;
    background: var(--colorAlert, #eb0f00);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    line-height: 16px;
    text-align: center;
    pointer-events: none;
    z-index: 1;
}

/* ---------- Slide-in activity panel ---------- */

.seopress-admin-header-panel {
    position: fixed;
    top: var(--seopress-panel-top, 32px);
    right: 0;
    bottom: 0;
    width: 380px;
    max-width: 100vw;
    background: #fff;
    border-left: 1px solid var(--seopress-header-color-border);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.06);
    transform: translateX(100%);
    transition: transform 0.2s ease;
    z-index: 100050;
    display: flex;
    flex-direction: column;
    pointer-events: none;
}

.seopress-admin-header-panel.is-open {
    transform: translateX(0);
    pointer-events: auto;
}

.seopress-admin-header-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--seopress-header-space-3);
    padding: var(--seopress-header-space-4) var(--seopress-header-space-5);
    border-bottom: 1px solid var(--seopress-header-color-border);
}

.seopress-admin-header-panel__title {
    margin: 0;
    color: var(--seopress-header-color-text);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
}

.seopress-admin-header-panel__close.components-button.has-icon {
    color: var(--seopress-header-color-text-muted);
}

.seopress-admin-header-panel__body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: var(--seopress-header-space-4) var(--seopress-header-space-5);
    color: var(--seopress-header-color-text);
    font-size: 13px;
    line-height: 1.55;
}

.seopress-admin-header-panel__placeholder {
    margin: 0;
    color: var(--seopress-header-color-text-muted);
}

/* ---------- Help panel ---------- */

/* Row layout is handled by the native <Flex>; this only spaces the block. */
.seopress-admin-header-help__search {
    margin-bottom: var(--seopress-header-space-4);
}

.seopress-admin-header-help__section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--seopress-header-color-border);
}

.seopress-admin-header-help__section:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.seopress-admin-header-help__section h3 {
    margin: 0 0 var(--seopress-header-space-2) 0;
    color: var(--seopress-header-color-text);
    font-size: 13px;
    font-weight: 600;
}

.seopress-admin-header-help__section p {
    margin: 0 0 var(--seopress-header-space-3) 0;
    color: var(--seopress-header-color-text-muted);
    font-size: 12px;
    line-height: 1.55;
}

.seopress-admin-header-help__guides {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--seopress-header-space-2);
}

.seopress-admin-header-help__guides a {
    display: flex;
    align-items: center;
    gap: var(--seopress-header-space-3);
    padding: 10px;
    color: var(--seopress-header-color-text);
    text-decoration: none;
    border: 1px solid var(--seopress-header-color-border);
    border-radius: var(--seopress-header-radius);
}

.seopress-admin-header-help__guides a:hover,
.seopress-admin-header-help__guides a:focus-visible {
    border-color: var(--wp-admin-theme-color);
    box-shadow: 0 0 0 1px var(--wp-admin-theme-color);
}

.seopress-admin-header-help__guides img {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
}

.seopress-admin-header-help__guides strong {
    display: block;
    color: var(--seopress-header-color-text);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
}

.seopress-admin-header-help__guides small {
    display: block;
    color: var(--seopress-header-color-text-muted);
    font-size: 12px;
    line-height: 1.45;
    margin-top: 2px;
}

.seopress-admin-header-help__products {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--seopress-header-space-2);
}

/*
 * The <a> hugs its image instead of stretching to the column width —
 * otherwise the link click target (and the focus outline) extends past
 * the visible product card on the right.
 */
.seopress-admin-header-help__products a {
    display: inline-flex;
    line-height: 0;
    border-radius: var(--seopress-header-radius);
}

.seopress-admin-header-help__products img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ---------- Display panel ---------- */

.seopress-admin-header-display h3 {
    margin: 0 0 var(--seopress-header-space-3) 0;
    color: var(--seopress-header-color-text);
    font-size: 13px;
    font-weight: 600;
}

.seopress-admin-header-display__list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--seopress-header-space-3);
}

/* ---------- Notifications panel ---------- */

.seopress-admin-header-notifications__count {
    color: var(--seopress-header-color-text-muted);
    font-size: 12px;
    margin: 0 0 var(--seopress-header-space-3) 0;
}

.seopress-admin-header-notifications__list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--seopress-header-space-2);
}

.seopress-admin-header-notifications__list li {
    margin: 0;
}

/*
 * Notification cards are server-rendered by Notifications->renderNotification()
 * and injected via dangerouslySetInnerHTML. The severity dot
 * (.seopress-impact, position:absolute; top:0; left:0) only had a
 * positioning context + left gutter through the legacy
 * `#seopress-notifications-center .seopress-alert` rule, which doesn't
 * exist in the React panel — so the dot was pinning to the panel corner.
 * Re-establish the relative context and reserve the 24px dot's gutter,
 * scoped to the notifications panel so no other screen is affected.
 */
.seopress-admin-header-notifications .seopress-alert {
    position: relative;
    padding-left: 28px;
}

/* Compact the severity dot for the panel (legacy is 24px / 8px). */
.seopress-admin-header-notifications .seopress-alert .seopress-impact {
    width: 16px;
    height: 16px;
}

.seopress-admin-header-notifications .seopress-alert .seopress-impact::after {
    width: 6px;
    height: 6px;
    top: calc(50% - 3px);
    left: calc(50% - 3px);
}

/*
 * The action row (.seopress-alert-actions) only got its flex layout +
 * gap from the legacy `#seopress-notifications-center` scope, absent in
 * the React panel — so the CTA / Dismiss buttons were sitting flush
 * against each other. Re-establish it here.
 */
.seopress-admin-header-notifications .seopress-alert-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--seopress-header-space-3);
}

.seopress-admin-header-notifications__empty {
    text-align: center;
    padding: 32px var(--seopress-header-space-4);
}

.seopress-admin-header-notifications__empty h3 {
    margin: var(--seopress-header-space-3) 0 0 0;
    color: var(--seopress-header-color-text);
    font-size: 13px;
    font-weight: 600;
}

.seopress-admin-header-notifications__hidden {
    margin-top: var(--seopress-header-space-4);
    padding-top: var(--seopress-header-space-4);
    border-top: 1px solid var(--seopress-header-color-border);
}

.seopress-admin-header-notifications__hidden img {
    margin-right: var(--seopress-header-space-2);
    vertical-align: middle;
}

/*
 * The expanded hidden list sits straight under the toggle button
 * (the <ul> has margin:0), which glued the first card's title to it.
 * Add breathing room so it reads like the rest of the panel.
 */
.seopress-admin-header-notifications__hidden
    .seopress-admin-header-notifications__list {
    margin-top: var(--seopress-header-space-3);
}

/* ---------- Focus management ---------- */

/*
 * Buttons get the WP-standard inset box-shadow ring only; everything
 * else gets an offset outline. Never stack both on one element — a
 * rounded button with outline + box-shadow reads as a fuzzy halo
 * (the "blob" behind the open drawer was the focused trigger getting
 * both rings at once).
 */
/* Skip native form controls too — they get their own focus ring via the
   wp-components stylesheet (box-shadow on .components-text-control__input,
   etc.) and stacking the outline produces a visible double halo. */
#seopress-admin-header-root :focus-visible:not(.components-button):not(input):not(textarea):not(select),
.seopress-admin-header-panel :focus-visible:not(.components-button):not(input):not(textarea):not(select) {
    outline: 2px solid var(--wp-admin-theme-color, #2271b1);
    outline-offset: 2px;
}

#seopress-admin-header-root .components-button:focus-visible,
.seopress-admin-header-panel .components-button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--wp-admin-theme-color, #2271b1);
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    .seopress-admin-header-panel,
    .seopress-promo-banner__cta,
    #seopress-admin-header-root * {
        transition-duration: 0.001ms !important;
        animation-duration: 0.001ms !important;
    }
}

/* ---------- Responsive ---------- */

@media (max-width: 782px) {
    .seopress-admin-header-panel {
        --seopress-panel-top: 46px;
    }

    .seopress-admin-header {
        padding: var(--seopress-header-space-3) var(--seopress-header-space-4);
        min-height: 56px;
    }

    .seopress-promo-banner {
        padding: var(--seopress-header-space-2) var(--seopress-header-space-4);
        flex-wrap: wrap;
    }

    /* 44×44 tap targets on touch viewports (WCAG 2.5.5 / RGAA 13.x). */
    #seopress-admin-header-root .seopress-admin-header__action.components-button.has-icon {
        min-width: 44px;
        height: 44px;
    }
}

@media (max-width: 600px) {
    .seopress-admin-header-panel {
        width: 100vw;
    }

    .seopress-admin-header-panel__head,
    .seopress-admin-header-panel__body {
        padding-left: var(--seopress-header-space-4);
        padding-right: var(--seopress-header-space-4);
    }
}

@media (max-width: 480px) {
    .seopress-admin-header {
        gap: var(--seopress-header-space-2);
    }

    /* Keep the breadcrumb visible but compact: shrink the type and let the
       wrap rule on the <ol> handle multi-line gracefully. */
    .seopress-admin-header__breadcrumb {
        min-width: 0;
        flex: 1 1 auto;
    }

    .seopress-admin-header__breadcrumb li {
        font-size: 12px;
    }

    .seopress-admin-header__actions {
        flex-shrink: 0;
    }
}

