/* ========== Motyw ciemny ========== */
html[data-pk-theme='dark'] {
    --pk-bg: #0f172a;
    --pk-surface: #1e293b;
    --pk-border: #334155;
    --pk-text: #f1f5f9;
    --pk-text-muted: #94a3b8;
    /* Nie nadpisuj --pk-btn-default-* / accent / link — to kolory firmowe z RCS */
    color-scheme: dark;
}

html[data-pk-theme='dark'] .pk-sidebar {
    background: var(--pk-surface);
}

html[data-pk-theme='dark'] .pk-field input,
html[data-pk-theme='dark'] .pk-form-grid .pk-field input,
html[data-pk-theme='dark'] .pk-search__input,
html[data-pk-theme='dark'] .pk-select {
    background: #0f172a;
    color: var(--pk-text);
    border-color: var(--pk-border);
}

html[data-pk-theme='dark'] .pk-topbar-select {
    background-color: #0f172a;
    color: #f1f5f9;
    border-color: var(--pk-border);
    color-scheme: dark;
}

html[data-pk-theme='dark'] .pk-topbar-select:hover,
html[data-pk-theme='dark'] .pk-topbar-select:focus,
html[data-pk-theme='dark'] .pk-topbar-select:focus-visible,
html[data-pk-theme='dark'] .pk-topbar-select:active {
    background-color: #334155;
    color: #f8fafc;
    border-color: #64748b;
}

html[data-pk-theme='dark'] .pk-topbar-select option {
    background-color: #1e293b;
    color: #f8fafc;
}

html[data-pk-theme='dark'] .pk-topbar__logout {
    background: var(--pk-btn-default-bg);
    color: var(--pk-btn-default-text);
    border-color: color-mix(in srgb, var(--pk-nav-text, #fff) 25%, transparent);
}

html[data-pk-theme='dark'] .pk-topbar__logout:hover {
    filter: brightness(1.08);
}

html[data-pk-theme='light'] .pk-topbar-select {
    color-scheme: light;
}

/* ========== WCAG — skala tekstu (panel + RCS) ========== */
html.pk-a11y-text-lg {
    font-size: 18px;
}

html.pk-a11y-text-xl {
    font-size: 20px;
}

html.pk-a11y-line-height body,
html.pk-a11y-line-height .pk-rcs-injected {
    line-height: 1.65 !important;
}

html.pk-a11y-text-spacing body {
    letter-spacing: 0.04em;
    word-spacing: 0.12em;
}

html.pk-a11y-readable-font body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-variant-numeric: lining-nums;
}

/* ========== WCAG — kontrast i kolory ========== */
html.pk-a11y-contrast {
    --pk-border: #0f172a;
    --pk-text: #000;
    --pk-text-muted: #1e293b;
    --pk-accent: #1d4ed8;
    --pk-link: #1e3a8a;
}

html.pk-a11y-contrast[data-pk-theme='dark'] {
    --pk-text: #fff;
    --pk-text-muted: #f1f5f9;
    --pk-border: #fff;
    --pk-bg: #000;
    --pk-surface: #0a0a0a;
    --pk-link: #93c5fd;
}

html.pk-a11y-contrast .pk-card,
html.pk-a11y-contrast .pk-topbar-select,
html.pk-a11y-contrast .pk-list-card {
    border-width: 2px;
}

html.pk-a11y-grayscale body {
    filter: grayscale(1);
}

html.pk-a11y-grayscale .pk-topbar--viewport,
html.pk-a11y-grayscale .pk-credit-bar--viewport {
    filter: grayscale(1);
}

/* ========== WCAG — linki (w tym RCS HTML) ========== */
html.pk-a11y-underline-links a {
    text-decoration: underline !important;
    text-underline-offset: 0.15em;
}

html.pk-a11y-highlight-links a {
    background-color: #fef08a !important;
    color: #1e3a8a !important;
    padding: 0 2px;
    border-radius: 2px;
}

html.pk-a11y-contrast.pk-a11y-highlight-links a {
    background-color: #ff0 !important;
    color: #000 !important;
}

/* ========== WCAG — fokus i cele dotykowe ========== */
html.pk-a11y-strong-focus :focus-visible {
    outline: 3px solid #f59e0b !important;
    outline-offset: 3px;
}

html.pk-a11y-large-targets .pk-btn,
html.pk-a11y-large-targets .pk-nav__link,
html.pk-a11y-large-targets .pk-topbar-select,
html.pk-a11y-large-targets .pk-chip,
html.pk-a11y-large-targets .pk-rental-row {
    min-height: 44px;
}

html.pk-a11y-large-targets .pk-rcs-injected a,
html.pk-a11y-large-targets .pk-rcs-injected button {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    box-sizing: border-box;
}

/* ========== WCAG — ruch ========== */
html.pk-a11y-reduce-motion *,
html.pk-a11y-reduce-motion *::before,
html.pk-a11y-reduce-motion *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
}

/* ========== WCAG — obrazy ========== */
html.pk-a11y-hide-images img:not([role='presentation']):not([alt='']) {
    opacity: 0.15;
}

html.pk-a11y-hide-images .pk-rcs-injected img[alt=''],
html.pk-a11y-hide-images .pk-rcs-injected img:not([alt]) {
    visibility: hidden;
    height: 0;
    width: 0;
    overflow: hidden;
}

/*
 * Nagłówek i stopka HTML z RCS (inline style) — wymuszenie dostępności
 * gdy aktywne są klasy WCAG na <html>
 */
html.pk-a11y-text-lg .pk-rcs-injected,
html.pk-a11y-text-xl .pk-rcs-injected {
    font-size: inherit !important;
}

html.pk-a11y-text-spacing .pk-rcs-injected,
html.pk-a11y-text-spacing .pk-rcs-injected p,
html.pk-a11y-text-spacing .pk-rcs-injected span,
html.pk-a11y-text-spacing .pk-rcs-injected a,
html.pk-a11y-text-spacing .pk-rcs-injected li,
html.pk-a11y-text-spacing .pk-rcs-injected div {
    letter-spacing: 0.04em !important;
    word-spacing: 0.12em !important;
}

html.pk-a11y-readable-font .pk-rcs-injected,
html.pk-a11y-readable-font .pk-rcs-injected * {
    font-family: inherit !important;
}

html.pk-a11y-contrast .pk-rcs-injected {
    background: #fff !important;
    color: #000 !important;
    border-color: #000 !important;
}

html.pk-a11y-contrast[data-pk-theme='dark'] .pk-rcs-injected {
    background: #000 !important;
    color: #fff !important;
    border-color: #fff !important;
}

html.pk-a11y-contrast .pk-rcs-injected * {
    background-color: transparent !important;
    color: inherit !important;
    border-color: currentColor !important;
    text-shadow: none !important;
    box-shadow: none !important;
}

html.pk-a11y-contrast .pk-rcs-injected a {
    color: #1e40af !important;
    font-weight: 700 !important;
}

html.pk-a11y-contrast[data-pk-theme='dark'] .pk-rcs-injected a {
    color: #93c5fd !important;
}

html[data-pk-theme='dark']:not(.pk-a11y-contrast) .pk-rcs-injected {
    background: #1e293b !important;
    color: #f1f5f9 !important;
}

html[data-pk-theme='dark']:not(.pk-a11y-contrast) .pk-rcs-injected * {
    color: inherit !important;
}

html[data-pk-theme='dark']:not(.pk-a11y-contrast) .pk-rcs-injected a {
    color: #93c5fd !important;
}

html.pk-a11y-grayscale .pk-rcs-injected {
    filter: grayscale(1);
}

html.pk-a11y-reduce-motion .pk-rcs-injected * {
    animation: none !important;
    transition: none !important;
}

/* ========== Pasek górny — preferencje sesji ========== */
.pk-topbar__prefs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.pk-topbar__pref {
    display: flex;
    align-items: center;
    margin: 0;
}

.pk-topbar-select {
    appearance: none;
    background: var(--pk-surface);
    border: 1px solid var(--pk-border);
    color: var(--pk-text);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 8px;
    cursor: pointer;
    line-height: 1.2;
}

.pk-topbar-select:hover,
.pk-topbar-select:focus-visible {
    background: var(--pk-btn-default-bg);
    border-color: color-mix(in srgb, var(--pk-accent) 35%, var(--pk-border));
}

.pk-topbar-select--btn {
    min-width: 64px;
}

.pk-topbar__user-link {
    color: inherit;
    text-decoration: none;
    font-size: 0.8125rem;
    white-space: nowrap;
    padding: 4px 8px;
    border-radius: 8px;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pk-topbar__user-link:hover {
    background: color-mix(in srgb, var(--pk-text) 6%, transparent);
    text-decoration: underline;
}

.pk-topbar__user-email {
    font-weight: 600;
}

.pk-a11y-wrap {
    position: relative;
}

.pk-a11y-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 300;
    width: min(320px, calc(100vw - 24px));
    max-height: min(70vh, 520px);
    overflow-y: auto;
    padding: 14px 16px;
    background: #1e293b;
    color: #f8fafc;
    border: 1px solid #475569;
    border-radius: var(--pk-radius-lg);
    box-shadow: var(--pk-shadow-lg);
}

.pk-a11y-panel__title {
    margin: 0 0 6px;
    font-size: 0.875rem;
    font-weight: 700;
}

.pk-a11y-panel__hint {
    margin: 0 0 12px;
    font-size: 0.6875rem;
    line-height: 1.4;
    opacity: 0.85;
}

.pk-a11y-fieldset {
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 10px 12px 8px;
    margin: 0 0 10px;
}

.pk-a11y-fieldset legend {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0 4px;
}

.pk-a11y-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
    font-size: 0.75rem;
}

.pk-a11y-select {
    font-family: inherit;
    font-size: 0.8125rem;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #64748b;
    background: #0f172a;
    color: #f8fafc;
}

.pk-a11y-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.8125rem;
    margin-bottom: 6px;
    cursor: pointer;
    line-height: 1.35;
}

.pk-a11y-check:last-child {
    margin-bottom: 0;
}

.pk-a11y-panel__actions {
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.pk-a11y-reset {
    width: 100%;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.pk-a11y-reset:hover {
    background: rgba(255, 255, 255, 0.08);
}

.pk-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.pk-topbar-select--theme {
    min-width: 0;
}

.pk-topbar__a11y-label--compact {
    display: none;
}

@media (max-width: 900px) {
    .pk-topbar__prefs {
        gap: 6px;
    }

    .pk-topbar-select {
        padding: 5px 8px;
        font-size: 0.75rem;
    }

    .pk-topbar-select--theme {
        width: auto;
        min-width: 0;
        padding-left: 8px;
        padding-right: 8px;
    }

    .pk-topbar__a11y-label--full {
        display: none;
    }

    .pk-topbar__a11y-label--compact {
        display: inline;
    }

    .pk-topbar-select--btn {
        min-width: auto;
        padding-left: 8px;
        padding-right: 8px;
    }
}
