/* TheaCRM v2.8.568 – system accent components r1
   Extends the existing per-user colour scheme to shared interactive UX.
   Semantic danger, warning, info and success statuses remain untouched. */

body.thea-app-shell {
  --thea-system-accent: var(--primary-color, #2e7d32);
  --thea-system-accent-hover: var(--primary-hover, #1b5e20);
  --thea-system-accent-rgb: var(--thea-primary-rgb, 46, 125, 50);
  --thea-system-accent-soft: var(--thea-primary-soft, var(--highlight-bg, #e8f5e9));
  --thea-system-accent-soft-2: var(--thea-primary-soft-2, #fbfdfb);
  --thea-system-accent-border: var(--border-color, #c8e6c9);
  --thea-system-accent-text: var(--thea-primary-text, var(--secondary-color, #004d00));
  --thea-system-accent-contrast: #fff;

  /* Bridge older shared layers to the current user-selected palette. */
  --thea-primary: var(--thea-system-accent);
  --thea-primary-soft: rgba(var(--thea-system-accent-rgb), .10);
  --thea-ui-primary: var(--thea-system-accent);
  --thea-ui-primary-soft: rgba(var(--thea-system-accent-rgb), .10);

  /* Bootstrap variables used by utilities and components. */
  --bs-primary: var(--thea-system-accent);
  --bs-primary-rgb: var(--thea-system-accent-rgb);
  --bs-link-color: var(--thea-system-accent);
  --bs-link-color-rgb: var(--thea-system-accent-rgb);
  --bs-link-hover-color: var(--thea-system-accent-hover);
  --bs-focus-ring-color: rgba(var(--thea-system-accent-rgb), .25);
}

/* Legacy list pages used fixed forest-green variables. */
body.thea-app-shell .thea-list-page {
  --thea-list-green: var(--thea-system-accent);
  --thea-list-green-dark: var(--thea-system-accent-hover);
  --thea-list-soft: var(--thea-system-accent-soft-2);
}

/* Page/module headings: colour the navigational identity, not every heading. */
body.thea-app-shell #mainContent :is(
  .thea-list-title,
  .thea-ui-module-title,
  .thea-ui-module-title-standalone,
  .thea-page-title,
  .page-title,
  .project-page-title
) {
  color: var(--thea-system-accent) !important;
}

body.thea-app-shell #mainContent .thea-ui-module-header :is(h1, h2, h3),
body.thea-app-shell #mainContent .thea-document-toolbar :is(h1, h2, h3) {
  color: var(--thea-system-accent) !important;
}

body.thea-app-shell #mainContent :is(
  .thea-page-title-icon,
  .thea-module-icon,
  .thea-list-title-icon
) {
  color: var(--thea-system-accent) !important;
}

/* Primary and historical success actions share the selected system colour. */
body.thea-app-shell :is(
  .btn-primary,
  .btn-success,
  .btn-ghost-primary,
  .stock-primary-btn,
  .thea-primary-action
) {
  --bs-btn-bg: var(--thea-system-accent);
  --bs-btn-border-color: var(--thea-system-accent);
  --bs-btn-hover-bg: var(--thea-system-accent-hover);
  --bs-btn-hover-border-color: var(--thea-system-accent-hover);
  --bs-btn-active-bg: var(--thea-system-accent-hover);
  --bs-btn-active-border-color: var(--thea-system-accent-hover);
  background-color: var(--thea-system-accent) !important;
  border-color: var(--thea-system-accent) !important;
  color: var(--thea-system-accent-contrast) !important;
  box-shadow: 0 5px 14px rgba(var(--thea-system-accent-rgb), .20) !important;
}

body.thea-app-shell :is(
  .btn-primary,
  .btn-success,
  .btn-ghost-primary,
  .stock-primary-btn,
  .thea-primary-action
):is(:hover, :focus-visible, :active, .active) {
  background-color: var(--thea-system-accent-hover) !important;
  border-color: var(--thea-system-accent-hover) !important;
  color: var(--thea-system-accent-contrast) !important;
  box-shadow: 0 7px 18px rgba(var(--thea-system-accent-rgb), .28) !important;
}

body.thea-app-shell :is(.btn-outline-primary, .btn-outline-success) {
  --bs-btn-color: var(--thea-system-accent);
  --bs-btn-border-color: var(--thea-system-accent);
  --bs-btn-hover-bg: var(--thea-system-accent);
  --bs-btn-hover-border-color: var(--thea-system-accent);
  --bs-btn-active-bg: var(--thea-system-accent-hover);
  --bs-btn-active-border-color: var(--thea-system-accent-hover);
  color: var(--thea-system-accent) !important;
  border-color: var(--thea-system-accent) !important;
}

body.thea-app-shell :is(.btn-outline-primary, .btn-outline-success):is(:hover, :focus-visible, :active, .active),
body.thea-app-shell .btn-check:checked + :is(.btn-outline-primary, .btn-outline-success) {
  color: var(--thea-system-accent-contrast) !important;
  background-color: var(--thea-system-accent-hover) !important;
  border-color: var(--thea-system-accent-hover) !important;
}

body.thea-app-shell .btn-link {
  color: var(--thea-system-accent) !important;
}
body.thea-app-shell .btn-link:hover,
body.thea-app-shell .btn-link:focus-visible {
  color: var(--thea-system-accent-hover) !important;
}

/* Inline content links. Card wrappers and semantic status links are excluded. */
body.thea-app-shell #mainContent a:not(.btn):not(.badge):not(.dropdown-item):not(.list-group-item):not(.nav-link):not(.page-link):not(.alert-link):not(.stretched-link):not(.text-decoration-none):not(.text-danger):not(.link-danger):not(.text-warning):not(.link-warning):not(.text-info):not(.link-info),
body.thea-app-shell .thea-app-footer a:not(.btn) {
  color: var(--thea-system-accent) !important;
  text-decoration-color: rgba(var(--thea-system-accent-rgb), .42);
  text-underline-offset: .16em;
}

body.thea-app-shell #mainContent a:not(.btn):not(.badge):not(.dropdown-item):not(.list-group-item):not(.nav-link):not(.page-link):not(.alert-link):not(.stretched-link):not(.text-decoration-none):not(.text-danger):not(.link-danger):not(.text-warning):not(.link-warning):not(.text-info):not(.link-info):is(:hover, :focus-visible),
body.thea-app-shell .thea-app-footer a:not(.btn):is(:hover, :focus-visible) {
  color: var(--thea-system-accent-hover) !important;
  text-decoration-color: currentColor;
}

/* Common clickable identifiers and document numbers. */
body.thea-app-shell #mainContent :is(
  .invoice-number,
  .offer-number,
  .document-number,
  .thea-entity-number,
  .thea-entity-id,
  .thea-clickable-id,
  .doklady-doc-number-line
) {
  color: var(--thea-system-accent) !important;
}

body.thea-app-shell #mainContent a.text-decoration-none > :is(
  h1,
  h2,
  h3,
  .invoice-number,
  .offer-number,
  .document-number,
  .thea-entity-number,
  .thea-entity-id,
  .fw-semibold
) {
  color: var(--thea-system-accent) !important;
}

/* Pagination: inactive links use the accent; current page is filled. */
body.thea-app-shell .pagination .page-link,
body.thea-app-shell .thea-ui-pagination .page-link {
  color: var(--thea-system-accent) !important;
}

body.thea-app-shell .pagination .page-link:is(:hover, :focus-visible),
body.thea-app-shell .thea-ui-pagination .page-link:is(:hover, :focus-visible) {
  color: var(--thea-system-accent-hover) !important;
  background-color: var(--thea-system-accent-soft) !important;
  border-color: var(--thea-system-accent-border) !important;
}

body.thea-app-shell .pagination .page-item.active .page-link,
body.thea-app-shell .thea-ui-pagination .page-item.active .page-link {
  color: var(--thea-system-accent-contrast) !important;
  background-color: var(--thea-system-accent) !important;
  border-color: var(--thea-system-accent) !important;
  box-shadow: 0 4px 12px rgba(var(--thea-system-accent-rgb), .20);
}

body.thea-app-shell .pagination .page-item.disabled .page-link,
body.thea-app-shell .thea-ui-pagination .page-item.disabled .page-link {
  color: #7b858f !important;
  background-color: #f1f3f5 !important;
  border-color: #dee2e6 !important;
  box-shadow: none;
}

/* Active tabs, pills, list choices, dropdown choices and accordions. */
body.thea-app-shell .nav-tabs .nav-link:is(:hover, :focus-visible),
body.thea-app-shell .nav-tabs .nav-link.active {
  color: var(--thea-system-accent) !important;
  border-bottom-color: var(--thea-system-accent) !important;
}
body.thea-app-shell .nav-tabs .nav-link.active {
  box-shadow: inset 0 -3px 0 var(--thea-system-accent);
}

body.thea-app-shell .nav-pills .nav-link.active,
body.thea-app-shell .list-group-item.active,
body.thea-app-shell .dropdown-item.active,
body.thea-app-shell .dropdown-item:active {
  color: var(--thea-system-accent-contrast) !important;
  background-color: var(--thea-system-accent) !important;
  border-color: var(--thea-system-accent) !important;
}

body.thea-app-shell .dropdown-item:is(:hover, :focus),
body.thea-app-shell .list-group-item-action:is(:hover, :focus) {
  color: var(--thea-system-accent-text);
  background-color: var(--thea-system-accent-soft);
}

body.thea-app-shell .accordion-button:not(.collapsed) {
  color: var(--thea-system-accent-text);
  background-color: var(--thea-system-accent-soft);
  box-shadow: inset 0 calc(-1 * var(--bs-accordion-border-width, 1px)) 0 var(--thea-system-accent-border);
}
body.thea-app-shell .accordion-button:not(.collapsed)::after {
  filter: none;
}

/* Native controls which visually represent an active choice. */
body.thea-app-shell :is(.form-check-input, .form-range):focus,
body.thea-app-shell :is(.form-control, .form-select):focus {
  border-color: var(--thea-system-accent-border) !important;
  box-shadow: 0 0 0 .22rem rgba(var(--thea-system-accent-rgb), .18) !important;
}
body.thea-app-shell .form-range::-webkit-slider-thumb {
  background-color: var(--thea-system-accent);
}
body.thea-app-shell .form-range::-moz-range-thumb {
  background-color: var(--thea-system-accent);
}

body.thea-app-shell :is(a, button, input, select, textarea, [role="button"]):focus-visible {
  outline-color: rgba(var(--thea-system-accent-rgb), .55);
}

body.thea-app-shell ::selection {
  background: rgba(var(--thea-system-accent-rgb), .22);
}

@media (prefers-color-scheme: dark) {
  body.thea-app-shell {
    --thea-system-link-dark: var(--accent-color, var(--thea-system-accent));
  }

  body.thea-app-shell #mainContent a:not(.btn):not(.badge):not(.dropdown-item):not(.list-group-item):not(.nav-link):not(.page-link):not(.alert-link):not(.stretched-link):not(.text-decoration-none):not(.text-danger):not(.link-danger):not(.text-warning):not(.link-warning):not(.text-info):not(.link-info),
  body.thea-app-shell .thea-app-footer a:not(.btn) {
    color: var(--thea-system-link-dark) !important;
  }

  body.thea-app-shell .pagination .page-item.disabled .page-link,
  body.thea-app-shell .thea-ui-pagination .page-item.disabled .page-link {
    color: #9aa4ae !important;
    background-color: #242a33 !important;
    border-color: #3b424d !important;
  }
}
