/* Final-layer overrides (loaded last).
   Purpose: replace previous !important usage with deterministic cascade order. */

:root {
  --ui-font-primary: "Inter", "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

/* Global typography/color standardization */
:where(*):not(.material-symbols-outlined) {
  font-family: var(--ui-font-primary);
}

body,
p,
span,
label,
small,
strong,
em,
li,
td,
input,
textarea,
select {
  color: var(--ui-text-standard);
}

h2,
h3,
.card h2,
.detail-panel h2,
.ui-card h2,
.ui-panel h2,
.g-card-title,
.tracker-filter-card-title,
.tracker-filter-card-count,
.pfe-kpi-label,
.pfe-kpi-value,
th,
.data-table th,
.ui-table th,
thead th {
  color: var(--ui-text-standard);
}

tbody td,
.data-table tbody td,
.ui-table tbody td,
tbody td *:not(input):not(textarea):not(select) {
  color: var(--ui-text-standard);
}

tbody td :is(i, svg, .material-icons, .material-symbols-outlined),
.data-table tbody td :is(i, svg, .material-icons, .material-symbols-outlined),
.ui-table tbody td :is(i, svg, .material-icons, .material-symbols-outlined) {
  color: var(--ui-text-standard);
  fill: currentColor;
  stroke: currentColor;
}

button,
.toolbar-btn,
.ui-btn,
.g-btn,
.theme-select-trigger,
.theme-select-option,
.theme-select-group-label,
select,
.g-select,
input[list] {
  color: #1f2663;
}

/* Unified disabled button style (same as danger-disabled) */
:where(.toolbar-btn, .ui-btn, .g-btn, button):disabled,
:where(.toolbar-btn, .ui-btn, .g-btn, button)[aria-disabled="true"] {
  color: #8f8f8f;
  background: #f2f2f2;
  border-color: #d2d2d2;
  opacity: 1;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

:where(.toolbar-btn, .ui-btn, .g-btn, button):disabled:hover,
:where(.toolbar-btn, .ui-btn, .g-btn, button):disabled:focus,
:where(.toolbar-btn, .ui-btn, .g-btn, button):disabled:focus-visible,
:where(.toolbar-btn, .ui-btn, .g-btn, button)[aria-disabled="true"]:hover,
:where(.toolbar-btn, .ui-btn, .g-btn, button)[aria-disabled="true"]:focus,
:where(.toolbar-btn, .ui-btn, .g-btn, button)[aria-disabled="true"]:focus-visible {
  color: #8f8f8f;
  background: #f2f2f2;
  border-color: #d2d2d2;
  opacity: 1;
  box-shadow: none;
  transform: none;
}

/* Higher-specificity lock so generic .toolbar-btn:hover rules never alter disabled visuals */
.toolbar-btn:disabled:hover,
.toolbar-btn:disabled:focus,
.toolbar-btn:disabled:focus-visible,
.ui-btn:disabled:hover,
.ui-btn:disabled:focus,
.ui-btn:disabled:focus-visible,
.g-btn:disabled:hover,
.g-btn:disabled:focus,
.g-btn:disabled:focus-visible,
button:disabled:hover,
button:disabled:focus,
button:disabled:focus-visible {
  color: #8f8f8f;
  background: #f2f2f2;
  border-color: #d2d2d2;
  opacity: 1;
  box-shadow: none;
  transform: none;
}

/* Operations-specific disabled hover lock (beats page-level hover rules) */
.main-tracker-directory-body .main-tracker-controls-group .toolbar-btn:disabled,
.main-tracker-directory-body .main-tracker-controls-group .ui-btn:disabled,
.main-tracker-directory-body .table-pager .toolbar-btn:disabled,
.main-tracker-directory-body .table-pager .ui-btn:disabled,
.main-tracker-directory-body .main-tracker-controls-group .toolbar-btn:disabled:hover,
.main-tracker-directory-body .main-tracker-controls-group .ui-btn:disabled:hover,
.main-tracker-directory-body .table-pager .toolbar-btn:disabled:hover,
.main-tracker-directory-body .table-pager .ui-btn:disabled:hover,
.main-tracker-directory-body .main-tracker-controls-group .toolbar-btn:disabled:focus,
.main-tracker-directory-body .main-tracker-controls-group .ui-btn:disabled:focus,
.main-tracker-directory-body .table-pager .toolbar-btn:disabled:focus,
.main-tracker-directory-body .table-pager .ui-btn:disabled:focus,
.main-tracker-directory-body .main-tracker-controls-group .toolbar-btn:disabled:focus-visible,
.main-tracker-directory-body .main-tracker-controls-group .ui-btn:disabled:focus-visible,
.main-tracker-directory-body .table-pager .toolbar-btn:disabled:focus-visible,
.main-tracker-directory-body .table-pager .ui-btn:disabled:focus-visible {
  color: #8f8f8f;
  background: #f2f2f2;
  border-color: #d2d2d2;
  opacity: 1;
  box-shadow: none;
  transform: none;
}

/* Danger button: keep same color on hover/focus/active */
:where(.toolbar-btn, .ui-btn, .g-btn).danger,
:where(.toolbar-btn, .ui-btn, .g-btn).danger:hover,
:where(.toolbar-btn, .ui-btn, .g-btn).danger:focus,
:where(.toolbar-btn, .ui-btn, .g-btn).danger:focus-visible,
:where(.toolbar-btn, .ui-btn, .g-btn).danger:active {
  color: #ffffff;
  background: #ff0000;
  border-color: #ff0000;
}

/* Operations Dashboard: search textbox fills remaining toolbar width */
.main-tracker-directory-body #main-tracker-toolbar #main-tracker-search-input {
  flex: 1 1 120px;
  width: 0;
  min-width: 120px;
  max-width: none;
}

/* Operations entry modal top actions: keep as normal button style in all states */
.main-tracker-directory-body #entry-modal :is(#toggle-required-only-btn, #cancel-modal, button[form="entry-form"]),
.main-tracker-directory-body #entry-modal :is(#toggle-required-only-btn, #cancel-modal, button[form="entry-form"]):hover,
.main-tracker-directory-body #entry-modal :is(#toggle-required-only-btn, #cancel-modal, button[form="entry-form"]):focus,
.main-tracker-directory-body #entry-modal :is(#toggle-required-only-btn, #cancel-modal, button[form="entry-form"]):focus-visible,
.main-tracker-directory-body #entry-modal :is(#toggle-required-only-btn, #cancel-modal, button[form="entry-form"]):active {
  color: #1f2663;
  background: #ffffff;
  border-color: #d2d2d2;
  box-shadow: none;
  transform: none;
}

/* Operations Dashboard normal buttons: enforce same visual style as modal normal buttons */
.main-tracker-directory-body :is(.main-tracker-controls-group, .table-pager, .ui-modal, .modal) :is(.toolbar-btn, .ui-btn):not(.danger):not(:disabled),
.main-tracker-directory-body :is(.main-tracker-controls-group, .table-pager, .ui-modal, .modal) :is(.toolbar-btn, .ui-btn):not(.danger):not(:disabled):hover,
.main-tracker-directory-body :is(.main-tracker-controls-group, .table-pager, .ui-modal, .modal) :is(.toolbar-btn, .ui-btn):not(.danger):not(:disabled):focus,
.main-tracker-directory-body :is(.main-tracker-controls-group, .table-pager, .ui-modal, .modal) :is(.toolbar-btn, .ui-btn):not(.danger):not(:disabled):focus-visible,
.main-tracker-directory-body :is(.main-tracker-controls-group, .table-pager, .ui-modal, .modal) :is(.toolbar-btn, .ui-btn):not(.danger):not(:disabled):active {
  color: #1f2663;
  background: #ffffff;
  border-color: #d2d2d2;
  box-shadow: none;
  transform: none;
}

/* Keep PF floating filter menu above modal */
body > .filter-menu[data-pf-menu="1"],
body > .ui-filter-menu[data-pf-menu="1"] {
  z-index: 10060;
}

/* Feed Generator + Proxies QR pager strip background alignment */
body.feeder-directory-body .feeder-main-panel > .table-section,
body.feeder-directory-body .feeder-main-panel > .table-section > form#delete-form,
body.feeder-directory-body .feeder-main-panel > .table-section > form#delete-form > .table-pager.ui-pager.table-full-width.main-tracker-pager-groups,
body.ipqr-directory-body .table-section,
body.ipqr-directory-body .table-section > form#ipqr-delete-form,
body.ipqr-directory-body .table-section > form#ipqr-delete-form > .table-pager.ui-pager.table-full-width.main-tracker-pager-groups {
  background: #e5e9ef;
}

body.feeder-directory-body .feeder-main-panel > .table-section > form#delete-form > .table-pager.ui-pager.table-full-width.main-tracker-pager-groups,
body.ipqr-directory-body .table-section > form#ipqr-delete-form > .table-pager.ui-pager.table-full-width.main-tracker-pager-groups {
  border-top: 0;
  border-color: transparent;
  box-shadow: none;
}

html body.feeder-directory-body .feeder-main-panel .table-pager.ui-pager.table-full-width.main-tracker-pager-groups,
html body.ipqr-directory-body .table-pager.ui-pager.table-full-width.main-tracker-pager-groups {
  background-color: #e5e9ef;
  background-image: none;
  border-top-width: 0;
  border-top-style: solid;
  border-top-color: transparent;
}

/* Sticky top headers for key tables */
html body.ipqr-directory-body #ipqr-table thead th.checkbox-col,
html body.ipqr-directory-body #ipqr-table thead th.action-col,
html body.main-tracker-directory-body #main-tracker-table thead th.checkbox-col,
html body.main-tracker-directory-body #main-tracker-table thead th.main-tracker-users-col,
html body.main-tracker-directory-body #main-tracker-table thead th.action-col {
  position: sticky;
  top: 0;
  z-index: 60;
  background: #f3f6fb;
}

html body.ipqr-directory-body #ipqr-table thead th.checkbox-col {
  left: 0;
}

html body.ipqr-directory-body #ipqr-table thead th.action-col {
  left: 46px;
}

/* Desktop floating drawers */
@media (min-width: 821px) {
  body .app-shell {
    gap: 0;
  }

  body .app-main {
    width: 100%;
    max-width: 100%;
  }

  body #app-drawer {
    position: fixed;
    top: 64px;
    left: 12px;
    width: 230px;
    height: calc(100dvh - 76px);
    max-height: calc(100dvh - 76px);
    z-index: 90;
    box-shadow: 0 14px 34px rgba(27, 38, 50, 0.18);
    transition: transform 0.2s ease, opacity 0.2s ease;
    display: flex;
  }

  body.drawer-open #app-drawer {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  body.drawer-closed #app-drawer {
    transform: translateX(calc(-100% - 18px));
    opacity: 0;
    pointer-events: none;
  }

  body .user-menu-drawer {
    top: 64px;
    right: 12px;
    width: min(300px, calc(100vw - 24px));
    height: calc(100dvh - 76px);
    border: 1px solid rgba(29, 42, 52, 0.14);
    border-radius: 12px;
    box-shadow: 0 14px 34px rgba(27, 38, 50, 0.18);
    transform: translateX(calc(100% + 18px));
  }

  body.user-menu-open .user-menu-drawer {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }
}

/* Unified table border normalization across all global-skin tables,
   including modal tables (even tables without IDs). */
html body table.data-table.ui-table.mt-table-unified {
  border: 1px solid #d8e0ea;
}

html body table.data-table.ui-table.mt-table-unified thead th {
  border-bottom-color: #d8e0ea;
  border-right-color: #e3e8ef;
}

html body table.data-table.ui-table.mt-table-unified tbody td {
  border-top-color: #e3e8ef;
  border-right-color: #e3e8ef;
}

html body table.data-table.ui-table.mt-table-unified thead th:last-child,
html body table.data-table.ui-table.mt-table-unified tbody td:last-child {
  border-right-color: transparent;
}
