/* Bored Tracking — banner Consent Mode v2.
   Wszystkie klasy z prefixem .bt- (BEM) żeby uniknąć kolizji z motywem.
   3 layouty: bar (pasek na dole), modal (wyśrodkowany), corner (karta w rogu).
   Dark/light auto przez prefers-color-scheme. */

.bt-consent-banner,
.bt-consent-banner * {
    box-sizing: border-box;
}

.bt-consent-banner {
    position: fixed;
    /* Max signed int32 — przebija typowe 3rd-party widgety (Tawk.to, Intercom,
       Messenger plugin, Drift) które używają 999999..2147483600 dla swoich z-index. */
    z-index: 2147483647;
    background: #ffffff;
    color: #1a1a1a;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

@media (prefers-color-scheme: dark) {
    .bt-consent-banner {
        background: #1f2024;
        color: #f0f0f0;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);
    }
}

/* ---------- Layout: bar (full-width, bottom) ---------- */

.bt-consent-banner.bt-layout-bar {
    bottom: 0;
    left: 0;
    right: 0;
    padding: 18px 20px;
    border-top: 1px solid rgba(127, 127, 127, 0.18);
}

.bt-consent-banner.bt-layout-bar .bt-consent-banner__inner {
    max-width: 1200px;
    margin: 0 auto;
}

/* ---------- Layout: modal (centered overlay) ---------- */

.bt-consent-banner.bt-layout-modal {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 600px;
    width: calc(100% - 32px);
    border-radius: 14px;
    padding: 24px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}

.bt-consent-banner.bt-layout-modal::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: -1;
}

/* ---------- Layout: corner (bottom card, lewy lub prawy róg) ---------- */

.bt-consent-banner.bt-layout-corner {
    bottom: 16px;
    max-width: 380px;
    border-radius: 14px;
    padding: 20px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}

.bt-consent-banner.bt-layout-corner.bt-corner-right {
    right: 16px;
}

.bt-consent-banner.bt-layout-corner.bt-corner-left {
    left: 16px;
}

/* Fallback gdy class .bt-corner-* nie została dodana (legacy) — domyślnie prawa. */
.bt-consent-banner.bt-layout-corner:not(.bt-corner-left):not(.bt-corner-right) {
    right: 16px;
}

/* ---------- Mobile (<640px) ---------- */
/* Niezależnie od wybranego layoutu (bar / modal / corner / corner-left / corner-right)
   na mobile banner pokazuje się jako wyśrodkowany modal z overlayem. Powód:
   - bardziej widoczny niż pasek na dole
   - nie koliduje z floating UI elementami (mobile FAB, fixed bottom nav, toolbary OS)
   - mniej ryzyka że user przegapi banner i wysyła trafficu do GA/Pixel bez consent. */
@media (max-width: 640px) {
    .bt-consent-banner,
    .bt-consent-banner.bt-layout-bar,
    .bt-consent-banner.bt-layout-modal,
    .bt-consent-banner.bt-layout-corner,
    .bt-consent-banner.bt-layout-corner.bt-corner-right,
    .bt-consent-banner.bt-layout-corner.bt-corner-left {
        top: 50%;
        left: 50%;
        right: auto;
        bottom: auto;
        transform: translate(-50%, -50%);
        width: calc(100% - 24px);
        max-width: 460px;
        max-height: calc(100vh - 24px);
        border-radius: 14px;
        padding: 20px;
        overflow-y: auto;
    }

    /* Overlay tła dla każdego layoutu na mobile — modal-like UX. */
    .bt-consent-banner::before {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.55);
        z-index: -1;
    }
}

/* ---------- Inner content ---------- */

.bt-consent-banner__title {
    margin: 0 0 8px;
    font-size: 17px;
    font-weight: 600;
    color: inherit;
}

.bt-consent-banner__body {
    margin: 0 0 16px;
    font-size: 14px;
    color: inherit;
}

.bt-consent-banner__link {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.bt-consent-banner__link:hover {
    text-decoration-thickness: 2px;
}

/* ---------- Settings panel (kategorie) ---------- */

.bt-consent-banner__settings {
    margin: 16px 0;
    padding-top: 16px;
    border-top: 1px solid rgba(127, 127, 127, 0.18);
    display: grid;
    gap: 12px;
}

/* Override `display: grid` gdy panel ma HTML attribute `hidden`.
   Bez tego author CSS wygrywa nad UA stylesheet (display: none od [hidden])
   i settings panel jest widoczny od razu zamiast tylko po kliku "Ustawienia". */
.bt-consent-banner__settings[hidden] {
    display: none;
}

.bt-consent-banner__category {
    border: 0;
    margin: 0;
    padding: 0;
}

.bt-consent-banner__category label {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 12px;
    align-items: start;
    cursor: pointer;
}

.bt-consent-banner__category input[type="checkbox"] {
    grid-row: span 2;
    margin: 4px 0 0;
    width: 18px;
    height: 18px;
    accent-color: #1a73e8;
    cursor: pointer;
}

.bt-consent-banner__category input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.bt-consent-banner__category strong {
    font-size: 14px;
    font-weight: 600;
}

.bt-consent-banner__category span {
    grid-column: 2;
    font-size: 13px;
    opacity: 0.78;
}

/* ---------- Akcje (przyciski) ---------- */

.bt-consent-banner__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: stretch;
}

/* Wszystkie przyciski biorą równy share dostępnej szerokości — 3 buttons obok
   siebie (lub 4 z "Zapisz wybór" gdy settings panel rozwinięty).
   `min-width: 0` pozwala na shrink tekstu bez overflow w wąskich kontenerach. */
.bt-consent-banner__actions > .bt-consent-banner__btn {
    flex: 1 1 0;
    min-width: 0;
}

/* Bardzo wąskie ekrany — mniej padding żeby buttons się mieściły bez wrap labela. */
@media (max-width: 480px) {
    .bt-consent-banner__btn {
        padding: 10px 10px;
        font-size: 13px;
    }
}

.bt-consent-banner__btn {
    appearance: none;
    border: 0;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    line-height: 1.2;
    transition: opacity 0.15s ease, transform 0.05s ease;
}

.bt-consent-banner__btn:hover {
    opacity: 0.88;
}

.bt-consent-banner__btn:active {
    transform: scale(0.98);
}

.bt-consent-banner__btn:focus-visible {
    outline: 2px solid #1a73e8;
    outline-offset: 2px;
}

.bt-consent-banner__btn--primary {
    background: #1a73e8;
    color: #ffffff;
}

.bt-consent-banner__btn--primary:hover {
    background: #1666cc;
    opacity: 1;
}

.bt-consent-banner__btn--secondary {
    background: rgba(127, 127, 127, 0.15);
    color: inherit;
}

@media (prefers-color-scheme: dark) {
    .bt-consent-banner__btn--secondary {
        background: rgba(255, 255, 255, 0.1);
    }
}

/* Stan otwartego bannera (do ewentualnego scroll-lock w bar/corner — w MVP nie blokujemy
   scrolla, modal sam jest wyśrodkowany z overlay'em).
   Klasę dorzuca JS do <body>; do customizacji w motywie. */
body.bt-consent-banner-open {
    /* MVP: nic. Hook do override'u przez motyw / customizację. */
}

/* ---------- Floating revoke button (RODO Art. 7(3)) ---------- */

.bt-consent-revoke {
    position: fixed;
    bottom: 16px;
    /* Jeden niżej niż banner — nie przebije bannera gdy oba widoczne (i tak
       button jest hidden gdy banner open, ale safety margin). */
    z-index: 2147483646;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 0;
    background: #1a1a1a;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    opacity: 0.85;
    padding: 0;
    font-family: inherit;
    transition: opacity 0.15s ease, transform 0.05s ease;
}

.bt-consent-revoke:hover {
    opacity: 1;
}

.bt-consent-revoke:active {
    transform: scale(0.95);
}

.bt-consent-revoke:focus-visible {
    outline: 2px solid #1a73e8;
    outline-offset: 2px;
    opacity: 1;
}

.bt-consent-revoke--right { right: 16px; }
.bt-consent-revoke--left  { left: 16px; }

@media (prefers-color-scheme: dark) {
    .bt-consent-revoke {
        background: #f0f0f0;
        color: #1a1a1a;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    }
}

/* Ukryj button gdy banner jest otwarty (uniknięcie wizualnego nakładania) */
body.bt-consent-banner-open .bt-consent-revoke {
    display: none;
}

/* Inline link rendered przez shortcode — nie nadpisujemy stylu motywu, tylko
   zapewniamy podstawowy `cursor: pointer` (bo href="#"). */
.bt-consent-link {
    cursor: pointer;
}
