/*
 * maybe-ui.css — struktura wspólnych komponentów Maybe.Wasm (Table, Tabs, ModalShell, LoadedView, ToastContainer…).
 *
 * Wyłącznie tokeny --pw-*: kolory, promienie, odstępy i czcionki daje motyw aplikacji (drappic-theme.css, metro-theme.css…).
 * Host ładuje ten plik PRZED swoim motywem: reguły motywu o tej samej wadze wygrywają, więc aplikacja, której komponent
 * ma wyglądać inaczej (Metro — tabela i okno po staremu), nadpisuje tylko różnicę. Bez Bootstrapa.
 * Adres: _content/Maybe.Wasm/css/maybe-ui.css.
 */

/* === TABLE (Table) === */
.pw-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.pw-table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    font-size: var(--pw-text-body);
    color: var(--pw-text);
}

.pw-table th,
.pw-table td {
    padding: 0.625rem 0.75rem;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--pw-line-soft, var(--pw-border));
}

.pw-table th {
    font-size: var(--pw-text-small);
    font-weight: 600;
    color: var(--pw-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    border-bottom: 1px solid var(--pw-border);
    user-select: none;
}

.pw-table tbody tr:last-child th,
.pw-table tbody tr:last-child td {
    border-bottom: none;
}

.pw-table tbody tr:hover td {
    background-color: var(--pw-bg-hover, var(--pw-bg-light));
}

.pw-table--compact th,
.pw-table--compact td {
    padding: 0.375rem 0.5rem;
}

.pw-table--striped > tbody > tr:nth-child(even) {
    background: var(--pw-table-stripe, var(--pw-bg-light));
}

.pw-table__empty {
    text-align: center;
}

.pw-table__row--clickable {
    cursor: pointer;
}

.pw-table__row--deleted > td {
    color: var(--pw-text-light, var(--pw-text-muted));
    text-decoration: line-through;
}

.pw-table__cell--actions {
    text-align: right;
    white-space: nowrap;
}

/* === TABS (Tabs + TabPage) === */
.pw-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.pw-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    flex: 1;
    min-width: 100px;
    padding: 0.6rem 1rem;
    border: 2px solid var(--pw-border);
    border-radius: var(--pw-radius-sm);
    background: var(--pw-bg-card);
    color: var(--pw-text-muted);
    font: inherit;
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.pw-tab:hover {
    border-color: var(--pw-primary-light, var(--pw-primary));
    color: var(--pw-text);
}

.pw-tab--active,
.pw-tab--active:hover {
    border-color: var(--pw-primary);
    background: var(--pw-primary-subtle);
    color: var(--pw-primary-dark, var(--pw-primary));
    font-weight: 600;
}

.pw-tab--deleted {
    text-decoration: line-through;
    opacity: .6;
}

/* === MODAL (ModalShell, ModalHost, ConfirmDeleteDialog) === */
.pw-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--pw-z-overlay);
}

.pw-modal {
    background: var(--pw-bg-card);
    border-radius: var(--pw-radius);
    box-shadow: var(--pw-shadow-lg);
    min-width: 360px;
    max-width: 90vw;
    /* Overlay tylko centruje — okno wyższe od ekranu przewija się samo, inaczej byłoby przycięte. */
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.pw-modal--lg {
    width: 800px;
}

.pw-modal--xl {
    width: 1140px;
}

.pw-modal-header {
    padding: 1.25rem 1.5rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    user-select: none;
}

.pw-modal-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: var(--pw-text-section);
    font-weight: 600;
    color: var(--pw-text);
    user-select: none;
}

/* Krzyżyk stoi w znaczniku przed tytułem, a na ekranie na końcu nagłówka. */
.pw-modal-close {
    order: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 22px;
    line-height: 1;
    color: var(--pw-text-muted);
    background: transparent;
    border: 0;
    border-radius: var(--pw-radius-sm);
    cursor: pointer;
}

.pw-modal-close:hover,
.pw-modal-close:focus-visible {
    color: var(--pw-text);
    background: var(--pw-bg-light);
    outline: 0;
}

.pw-modal-body {
    padding: 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.pw-modal-footer {
    padding: 0.75rem 1.5rem 1.25rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.pw-modal-overlay--inline {
    position: static;
    display: block;
    padding: 0;
    overflow: visible;
    background: none;
    z-index: auto;
}

.pw-modal-overlay--inline > .pw-modal {
    max-width: 100%;
    min-width: 0;
    margin: 0;
    box-shadow: none;
}

/* === ALERT (LoadedView, ToastContainer, SignOutNotice) === */
.pw-alert {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding: 12px 16px;
    border: 1px solid transparent;
    border-radius: var(--pw-radius);
}

.pw-alert--success {
    color: var(--pw-success-text, var(--pw-success));
    background-color: var(--pw-success-bg, color-mix(in srgb, var(--pw-success) 10%, transparent));
    border-color: var(--pw-success-border, color-mix(in srgb, var(--pw-success) 30%, transparent));
}

.pw-alert--warning {
    color: var(--pw-warning-text, var(--pw-text));
    background-color: var(--pw-warning-bg, color-mix(in srgb, var(--pw-warning) 12%, transparent));
    border-color: var(--pw-warning-border, color-mix(in srgb, var(--pw-warning) 35%, transparent));
}

.pw-alert--info {
    color: var(--pw-info-text, var(--pw-info));
    background-color: var(--pw-info-bg, color-mix(in srgb, var(--pw-info) 10%, transparent));
    border-color: var(--pw-info-border, color-mix(in srgb, var(--pw-info) 30%, transparent));
}

.pw-alert--danger {
    color: var(--pw-danger-text, var(--pw-danger));
    background-color: var(--pw-danger-subtle, color-mix(in srgb, var(--pw-danger) 10%, transparent));
    border-color: var(--pw-danger-border, color-mix(in srgb, var(--pw-danger) 30%, transparent));
}

.pw-loaded-view__retry {
    margin-left: auto;
}

.pw-sign-out-notice {
    align-items: flex-start;
    margin-top: 1rem;
}

/* === TOAST (ToastContainer) — stos w prawym górnym rogu; na telefonie na całą szerokość z odstępem 15 px. === */
.pw-toast-container {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: var(--pw-z-toast, var(--pw-z-dialog));
    width: 360px;
    max-width: calc(100% - 30px);
}

.pw-toast {
    position: relative;
    display: block;
    margin-bottom: 10px;
    padding-right: 35px;
    background-color: var(--pw-bg-card);
    box-shadow: var(--pw-shadow-lg);
}

.pw-toast__close {
    position: absolute;
    top: 6px;
    right: 6px;
}

.pw-toast__title {
    display: block;
    margin-bottom: 2px;
}

/* === SPINNER (InlineSpinner) i LOADING (LoadedView) === */
.pw-spinner {
    display: inline-block;
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    border: 0.2em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: pw-spin .75s linear infinite;
}

.pw-spinner--sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

.pw-spinner--lg {
    width: 2.5rem;
    height: 2.5rem;
    border-width: 0.25em;
}

@keyframes pw-spin {
    to { transform: rotate(360deg); }
}

.pw-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 32px 12px;
    color: var(--pw-text-muted);
    user-select: none;
}

/* === EMPTY STATE (EmptyState) i ERROR CARD (ErrorCard) === */
.pw-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3rem 1.5rem;
    color: var(--pw-text-muted);
    text-align: center;
    user-select: none;
}

.pw-empty-state__icon {
    font-size: 2rem;
    opacity: .5;
}

.pw-empty-state__icon:empty {
    display: none;
}

.pw-error-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 3rem 1.5rem;
    text-align: center;
}

.pw-error-card__icon {
    font-size: 3rem;
    color: var(--pw-danger);
}

.pw-error-card__title {
    margin: 0;
}

.pw-error-card__message {
    margin: 0;
    color: var(--pw-text-muted);
}

/* === TOGGLE (Toggle) === */
.pw-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: var(--pw-control-height, 2.25rem);
    margin: 0;
    font-weight: 400;
    cursor: pointer;
    user-select: none;
}

.pw-toggle__input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.pw-toggle__track {
    position: relative;
    flex-shrink: 0;
    width: 36px;
    height: 20px;
    background: var(--pw-border-input, var(--pw-border));
    border-radius: var(--pw-radius-pill, 999px);
    transition: background-color .15s ease;
}

.pw-toggle__track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--pw-white, #fff);
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.2);
    transition: transform .15s ease;
}

.pw-toggle__input:checked + .pw-toggle__track {
    background: var(--pw-primary);
}

.pw-toggle__input:checked + .pw-toggle__track::after {
    transform: translateX(16px);
}

.pw-toggle__input:focus-visible + .pw-toggle__track {
    box-shadow: var(--pw-focus-ring);
}

.pw-toggle--disabled {
    cursor: default;
    opacity: 0.6;
}

/* === PROGRESS (ProgressBar) === */
.pw-progress {
    position: relative;
    width: 100%;
    height: 4px;
    overflow: hidden;
    background: var(--pw-primary-subtle);
    border-radius: var(--pw-radius-pill, 999px);
}

.pw-progress__bar {
    height: 100%;
    background: var(--pw-primary);
    border-radius: inherit;
    transition: width .2s ease;
}

.pw-progress--indeterminate > .pw-progress__bar {
    position: absolute;
    width: 35%;
    animation: pw-progress-slide 1.1s ease-in-out infinite;
}

@keyframes pw-progress-slide {
    from { left: -35%; }
    to { left: 100%; }
}

/* === FORM (AddressEditor, ContactEditor, PersonalDataEditor, ValidatedTextField, DecimalInput) === */
.pw-form-section-title {
    margin: 0 0 1rem;
    padding-bottom: 0.5rem;
    font-weight: 600;
    color: var(--pw-text-muted);
    border-bottom: 1px solid var(--pw-border);
}

/* Siatka 12 kolumn; na wąskim ekranie każde pole na całą szerokość. */
.pw-form-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.pw-form-grid > * {
    grid-column: span 12;
}

@media (min-width: 768px) {
    .pw-form-grid__cell--3 { grid-column: span 3; }
    .pw-form-grid__cell--6 { grid-column: span 6; }
    .pw-form-grid__cell--9 { grid-column: span 9; }
}

.pw-field-error {
    font-size: var(--pw-text-small);
    color: var(--pw-danger);
}

/* Pole z dopiskiem (jednostka, strzałki kroku): pole rośnie, dopisek trzyma szerokość, zaokrąglenia tylko na zewnątrz. */
.pw-input-group {
    display: flex;
    align-items: stretch;
    width: 100%;
}

.pw-input-group > .pw-input {
    position: relative;
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}

.pw-input-group > .pw-input:focus {
    z-index: 5;
}

.pw-input-group > .pw-input:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.pw-input-group__addon {
    display: flex;
    align-items: center;
    padding: 0 0.6rem;
    margin-left: -1px;
    font-size: var(--pw-text-small);
    color: var(--pw-text-muted);
    background: var(--pw-bg-light);
    border: 1px solid var(--pw-border-input, var(--pw-border));
    white-space: nowrap;
}

.pw-input-group__addon:last-child {
    border-top-right-radius: var(--pw-radius-sm);
    border-bottom-right-radius: var(--pw-radius-sm);
}

/* === COMMUNICATION BUTTONS (EmailButton, SmsButton, PhoneCallButton) === */
.pw-comm-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: var(--pw-radius-sm);
    border: 1.5px solid var(--pw-border);
    background: var(--pw-bg-card);
    color: var(--pw-text-muted);
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
    text-decoration: none;
    user-select: none;
    flex-shrink: 0;
}

.pw-comm-button:hover {
    border-color: var(--pw-primary-light, var(--pw-primary));
    color: var(--pw-primary);
    background: var(--pw-primary-subtle);
}

.pw-comm-button:disabled,
.pw-comm-button[aria-disabled="true"] {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* === GUID CHIP (GuidChip) === */
.pw-guid-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    max-width: 100%;
    font-family: var(--pw-font-mono, Consolas, Menlo, Monaco, 'Courier New', monospace);
    font-size: var(--pw-text-caption, var(--pw-text-small));
    line-height: 1.2;
    color: var(--pw-text-light, var(--pw-text-muted));
    user-select: text;
}

.pw-guid-chip__value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pw-guid-chip__copy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    padding: 0;
    border: none;
    border-radius: var(--pw-radius-sm);
    background: transparent;
    color: inherit;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.pw-guid-chip__copy:hover {
    opacity: 1;
    color: var(--pw-primary);
    background: var(--pw-primary-subtle);
}

.pw-guid-chip__copy:focus-visible {
    outline: 1px solid var(--pw-primary);
    outline-offset: 1px;
}

/* === CULTURE SWITCHER (CultureSwitcher) — kody obok siebie albo lista rozwijana === */
.pw-culture-switcher--pills {
    display: flex;
    gap: 2px;
    background: var(--pw-border);
    border-radius: 6px;
    padding: 2px;
}

.pw-culture-pill {
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
    color: var(--pw-text-muted);
    transition: background 0.15s, color 0.15s;
}

.pw-culture-pill:hover {
    background: rgba(15, 23, 42, 0.08);
    color: var(--pw-primary);
}

.pw-culture-pill.active {
    background: var(--pw-primary);
    color: #fff;
}

.pw-culture-switcher--dropdown {
    position: relative;
}

.pw-culture-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    font: inherit;
    color: inherit;
    white-space: nowrap;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--pw-radius);
    cursor: pointer;
}

.pw-culture-caret {
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 2px;
    vertical-align: middle;
    border-top: 4px solid;
    border-right: 4px solid transparent;
    border-left: 4px solid transparent;
}

.pw-culture-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--pw-z-base, 1);
    padding: 0;
    background: transparent;
    border: none;
    cursor: default;
}

.pw-culture-menu {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: var(--pw-z-popover);
    min-width: 160px;
    margin: 2px 0 0;
    padding: 5px 0;
    font-size: var(--pw-text-body);
    text-align: left;
    list-style: none;
    background-color: var(--pw-bg-card);
    border: 1px solid var(--pw-border);
    border-radius: var(--pw-radius);
    box-shadow: var(--pw-shadow-lg);
}

.pw-culture-option {
    display: flex;
    gap: 8px;
    width: 100%;
    padding: 3px 20px;
    font: inherit;
    color: var(--pw-text);
    white-space: nowrap;
    text-align: left;
    background: transparent;
    border: none;
    cursor: pointer;
}

.pw-culture-option:hover,
.pw-culture-option:focus-visible {
    background-color: var(--pw-bg-light);
}

.pw-culture-option.active {
    color: var(--pw-white, #fff);
    background-color: var(--pw-primary);
}

.pw-culture-option-code {
    min-width: 22px;
    font-weight: 700;
}

/* === GATE (Gate) === */
.pw-gate-disabled {
    position: relative;
    opacity: 0.4;
    pointer-events: none;
}

.pw-gate-info {
    color: var(--pw-info);
    pointer-events: auto;
    cursor: help;
}

.pw-gate-upsell {
    display: block;
    margin-top: 0.25rem;
    font-size: var(--pw-text-small);
    color: var(--pw-text-muted);
}

/* === DECIMAL INPUT (DecimalInput) — strzałki kroku jako dopisek pola === */
.pw-decimal-input__spinners {
    flex-direction: column;
    padding: 0;
    width: 1.25rem;
    overflow: hidden;
}

.pw-decimal-input__spin-btn {
    flex: 1;
    min-height: 0;
    width: 100%;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.5rem;
    color: var(--pw-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    user-select: none;
}

.pw-decimal-input__spin-btn:hover:not([disabled]) {
    background-color: rgba(0, 0, 0, 0.06);
}

.pw-decimal-input__spin-btn[disabled] {
    opacity: 0.4;
    cursor: default;
}

.pw-decimal-input__spin-btn + .pw-decimal-input__spin-btn {
    border-top: 1px solid var(--pw-border);
}

/* === BREADCRUMB (Breadcrumb) === */
.pw-breadcrumb {
    display: block;
}

.pw-breadcrumb__list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--pw-text-small);
    color: var(--pw-text-muted);
    user-select: none;
}

.pw-breadcrumb__item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.pw-breadcrumb__item:not(:last-child)::after {
    content: "›";
    color: var(--pw-text-light);
}

.pw-breadcrumb__link {
    color: var(--pw-text-muted);
    text-decoration: none;
}

.pw-breadcrumb__link:hover {
    color: var(--pw-primary);
    text-decoration: underline;
}

.pw-breadcrumb__current {
    color: var(--pw-text);
    font-weight: 600;
}

/* === BUSY DOTS (BusyDots) === */
/* Wygląd przeniesiony jeden do jednego z panelu asystenta (concierge-panel__busy-dots) — znak pracy ma
   być w całej aplikacji ten sam, żeby użytkownik rozpoznawał go bez czytania. */
.pw-busy-dots {
    display: inline-flex;
    gap: 0.2rem;
    align-items: center;
}

.pw-busy-dots span {
    width: 0.35rem;
    height: 0.35rem;
    border-radius: 999px;
    background: var(--pw-primary);
    animation: pw-busy-bounce 1.2s ease-in-out infinite;
}

.pw-busy-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.pw-busy-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes pw-busy-bounce {
    0%, 60%, 100% {
        opacity: 0.35;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-0.25rem);
    }
}

/* Ruch wyłączony dla osób, którym szkodzi. Zostaje sam rytm przezroczystości — nadal widać,
   że coś trwa, a nic nie skacze po ekranie. */
@media (prefers-reduced-motion: reduce) {
    .pw-busy-dots span {
        animation-duration: 2s;
    }

    @keyframes pw-busy-bounce {
        0%, 60%, 100% {
            opacity: 0.35;
        }

        30% {
            opacity: 1;
        }
    }
}

/* === COMBO BOX (ComboBoxInput) === */
/* Pole z listą podpowiedzi. Kotwica dla listy i dla strzałki — obie stoją względem tego pudełka. */
.pw-combo {
    position: relative;
}

/* Miejsce na strzałkę po prawej, żeby dłuższy wpis pod nią nie wjeżdżał. */
.pw-combo__input {
    padding-right: 1.75rem;
}

.pw-combo__toggle {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--pw-text-muted);
    cursor: pointer;
}

.pw-combo__toggle:hover:not([disabled]) {
    color: var(--pw-text);
}

.pw-combo__toggle[disabled] {
    opacity: 0.5;
    cursor: default;
}

/* Przykrycie na całe okno — łapie kliknięcie poza listą. Leży POD listą (z-index o jeden niżej),
   więc sama lista zostaje klikalna. */
.pw-combo__backdrop {
    position: fixed;
    inset: 0;
    z-index: calc(var(--pw-z-popover) - 1);
}

.pw-combo__menu {
    position: absolute;
    z-index: var(--pw-z-popover);
    top: calc(100% + 0.25rem);
    left: 0;
    right: 0;
    max-height: 14rem;
    margin: 0;
    padding: 0.25rem;
    overflow-y: auto;
    list-style: none;
    border: 1px solid var(--pw-border);
    border-radius: var(--pw-radius-sm);
    background: var(--pw-bg-card);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);

    /* Lista stoi na własnym, jasnym tle — poświata, którą dziedziczy po pasku szkicownika, rozmywałaby
       tu litery zamiast je wyciągać. */
    text-shadow: none;
}

.pw-combo__option {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    width: 100%;
    padding: 0.3rem 0.5rem;
    border: 0;
    border-radius: var(--pw-radius-sm);
    background: transparent;
    color: var(--pw-text);
    font-size: var(--pw-text-body);
    text-align: left;
    cursor: pointer;
}

.pw-combo__option:hover,
.pw-combo__option--active {
    background: var(--pw-bg-soft);
}

.pw-combo__option-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Dopisek przy pozycji — wyjaśnia, co pozycja robi, i nie bierze udziału w zawężaniu listy. */
.pw-combo__option-hint {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--pw-text-caption);
    color: var(--pw-text-muted);
}

/* === FILTERS (FilterBar, FilterControl) === */
.pw-filters {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

/* Wynik i „Wyczyść” siedzą w prawym dolnym rogu kontrolki, pod siatką pól. */
.pw-filters__summary {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

.pw-filters__count {
    font-size: var(--pw-text-small);
    color: var(--pw-text-muted);
    white-space: nowrap;
}

/*
 * Stała liczba kolumn zamiast zawijanego flexa: pola mają stać w równych kolumnach, a nie rozciągać się
 * do szerokości kontrolki, gdy jest ich mniej niż mieści się w wierszu. Powyżej czterech pól siatka sama
 * przenosi nadmiar do kolejnego wiersza.
 */
.pw-filters__fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: end;
    gap: 0.75rem;
}

@media (min-width: 576px) {
    .pw-filters__fields {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 992px) {
    .pw-filters__fields {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Klasy rysowane przez komponent-dziecko FilterControl. */
.pw-filters__range {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.pw-filters__range-separator {
    color: var(--pw-text-muted);
    user-select: none;
}

.pw-filters__multichoice {
    position: relative;
}

.pw-filters__backdrop {
    position: fixed;
    inset: 0;
    z-index: calc(var(--pw-z-dropdown) - 1);
}

.pw-filters__dropdown {
    position: absolute;
    z-index: var(--pw-z-dropdown);
    top: calc(100% + 0.25rem);
    left: 0;
    min-width: 100%;
    max-height: 16rem;
    overflow-y: auto;
    padding: 0.25rem;
    border: 1px solid var(--pw-border);
    border-radius: var(--pw-radius-sm);
    background: var(--pw-bg-card);
    box-shadow: var(--pw-shadow-card);
}

.pw-filters__dropdown-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    border-radius: var(--pw-radius-sm);
    font-weight: normal;
    cursor: pointer;
}

.pw-filters__dropdown-option:hover {
    background: var(--pw-bg-soft);
}

/* === COLOR PALETTE (ColorPalettePicker) === */
.pw-color-palette-picker {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.pw-color-palette-picker__grid {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.pw-color-palette-picker__row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.pw-color-palette-picker__row--grayscale {
    margin-top: 0.375rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--pw-border);
}

.pw-color-palette-picker__swatch {
    position: relative;
    flex: 0 0 auto;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: 1px solid var(--pw-overlay-border);
    border-radius: var(--pw-radius-sm);
    cursor: pointer;
    user-select: none;
    transition: transform 0.1s ease;
}

.pw-color-palette-picker__swatch:hover:not(:disabled) {
    transform: scale(1.08);
}

.pw-color-palette-picker__swatch:focus-visible {
    outline: 2px solid var(--pw-primary);
    outline-offset: 2px;
}

.pw-color-palette-picker__swatch:disabled {
    cursor: default;
    opacity: 0.5;
}

.pw-color-palette-picker__swatch--selected {
    border: 2px solid var(--pw-primary);
    box-shadow: 0 0 0 2px var(--pw-bg-card), 0 0 0 4px var(--pw-primary);
}

.pw-color-palette-picker__swatch-check {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.pw-color-palette-picker__swatch-check-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: var(--pw-primary);
    color: var(--pw-white);
    box-shadow: var(--pw-shadow-card);
}

.pw-color-palette-picker__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.pw-color-palette-picker__custom-label,
.pw-color-palette-picker__hex-label {
    font-size: var(--pw-text-small);
    color: var(--pw-text-muted);
}

.pw-color-palette-picker__custom-input {
    width: 2.5rem;
    height: 2rem;
    padding: 0.125rem;
    border: 1px solid var(--pw-border);
    border-radius: var(--pw-radius-sm);
    background: var(--pw-bg-card);
    cursor: pointer;
}

.pw-color-palette-picker__custom-input:disabled {
    cursor: default;
    opacity: 0.5;
}

.pw-color-palette-picker__hex-input {
    width: 7rem;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--pw-border);
    border-radius: var(--pw-radius-sm);
    background: var(--pw-bg-card);
    color: var(--pw-text);
    font-size: var(--pw-text-body);
}

.pw-color-palette-picker__hex-input:disabled {
    opacity: 0.5;
}

.pw-color-palette-picker__clear:disabled {
    cursor: default;
}

@media (max-width: 640.98px) {
    .pw-color-palette-picker__swatch {
        width: 1.5rem;
        height: 1.5rem;
    }
}

/* === COLOR INPUT (ColorInput) === */
.pw-color-input {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.pw-color-input__palette {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pw-color-input__swatch {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 2px solid var(--pw-white);
    border-radius: 50%;
    box-shadow: 0 0 0 1px var(--pw-overlay-border);
    cursor: pointer;
    transition: transform .1s ease;
}

.pw-color-input__swatch:hover:not(:disabled) {
    transform: scale(1.12);
}

.pw-color-input__swatch--selected {
    box-shadow: 0 0 0 2px var(--pw-primary);
}

.pw-color-input__custom {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-weight: 400;
}

.pw-color-input__picker {
    width: 30px;
    height: 30px;
    padding: 0;
    background: none;
    border: 1px solid var(--pw-border-input);
    border-radius: var(--pw-radius-sm);
    cursor: pointer;
}

.pw-color-input__hex {
    width: 96px;
    font-family: var(--pw-font-mono);
}

/* === BUSY OVERLAY (BusyOverlay) === */
.pw-busy-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--pw-z-busy);
    display: grid;
    place-items: center;
    background: rgba(17, 24, 39, 0.35);
    backdrop-filter: blur(4px);
}

.pw-busy-box {
    min-width: 220px;
    max-width: 90vw;
    padding: 1.25rem 1.5rem;
    border-radius: var(--pw-radius);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--pw-shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.pw-busy-spinner {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 4px solid rgba(31, 41, 55, 0.2);
    border-top-color: rgba(31, 41, 55, 0.9);
    animation: pw-busy-spin 0.9s linear infinite;
}

.pw-busy-text {
    font-size: var(--pw-text-body);
    font-weight: 600;
    color: var(--pw-text);
    text-align: center;
}

@keyframes pw-busy-spin {
    to {
        transform: rotate(360deg);
    }
}

/* === NUMBER INPUT (NumberInput) === */
.pw-number-input {
    display: flex;
    align-items: stretch;
    width: 100%;
    max-width: 180px;
    height: var(--pw-control-height);
    background: var(--pw-bg-card);
    border: 1px solid var(--pw-border-input);
    border-radius: var(--pw-radius-sm);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.pw-number-input:focus-within {
    border-color: var(--pw-primary);
    box-shadow: var(--pw-focus-ring);
}

.pw-number-input--disabled {
    background: var(--pw-bg-light);
}

.pw-number-input__field {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    text-align: center;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    font-variant-numeric: tabular-nums;
    appearance: textfield;
}

.pw-number-input__field:focus {
    border: 0;
    box-shadow: none;
}

.pw-number-input__field::-webkit-outer-spin-button,
.pw-number-input__field::-webkit-inner-spin-button {
    margin: 0;
    appearance: none;
}

.pw-number-input__unit {
    display: flex;
    align-items: center;
    padding-right: 6px;
    font-size: var(--pw-text-small);
    color: var(--pw-text-muted);
    user-select: none;
}

.pw-number-input__step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    padding: 0;
    font-size: var(--pw-text-small);
    color: var(--pw-text-muted);
    background: transparent;
    border: 0;
    cursor: pointer;
}

.pw-number-input__step:hover:not(:disabled) {
    color: var(--pw-primary);
    background: var(--pw-primary-subtle);
}

.pw-number-input__step:first-child {
    border-right: 1px solid var(--pw-border);
    border-radius: var(--pw-radius-sm) 0 0 var(--pw-radius-sm);
}

.pw-number-input__step:last-child {
    border-left: 1px solid var(--pw-border);
    border-radius: 0 var(--pw-radius-sm) var(--pw-radius-sm) 0;
}

.pw-number-input__step:disabled {
    opacity: .4;
    cursor: not-allowed;
}

/* === RICH TEXT (RichTextEditor) === */
/* Ramka edytora w stylu pola (.pw-input): pasek przycisków nad paskiem Quilla, treść min. 240 px. Wnętrze tworzy Quill. */
.pw-rich-text {
    display: flex;
    flex-direction: column;
    background: var(--pw-bg-card);
    border: 1px solid var(--pw-border-input);
    border-radius: var(--pw-radius-sm);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.pw-rich-text:focus-within {
    border-color: var(--pw-primary);
    box-shadow: var(--pw-focus-ring);
}

.pw-rich-text--invalid {
    border-color: var(--pw-danger);
}

.pw-rich-text__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: var(--pw-bg-soft);
    border-bottom: 1px solid var(--pw-border);
    border-radius: var(--pw-radius-sm) var(--pw-radius-sm) 0 0;
}

.pw-rich-text__spacer {
    flex: 1 1 auto;
}

.pw-rich-text__source {
    min-height: 240px;
    font-family: var(--pw-font-mono);
    font-size: var(--pw-text-small);
    border: 0;
    border-radius: 0 0 var(--pw-radius-sm) var(--pw-radius-sm);
}

.pw-rich-text__source:focus {
    box-shadow: none;
}

.pw-rich-text__host--hidden {
    display: none;
}

.pw-rich-text__host .ql-toolbar.ql-snow {
    font-family: var(--pw-font);
    border: 0;
    border-bottom: 1px solid var(--pw-border);
}

.pw-rich-text__host .ql-container.ql-snow {
    font-family: var(--pw-font);
    font-size: var(--pw-text-body);
    border: 0;
}

.pw-rich-text__host .ql-editor {
    min-height: 240px;
    max-height: 60vh;
    line-height: 1.6;
}

.pw-rich-text__host .ql-editor img,
.pw-rich-text__host .ql-editor video {
    max-width: 100%;
    height: auto;
    border-radius: var(--pw-radius-sm);
}

.pw-rich-text__host .ql-editor.ql-blank::before {
    font-style: normal;
    color: var(--pw-text-placeholder);
}

.pw-rich-text__host .ql-snow .ql-stroke {
    stroke: var(--pw-text-plate);
}

.pw-rich-text__host .ql-snow .ql-fill {
    fill: var(--pw-text-plate);
}

.pw-rich-text__host .ql-snow button:hover .ql-stroke,
.pw-rich-text__host .ql-snow .ql-active .ql-stroke {
    stroke: var(--pw-primary);
}

.pw-rich-text__host .ql-snow button:hover .ql-fill,
.pw-rich-text__host .ql-snow .ql-active .ql-fill {
    fill: var(--pw-primary);
}
