/*
 * Webpulse Consent Manager — banner + modal styling
 *
 * Class-prefixed (`webpulse-consent`) so it can sit alongside any theme
 * without selector collisions. Uses CSS custom properties so themes can
 * override the accent color without forking the file:
 *
 *   :root {
 *     --wpls-consent-accent: #1d4ed8;
 *     --wpls-consent-radius: 12px;
 *   }
 *
 * Z-index uses 2147483645 (just below the max int) so the banner sits
 * above Elementor popups, chat widgets, and most third-party overlays
 * without going to the absolute top (some assistive-tech overlays use
 * 2147483647 and we don't want to cover them).
 */

.webpulse-consent {
    --wpls-consent-accent: #0f766e;
    --wpls-consent-accent-fg: #ffffff;
    --wpls-consent-text: #111827;
    --wpls-consent-muted: #6b7280;
    --wpls-consent-bg: #ffffff;
    --wpls-consent-border: #e5e7eb;
    --wpls-consent-radius: 12px;
    --wpls-consent-shadow: 0 10px 40px rgba(15, 23, 42, 0.18);
    --wpls-consent-z: 2147483645;

    position: fixed;
    inset: 0;
    z-index: var(--wpls-consent-z);
    pointer-events: none;
    color: var(--wpls-consent-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.webpulse-consent[hidden] {
    display: none;
}

.webpulse-consent[data-state="banner"] .webpulse-consent__banner {
    transform: translateY(0);
}

.webpulse-consent[data-state="manage"] .webpulse-consent__banner {
    transform: translateY(100%);
}

.webpulse-consent[data-state="manage"] .webpulse-consent__modal {
    display: flex;
}

/* === Bottom banner === */
.webpulse-consent__banner {
    pointer-events: auto;
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: 1080px;
    margin: 0 auto;
    background: var(--wpls-consent-bg);
    border: 1px solid var(--wpls-consent-border);
    border-radius: var(--wpls-consent-radius);
    box-shadow: var(--wpls-consent-shadow);
    transform: translateY(120%);
    transition: transform 280ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.webpulse-consent__banner-inner {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 20px;
}

@media (min-width: 768px) {
    .webpulse-consent__banner-inner {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 24px;
        padding: 18px 24px;
    }
}

.webpulse-consent__banner-text {
    flex: 1 1 auto;
    min-width: 0;
}

.webpulse-consent__banner-title {
    display: block;
    margin-bottom: 4px;
    font-size: 15px;
    font-weight: 600;
    color: var(--wpls-consent-text);
}

.webpulse-consent__banner-body {
    margin: 0;
    color: var(--wpls-consent-muted);
    font-size: 13.5px;
}

.webpulse-consent__banner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0;
}

/* === Buttons ===
 * Parent-scoped (`.webpulse-consent .webpulse-consent__btn`) so specificity
 * is (0,2,0) — beats Tailwind preflight's `[type=button]` (0,1,0) regardless
 * of load order. The theme's compiled Tailwind CSS usually loads AFTER
 * plugin CSS, so a (0,1,0)-vs-(0,1,0) tie would let preflight win and our
 * Accept button would go transparent. Class-scoping wins cleanly.
 */
.webpulse-consent .webpulse-consent__btn {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px 18px;
    font: inherit;
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
    line-height: 1;
    text-transform: none;
    background-image: none;
}

.webpulse-consent .webpulse-consent__btn:focus-visible {
    outline: 2px solid var(--wpls-consent-accent);
    outline-offset: 2px;
}

.webpulse-consent .webpulse-consent__btn--primary {
    background-color: var(--wpls-consent-accent);
    color: var(--wpls-consent-accent-fg);
    border-color: var(--wpls-consent-accent);
}
.webpulse-consent .webpulse-consent__btn--primary:hover {
    filter: brightness(1.08);
}

.webpulse-consent .webpulse-consent__btn--ghost {
    background-color: transparent;
    color: var(--wpls-consent-text);
    border-color: var(--wpls-consent-border);
}
.webpulse-consent .webpulse-consent__btn--ghost:hover {
    background-color: #f3f4f6;
}

.webpulse-consent .webpulse-consent__btn--link {
    background-color: transparent;
    color: var(--wpls-consent-accent);
    border-color: transparent;
    padding: 10px 8px;
    text-decoration: underline;
}
.webpulse-consent .webpulse-consent__btn--link:hover {
    text-decoration: none;
}

.webpulse-consent__link {
    color: var(--wpls-consent-accent);
    text-decoration: underline;
}
.webpulse-consent__link:hover {
    text-decoration: none;
}

/* === Manage modal === */
.webpulse-consent__modal {
    pointer-events: auto;
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.webpulse-consent__modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.55);
}

.webpulse-consent__modal-card {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 32px);
    overflow: hidden;
    background: var(--wpls-consent-bg);
    border-radius: var(--wpls-consent-radius);
    box-shadow: var(--wpls-consent-shadow);
    display: flex;
    flex-direction: column;
}

.webpulse-consent__modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--wpls-consent-border);
}

.webpulse-consent__modal-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.webpulse-consent .webpulse-consent__modal-close {
    background-color: transparent;
    background-image: none;
    border: 0;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: var(--wpls-consent-muted);
    padding: 4px 8px;
    -webkit-appearance: none;
    appearance: none;
}
.webpulse-consent .webpulse-consent__modal-close:hover {
    color: var(--wpls-consent-text);
}

.webpulse-consent__modal-body {
    padding: 18px 20px;
    overflow-y: auto;
}

.webpulse-consent__modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--wpls-consent-border);
}

.webpulse-consent__intro {
    margin: 0 0 16px;
    color: var(--wpls-consent-muted);
    font-size: 13.5px;
}

.webpulse-consent__gpc-notice {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    color: #78350f;
    padding: 10px 12px;
    border-radius: 8px;
    margin: 0 0 16px;
    font-size: 13px;
}

/* === Categories list === */
.webpulse-consent__categories {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.webpulse-consent__category {
    background: #f9fafb;
    border: 1px solid var(--wpls-consent-border);
    border-radius: 10px;
}

.webpulse-consent__category-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    cursor: pointer;
}

.webpulse-consent__category-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.webpulse-consent__category-text strong {
    font-size: 14px;
}

.webpulse-consent__category-text span {
    color: var(--wpls-consent-muted);
    font-size: 12.5px;
}

.webpulse-consent__toggle {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--wpls-consent-accent);
    cursor: pointer;
}

.webpulse-consent__toggle:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* === Floating privacy tab ===
 * Persistent reopener for the preferences modal. Hidden by default
 * (`display: none`) and revealed by JS via the `is-visible` class once
 * `BOOT.ts > 0` or after the first user action.
 *
 * Selectors all use `button.webpulse-consent-tab` (specificity 0,1,1) to
 * beat Tailwind preflight's `[type=button] { background-color: transparent }`
 * (0,1,0). Without this bump, theme CSS loading after plugin CSS would
 * win the tie and the tab would render with no background — invisible
 * on light pages.
 */
button.webpulse-consent-tab {
    display: none;
    position: fixed;
    bottom: 16px;
    left: 16px;
    z-index: 2147483644;
    align-items: center;
    gap: 6px;
    padding: 10px;
    margin: 0;
    border: 0;
    border-radius: 999px;
    background-color: #0f766e;
    background-image: none;
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.25);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    text-transform: none;
    -webkit-appearance: none;
    appearance: none;
    transition: transform 180ms ease, box-shadow 180ms ease, padding-right 220ms ease;
}

button.webpulse-consent-tab.is-visible {
    display: inline-flex;
}

/* Position modifiers — JS adds the matching modifier class based on the
 * admin setting. Allows easy switch between corners without touching CSS. */
button.webpulse-consent-tab.webpulse-consent-tab--right {
    left: auto;
    right: 16px;
}

button.webpulse-consent-tab:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(15, 23, 42, 0.32);
    padding-right: 16px;
}

button.webpulse-consent-tab.webpulse-consent-tab--right:hover {
    /* Symmetric padding-out on the right-aligned variant — expand to
     * the LEFT on hover so the icon stays anchored to the screen edge. */
    padding-right: 10px;
    padding-left: 16px;
}

button.webpulse-consent-tab:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px #0f766e;
}

.webpulse-consent-tab__icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: block;
}

.webpulse-consent-tab__label {
    /* Hidden by default — slides into view on hover. Keeps the resting
     * state a discreet circle icon, only expands when the user is
     * actively engaging. */
    display: none;
    white-space: nowrap;
}

button.webpulse-consent-tab:hover .webpulse-consent-tab__label,
button.webpulse-consent-tab:focus-visible .webpulse-consent-tab__label {
    display: inline;
}

/* Theme can override the accent color (matches banner):
 * button.webpulse-consent-tab { background-color: #YOURBRAND !important; } */

/* === Standalone preferences button (shortcode) ===
 * Rendered outside `.webpulse-consent` (in footer / privacy policy), so
 * it can't borrow the parent-scoped specificity used by the in-banner
 * buttons. The element+attribute combo here is (0,1,1) which still
 * beats Tailwind preflight's `[type=button]` (0,1,0).
 */
button.webpulse-consent__btn--link[data-wpls-action="open-preferences"] {
    background-color: transparent;
    background-image: none;
    border: 0;
    padding: 0;
    color: var(--wpls-consent-accent, currentColor);
    cursor: pointer;
    font: inherit;
    text-decoration: underline;
    text-transform: none;
    -webkit-appearance: none;
    appearance: none;
}
