/* Rebbify — correção de contraste claro/escuro (2026-10-06)
   Camada final e conservadora: não altera layout, dimensões nem regras de negócio. */

html[data-theme="light"] {
    color-scheme: light;
}
html[data-theme="dark"] {
    color-scheme: dark;
}

/* Utilitários Bootstrap/legados com cores fixas precisam acompanhar o tema. */
html[data-theme="dark"] :is(.rebbify-public-ui,.rebbify-passenger-ui) :is(.text-dark,.text-black,.text-body,.text--black,.text--dark) {
    color: var(--rb-text, #f5f5f8) !important;
}
html[data-theme="dark"] :is(.rebbify-public-ui,.rebbify-passenger-ui) :is(.text-muted,.text-secondary,.text--muted,.form-text) {
    color: var(--rb-muted, #c2c2cc) !important;
}
html[data-theme="dark"] :is(.rebbify-public-ui,.rebbify-passenger-ui) :is(.bg-white,.bg-light) {
    background-color: var(--rb-solid, #18181d) !important;
    color: var(--rb-text, #f5f5f8) !important;
}

/* Superfícies padrões que costumavam manter fundo claro/escuro fixo. */
html[data-theme="dark"] :is(.rebbify-public-ui,.rebbify-passenger-ui) :is(
    .card,.common-card,.modal-content,.offcanvas,.dropdown-menu,.list-group-item,
    .accordion-item,.accordion-button,.toast,.popover,.pagination .page-link
) {
    background-color: var(--rb-solid, #18181d) !important;
    color: var(--rb-text, #f5f5f8) !important;
    border-color: var(--rb-border, #32323b) !important;
}
html[data-theme="dark"] :is(.rebbify-public-ui,.rebbify-passenger-ui) .accordion-button:not(.collapsed) {
    background-color: var(--rb-selected, #211d2b) !important;
    color: var(--rb-text, #f5f5f8) !important;
}
html[data-theme="dark"] :is(.rebbify-public-ui,.rebbify-passenger-ui) :is(.card-header,.card-footer,.modal-header,.modal-footer,.offcanvas-header) {
    background-color: var(--rb-solid, #18181d) !important;
    color: var(--rb-text, #f5f5f8) !important;
    border-color: var(--rb-border, #32323b) !important;
}

/* Inputs, selects e plugins. Mantém texto e placeholder legíveis nos dois temas. */
html[data-theme="dark"] :is(.rebbify-public-ui,.rebbify-passenger-ui) :is(
    .form-control,.form--control,.form-select,textarea,input[type="text"],input[type="email"],
    input[type="password"],input[type="number"],input[type="tel"],input[type="search"],input[type="url"],
    .input-group-text,.select2-selection,.select2-dropdown,.select2-search__field
) {
    background-color: var(--rb-solid, #18181d) !important;
    color: var(--rb-text, #f5f5f8) !important;
    border-color: var(--rb-border, #32323b) !important;
}
html[data-theme="dark"] :is(.rebbify-public-ui,.rebbify-passenger-ui) :is(input,textarea)::placeholder {
    color: var(--rb-muted, #9494a1) !important;
    opacity: 1;
}
html[data-theme="dark"] :is(.rebbify-public-ui,.rebbify-passenger-ui) .select2-container--default .select2-results__option {
    background: var(--rb-solid, #18181d) !important;
    color: var(--rb-text, #f5f5f8) !important;
}
html[data-theme="dark"] :is(.rebbify-public-ui,.rebbify-passenger-ui) .select2-container--default :is(
    .select2-results__option--selected,.select2-results__option--highlighted.select2-results__option--selectable
) {
    background: var(--rb-selected, #211d2b) !important;
    color: var(--rb-text, #f5f5f8) !important;
}

/* Tabelas e menus contextuais. */
html[data-theme="dark"] :is(.rebbify-public-ui,.rebbify-passenger-ui) .table {
    --bs-table-bg: var(--rb-solid, #18181d);
    --bs-table-color: var(--rb-text, #f5f5f8);
    --bs-table-border-color: var(--rb-border, #32323b);
    --bs-table-striped-bg: var(--rb-soft, #24242b);
    --bs-table-striped-color: var(--rb-text, #f5f5f8);
    --bs-table-hover-bg: var(--rb-selected, #211d2b);
    --bs-table-hover-color: var(--rb-text, #f5f5f8);
    color: var(--rb-text, #f5f5f8) !important;
}
html[data-theme="dark"] :is(.rebbify-public-ui,.rebbify-passenger-ui) .table :is(th,td) {
    color: var(--rb-text, #f5f5f8) !important;
    border-color: var(--rb-border, #32323b) !important;
}
html[data-theme="dark"] :is(.rebbify-public-ui,.rebbify-passenger-ui) :is(.dropdown-item,.list-group-item-action,.page-link) {
    color: var(--rb-text, #f5f5f8) !important;
}
html[data-theme="dark"] :is(.rebbify-public-ui,.rebbify-passenger-ui) :is(.dropdown-item,.list-group-item-action,.page-link):hover {
    background-color: var(--rb-soft, #24242b) !important;
    color: var(--rb-text, #f5f5f8) !important;
}

/* Elementos desabilitados/readonly não podem voltar a texto preto. */
html[data-theme="dark"] :is(.rebbify-public-ui,.rebbify-passenger-ui) :is(input,textarea,select,.form-control,.form-select):disabled,
html[data-theme="dark"] :is(.rebbify-public-ui,.rebbify-passenger-ui) :is(input,textarea,.form-control)[readonly] {
    background-color: var(--rb-soft, #24242b) !important;
    color: var(--rb-muted, #c2c2cc) !important;
    opacity: 1;
}

/* Fechar modais/offcanvas no fundo escuro. */
html[data-theme="dark"] :is(.rebbify-public-ui,.rebbify-passenger-ui) .btn-close {
    filter: invert(1) grayscale(1) brightness(1.8);
}

/* Tema claro: impede herança de texto branco em superfícies claras nos componentes básicos. */
html[data-theme="light"] :is(.rebbify-public-ui,.rebbify-passenger-ui) :is(.card,.common-card,.modal-content,.dropdown-menu,.offcanvas,.accordion-item) {
    color: var(--rb-text, #202027);
}
