/* Shared form accessibility and responsive layouts retain the original button palette and sizes. */
[data-bs-theme="dark"] :is(.form-control, .form-select):where(:not(:focus):not(.is-invalid):not(.is-valid):not(.was-validated *)) {
  border-color: #747474;
}
body a:focus-visible, body button:focus-visible, summary:focus-visible {
  outline: 3px solid var(--pe-body-color, #176baf);
  outline-offset: 3px;
}
.deviz-subtotals { flex-wrap: wrap; min-width: 0; max-width: 100%; }
.deviz-subtotals .badge { white-space: normal; }
.ui-filters-summary { display: none; }
/* Controls must fit their cells, including columns with inline width limits. */
.ui-entry-table :is(input.form-control, textarea.form-control, select.form-select) {
  min-width: 0;
  max-width: 100%;
}
.wa-details > summary { cursor: pointer; font-weight: 600; }
.wa-details[open] > summary { margin-bottom: 1rem; }
.notification-title-link { color: inherit; text-decoration: none; }
.notification-title-link:hover { text-decoration: underline; }
.notification-message-details > summary { list-style: none; cursor: pointer; }
.notification-message-details > summary::-webkit-details-marker { display: none; }
.notification-message-preview { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.notification-message-full { white-space: pre-wrap; overflow-wrap: anywhere; }
.notification-message-details .notification-collapse-label,
.notification-message-details[open] .notification-message-preview,
.notification-message-details[open] .notification-expand-label { display: none; }
.notification-message-details[open] .notification-collapse-label { display: inline; }
.notification-expand-label, .notification-collapse-label { font-size: .875rem; text-decoration: underline; }

/* Flatpickr remains the date/range/time picker; only its dark palette changes. */
[data-bs-theme="dark"] .flatpickr-calendar {
  background: #282828;
  color: #dee2e6;
  outline: 1px solid #747474;
  box-shadow: 0 5px 20px #0008;
}
[data-bs-theme="dark"] .flatpickr-calendar :is(.flatpickr-month, .flatpickr-weekday, .flatpickr-current-month, .numInputWrapper, .flatpickr-time input, .flatpickr-time .flatpickr-time-separator, .flatpickr-time .flatpickr-am-pm) {
  color: #dee2e6;
  background: transparent;
}
[data-bs-theme="dark"] .flatpickr-current-month :is(select.flatpickr-monthDropdown-months, option) { background: #282828; color: #dee2e6; }
[data-bs-theme="dark"] .flatpickr-day { color: #dee2e6; }
[data-bs-theme="dark"] .flatpickr-day:is(.prevMonthDay, .nextMonthDay, .flatpickr-disabled),
[data-bs-theme="dark"] .flatpickr-day.flatpickr-disabled:hover { color: #969696; }
[data-bs-theme="dark"] .flatpickr-day:not(.flatpickr-disabled):is(:hover, :focus) { background: #454545; border-color: #888; }
[data-bs-theme="dark"] .flatpickr-day:is(.selected, .startRange, .endRange),
[data-bs-theme="dark"] .flatpickr-day:is(.selected, .startRange, .endRange):is(:hover, :focus) { background: #b51f2d; border-color: #b51f2d; color: #fff; }
[data-bs-theme="dark"] .flatpickr-day.inRange { background: #503336; border-color: #503336; box-shadow: -5px 0 0 #503336, 5px 0 0 #503336; }
[data-bs-theme="dark"] .flatpickr-months :is(.flatpickr-prev-month, .flatpickr-next-month) { color: #dee2e6; fill: #dee2e6; }
[data-bs-theme="dark"] .flatpickr-calendar.arrowTop::after { border-bottom-color: #282828; }
[data-bs-theme="dark"] .flatpickr-calendar.arrowBottom::after { border-top-color: #282828; }
[data-bs-theme="dark"] .flatpickr-time { border-top-color: #747474; }
[data-bs-theme="dark"] .flatpickr-time :is(input:hover, input:focus, .flatpickr-am-pm:hover, .flatpickr-am-pm:focus) { background: #454545; }

@media (max-width: 767.98px) {
  .app-wrapper .ui-table-checkbox .form-check-input { min-height: 24px; min-width: 24px; margin: 10px; }
  .ui-filters { margin-bottom: 1rem; }
  .ui-filters-summary {
    display: list-item;
    padding: .7rem 1rem;
    border: 1px solid var(--pe-border-color, #747474);
    border-radius: .5rem;
    font-weight: 600;
    cursor: pointer;
  }
  .ui-filters[open] > summary { margin-bottom: 1rem; }
  .ui-client-search { flex-wrap: wrap; gap: .5rem; }
  .ui-client-search > .form-control { flex: 1 0 100%; width: 100%; border-radius: var(--pe-border-radius) !important; }
  .ui-client-search > .btn { margin-left: 0 !important; border-radius: var(--pe-border-radius) !important; }
  .notification-preferences .pref-channel-unavailable { display: none; }
  .notification-preferences .pref-channel-app { width: 5.5rem !important; }
  .notification-preferences td:first-child { overflow-wrap: anywhere; }
  .notification-preferences td:first-child .d-flex > div { min-width: 0; }

  /* Reuse the actual cells/controls: no cloned forms, ids, inputs or handlers. */
  .ui-mobile-table { display: block; width: 100% !important; min-width: 0 !important; white-space: normal !important; }
  .ui-mobile-table thead { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
  .ui-mobile-table tbody, .ui-mobile-table tfoot { display: block; width: 100%; }
  .ui-mobile-table tbody > tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
    padding: 1rem;
    margin-bottom: .75rem;
    border: 1px solid var(--pe-border-color, var(--line, #747474));
    border-radius: .5rem;
    background: var(--pe-secondary-bg, var(--card, transparent));
  }
  .ui-mobile-table tbody > tr > td {
    display: block;
    min-width: 0 !important;
    max-width: none !important;
    width: auto !important;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
    overflow-wrap: anywhere;
    white-space: normal !important;
    text-align: start !important;
  }
  .ui-mobile-table tbody > tr > td::before { content: attr(data-col-label); display: block; font-size: .8rem; font-weight: 600; margin-bottom: .25rem; color: var(--pe-secondary-color, var(--muted, inherit)); }
  .ui-mobile-table :is(.ui-table-description, .ui-table-identity, .ui-table-actions, .ui-table-full-row) { grid-column: 1 / -1; }
  .ui-mobile-table .ui-table-identity { order: -1; font-weight: 600; }
  .ui-table-select-all thead input[type="checkbox"] { width: 24px; height: 24px; margin: 10px; }
  .ui-mobile-table .ui-table-full-row::before { display: none; }
  .ui-mobile-table .ui-table-actions > .btn { margin: .25rem; }
  .ui-entry-table :is(input.form-control, textarea.form-control, select.form-select) { width: 100%; min-width: 0; max-width: 100%; font-size: 16px; }
  .ui-entry-table textarea { min-height: 5rem; }
  .ui-mobile-table tfoot > tr { display: flex; flex-wrap: wrap; gap: .75rem; padding: .75rem; }
  .ui-mobile-table tfoot > tr > td { border: 0; padding: .25rem; }
  .ui-mobile-table tfoot > tr > td[data-col-label]::before { content: attr(data-col-label); display: block; font-size: .8rem; font-weight: 400; }
  .ui-mobile-table tfoot > tr > td.ui-table-empty-total { display: none; }
  .ui-table-select-all thead { position: static; width: auto; height: auto; clip-path: none; overflow: visible; display: block; }
  .ui-table-select-all thead tr { display: block; }
  .ui-table-select-all thead th { display: none; }
  .ui-table-select-all thead th:has(input[type="checkbox"]) { display: flex; align-items: center; gap: .75rem; padding: .75rem; width: auto !important; min-width: 0 !important; }
  .ui-table-select-all thead th:has(input[type="checkbox"])::after { content: 'Selectează toate'; }
  .ath-table-scroll:has(.ui-mobile-table) .ath-top-scroll { display: none; }
}
