/* =============================================
   GLOBALNE NADPISANIA MOTYWU
   ---------------------------------------------
   Ten plik jest celowo ładowany również w stopkach.
   Dzięki temu wygrywa z lokalnymi <style> w pojedynczych widokach.
   ============================================= */

:root,
[data-theme="light"] {
  --surface-0: #ffffff;
  --surface-1: #f8fafc;
  --surface-2: #eef2f7;
  --surface-3: #e2e8f0;
  --text-main: #1f2937;
  --text-light: #64748b;
  --text-muted: #6b7280;
  --border-color: rgba(15, 23, 42, 0.12);
  --border-strong: #cbd5e1;
  --input-bg: #ffffff;
  --input-text: #111827;
  --input-placeholder: #6b7280;
  --focus-ring: rgba(59, 130, 246, 0.35);
  --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg-body: #0b1220;
  --bg-light: #111827;
  --bg-panel: #162033;
  --surface-0: #0b1220;
  --surface-1: #111827;
  --surface-2: #162033;
  --surface-3: #1f2a3d;
  --text-main: #e5e7eb;
  --text-light: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: rgba(226, 232, 240, 0.16);
  --border-strong: #334155;
  --input-bg: #0f172a;
  --input-text: #f8fafc;
  --input-placeholder: #94a3b8;
  --focus-ring: rgba(96, 165, 250, 0.35);
  --shadow-soft: 0 14px 38px rgba(0, 0, 0, 0.38);
}

[data-theme="dark"] html,
[data-theme="dark"] body {
  background: var(--bg-body) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] body {
  scrollbar-color: #475569 #0f172a;
}

[data-theme="dark"] ::selection {
  background: rgba(96, 165, 250, 0.38);
  color: #ffffff;
}

/* Powierzchnie: Bootstrap, stare widoki i elementy z klasami tailwindowymi */
[data-theme="dark"] .bg-white,
[data-theme="dark"] .bg-light,
[data-theme="dark"] .card,
[data-theme="dark"] .card-body,
[data-theme="dark"] .card-header,
[data-theme="dark"] .card-footer,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .modal-body,
[data-theme="dark"] .modal-footer,
[data-theme="dark"] .list-group-item,
[data-theme="dark"] .accordion-item,
[data-theme="dark"] .accordion-button,
[data-theme="dark"] .offcanvas,
[data-theme="dark"] .toast,
[data-theme="dark"] .popover,
[data-theme="dark"] .dropdown-menu,
[data-theme="dark"] .table-container,
[data-theme="dark"] .table-wrapper,
[data-theme="dark"] .summary-container,
[data-theme="dark"] .preview-section,
[data-theme="dark"] .form-section,
[data-theme="dark"] .widget,
[data-theme="dark"] .box,
[data-theme="dark"] .empty-state,
[data-theme="dark"] .invitation-card,
[data-theme="dark"] .meeting-link,
[data-theme="dark"] .question-bubble,
[data-theme="dark"] .node-item,
[data-theme="dark"] .comment-modal,
[data-theme="dark"] .global-node-dropdown,
[data-theme="dark"] .choices__inner,
[data-theme="dark"] .choices__list--dropdown,
[data-theme="dark"] .choices__list[aria-expanded],
[data-theme="dark"] .tox .tox-toolbar,
[data-theme="dark"] .tox .tox-toolbar__primary,
[data-theme="dark"] .tox .tox-edit-area__iframe,
[data-theme="dark"] .jodit-container,
[data-theme="dark"] .jodit-workplace,
[data-theme="dark"] .jodit-wysiwyg,
[data-theme="dark"] .jodit-toolbar__box {
  background-color: var(--bg-panel) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .card-header,
[data-theme="dark"] .accordion-button:not(.collapsed),
[data-theme="dark"] .popover-header,
[data-theme="dark"] thead,
[data-theme="dark"] .table thead th,
[data-theme="dark"] .sticky-top.bg-light,
[data-theme="dark"] .sticky-col.bg-white,
[data-theme="dark"] header.bg-white {
  background-color: var(--surface-3) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
}

/* Kafelki na stronie głównej trzymają obrazek jako background-image na .card.
   .card-body musi zostać przezroczyste, inaczej przykrywa zdjęcie w dark mode. */
[data-theme="dark"] .card[style*="background-image" i],
[data-theme="dark"] .card[style*="backgroundImage" i] {
  background-color: var(--bg-panel) !important;
}

[data-theme="dark"] .card[style*="background-image" i] .card-body,
[data-theme="dark"] .card[style*="backgroundImage" i] .card-body {
  background-color: transparent !important;
}

[data-theme="dark"] .modal-title,
[data-theme="dark"] .card-title,
[data-theme="dark"] .accordion-button,
[data-theme="dark"] .dropdown-item,
[data-theme="dark"] .dropdown-item-text,
[data-theme="dark"] .list-group-item,
[data-theme="dark"] .breadcrumb-item.active,
[data-theme="dark"] label,
[data-theme="dark"] .form-label,
[data-theme="dark"] .form-check-label,
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6 {
  color: var(--text-main) !important;
}

[data-theme="dark"] .text-dark:not(.badge),
[data-theme="dark"] .text-body,
[data-theme="dark"] .text-black,
[data-theme="dark"] .text-slate-900,
[data-theme="dark"] .text-gray-900,
[data-theme="dark"] .text-gray-800,
[data-theme="dark"] .text-slate-800 {
  color: var(--text-main) !important;
}

[data-theme="dark"] .text-muted,
[data-theme="dark"] .form-text,
[data-theme="dark"] .small,
[data-theme="dark"] .text-secondary,
[data-theme="dark"] .text-slate-500,
[data-theme="dark"] .text-slate-600,
[data-theme="dark"] .text-gray-500,
[data-theme="dark"] .text-gray-600 {
  color: var(--text-muted) !important;
}

[data-theme="dark"] a:not(.btn):not(.dropdown-item):not(.nav-link):not(.footer-link) {
  color: #93c5fd;
}

[data-theme="dark"] a:not(.btn):not(.dropdown-item):not(.nav-link):not(.footer-link):hover {
  color: #bfdbfe;
}

/* Formularze */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-control-sm,
[data-theme="dark"] textarea,
[data-theme="dark"] select,
[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
[data-theme="dark"] .input-group-text,
[data-theme="dark"] .choices__input,
[data-theme="dark"] .choices__item,
[data-theme="dark"] .tox .tox-textarea,
[data-theme="dark"] .tox .tox-textfield {
  background-color: var(--input-bg) !important;
  color: var(--input-text) !important;
  border-color: var(--border-strong) !important;
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):focus {
  background-color: #111c2f !important;
  color: var(--input-text) !important;
  border-color: #60a5fa !important;
  box-shadow: 0 0 0 0.2rem var(--focus-ring) !important;
}

[data-theme="dark"] .form-control::placeholder,
[data-theme="dark"] textarea::placeholder,
[data-theme="dark"] input::placeholder {
  color: var(--input-placeholder) !important;
  opacity: 1;
}

[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="time"],
[data-theme="dark"] input[type="month"],
[data-theme="dark"] input[type="datetime-local"] {
  color-scheme: dark;
}

[data-theme="dark"] input::-webkit-calendar-picker-indicator,
[data-theme="dark"] .btn-close {
  filter: invert(1) grayscale(1);
}

[data-theme="dark"] .form-check-input {
  background-color: #0f172a !important;
  border-color: #64748b !important;
}

[data-theme="dark"] .form-check-input:checked {
  background-color: #3b82f6 !important;
  border-color: #3b82f6 !important;
}

/* Tabele */
[data-theme="dark"] .table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text-main);
  --bs-table-border-color: var(--border-color);
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .table > :not(caption) > * > * {
  background-color: transparent !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > *,
[data-theme="dark"] .table-striped tbody tr:nth-child(odd) td,
[data-theme="dark"] .table-striped tbody tr:nth-child(odd) th {
  background-color: rgba(148, 163, 184, 0.08) !important;
}

[data-theme="dark"] .table-hover > tbody > tr:hover > *,
[data-theme="dark"] .table-hover tbody tr:hover,
[data-theme="dark"] .table-row:hover {
  background-color: rgba(96, 165, 250, 0.12) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] .table-dark {
  --bs-table-bg: #111827;
  --bs-table-striped-bg: #1f2937;
  --bs-table-hover-bg: #273449;
  --bs-table-color: #f8fafc;
}

/* Stany tabel muszą mieć własny kontrast; inaczej ostrzeżenia z panelu bocznego
   potrafią dostać jasny tekst na żółtym tle. */
[data-theme="dark"] .table-warning,
[data-theme="dark"] .table-warning > th,
[data-theme="dark"] .table-warning > td,
[data-theme="dark"] .table-warning > * > * {
  --bs-table-bg: #fef3c7;
  --bs-table-striped-bg: #fde68a;
  --bs-table-hover-bg: #fcd34d;
  background-color: #fef3c7 !important;
  color: #422006 !important;
  border-color: #f59e0b !important;
}

[data-theme="dark"] .table-danger,
[data-theme="dark"] .table-danger > th,
[data-theme="dark"] .table-danger > td,
[data-theme="dark"] .table-danger > * > * {
  --bs-table-bg: #fee2e2;
  --bs-table-striped-bg: #fecaca;
  --bs-table-hover-bg: #fca5a5;
  background-color: #fee2e2 !important;
  color: #7f1d1d !important;
  border-color: #f87171 !important;
}

[data-theme="dark"] .table-success,
[data-theme="dark"] .table-success > th,
[data-theme="dark"] .table-success > td,
[data-theme="dark"] .table-success > * > * {
  --bs-table-bg: #dcfce7;
  --bs-table-striped-bg: #bbf7d0;
  --bs-table-hover-bg: #86efac;
  background-color: #dcfce7 !important;
  color: #064e3b !important;
  border-color: #22c55e !important;
}

/* Dropdowny i menu */
[data-theme="dark"] .dropdown-menu,
[data-theme="dark"] .global-node-dropdown,
[data-theme="dark"] #context-menu {
  box-shadow: var(--shadow-soft) !important;
}

[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus,
[data-theme="dark"] .choices__list--dropdown .choices__item--selectable.is-highlighted {
  background-color: rgba(96, 165, 250, 0.14) !important;
  color: #f8fafc !important;
}

[data-theme="dark"] .dropdown-divider,
[data-theme="dark"] hr,
[data-theme="dark"] .border,
[data-theme="dark"] .border-top,
[data-theme="dark"] .border-end,
[data-theme="dark"] .border-bottom,
[data-theme="dark"] .border-start,
[data-theme="dark"] .border-gray-200,
[data-theme="dark"] .border-slate-200 {
  border-color: var(--border-color) !important;
}

/* Przyciski */
[data-theme="dark"] .btn-light,
[data-theme="dark"] .btn-outline-light {
  background-color: var(--surface-2) !important;
  border-color: var(--border-strong) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] .btn-outline-dark,
[data-theme="dark"] .btn-dark {
  background-color: #1f2937 !important;
  border-color: #475569 !important;
  color: #f8fafc !important;
}

[data-theme="dark"] .btn-outline-dark:hover,
[data-theme="dark"] .btn-dark:hover,
[data-theme="dark"] .btn-light:hover {
  background-color: #334155 !important;
  border-color: #64748b !important;
  color: #ffffff !important;
}

[data-theme="dark"] .btn-outline-secondary {
  color: #cbd5e1 !important;
  border-color: #64748b !important;
}

[data-theme="dark"] .btn-outline-secondary:hover {
  background-color: #334155 !important;
  color: #ffffff !important;
}

/* Badge i alerty - zachowujemy kontrast */
[data-theme="dark"] .badge.bg-light,
[data-theme="dark"] .badge.badge-light {
  background-color: #334155 !important;
  color: #f8fafc !important;
}

[data-theme="dark"] .badge.bg-warning.text-dark,
[data-theme="dark"] .badge.bg-info.text-dark,
[data-theme="dark"] .badge.bg-success.text-dark {
  color: #111827 !important;
}

[data-theme="dark"] .alert {
  background-color: var(--surface-2) !important;
  border-color: var(--border-color) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] .alert-warning,
[data-theme="dark"] [style*="background: #fff3cd" i],
[data-theme="dark"] [style*="background-color: #fff3cd" i] {
  background-color: #3b2f12 !important;
  border-color: #b7791f !important;
  color: #fde68a !important;
}

[data-theme="dark"] .alert-danger {
  background-color: #3b1518 !important;
  border-color: #7f1d1d !important;
  color: #fecaca !important;
}

[data-theme="dark"] .alert-success {
  background-color: #143524 !important;
  border-color: #166534 !important;
  color: #bbf7d0 !important;
}

/* Nadpisanie starych inline'owych jasnych powierzchni */
[data-theme="dark"] :not(.badge)[style*="background: white" i],
[data-theme="dark"] :not(.badge)[style*="background:white" i],
[data-theme="dark"] :not(.badge)[style*="background: #fff" i],
[data-theme="dark"] :not(.badge)[style*="background:#fff" i],
[data-theme="dark"] :not(.badge)[style*="background: #ffffff" i],
[data-theme="dark"] :not(.badge)[style*="background:#ffffff" i],
[data-theme="dark"] :not(.badge)[style*="background-color: white" i],
[data-theme="dark"] :not(.badge)[style*="background-color:white" i],
[data-theme="dark"] :not(.badge)[style*="background-color: #fff" i],
[data-theme="dark"] :not(.badge)[style*="background-color:#fff" i],
[data-theme="dark"] :not(.badge)[style*="background-color: #ffffff" i],
[data-theme="dark"] :not(.badge)[style*="background-color:#ffffff" i],
[data-theme="dark"] :not(.badge)[style*="background-color: #f8f9fa" i],
[data-theme="dark"] :not(.badge)[style*="background-color:#f8f9fa" i],
[data-theme="dark"] :not(.badge)[style*="background: #f8f9fa" i],
[data-theme="dark"] :not(.badge)[style*="background:#f8f9fa" i] {
  background-color: var(--bg-panel) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] :not(.badge):not(.btn)[style*="color: black" i],
[data-theme="dark"] :not(.badge):not(.btn)[style*="color:black" i],
[data-theme="dark"] :not(.badge):not(.btn)[style*="color: #000" i],
[data-theme="dark"] :not(.badge):not(.btn)[style*="color:#000" i],
[data-theme="dark"] :not(.badge):not(.btn)[style*="color: #212529" i],
[data-theme="dark"] :not(.badge):not(.btn)[style*="color:#212529" i] {
  color: var(--text-main) !important;
}

/* Stare klasy i komponenty ekranów */
[data-theme="dark"] .jumbotron,
[data-theme="dark"] .rounded-lg,
[data-theme="dark"] .shelf-tiles,
[data-theme="dark"] .add-shelf-btn,
[data-theme="dark"] .add-shelf-between,
[data-theme="dark"] .table-responsive,
[data-theme="dark"] .table-responsive-lg,
[data-theme="dark"] .calendar-container,
[data-theme="dark"] .content,
[data-theme="dark"] .container-xl,
[data-theme="dark"] .container-fluid:not(.navbar .container-fluid),
[data-theme="dark"] main.bg-white,
[data-theme="dark"] .bg-slate-50,
[data-theme="dark"] .bg-gray-50 {
  background-color: var(--bg-body) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] .shadow,
[data-theme="dark"] .shadow-sm,
[data-theme="dark"] .shadow-lg,
[data-theme="dark"] .shadow-2xl {
  box-shadow: var(--shadow-soft) !important;
}

[data-theme="dark"] pre,
[data-theme="dark"] code,
[data-theme="dark"] kbd {
  background-color: #0f172a !important;
  color: #e2e8f0 !important;
  border-color: var(--border-color) !important;
}

/* Edytory WYSIWYG */
[data-theme="dark"] .jodit-toolbar-button,
[data-theme="dark"] .jodit-toolbar-button__button,
[data-theme="dark"] .tox .tox-tbtn,
[data-theme="dark"] .tox .tox-mbtn {
  color: var(--text-main) !important;
}

[data-theme="dark"] .jodit-toolbar-button:hover,
[data-theme="dark"] .tox .tox-tbtn:hover,
[data-theme="dark"] .tox .tox-mbtn:hover {
  background-color: rgba(96, 165, 250, 0.14) !important;
}

[data-theme="dark"] .tox-tinymce,
[data-theme="dark"] .tox .tox-menubar,
[data-theme="dark"] .tox .tox-statusbar,
[data-theme="dark"] .tox .tox-toolbar-overlord,
[data-theme="dark"] .tox .tox-edit-area {
  background-color: #0f172a !important;
  border-color: var(--border-color) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] .tox .tox-mbtn,
[data-theme="dark"] .tox .tox-tbtn,
[data-theme="dark"] .tox .tox-statusbar__path-item,
[data-theme="dark"] .tox .tox-statusbar__wordcount {
  color: var(--text-main) !important;
}

[data-theme="dark"] .tox .tox-tbtn svg,
[data-theme="dark"] .tox .tox-mbtn svg {
  fill: var(--text-main) !important;
}

/* Widoki z mocnym lokalnym CSS */
[data-theme="dark"] #ticketsTable,
[data-theme="dark"] #ticketsTable tr,
[data-theme="dark"] #ticketsTable td,
[data-theme="dark"] .table.table-striped tbody#ticketsTable tr:nth-child(odd) td,
[data-theme="dark"] .table.table-striped tbody#ticketsTable tr:nth-child(odd) th,
[data-theme="dark"] .table.table-striped tbody#ticketsTable tr:nth-child(even) td,
[data-theme="dark"] .table.table-striped tbody#ticketsTable tr:nth-child(even) th {
  background-color: var(--bg-panel) !important;
  background-image: none !important;
  color: var(--text-main) !important;
  --bs-table-accent-bg: var(--bg-panel) !important;
}

[data-theme="dark"] #ticketsTable tr:nth-child(even) td,
[data-theme="dark"] #ticketsTable tr:nth-child(even) th {
  background-color: rgba(148, 163, 184, 0.08) !important;
  --bs-table-accent-bg: rgba(148, 163, 184, 0.08) !important;
}

[data-theme="dark"] #ticketsTable tr:hover td,
[data-theme="dark"] #ticketsTable tr:hover th,
[data-theme="dark"] #requests-table tbody tr:hover td,
[data-theme="dark"] #requests-table tbody tr:hover th {
  background-color: rgba(96, 165, 250, 0.14) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] #requests-table tbody tr,
[data-theme="dark"] #requests-table tbody tr td,
[data-theme="dark"] #requests-table tbody tr th {
  background-color: var(--bg-panel) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] #noweRW .modal-content,
[data-theme="dark"] #noweRW .modal-body,
[data-theme="dark"] #noweRW .selected-product-card,
[data-theme="dark"] #noweRW .product-list,
[data-theme="dark"] #noweRW .autocomplete-list {
  background-color: var(--bg-panel) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] #noweRW .product-item,
[data-theme="dark"] #noweRW .autocomplete-item {
  background-color: var(--bg-panel) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] #noweRW .product-item:hover,
[data-theme="dark"] #noweRW .autocomplete-item:hover {
  background-color: rgba(96, 165, 250, 0.14) !important;
}

[data-theme="dark"] #noweRW .product-item.selected {
  background-color: rgba(59, 130, 246, 0.22) !important;
  border-left-color: #60a5fa !important;
}

[data-theme="dark"] #noweRW .product-name,
[data-theme="dark"] #noweRW .form-label-custom,
[data-theme="dark"] #noweRW .search-field label {
  color: var(--text-main) !important;
}

[data-theme="dark"] #noweRW .product-details-inline,
[data-theme="dark"] #noweRW .no-results {
  color: var(--text-muted) !important;
}

[data-theme="dark"] #noweRW .quantity-btn,
[data-theme="dark"] #noweRW .btn-secondary-custom,
[data-theme="dark"] #noweRW .step.inactive {
  background-color: var(--surface-2) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] #noweRW .step-line {
  background-color: var(--border-strong) !important;
}

[data-theme="dark"] #noweRW .sn-locked-info {
  background-color: #3b2f12 !important;
  border-color: #b7791f !important;
  color: #fde68a !important;
}

[data-theme="dark"] .test-firefox .table-borderless,
[data-theme="dark"] .test-firefox .table-borderless th,
[data-theme="dark"] .test-firefox .table-borderless td,
[data-theme="dark"] #modal-body3,
[data-theme="dark"] #modal-body3 .card,
[data-theme="dark"] #modal-body3 .card-body,
[data-theme="dark"] #modal-body3 table,
[data-theme="dark"] #modal-body3 th,
[data-theme="dark"] #modal-body3 td {
  background-color: var(--bg-panel) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .gcal-admin {
  --gcal-border: var(--border-color);
  --gcal-muted: var(--text-muted);
  --gcal-surface: var(--bg-panel);
  --gcal-background: var(--bg-body);
  background-color: var(--bg-body) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] .gcal-card,
[data-theme="dark"] .gcal-calendar-card,
[data-theme="dark"] .gcal-stat,
[data-theme="dark"] .gcal-modal-panel,
[data-theme="dark"] .gcal-permission-row,
[data-theme="dark"] .gcal-empty,
[data-theme="dark"] #delete-calendar-summary {
  background: var(--bg-panel) !important;
  border-color: var(--border-color) !important;
  color: var(--text-main) !important;
  box-shadow: var(--shadow-soft) !important;
}

[data-theme="dark"] .gcal-calendar-card:hover {
  background: #1f2a3d !important;
  border-color: #60a5fa !important;
}

[data-theme="dark"] .gcal-input,
[data-theme="dark"] .gcal-select,
[data-theme="dark"] .gcal-textarea {
  background: var(--input-bg) !important;
  border-color: var(--border-strong) !important;
  color: var(--input-text) !important;
}

[data-theme="dark"] .gcal-button-secondary {
  background: var(--surface-2) !important;
  border-color: var(--border-color) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] .gcal-button-danger {
  background: rgba(220, 38, 38, 0.14) !important;
  border-color: rgba(248, 113, 113, 0.45) !important;
  color: #fecaca !important;
}

[data-theme="dark"] .gcal-chip,
[data-theme="dark"] .gcal-avatar {
  background: var(--surface-2) !important;
  color: #bfdbfe !important;
}

[data-theme="dark"] .gcal-error,
[data-theme="dark"] .gcal-admin .bg-red-50,
[data-theme="dark"] .gcal-admin .bg-blue-50,
[data-theme="dark"] .gcal-admin .bg-blue-50\/60 {
  background: rgba(59, 130, 246, 0.12) !important;
  border-color: rgba(96, 165, 250, 0.35) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] .gcal-skeleton {
  background: linear-gradient(90deg, #111827 25%, #1f2a3d 50%, #111827 75%) !important;
  background-size: 200% 100% !important;
}

[data-theme="dark"] .gcal-admin .text-slate-950,
[data-theme="dark"] .gcal-admin .text-slate-900,
[data-theme="dark"] .gcal-admin .text-slate-800 {
  color: var(--text-main) !important;
}

[data-theme="dark"] .gcal-admin .text-slate-600,
[data-theme="dark"] .gcal-admin .text-slate-500,
[data-theme="dark"] .gcal-admin .text-slate-400 {
  color: var(--text-muted) !important;
}

/* Szczegóły serwisu */
[data-theme="dark"] .service-details-page,
.service-details-dark {
  color: var(--text-main) !important;
}

[data-theme="dark"] .service-details-page :where(p, span, div, label, small, strong, b, h1, h2, h3, h4, h5, h6):not(.btn):not(.badge):not(.status-badge):not(.decision-badge),
.service-details-dark :where(p, span, div, label, small, strong, b, h1, h2, h3, h4, h5, h6):not(.btn):not(.badge):not(.status-badge):not(.decision-badge) {
  color: var(--text-main) !important;
}

[data-theme="dark"] .service-details-page :where(.text-muted, .text-secondary, .info-label, .form-text, .product-details, .message-date, .no-messages, #notesSaveStatus, #issueCharCount2),
.service-details-dark :where(.text-muted, .text-secondary, .info-label, .form-text, .product-details, .message-date, .no-messages, #notesSaveStatus, #issueCharCount2) {
  color: #cbd5e1 !important;
}

[data-theme="dark"] .service-details-page [style*="color: #6c757d"],
[data-theme="dark"] .service-details-page [style*="color:#6c757d"],
[data-theme="dark"] .service-details-page [style*="color: #64748b"],
[data-theme="dark"] .service-details-page [style*="color:#64748b"],
[data-theme="dark"] .service-details-page [style*="color: #2c3e50"],
[data-theme="dark"] .service-details-page [style*="color:#2c3e50"],
[data-theme="dark"] .service-details-page [style*="color: #333"],
[data-theme="dark"] .service-details-page [style*="color:#333"],
.service-details-dark [style*="color: #6c757d"],
.service-details-dark [style*="color:#6c757d"],
.service-details-dark [style*="color: #64748b"],
.service-details-dark [style*="color:#64748b"],
.service-details-dark [style*="color: #2c3e50"],
.service-details-dark [style*="color:#2c3e50"],
.service-details-dark [style*="color: #333"],
.service-details-dark [style*="color:#333"] {
  color: #e5e7eb !important;
}

[data-theme="dark"] .service-details-page .bi-inbox,
.service-details-dark .bi-inbox {
  color: #94a3b8 !important;
}

[data-theme="dark"] #mainContent,
[data-theme="dark"] #serviceContent {
  color: var(--text-main) !important;
}

[data-theme="dark"] #loadingSpinner .text-dark,
[data-theme="dark"] #noDataMessage .text-dark,
[data-theme="dark"] #serviceContent .text-dark,
[data-theme="dark"] #editServiceModal .text-dark {
  color: var(--text-main) !important;
}

[data-theme="dark"] #noDataMessage .text-muted,
[data-theme="dark"] #serviceContent .text-muted,
[data-theme="dark"] #serviceContent [style*="color: #6c757d"],
[data-theme="dark"] #editServiceModal [style*="color: #6c757d"] {
  color: var(--text-muted) !important;
}

[data-theme="dark"] #serviceContent .section-title {
  color: var(--text-main) !important;
  border-color: var(--border-strong) !important;
}

[data-theme="dark"] #serviceContent .info-label,
[data-theme="dark"] #addClaimModal .info-label,
[data-theme="dark"] #claimDecisionModal .info-label,
[data-theme="dark"] #claimDetailsModal .info-label {
  color: var(--text-muted) !important;
}

[data-theme="dark"] #serviceContent .info-value,
[data-theme="dark"] #claimDetailsModal .info-value,
[data-theme="dark"] #addClaimModal .modal-title,
[data-theme="dark"] #claimDecisionModal .modal-title,
[data-theme="dark"] #editServiceModal .modal-title,
[data-theme="dark"] #claimDetailsModal .modal-title,
[data-theme="dark"] #emailNotificationModal .modal-title {
  color: var(--text-main) !important;
}

[data-theme="dark"] #serviceContent .card,
[data-theme="dark"] #serviceContent .card-body,
[data-theme="dark"] #addClaimModal .modal-content,
[data-theme="dark"] #claimDecisionModal .modal-content,
[data-theme="dark"] #editServiceModal .modal-content,
[data-theme="dark"] #completeServiceModal .modal-content,
[data-theme="dark"] #cancelServiceModal .modal-content,
[data-theme="dark"] #claimDetailsModal .modal-content,
[data-theme="dark"] #emailNotificationModal .modal-content {
  background: var(--bg-panel) !important;
  border-color: var(--border-color) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] #serviceContent #issueDescription,
[data-theme="dark"] #serviceContent [style*="background: #f8f9fa"],
[data-theme="dark"] #serviceContent [style*="background-color: #f8f9fa"] {
  background: var(--surface-1) !important;
  border-color: var(--border-strong) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] #serviceContent .claim-card {
  background: var(--surface-2) !important;
  border-color: var(--border-color) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] #serviceContent .claim-card:hover {
  background: var(--surface-3) !important;
  border-color: #60a5fa !important;
}

[data-theme="dark"] #serviceContent .claim-card-pending {
  background: rgba(245, 158, 11, 0.13) !important;
  border-left-color: #f59e0b !important;
}

[data-theme="dark"] #serviceContent .claim-card-completed {
  background: rgba(34, 197, 94, 0.12) !important;
  border-left-color: #22c55e !important;
}

[data-theme="dark"] #serviceContent .claim-card span:not(.badge),
[data-theme="dark"] #serviceContent .claim-card div:not(.badge) {
  color: var(--text-main);
}

[data-theme="dark"] #modalAnulacjaSerwisu .modal-content,
[data-theme="dark"] #modalAnulacjaSerwisu .modal-body,
[data-theme="dark"] #modalAnulacjaSerwisu .modal-footer {
  background: var(--bg-panel) !important;
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] #modalAnulacjaSerwisu .form-label {
  color: var(--text-main) !important;
}

[data-theme="dark"] #modalAnulacjaSerwisu .alert,
[data-theme="dark"] #cancelServiceModal .alert-warning,
[data-theme="dark"] #completeServiceModal .alert-info {
  background: rgba(245, 158, 11, 0.14) !important;
  border-color: rgba(251, 191, 36, 0.4) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] #completeServiceModal .alert-info {
  background: rgba(59, 130, 246, 0.14) !important;
  border-color: rgba(96, 165, 250, 0.4) !important;
}

[data-theme="dark"] #modalAnulacjaSerwisu .info-message {
  background: rgba(245, 158, 11, 0.14) !important;
  border-left-color: #fbbf24 !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] #modalAnulacjaSerwisu .info-message small {
  color: var(--text-main) !important;
}

[data-theme="dark"] #emailNotificationModal .message-item {
  background: var(--surface-2) !important;
  border-color: #60a5fa !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] #emailNotificationModal .message-from,
[data-theme="dark"] #emailNotificationModal .message-subject,
[data-theme="dark"] #emailNotificationModal .message-preview {
  color: var(--text-main) !important;
}

[data-theme="dark"] #emailNotificationModal .message-date,
[data-theme="dark"] #emailNotificationModal .no-messages {
  color: var(--text-muted) !important;
}

[data-theme="dark"] #emailNotificationModal .message-content::after {
  background: linear-gradient(to bottom, rgba(22, 32, 51, 0), var(--surface-2)) !important;
}

[data-theme="dark"] #editServiceModal #ean-result-card .selected-product-card,
[data-theme="dark"] #editServiceModal .selected-product-card {
  background: var(--surface-2) !important;
  border-color: var(--border-color) !important;
  color: var(--text-main) !important;
}

[data-theme="dark"] #editServiceModal .card-warning {
  background: rgba(245, 158, 11, 0.13) !important;
  border-left-color: #f59e0b !important;
}

[data-theme="dark"] #editServiceModal .card-ok {
  background: rgba(34, 197, 94, 0.12) !important;
  border-left-color: #22c55e !important;
}

[data-theme="dark"] #editServiceModal .product-name,
[data-theme="dark"] #editServiceModal .product-details {
  color: var(--text-main) !important;
}

/* Stopka */
[data-theme="dark"] footer,
[data-theme="dark"] .footer {
  background-color: var(--footer-bg, #0f172a) !important;
  color: var(--footer-text, #cbd5e1) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .footer-link,
[data-theme="dark"] .footerlink {
  color: var(--footer-text, #cbd5e1) !important;
}

[data-theme="dark"] .footer-link:hover,
[data-theme="dark"] .footerlink:hover {
  color: var(--footer-link-hover, #ffffff) !important;
}

/* Przełącznik motywu w dropdownie użytkownika */
.theme-toggle-menu-item {
  align-items: center !important;
  gap: 12px;
}

.theme-toggle-menu-item .theme-toggle-copy {
  flex: 1;
  min-width: 0;
}

.theme-toggle-menu-item .theme-toggle-copy span {
  display: block;
  line-height: 1.1;
}

.theme-toggle-menu-item .theme-toggle-label {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.2;
  color: var(--text-muted, #6b7280);
}

.theme-toggle-menu-item .theme-toggle-inline {
  flex: 0 0 auto;
  width: 54px;
  height: 28px;
  transform: scale(0.92);
  transform-origin: center right;
}

.theme-toggle-menu-item .theme-toggle-inline .toggle-thumb {
  width: 22px;
  height: 22px;
  top: 3px;
  left: 3px;
}

.theme-toggle-menu-item .theme-toggle-inline .toggle-thumb svg {
  width: 13px;
  height: 13px;
}

[data-theme="dark"] .theme-toggle-menu-item .theme-toggle-inline .toggle-thumb {
  transform: translateX(26px);
}

[data-theme="dark"] .theme-toggle-menu-item .theme-toggle-label {
  color: var(--text-muted, #94a3b8) !important;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

/* Bootstrap 5.0 — widoczna kropka wyłączonego switcha w dark mode */
[data-theme="dark"] .form-switch .form-check-input:not(:checked) {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23e2e8f0'/%3e%3c/svg%3e");
}

/* Bootstrap zmienia grafikę po focusie, więc poprawiamy także ten stan */
[data-theme="dark"] .form-switch .form-check-input:not(:checked):focus {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23f8fafc'/%3e%3c/svg%3e");
}