/* ============================================================
 * Complianz Cookie Banner — Design overrides (Etap 7.2/7.8)
 * ============================================================
 * Source of truth:
 *   nexus/projects/top-end/_audit/etap-7-2-8-cookie-banner-spec-2026-05-14.md
 *   Mieszko /decyzje 7.2-8 sesja 067 — Wariant C + Design spec lines 108-160
 *
 * Wymagania spec:
 *   - Center modal viewport (desktop) / bottom sheet (mobile)
 *   - Backdrop fullscreen navy 70% + blur
 *   - Block scroll while banner visible
 *   - Brand colors: beige bg / navy-dark text / burgund accept / navy deny
 *
 * Complianz domyślne klasy:
 *   .cmplz-cookiebanner.cmplz-show          — widoczny banner
 *   .cmplz-soft-cookiewall.cmplz-show       — backdrop wrapper (gdy soft_cookiewall=1)
 *   .cmplz-cookiebanner.cmplz-center        — Complianz claim center (faktycznie corner)
 * ============================================================ */

/* --- 1. Banner pozycja: center modal viewport (override Complianz default corner) --- */
.cmplz-cookiebanner.cmplz-show {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;
    max-width: 540px !important;
    width: calc(100% - 32px) !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25) !important;
    z-index: 999999 !important;
    background: var(--beige-light, #F5EDE0) !important;
    color: var(--navy-dark, #24394A) !important;
    padding: 2rem 2.25rem 1.75rem !important;
    line-height: 1.55 !important;
}

/* --- 1a. Logo Dominiki w headerze --- */
/* Override Complianz default grid-template-columns: 100px 1fr 100px (ogranicza logo do 100px col) */
.cmplz-cookiebanner.cmplz-show .cmplz-header,
.cmplz-cookiebanner .cmplz-header {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    gap: 0.5rem !important;
    margin-bottom: 0.5rem !important;
    grid-template-columns: none !important;
    grid-template-rows: none !important;
}
/* Override Complianz @media max-width:425px { .cmplz-title { display: none } } */
.cmplz-cookiebanner.cmplz-show .cmplz-header .cmplz-title,
.cmplz-cookiebanner .cmplz-header .cmplz-title {
    display: block !important;
    grid-column-start: auto !important;
    justify-self: center !important;
}
.cmplz-cookiebanner.cmplz-show .cmplz-logo {
    width: auto !important;
    height: auto !important;
    margin: 0 0 0.25rem !important;
    line-height: 0 !important;
}
/* Logo image — override Complianz default max-height:40px */
.cmplz-cookiebanner.cmplz-show .cmplz-logo-img {
    display: block !important;
    height: 88px !important;
    width: auto !important;
    max-width: 360px !important;
    max-height: 88px !important;
    margin: 0 auto 0.5rem !important;
}
@media (max-width: 767px) {
    .cmplz-cookiebanner.cmplz-show .cmplz-logo-img {
        height: 56px !important;
        max-height: 56px !important;
        max-width: 220px !important;
        margin: 0 auto 0.25rem !important;
    }
}
@media (max-width: 480px) {
    .cmplz-cookiebanner.cmplz-show .cmplz-logo-img {
        height: 48px !important;
        max-height: 48px !important;
        max-width: 200px !important;
    }
}

/* --- 1b. Title + subtitle typography (friendly formatting) --- */
.cmplz-cookiebanner.cmplz-show .cmplz-title {
    font-family: 'Playfair Display', Georgia, serif !important;
    font-size: 1.5rem !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    color: var(--navy-dark, #24394A) !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important; /* Override Complianz @media max-width:425px {display:none} */
}
.cmplz-cookiebanner.cmplz-show .cmplz-subtitle {
    font-family: 'Lora', Georgia, serif !important;
    font-style: italic !important;
    font-size: 0.95rem !important;
    font-weight: 400 !important;
    line-height: 1.4 !important;
    color: var(--burgund, #7A2830) !important;
    margin: 0.25rem 0 0.5rem !important;
    text-align: center !important;
}

/* --- 1c. Close button (X) — subtle in top-right corner --- */
.cmplz-cookiebanner.cmplz-show .cmplz-close {
    position: absolute !important;
    top: 1rem !important;
    right: 1rem !important;
    width: 28px !important;
    height: 28px !important;
    opacity: 0.6 !important;
    transition: opacity 150ms ease !important;
}
.cmplz-cookiebanner.cmplz-show .cmplz-close:hover {
    opacity: 1 !important;
}
.cmplz-cookiebanner.cmplz-show .cmplz-close svg {
    fill: var(--navy-dark, #24394A) !important;
}

/* --- 1d. Body message — friendly spacing --- */
.cmplz-cookiebanner.cmplz-show .cmplz-body {
    margin-top: 0.75rem !important;
}
.cmplz-cookiebanner.cmplz-show .cmplz-message {
    font-size: 0.95rem !important;
    line-height: 1.55 !important;
    margin-bottom: 1.25rem !important;
}

/* --- 1e. Divider subtle --- */
.cmplz-cookiebanner.cmplz-show .cmplz-divider-header {
    border-top: 1px solid rgba(36, 57, 74, 0.12) !important;
    margin: 0.75rem 0 0.5rem !important;
}

/* --- 1f. Buttons row spacing --- */
.cmplz-cookiebanner.cmplz-show .cmplz-buttons {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.6rem !important;
    margin-top: 1rem !important;
}

/* --- 1g. Footer links subtle --- */
.cmplz-cookiebanner.cmplz-show .cmplz-links {
    margin-top: 1rem !important;
    font-size: 0.85rem !important;
    text-align: center !important;
    opacity: 0.85 !important;
}

/* --- 1h. Category details — chevron arrow (rozwija/zwija opis kategorii) --- */
.cmplz-cookiebanner.cmplz-show .cmplz-category .cmplz-icon {
    width: 22px !important;
    height: 22px !important;
    flex-shrink: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: transform 200ms ease !important;
}
.cmplz-cookiebanner.cmplz-show .cmplz-category .cmplz-icon svg {
    width: 18px !important;
    height: 18px !important;
    fill: var(--navy-dark, #24394A) !important;
}
.cmplz-cookiebanner.cmplz-show .cmplz-category[open] .cmplz-icon {
    transform: rotate(180deg) !important;
}
.cmplz-cookiebanner.cmplz-show .cmplz-category summary {
    padding-right: 0.5rem !important;
    cursor: pointer !important;
    list-style: none !important;
}
.cmplz-cookiebanner.cmplz-show .cmplz-category summary::-webkit-details-marker {
    display: none !important;
}
.cmplz-cookiebanner.cmplz-show .cmplz-category-header {
    gap: 0.5rem !important;
    padding: 0.5rem 0 !important;
}
.cmplz-cookiebanner.cmplz-show .cmplz-always-active {
    color: #2D7A4F !important;
    font-weight: 500 !important;
    font-size: 0.9rem !important;
}

/* --- 2. Backdrop overlay — navy 70% fullscreen, blocks click + visible context --- */
.cmplz-soft-cookiewall.cmplz-show {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(36, 57, 74, 0.7) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
    z-index: 999998 !important;
    pointer-events: auto !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* --- 3. Lock html/body scroll while banner active (CSS :has() — Chrome 105+, FF 121+, Safari 15.4+) --- */
html:has(.cmplz-cookiebanner.cmplz-show),
body:has(.cmplz-cookiebanner.cmplz-show) {
    overflow: hidden !important;
    height: 100% !important;
    touch-action: none !important;
    overscroll-behavior: contain !important;
}

/* --- 4. Banner internals: text colors --- */
.cmplz-cookiebanner.cmplz-show .cmplz-title,
.cmplz-cookiebanner.cmplz-show .cmplz-header,
.cmplz-cookiebanner.cmplz-show .cmplz-message {
    color: var(--navy-dark, #24394A) !important;
}

.cmplz-cookiebanner.cmplz-show .cmplz-link,
.cmplz-cookiebanner.cmplz-show a {
    color: var(--burgund, #7A2830) !important;
}

/* --- 5. Buttons — brand colors per spec --- */
.cmplz-cookiebanner.cmplz-show .cmplz-btn.cmplz-accept {
    background-color: var(--burgund, #7A2830) !important;
    border-color: var(--burgund, #7A2830) !important;
    color: var(--beige, #EDE4D3) !important;
    font-weight: 600 !important;
    padding: 0.7rem 1.2rem !important;
    border-radius: 6px !important;
    min-height: 44px !important;
}
.cmplz-cookiebanner.cmplz-show .cmplz-btn.cmplz-accept:hover {
    background-color: var(--burgund-dark, #5C1E24) !important;
    border-color: var(--burgund-dark, #5C1E24) !important;
}

.cmplz-cookiebanner.cmplz-show .cmplz-btn.cmplz-deny {
    background-color: var(--navy, #33546A) !important;
    border-color: var(--navy, #33546A) !important;
    color: var(--beige, #EDE4D3) !important;
    font-weight: 600 !important;
    padding: 0.7rem 1.2rem !important;
    border-radius: 6px !important;
    min-height: 44px !important;
}
.cmplz-cookiebanner.cmplz-show .cmplz-btn.cmplz-deny:hover {
    background-color: var(--navy-dark, #24394A) !important;
    border-color: var(--navy-dark, #24394A) !important;
}

.cmplz-cookiebanner.cmplz-show .cmplz-btn.cmplz-view-preferences {
    background-color: transparent !important;
    border: 1px solid var(--navy, #33546A) !important;
    color: var(--navy-dark, #24394A) !important;
    font-weight: 600 !important;
    padding: 0.7rem 1.2rem !important;
    border-radius: 6px !important;
    min-height: 44px !important;
}
.cmplz-cookiebanner.cmplz-show .cmplz-btn.cmplz-view-preferences:hover {
    background-color: var(--navy, #33546A) !important;
    color: var(--beige, #EDE4D3) !important;
}

/* Save preferences (panel "Dostosuj") --- treat as primary in panel */
.cmplz-cookiebanner.cmplz-show .cmplz-btn.cmplz-save-preferences {
    background-color: var(--burgund, #7A2830) !important;
    border-color: var(--burgund, #7A2830) !important;
    color: var(--beige, #EDE4D3) !important;
    font-weight: 600 !important;
    padding: 0.7rem 1.2rem !important;
    border-radius: 6px !important;
    min-height: 44px !important;
}

/* --- 6. Toggle switches w panel "Dostosuj" --- */
.cmplz-cookiebanner.cmplz-show .cmplz-toggle-container .cmplz-toggle {
    background-color: var(--burgund, #7A2830) !important;
}

/* --- 7. Mobile: centered modal (jak desktop) + scrollable wewnątrz --- */
@media (max-width: 767px) {
    .cmplz-cookiebanner.cmplz-show {
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        bottom: auto !important;
        transform: translate(-50%, -50%) !important;
        max-width: calc(100vw - 16px) !important;
        width: calc(100vw - 16px) !important;
        border-radius: 12px !important;
        padding: 1rem 1rem 1.25rem !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
    }
    .cmplz-cookiebanner.cmplz-show .cmplz-btn {
        width: 100% !important;
        margin: 0.25rem 0 !important;
    }
    /* Compact spacing mobile — żeby pomieścić logo + body + buttons + linki */
    .cmplz-cookiebanner.cmplz-show .cmplz-message {
        font-size: 0.9rem !important;
        line-height: 1.45 !important;
        margin-bottom: 0.75rem !important;
    }
    .cmplz-cookiebanner.cmplz-show .cmplz-title {
        font-size: 1.25rem !important;
    }
    .cmplz-cookiebanner.cmplz-show .cmplz-subtitle {
        font-size: 0.85rem !important;
        margin: 0.1rem 0 0.25rem !important;
    }
    .cmplz-cookiebanner.cmplz-show .cmplz-header {
        margin-bottom: 0.25rem !important;
        gap: 0.25rem !important;
    }
    .cmplz-cookiebanner.cmplz-show .cmplz-buttons {
        margin-top: 0.5rem !important;
    }
    .cmplz-cookiebanner.cmplz-show .cmplz-links {
        margin-top: 0.75rem !important;
        padding-bottom: 0.25rem !important;
    }
    /* Custom scrollbar — subtle, brand-aligned */
    .cmplz-cookiebanner.cmplz-show::-webkit-scrollbar {
        width: 6px;
    }
    .cmplz-cookiebanner.cmplz-show::-webkit-scrollbar-thumb {
        background: rgba(36, 57, 74, 0.3);
        border-radius: 3px;
    }
}

/* --- 8. Anti-fallback: gdy soft_cookiewall NIE działa (no .cmplz-soft-cookiewall sibling),
 *      utworzymy backdrop pseudo-element via :before na html when banner visible.
 *      :has() fallback gdy browser ją wspiera (Chrome 105+/FF 121+/Safari 15.4+ = 99% 2026). --- */
html:has(.cmplz-cookiebanner.cmplz-show)::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(36, 57, 74, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999997;
    pointer-events: auto;
}
