/*
 * Banner Block — frontend styles
 *
 * The banner (#bb-banner) is rendered in normal page flow.
 * bb-banner--hidden  → invisible, no interaction, no space taken
 * bb-banner--visible → promoted to position:fixed, bottom:0
 *
 * The block's own WPBakery row provides all visual styling
 * (background, padding, fonts, colours).  We only handle
 * positioning and visibility here.
 *
 * The modal and re-open button are styled via CSS custom properties
 * injected by BB_Theme_Bridge from Impreza theme settings.
 */

/* ============================================================
   Banner wrapper — positioning only
   ============================================================ */

.bb-banner--hidden {
    /* Completely invisible and inert — takes no layout space */
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    clip: rect(0,0,0,0);
    white-space: nowrap;
}

.bb-banner--visible {
    /* Promoted to fixed — the block's row provides background + padding */
    position: fixed !important;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 99999;
    width: 100%;
    /* No background, border, padding or shadow here — the WPBakery row
       inside provides all of that */
}

/* Ensure the WPBakery row inside the visible banner fills the full width */
.bb-banner--visible .vc_row,
.bb-banner--visible .vc_row-fluid,
.bb-banner--visible .wpb_row {
    width: 100% !important;
    max-width: 100% !important;
    /* Remove only the outermost vertical margins so banner sits flush */
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* Animation */
@media (prefers-reduced-motion: no-preference) {
    .bb-banner--visible {
        animation: bb-slide-up 0.28s ease forwards;
    }
    @keyframes bb-slide-up {
        from { transform: translateY(100%); }
        to   { transform: translateY(0); }
    }
}

/* ============================================================
   Modal
   ============================================================ */

.bb-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    font-family: var(--bb-font-body, sans-serif);
}

.bb-modal[hidden] { display: none !important; }

.bb-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    cursor: pointer;
}

.bb-modal__dialog {
    position: relative;
    background: var(--bb-modal-bg, #ffffff);
    color: var(--bb-modal-text, #333333);
    border-radius: var(--bb-block-radius, 6px);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    overflow: hidden;
}

.bb-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--bb-modal-border, #ececec);
    flex-shrink: 0;
}

.bb-modal__title {
    font-family: var(--bb-font-heading, sans-serif);
    font-size: 18px;
    font-weight: 600;
    color: var(--bb-modal-heading, #2f4d5b);
    margin: 0;
}

.bb-modal__close {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--bb-modal-text, #555);
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color 0.15s, background 0.15s;
}

.bb-modal__close:hover,
.bb-modal__close:focus-visible {
    color: var(--bb-modal-heading, #111);
    background: var(--bb-modal-border, #f0f0f0);
    outline: none;
}

.bb-modal__body {
    overflow-y: auto;
    flex: 1;
}

.bb-modal__footer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--bb-modal-border, #ececec);
    flex-shrink: 0;
}

/* ============================================================
   Category rows
   ============================================================ */

.bb-category {
    border-bottom: 1px solid var(--bb-modal-border, #ececec);
}

.bb-category:last-child { border-bottom: none; }

.bb-category__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 24px;
}

.bb-category__name {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--bb-modal-heading, #2f4d5b);
    margin-bottom: 4px;
}

.bb-category__desc {
    font-size: 13px;
    color: var(--bb-modal-text, #666);
    line-height: 1.5;
    margin: 0;
}

/* ============================================================
   Toggle switch
   ============================================================ */

.bb-toggle {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.bb-toggle__input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.bb-toggle__track {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--bb-modal-border, #ccc);
    border-radius: 12px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.bb-toggle__track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.bb-toggle__input:checked + .bb-toggle__track {
    background: var(--bb-btn-bg, #e18e01);
}

.bb-toggle__input:checked + .bb-toggle__track::after {
    transform: translateX(20px);
}

.bb-toggle__input:focus-visible + .bb-toggle__track {
    outline: 2px solid var(--bb-btn-bg, #e18e01);
    outline-offset: 2px;
}

.bb-toggle--locked {
    font-size: 12px;
    font-weight: 600;
    color: var(--bb-btn-bg, #e18e01);
    cursor: default;
    white-space: nowrap;
}

/* ============================================================
   Modal buttons
   ============================================================ */

.bb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 20px;
    font-family: var(--bb-font-body, sans-serif);
    font-size: var(--bb-btn-size, 14px);
    font-weight: var(--bb-btn-weight, 700);
    letter-spacing: var(--bb-btn-tracking, 0.02em);
    text-transform: var(--bb-btn-transform, uppercase);
    line-height: 1;
    border-radius: var(--bb-btn-radius, 99px);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    border: none;
    box-shadow: none;
    margin: 0;
}

.bb-btn--primary {
    background: var(--bb-btn-bg, #e18e01);
    color: var(--bb-btn-text, #fff);
}

.bb-btn--primary:hover,
.bb-btn--primary:focus-visible {
    background: var(--bb-btn-hover, #c07a00);
    color: var(--bb-btn-text, #fff);
    outline: none;
}

.bb-btn--secondary {
    background: transparent;
    color: var(--bb-modal-text, #333);
    border: 1px solid var(--bb-modal-border, #ccc);
    border-radius: var(--bb-btn-radius, 99px);
}

.bb-btn--secondary:hover,
.bb-btn--secondary:focus-visible {
    border-color: var(--bb-modal-text, #333);
    outline: none;
}

.bb-btn--ghost {
    background: transparent;
    color: var(--bb-content-link, #333);
    border: none;
    padding-left: 8px;
    padding-right: 8px;
    font-size: 14px;
    font-weight: 400;
    letter-spacing: normal;
    text-transform: none;
}

.bb-btn--ghost:hover,
.bb-btn--ghost:focus-visible {
    text-decoration: underline;
    outline: none;
}

.bb-btn:focus-visible {
    outline: 2px solid var(--bb-btn-bg, #e18e01);
    outline-offset: 2px;
}

/* ============================================================
   Re-open button
   ============================================================ */

.bb-reopen {
    position: fixed;
    z-index: 99998;
    bottom: 16px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bb-content-bg, #fff);
    color: var(--bb-content-text, #333);
    font-family: var(--bb-font-body, sans-serif);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--bb-content-border, #ddd);
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: box-shadow 0.15s;
    white-space: nowrap;
}

.bb-reopen[hidden] { display: none !important; }
.bb-reopen--bottom-left  { left: 16px; }
.bb-reopen--bottom-right { right: 16px; }

.bb-reopen:hover,
.bb-reopen:focus-visible {
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    outline: none;
}

.bb-reopen:focus-visible {
    outline: 2px solid var(--bb-btn-bg, #e18e01);
    outline-offset: 2px;
}

/* ============================================================
   Admin notice
   ============================================================ */

.bb-notice {
    padding: 1rem;
    color: #c00;
    font-family: sans-serif;
    font-size: 14px;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 600px) {
    .bb-modal__footer {
        flex-direction: column;
        padding: 12px 16px;
    }

    .bb-modal__footer .bb-btn {
        width: 100%;
        justify-content: center;
    }

    .bb-category__row { padding: 14px 16px; }
}

/* ============================================================
   Suppress Impreza's bottom section border that appears above
   the banner. Impreza renders a border on .l-section and its
   child .l-section-h elements — we hide the last one when the
   banner is visible so no line bleeds through above it.
   ============================================================ */

body.bb-has-banner .l-section:last-of-type,
body.bb-has-banner .l-section:last-of-type .l-section-h,
body.bb-has-banner .l-section:last-of-type > .vc_row,
body.bb-has-banner .vc_row-full-width:last-of-type,
body.bb-has-banner .wpb_row:last-of-type {
    border-bottom: none !important;
    box-shadow: none !important;
}

/* Also cover the Impreza 'us-section' element variant */
body.bb-has-banner .w-section:last-of-type,
body.bb-has-banner [class*="l-section"]:last-of-type {
    border-bottom: none !important;
}
