/* Scoped warehouse UI theme. POS and Django Admin do not load this file. */
html[data-warehouse-theme="light"] {
  color-scheme: light;
  --warehouse-toggle-bg: rgba(255, 255, 255, .94);
  --warehouse-toggle-fg: #343a40;
  --warehouse-toggle-border: #d9dee3;
}
html[data-warehouse-theme="dark"] {
  color-scheme: dark;
  --warehouse-bg: #121417;
  --warehouse-surface: #1b1f24;
  --warehouse-surface-raised: #23282f;
  --warehouse-text: #e7e9ed;
  --warehouse-muted: #a5adb7;
  --warehouse-border: #3a424c;
  --warehouse-input: #171b20;
  --warehouse-hover: #2a3038;
  --warehouse-toggle-bg: var(--warehouse-surface);
  --warehouse-toggle-fg: var(--warehouse-text);
  --warehouse-toggle-border: var(--warehouse-border);
}

html[data-warehouse-theme="dark"] body {
  --bs-body-bg: var(--warehouse-bg);
  --bs-body-color: var(--warehouse-text);
  --bs-secondary-color: var(--warehouse-muted);
  --bs-tertiary-color: var(--warehouse-muted);
  --bs-border-color: var(--warehouse-border);
  color: var(--warehouse-text) !important;
  background-color: var(--warehouse-bg) !important;
}

html[data-warehouse-theme="dark"] :where(main, section, article, p, label, small, h1, h2, h3, h4, h5, h6, dt, dd, li, .form-label) {
  color: inherit;
}

html[data-warehouse-theme="dark"] body :where(.bg-white, .card, .card-header, .card-footer, .list-group-item, .modal-content, .modal-header, .modal-footer, .dropdown-menu, .popover, .offcanvas, .accordion-item, .accordion-button:not(.collapsed), .page-link, .quick-card, .quick-wrap, .page-wrapper, .table-card, .inventory-card, .fixed-bottom-panel, .operations-summary, .ingredient-row, .barcode-row, .ingredients-card, .ingredients-header, .select2-dropdown, .select2-results__option) {
  color: var(--warehouse-text) !important;
  background-color: var(--warehouse-surface) !important;
  border-color: var(--warehouse-border) !important;
}

html[data-warehouse-theme="dark"] body :where(.bg-light, .table-light, .alert-light, .alert-secondary, .accordion-button, .input-group-text, .dropdown-item:hover, .dropdown-item:focus, .list-group-item-action:hover, .list-group-item-action:focus, .page-link:hover, .table-hover > tbody > tr:hover > *, .table-striped > tbody > tr:nth-of-type(odd) > *) {
  color: var(--warehouse-text) !important;
  background-color: var(--warehouse-surface-raised) !important;
  border-color: var(--warehouse-border) !important;
}

html[data-warehouse-theme="dark"] body :where(.text-dark, .text-body, .text-secondary) {
  color: var(--warehouse-text) !important;
}

html[data-warehouse-theme="dark"] body :where(.text-muted, .page-subtitle, .info-label, .stat-label, .warehouse-name, .dataTables_info, .dataTables_length, .dataTables_filter, .dataTables_paginate) {
  color: var(--warehouse-muted) !important;
}

html[data-warehouse-theme="dark"] body :where(.dropdown-item, .nav-link, .navbar-brand) {
  color: var(--warehouse-text) !important;
}

html[data-warehouse-theme="dark"] :where(.navbar, .navbar-collapse, .navbar-nav) {
  color: var(--warehouse-text);
  background-color: var(--warehouse-surface);
  border-color: var(--warehouse-border);
}

html[data-warehouse-theme="dark"] .navbar-toggler-icon {
  filter: invert(1) grayscale(100%) brightness(180%);
}

html[data-warehouse-theme="dark"] :where(.dropdown-item.active, .dropdown-item:active, .nav-link.active) {
  color: #fff !important;
  background-color: #315f91 !important;
}

html[data-warehouse-theme="dark"] a:not(.btn):not(.badge):not(.dropdown-item) {
  color: #9fc7ff;
}

html[data-warehouse-theme="dark"] a:not(.btn):not(.badge):not(.dropdown-item):hover {
  color: #c3dcff;
}

html[data-warehouse-theme="dark"] :where(.border, .border-top, .border-bottom, hr, .table, .table > :not(caption) > * > *) {
  border-color: var(--warehouse-border) !important;
}

html[data-warehouse-theme="dark"] body :where(.table, .table > :not(caption) > * > *, table.dataTable) {
  --bs-table-color: var(--warehouse-text);
  --bs-table-bg: var(--warehouse-surface);
  --bs-table-border-color: var(--warehouse-border);
  --bs-table-striped-bg: #20252b;
  --bs-table-striped-color: var(--warehouse-text);
  --bs-table-hover-bg: var(--warehouse-hover);
  --bs-table-hover-color: var(--warehouse-text);
  color: var(--warehouse-text) !important;
  background-color: var(--warehouse-surface);
}

html[data-warehouse-theme="dark"] :where(input:not([type="checkbox"]):not([type="radio"]), textarea, select, .form-control, .form-select, .select2-container--default .select2-selection--single) {
  color: var(--warehouse-text) !important;
  background-color: var(--warehouse-input) !important;
  border-color: var(--warehouse-border) !important;
  color-scheme: dark;
}

html[data-warehouse-theme="dark"] :where(input, textarea, select, .form-control, .form-select)::placeholder {
  color: #8d97a3 !important;
  opacity: 1;
}

html[data-warehouse-theme="dark"] :where(input, textarea, select, .form-control, .form-select):focus {
  border-color: #7896b7 !important;
  box-shadow: 0 0 0 .2rem rgba(110, 155, 205, .2) !important;
}

html[data-warehouse-theme="dark"] :where(input, textarea, select, .form-control, .form-select):disabled,
html[data-warehouse-theme="dark"] :where(input, textarea, select, .form-control, .form-select)[readonly] {
  background-color: #20252b !important;
  color: #a5adb7 !important;
}

html[data-warehouse-theme="dark"] :where(.btn-light, .btn-outline-secondary, .btn-outline-dark, .btn-secondary:not(.text-bg-secondary), .btn-default) {
  color: var(--warehouse-text) !important;
  background-color: var(--warehouse-surface-raised) !important;
  border-color: var(--warehouse-border) !important;
}

html[data-warehouse-theme="dark"] :where(.btn-light, .btn-outline-secondary, .btn-outline-dark, .btn-secondary:not(.text-bg-secondary), .btn-default):hover {
  background-color: var(--warehouse-hover) !important;
  border-color: #59636f !important;
}

html[data-warehouse-theme="dark"] :where(.alert-success, .text-bg-success) { color: #d4f0dc !important; background-color: #173624 !important; border-color: #28583a !important; }
html[data-warehouse-theme="dark"] :where(.alert-warning, .text-bg-warning) { color: #f5e6b8 !important; background-color: #3a3018 !important; border-color: #655326 !important; }
html[data-warehouse-theme="dark"] :where(.alert-danger, .alert-error, .text-bg-danger) { color: #f4d0d0 !important; background-color: #3b2022 !important; border-color: #673438 !important; }
html[data-warehouse-theme="dark"] :where(.alert-info, .text-bg-info) { color: #cfe8f4 !important; background-color: #1c303a !important; border-color: #315466 !important; }
html[data-warehouse-theme="dark"] body :where(.bg-warning.text-dark, .badge.bg-warning, .btn-warning) { color: #2b2617 !important; }
html[data-warehouse-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); opacity: .85; }

html[data-warehouse-theme="dark"] :where(.header, .page-header, .category-header, .sticky-search, .category-group) {
  color: var(--warehouse-text) !important;
  background: var(--warehouse-surface) !important;
  border-color: var(--warehouse-border) !important;
}

html[data-warehouse-theme="dark"] :where(.header) {
  box-shadow: 0 8px 24px rgba(0, 0, 0, .24) !important;
}

html[data-warehouse-theme="dark"] :where(.category-header, .category-group, .inventory-card, .quick-card, .operations-summary, .page-wrapper, .card, .product-name, .info-value, .stat-value, .page-title) {
  color: var(--warehouse-text) !important;
}

html[data-warehouse-theme="dark"] :where(.inventory-card, .category-header, .quick-card, .quick-quantity, .page-wrapper, .page-header, .ingredient-row, .barcode-row, .card-header, .card-body, .card-footer, .table-responsive) {
  border-color: var(--warehouse-border) !important;
}

html[data-warehouse-theme="dark"] :where(.dataTables_wrapper .dataTables_paginate .paginate_button, .pagination .page-link) {
  color: var(--warehouse-text) !important;
  background: var(--warehouse-surface) !important;
  border-color: var(--warehouse-border) !important;
}

html[data-warehouse-theme="dark"] :where(.dataTables_wrapper .dataTables_paginate .paginate_button.current, .pagination .active .page-link) {
  color: #fff !important;
  background: #315f91 !important;
  border-color: #315f91 !important;
}

html[data-warehouse-theme="dark"] body :where(.modal-backdrop) { --bs-backdrop-bg: #000; --bs-backdrop-opacity: .72; }

.warehouse-theme-toggle {
  position: fixed;
  z-index: 1100;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--warehouse-toggle-fg, #343a40);
  background: var(--warehouse-toggle-bg, #fff);
  border: 1px solid var(--warehouse-toggle-border, #d9dee3);
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .14);
  cursor: pointer;
}

.warehouse-theme-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.warehouse-theme-toggle:focus-visible { outline: 3px solid #6c9ed0; outline-offset: 2px; }

@media print {
  html[data-warehouse-theme] { color-scheme: light !important; }
  html[data-warehouse-theme] body { color: #111 !important; background: #fff !important; }
  html[data-warehouse-theme] :where(.bg-white, .bg-light, .card, .card-header, .card-body, .card-footer, .table, .table > :not(caption) > * > *, .modal-content, .page-wrapper, .quick-card, .category-group, .category-header, .inventory-card) {
    color: #111 !important;
    background: #fff !important;
    border-color: #ccc !important;
    box-shadow: none !important;
  }
  html[data-warehouse-theme] :where(.text-muted, .text-secondary, .text-dark, a) { color: #333 !important; }
  .warehouse-theme-toggle { display: none !important; }
}
