/**
 * STDV Cookie Consent — frontend banner.
 *
 * Pixel-perfect z Figmy:
 *  - desktop: kategorie jako karty z tłem, przyciski w jednej linii
 *  - mobile: ten sam układ ale przyciski stack vertically
 *
 * Wszystkie style pod scope .stdv-cc — bez kolizji z motywem.
 * Klient może nadpisać CSS variables w admin (Banner / Custom CSS).
 */

/* CSS custom properties — domyślne neutralne wartości, override z admin settings. */
.stdv-cc {
    --stdv-cc-primary:        #2563EB;
    --stdv-cc-primary-hover:  #1D4ED8;
    --stdv-cc-on-primary:     #FFFFFF;
    --stdv-cc-bg:             #FFFFFF;
    --stdv-cc-text:           #111827;
    --stdv-cc-text-muted:     #6B7280;
    --stdv-cc-border:         #E5E7EB;
    --stdv-cc-bg-muted:       #F4F4F5;     /* tło karty kategorii */
    --stdv-cc-overlay:        rgba(17, 24, 39, 0.45);
    --stdv-cc-radius:         16px;        /* radius modal */
    --stdv-cc-card-radius:    14px;        /* radius karty kategorii */
    --stdv-cc-btn-radius:     999px;       /* pill */
    --stdv-cc-shadow:         0 20px 50px rgba(0, 0, 0, 0.18);
    --stdv-cc-font:           -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --stdv-cc-font-heading:   var(--stdv-cc-font);
}

/* Container — fullscreen wrapper z modal i overlay */
.stdv-cc {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    font-family: var(--stdv-cc-font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--stdv-cc-text);
    -webkit-font-smoothing: antialiased;
}
.stdv-cc.is-open {
    display: flex;
}

.stdv-cc__overlay {
    position: absolute;
    inset: 0;
    background: var(--stdv-cc-overlay);
    backdrop-filter: blur(2px);
}

.stdv-cc__modal {
    position: relative;
    width: 560px;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    background: var(--stdv-cc-bg);
    border-radius: var(--stdv-cc-radius);
    box-shadow: var(--stdv-cc-shadow);
    padding: 32px 32px 28px;
    box-sizing: border-box;
}

.stdv-cc__title {
    margin: 0 0 14px;
    font-family: var(--stdv-cc-font-heading);
    font-size: 30px;
    line-height: 1.1;
    font-weight: 700;
    color: var(--stdv-cc-text);
}

.stdv-cc__desc {
    margin: 0 0 20px;
    font-size: 13px;
    line-height: 1.55;
    color: var(--stdv-cc-text-muted);
}

/* -------------------------------------------------------------------------
   Categories — jako karty z tłem
   ------------------------------------------------------------------------- */
.stdv-cc__categories {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0 0 20px;
}

.stdv-cc__cat {
    background: var(--stdv-cc-bg-muted);
    border-radius: var(--stdv-cc-card-radius);
    overflow: hidden;
    transition: background 0.15s;
}

.stdv-cc__cat-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    cursor: pointer;
    user-select: none;
}
.stdv-cc__cat-head:focus-visible {
    outline: 2px solid var(--stdv-cc-primary);
    outline-offset: -2px;
    border-radius: var(--stdv-cc-card-radius);
}

.stdv-cc__cat-label {
    flex: 1 1 auto;
    font-size: 14px;
    font-weight: 600;
    color: var(--stdv-cc-text);
}

.stdv-cc__cat-badge {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--stdv-cc-primary);
}

.stdv-cc__cat-arrow {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    color: var(--stdv-cc-text);
    transition: transform 0.2s ease;
}
.stdv-cc__cat.is-open .stdv-cc__cat-arrow {
    transform: rotate(180deg);
}

.stdv-cc__cat-body {
    padding: 0 18px 16px;
    font-size: 13px;
    line-height: 1.55;
    color: var(--stdv-cc-text-muted);
}
.stdv-cc__cat-body p {
    margin: 0;
}

/* -------------------------------------------------------------------------
   Toggle switch
   ------------------------------------------------------------------------- */
.stdv-cc__switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    cursor: pointer;
}
.stdv-cc__switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.stdv-cc__switch-track {
    width: 38px;
    height: 22px;
    background: #C7C7CC;
    border-radius: 999px;
    transition: background 0.2s ease;
    display: inline-block;
    position: relative;
}
.stdv-cc__switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #FFFFFF;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.stdv-cc__switch input:checked + .stdv-cc__switch-track {
    background: var(--stdv-cc-primary);
}
.stdv-cc__switch input:checked + .stdv-cc__switch-track .stdv-cc__switch-thumb {
    transform: translateX(16px);
}
.stdv-cc__switch input:focus-visible + .stdv-cc__switch-track {
    outline: 2px solid var(--stdv-cc-primary);
    outline-offset: 2px;
}

.screen-reader-text {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* -------------------------------------------------------------------------
   Actions — przyciski w jednej linii na desktop, stack na mobile
   ------------------------------------------------------------------------- */
.stdv-cc__actions {
    display: flex;
    flex-direction: row;
    gap: 8px;
    margin: 4px 0 14px;
}

.stdv-cc__btn {
    flex: 1 1 0;
    min-width: 0;
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
    padding: 8px 6px;
    border-radius: var(--stdv-cc-btn-radius);
    text-align: center;
    line-height: 1.15;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    box-sizing: border-box;
    white-space: normal;
}
.stdv-cc__btn:focus-visible {
    outline: 2px solid var(--stdv-cc-primary);
    outline-offset: 2px;
}

/* Tryb "przycisk jako <span>" — gdy motyw psuje natywne <button> (np. globalny
   button:hover). Span z klasą .stdv-cc__btn wygląda identycznie, ale nie łapie
   reguł motywu dla <button>. Wymusza centrowanie i wyłącza zaznaczanie tekstu. */
.stdv-cc__btn--as-span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    user-select: none;
    -webkit-user-select: none;
}

/* -------------------------------------------------------------------------
   Placeholder zablokowanego osadzenia (iframe: YouTube/Mapy/Instagram…)
   ------------------------------------------------------------------------- */
.stdv-cc-embed {
    display: block;
    position: relative;
}
.stdv-cc-embed.is-blocked > iframe {
    display: none !important;
}
.stdv-cc-embed__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    min-height: 180px;
    margin: 0;
    padding: 24px;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.45;
    cursor: pointer;
    color: var(--stdv-cc-text, #111827);
    background: var(--stdv-cc-bg-muted, #F4F4F5);
    border: 1px dashed var(--stdv-cc-border, #E5E7EB);
    border-radius: var(--stdv-cc-card-radius, 14px);
    transition: border-color 0.15s, color 0.15s;
}
.stdv-cc-embed__btn:hover,
.stdv-cc-embed__btn:focus-visible {
    border-color: var(--stdv-cc-primary, #2563EB);
    color: var(--stdv-cc-primary, #2563EB);
    outline: none;
}

.stdv-cc__btn--primary {
    background: var(--stdv-cc-primary);
    color: var(--stdv-cc-on-primary);
    border: 1px solid var(--stdv-cc-primary);
}
.stdv-cc__btn--primary:hover {
    background: var(--stdv-cc-primary-hover);
    border-color: var(--stdv-cc-primary-hover);
}

.stdv-cc__btn--outline,
.stdv-cc__btn--link {           /* keep --link class for backwards compat — taki sam jak outline */
    background: transparent;
    color: var(--stdv-cc-primary);
    border: 1px solid var(--stdv-cc-primary);
}
.stdv-cc__btn--outline:hover,
.stdv-cc__btn--link:hover {
    background: var(--stdv-cc-primary);
    color: var(--stdv-cc-on-primary);
}

/* -------------------------------------------------------------------------
   Polityka link — pod przyciskami, centered, ze strzałką
   ------------------------------------------------------------------------- */
.stdv-cc__policy {
    display: block;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--stdv-cc-primary);
    text-decoration: none;
    padding: 6px;
    transition: color 0.15s;
}
.stdv-cc__policy:hover {
    color: var(--stdv-cc-primary-hover);
}
.stdv-cc__policy::after {
    content: " \2192";              /* arrow → */
    margin-left: 4px;
}

/* -------------------------------------------------------------------------
   Mobile — przyciski stack vertically
   ------------------------------------------------------------------------- */
@media (max-width: 540px) {
    .stdv-cc__modal {
        padding: 24px 20px 20px;
    }
    .stdv-cc__title {
        font-size: 26px;
    }
    .stdv-cc__actions {
        flex-direction: column;
        gap: 10px;
    }
    .stdv-cc__btn {
        width: 100%;
        flex: none;
    }
}

/* -------------------------------------------------------------------------
   Tabela deklaracji cookies — [stdv_cookie_table] / blok Gutenberga
   ------------------------------------------------------------------------- */
.stdv-cc-table {
    margin: 0 0 1.5em;
}
.stdv-cc-table__group {
    margin: 0 0 1.75em;
}
.stdv-cc-table__cat {
    margin: 0 0 .25em;
    font-size: 1.15em;
    font-weight: 700;
}
.stdv-cc-table__desc {
    margin: 0 0 .75em;
    color: var(--stdv-cc-text-muted, #6B7280);
}
.stdv-cc-table__list {
    width: 100%;
    border-collapse: collapse;
    font-size: .95em;
}
.stdv-cc-table__list th,
.stdv-cc-table__list td {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--stdv-cc-border, #E5E7EB);
    vertical-align: top;
}
.stdv-cc-table__list thead th {
    font-weight: 600;
    border-bottom-width: 2px;
}

/* -------------------------------------------------------------------------
   Warianty formy bannera: modal (domyślny) / bar (pasek) / box (karta w rogu)
   ------------------------------------------------------------------------- */

/* BAR — pasek na pełną szerokość u dołu, bez overlay, nie blokuje strony. */
.stdv-cc--bar {
    align-items: flex-end;
    justify-content: stretch;
    pointer-events: none;            /* tylko panel łapie kliknięcia */
}
.stdv-cc--bar .stdv-cc__overlay {
    display: none;
}
.stdv-cc--bar .stdv-cc__modal {
    pointer-events: auto;
    width: 100%;
    max-width: 100%;
    max-height: 85vh;
    border-radius: var(--stdv-cc-radius) var(--stdv-cc-radius) 0 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.16);
}
/* Pasek pełnej szerokości, ale zawartość wyśrodkowana (nie rozlana na cały ekran). */
.stdv-cc--bar .stdv-cc__modal > * {
    max-width: 1180px;
    margin-left: auto;
    margin-right: auto;
}

/* Większe ekrany: kategorie jako kafelki + węższe, prawo-wyrównane przyciski. */
@media (min-width: 782px) {
    .stdv-cc--bar .stdv-cc__categories {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        align-items: start;
    }
    .stdv-cc--bar .stdv-cc__actions {
        justify-content: flex-end;
        flex-wrap: wrap;
    }
    .stdv-cc--bar .stdv-cc__btn {
        flex: 0 0 auto;
        min-width: 150px;
    }
}
@media (min-width: 1100px) {
    .stdv-cc--bar .stdv-cc__categories {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* BOX — wąska karta w rogu (dół-lewo/prawo), bez overlay, nie blokuje strony. */
.stdv-cc--box {
    align-items: flex-end;
    pointer-events: none;
}
.stdv-cc--box .stdv-cc__overlay {
    display: none;
}
.stdv-cc--box.stdv-cc--box-br {
    justify-content: flex-end;
}
.stdv-cc--box.stdv-cc--box-bl {
    justify-content: flex-start;
}
.stdv-cc--box .stdv-cc__modal {
    pointer-events: auto;
    width: 380px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    margin: 16px;
}

/* Mobile — box i bar zajmują pełną szerokość (czytelność na małych ekranach). */
@media (max-width: 540px) {
    .stdv-cc--box {
        align-items: flex-end;
        justify-content: center;
    }
    .stdv-cc--box .stdv-cc__modal {
        width: 100%;
        max-width: 100%;
        margin: 8px;
    }
}

/* -------------------------------------------------------------------------
   Pływający widget „Zarządzaj cookies” (re-open) — [data-stdv-cookies-open]
   ------------------------------------------------------------------------- */
.stdv-cc-fab {
    position: fixed;
    bottom: 20px;
    z-index: 999998;                 /* poniżej modalu (999999) */
    width: 48px;
    height: 48px;
    padding: 0;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid var(--stdv-cc-border, #E5E7EB);
    border-radius: 50%;
    background: var(--stdv-cc-bg, #FFFFFF);
    color: var(--stdv-cc-primary, #2563EB);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stdv-cc-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}
.stdv-cc-fab:focus-visible {
    outline: 2px solid var(--stdv-cc-primary, #2563EB);
    outline-offset: 2px;
}
.stdv-cc-fab svg {
    width: 24px;
    height: 24px;
    display: block;
}
.stdv-cc-fab--br { right: 20px; }
.stdv-cc-fab--bl { left: 20px; }

@media (max-width: 540px) {
    .stdv-cc-fab { width: 44px; height: 44px; bottom: 16px; }
    .stdv-cc-fab--br { right: 16px; }
    .stdv-cc-fab--bl { left: 16px; }
}
