/**
 * AVDB Consent Banner, mobile-first (2026-10-07)
 * Base = phone. From 768px: a single bar as before (same house style).
 * Only loaded when abvb_consent_mf_active() is true.
 *
 * @package ABVBTheme
 */

#avdb-consent-banner.avdb-cmf[hidden],
#avdb-consent-banner.avdb-cmf [hidden] {
    display: none !important;
}

#avdb-consent-banner.avdb-cmf {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999999;
    box-sizing: border-box;
    max-height: min(72vh, 520px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    background: #000000;
    color: #ffffff;
    border-top: 2px solid #ACD400;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.45);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    transform: translateY(105%);
    transition: transform 0.28s ease;
}

#avdb-consent-banner.avdb-cmf.show {
    transform: translateY(0);
}

#avdb-consent-banner.avdb-cmf.is-behind-lead-modal {
    visibility: hidden;
}

#avdb-consent-banner.avdb-cmf *,
#avdb-consent-settings-modal * {
    box-sizing: border-box;
}

.avdb-cmf .avdb-consent-banner-content {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 1200px;
    margin: 0 auto;
}

.avdb-cmf .avdb-consent-text h3 {
    margin: 0 0 6px;
    font-size: 17px;
    line-height: 1.3;
    font-weight: 700;
    color: #ffffff;
}

.avdb-cmf .avdb-consent-text p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: #d9d9d9;
}

.avdb-cmf .avdb-consent-text a {
    color: #ACD400;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.avdb-cmf .avdb-consent-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.avdb-cmf .avdb-consent-btn,
#avdb-consent-settings-modal .avdb-consent-btn {
    min-height: 48px;
    margin: 0;
    padding: 12px 14px;
    border: 2px solid transparent;
    border-radius: 8px;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.avdb-cmf .avdb-consent-btn:disabled,
#avdb-consent-settings-modal .avdb-consent-btn:disabled {
    opacity: 0.6;
    cursor: progress;
}

.avdb-cmf .avdb-consent-btn-accept,
#avdb-consent-settings-modal .avdb-consent-btn-accept {
    background: #ACD400;
    border-color: #ACD400;
    color: #000000;
}

.avdb-cmf .avdb-consent-btn-reject,
#avdb-consent-settings-modal .avdb-consent-btn-reject {
    background: transparent;
    border-color: #ffffff;
    color: #ffffff;
}

.avdb-cmf .avdb-consent-btn-settings {
    grid-column: 1 / -1;
    min-height: 44px;
    padding: 8px;
    background: transparent;
    border-color: transparent;
    color: #ACD400;
    text-decoration: underline;
    text-underline-offset: 3px;
    font-size: 14px;
}

.avdb-cmf .avdb-consent-btn:focus-visible,
.avdb-cmf .avdb-consent-compact-label:focus-visible,
.avdb-cmf a:focus-visible,
#avdb-consent-settings-modal button:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 2px;
}

#avdb-consent-save-error {
    margin: 0;
    color: #ffb4a8;
    font-size: 14px;
}

/* Compact bar during lead forms: the choice stays visible on one line. */
#avdb-consent-banner.avdb-cmf.is-compact {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    border-radius: 12px 12px 0 0;
}

.avdb-cmf .avdb-consent-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 1200px;
    margin: 0 auto;
}

.avdb-cmf .avdb-consent-compact-label {
    flex: 1 1 auto;
    min-height: 44px;
    margin: 0;
    padding: 0 4px;
    background: transparent;
    border: 0;
    color: #ffffff;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.avdb-cmf .avdb-consent-compact .avdb-consent-btn {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 8px 12px;
    font-size: 14px;
}

#avdb-consent-spacer {
    height: 0;
}

/* Lift floating mobile CTAs above the compact bar. */
body.avdb-consent-compact .abvb-mobile-viewing-cta {
    bottom: calc(var(--avdb-consent-h, 0px) + 12px) !important;
}

/* Lead surfaces stay above consent UI (as before). */
.abvb-viewing-modal,
.abvb-callback,
.abvb-modal,
.thank-you-lease-modal {
    z-index: 1000001 !important;
}

/* ---------- Settings modal: bottom sheet on phones ---------- */

#avdb-consent-settings-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000002;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    background: rgba(0, 0, 0, 0.8);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#avdb-consent-settings-modal.show {
    display: flex;
}

#avdb-consent-settings-modal .avdb-consent-modal-content {
    position: relative;
    width: 100%;
    max-width: 600px;
    max-height: 88vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    background: #000000;
    border-top: 2px solid #ACD400;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
}

#avdb-consent-settings-modal .avdb-consent-modal-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    background: transparent;
    border: 0;
    border-radius: 8px;
    color: #cccccc;
    font-size: 28px;
    cursor: pointer;
}

#avdb-consent-settings-modal h2 {
    margin: 0 0 10px;
    padding-right: 44px;
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
}

#avdb-consent-settings-modal .avdb-consent-modal-content > p {
    margin: 0 0 8px;
    font-size: 14px;
    line-height: 1.5;
    color: #d9d9d9;
}

#avdb-consent-settings-modal .avdb-consent-option {
    padding: 14px 0;
    border-bottom: 1px solid #333333;
}

#avdb-consent-settings-modal .avdb-consent-option:last-of-type {
    border-bottom: 0;
}

#avdb-consent-settings-modal .avdb-consent-option-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}

#avdb-consent-settings-modal .avdb-consent-option-title {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
}

#avdb-consent-settings-modal .avdb-consent-option-description {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: #cccccc;
}

#avdb-consent-settings-modal .avdb-consent-toggle {
    position: relative;
    display: inline-block;
    flex: 0 0 auto;
    width: 54px;
    height: 28px;
    margin: 8px 0;
}

#avdb-consent-settings-modal .avdb-consent-toggle input {
    position: absolute;
    inset: -8px;
    width: calc(100% + 16px);
    height: calc(100% + 16px);
    margin: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
}

#avdb-consent-settings-modal .avdb-consent-toggle-slider {
    position: absolute;
    inset: 0;
    background: #333333;
    border: 2px solid #333333;
    border-radius: 28px;
    transition: 0.25s ease;
}

#avdb-consent-settings-modal .avdb-consent-toggle-slider:before {
    content: "";
    position: absolute;
    left: 2px;
    bottom: 2px;
    width: 20px;
    height: 20px;
    background: #666666;
    border-radius: 50%;
    transition: 0.25s ease;
}

#avdb-consent-settings-modal .avdb-consent-toggle input:checked + .avdb-consent-toggle-slider {
    background: #ACD400;
    border-color: #ACD400;
}

#avdb-consent-settings-modal .avdb-consent-toggle input:checked + .avdb-consent-toggle-slider:before {
    transform: translateX(26px);
    background: #000000;
}

#avdb-consent-settings-modal .avdb-consent-toggle input:disabled + .avdb-consent-toggle-slider {
    opacity: 0.5;
    background: #ACD400;
    border-color: #ACD400;
}

#avdb-consent-settings-modal .avdb-consent-toggle input:disabled + .avdb-consent-toggle-slider:before {
    transform: translateX(26px);
    background: #000000;
}

#avdb-consent-settings-modal .avdb-consent-toggle input:focus-visible + .avdb-consent-toggle-slider {
    outline: 3px solid #ffffff;
    outline-offset: 2px;
}

#avdb-consent-settings-modal .avdb-consent-modal-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    position: sticky;
    bottom: calc(-20px - env(safe-area-inset-bottom, 0px));
    margin: 12px -16px calc(-20px - env(safe-area-inset-bottom, 0px));
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
    background: #000000;
    border-top: 1px solid #333333;
}

/* Footer link to reopen the preferences. */
.avdb-consent-footer-link {
    padding: 0;
    background: none;
    border: 0;
    color: inherit;
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

/* Very short screens (landscape phones): text smaller, sheet scrolls. */
@media (max-height: 560px) {
    #avdb-consent-banner.avdb-cmf {
        max-height: 80vh;
        padding-top: 12px;
    }
    .avdb-cmf .avdb-consent-text p {
        font-size: 13px;
    }
    .avdb-cmf .avdb-consent-btn {
        min-height: 44px;
    }
}

/* ---------- Tablet/desktop: single bar as before ---------- */

@media (min-width: 768px) {
    #avdb-consent-banner.avdb-cmf {
        max-height: none;
        overflow: visible;
        padding: 20px 24px calc(20px + env(safe-area-inset-bottom, 0px));
        border-radius: 0;
        box-shadow: 0 -4px 20px rgba(172, 212, 0, 0.2);
    }

    .avdb-cmf .avdb-consent-banner-content {
        flex-direction: row;
        align-items: center;
        gap: 24px;
    }

    .avdb-cmf .avdb-consent-text {
        flex: 1 1 auto;
        min-width: 0;
    }

    .avdb-cmf .avdb-consent-text h3 {
        font-size: 18px;
    }

    .avdb-cmf .avdb-consent-buttons {
        display: flex;
        flex: 0 0 auto;
        gap: 12px;
    }

    .avdb-cmf .avdb-consent-btn {
        min-height: 46px;
        padding: 12px 22px;
        font-size: 14px;
    }

    .avdb-cmf .avdb-consent-btn-settings {
        padding: 12px 22px;
        border-color: #ACD400;
        text-decoration: none;
    }

    #avdb-consent-banner.avdb-cmf.is-compact {
        padding: 10px 24px;
        border-radius: 0;
    }

    .avdb-cmf .avdb-consent-compact .avdb-consent-btn {
        padding: 8px 18px;
    }

    #avdb-consent-settings-modal {
        align-items: center;
        padding: 20px;
    }

    #avdb-consent-settings-modal .avdb-consent-modal-content {
        max-height: 80vh;
        padding: 32px;
        border: 2px solid #ACD400;
        border-radius: 10px;
    }

    #avdb-consent-settings-modal h2 {
        font-size: 26px;
    }

    #avdb-consent-settings-modal .avdb-consent-modal-buttons {
        display: flex;
        justify-content: flex-end;
        position: static;
        margin: 24px 0 0;
        padding: 24px 0 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    #avdb-consent-banner.avdb-cmf,
    #avdb-consent-settings-modal .avdb-consent-toggle-slider,
    #avdb-consent-settings-modal .avdb-consent-toggle-slider:before {
        transition: none;
    }
}
