/* Global production-safe UI enhancements. Feature switches decide what initializes. */
:root {
  --gk-ui-z-loading: 1040;
  --gk-ui-z-dropdown: 1060;
  --gk-ui-z-modal-backdrop: 1070;
  --gk-ui-z-modal: 1080;
  --gk-ui-z-toast: 1090;
  --gk-ui-focus: 0 0 0 3px rgba(199, 154, 43, 0.24);
}

.gk-toasts-enabled #message {
  display: none !important;
}

select.form-control:not([multiple]),
select.custom-select:not([multiple]) {
  background-position: right 0.75rem center !important;
  direction: rtl !important;
  height: calc(2.25rem + 2px);
  line-height: 1.6 !important;
  min-height: calc(2.25rem + 2px);
  padding-block: 0.35rem !important;
  padding-left: 0.75rem !important;
  padding-right: 2rem !important;
  text-align: right !important;
  text-align-last: right;
  text-overflow: ellipsis;
  unicode-bidi: isolate;
  white-space: nowrap;
}

select.form-control:not([multiple]) option,
select.custom-select:not([multiple]) option {
  direction: rtl;
  text-align: right;
}

.gk-ui-nav-btn {
  align-items: center;
  background: #fff;
  border: 1px solid var(--aureum-card-border, #E4DED2);
  border-radius: 8px;
  color: var(--aureum-navy, #172033);
  display: inline-flex;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  gap: 6px;
  height: 36px;
  padding: 0 10px;
  transition: background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.gk-ui-nav-btn:hover,
.gk-ui-nav-btn:focus-visible {
  background: #F7F4EF;
  border-color: rgba(199, 154, 43, 0.55);
  box-shadow: var(--gk-ui-focus);
  outline: 0;
}

.gk-ui-nav-btn i {
  font-size: 1.1rem;
}

.gk-ui-nav-btn kbd {
  background: #F2F0ED;
  border: 1px solid #DED6C6;
  border-radius: 5px;
  color: var(--aureum-text-secondary, #667085);
  font-size: 0.66rem;
  line-height: 1;
  padding: 3px 5px;
}

.gk-ui-nav-btn-icon {
  justify-content: center;
  padding: 0;
  width: 36px;
}

.gk-loading-bar {
  background: linear-gradient(90deg, var(--aureum-gold, #C79A2B), var(--aureum-gold-bright, #FFD569));
  box-shadow: 0 0 10px rgba(199, 154, 43, 0.35);
  height: 3px;
  inset-block-start: 0;
  inset-inline-end: 0;
  position: fixed;
  transform: scaleX(0);
  transform-origin: right center;
  transition: transform 220ms ease, opacity 180ms ease;
  width: 100%;
  z-index: var(--gk-ui-z-loading);
}

.gk-loading-bar.is-visible {
  opacity: 1;
  transform: scaleX(0.72);
}

.gk-loading-bar.is-finishing {
  opacity: 0;
  transform: scaleX(1);
}

.gk-command-backdrop {
  align-items: flex-start;
  background: rgba(23, 32, 51, 0.28);
  display: none;
  inset: 0;
  justify-content: center;
  padding: 9vh 18px 24px;
  position: fixed;
  z-index: var(--gk-ui-z-modal);
}

.gk-command-backdrop.is-open {
  display: flex;
}

.gk-command-panel {
  background: #fff;
  border: 1px solid var(--aureum-card-border, #E4DED2);
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(23, 32, 51, 0.22);
  color: var(--aureum-text, #172033);
  display: flex;
  flex-direction: column;
  height: min(720px, calc(100vh - 96px));
  max-width: 760px;
  min-height: 260px;
  overflow: hidden;
  width: min(760px, 100%);
}

.gk-command-search {
  align-items: center;
  border-bottom: 1px solid var(--aureum-card-border, #E4DED2);
  display: flex;
  gap: 10px;
  padding: 12px 14px;
}

.gk-command-search i {
  color: var(--aureum-gold, #C79A2B);
  font-size: 1.25rem;
}

.gk-command-input {
  border: 0;
  color: var(--aureum-text, #172033);
  flex: 1;
  font-size: 1rem;
  outline: 0;
}

.gk-command-input::placeholder {
  color: #5B6678;
}

.gk-command-results {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
  scroll-padding: 12px;
}

.gk-command-group-title {
  color: var(--aureum-text-secondary, #667085);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 10px 10px 5px;
}

.gk-command-result {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: inherit;
  cursor: pointer;
  display: flex;
  gap: 10px;
  padding: 10px;
  text-align: right;
  width: 100%;
}

.gk-command-result:hover,
.gk-command-result.is-active {
  background: #F7F4EF;
}

.gk-command-icon {
  align-items: center;
  background: #F2F0ED;
  border-radius: 8px;
  color: var(--aureum-navy, #172033);
  display: inline-flex;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.gk-command-title {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
}

.gk-command-subtitle {
  color: var(--aureum-text-secondary, #667085);
  display: block;
  font-size: 0.76rem;
  margin-top: 2px;
}

.gk-command-empty {
  color: var(--aureum-text-secondary, #667085);
  padding: 28px 14px;
  text-align: center;
}

.gk-recent-menu {
  background: #fff;
  border: 1px solid var(--aureum-card-border, #E4DED2);
  border-radius: 10px;
  box-shadow: 0 16px 42px rgba(23, 32, 51, 0.18);
  color: var(--aureum-text, #172033);
  display: none;
  max-height: min(600px, 78vh);
  overflow-y: auto;
  padding: 10px;
  position: fixed;
  width: min(380px, calc(100vw - 24px));
  z-index: var(--gk-ui-z-dropdown);
}

.gk-recent-menu.is-open {
  display: block;
}

.gk-recent-section + .gk-recent-section {
  border-top: 1px solid #ECE6DA;
  margin-top: 8px;
  padding-top: 8px;
}

.gk-recent-heading {
  color: var(--aureum-text-secondary, #667085);
  font-size: 0.72rem;
  font-weight: 700;
  margin: 4px 4px 6px;
}

.gk-recent-item {
  align-items: center;
  border-radius: 8px;
  color: inherit;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  padding: 8px;
  text-decoration: none;
}

.gk-recent-item:hover {
  background: #F7F4EF;
  color: inherit;
  text-decoration: none;
}

.gk-recent-empty {
  color: var(--aureum-text-secondary, #667085);
  font-size: 0.8rem;
  padding: 8px;
}

.gk-toast-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  inset-block-start: 74px;
  inset-inline-end: 18px;
  position: fixed;
  width: min(410px, calc(100vw - 36px));
  z-index: var(--gk-ui-z-toast);
}

.gk-toast {
  align-items: flex-start;
  background: #fff;
  border: 1px solid var(--aureum-card-border, #E4DED2);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(23, 32, 51, 0.16);
  color: var(--aureum-text, #172033);
  display: flex;
  gap: 12px;
  overflow: hidden;
  padding: 13px 14px;
  position: relative;
}

.gk-toast::after {
  background: #E4DED2;
  bottom: 0;
  content: "";
  height: 3px;
  inset-inline: 0;
  position: absolute;
}

.gk-toast-success { background: linear-gradient(180deg, #fff, rgba(15, 118, 110, 0.035)); border-color: rgba(15, 118, 110, 0.26); }
.gk-toast-error { background: linear-gradient(180deg, #fff, rgba(180, 35, 24, 0.035)); border-color: rgba(180, 35, 24, 0.28); }
.gk-toast-warning { background: linear-gradient(180deg, #fff, rgba(199, 154, 43, 0.045)); border-color: rgba(199, 154, 43, 0.36); }
.gk-toast-info { background: linear-gradient(180deg, #fff, rgba(30, 42, 69, 0.035)); border-color: rgba(30, 42, 69, 0.22); }

.gk-toast-icon {
  align-items: center;
  background: #F2F0ED;
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  flex: 0 0 auto;
  height: 30px;
  justify-content: center;
  margin-top: 1px;
  width: 30px;
}

.gk-toast-icon i {
  font-size: 1.05rem;
}

.gk-toast-success .gk-toast-icon { background: var(--aureum-green, #0F766E); }
.gk-toast-error .gk-toast-icon { background: var(--aureum-red, #B42318); }
.gk-toast-warning .gk-toast-icon { background: var(--aureum-gold, #C79A2B); }
.gk-toast-info .gk-toast-icon { background: var(--aureum-navy, #172033); }
.gk-toast-success::after { background: var(--aureum-green, #0F766E); }
.gk-toast-error::after { background: var(--aureum-red, #B42318); }
.gk-toast-warning::after { background: var(--aureum-gold, #C79A2B); }
.gk-toast-info::after { background: var(--aureum-navy, #172033); }

.gk-toast-title {
  font-size: 0.84rem;
  font-weight: 800;
  margin-bottom: 2px;
}

.gk-toast-message {
  color: var(--aureum-text-secondary, #667085);
  font-size: 0.81rem;
  line-height: 1.55;
}

.gk-toast-close {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--aureum-text-secondary, #667085);
  display: inline-flex;
  height: 28px;
  justify-content: center;
  margin-inline-start: auto;
  padding: 0;
  width: 28px;
}

.gk-toast-close:hover,
.gk-toast-close:focus-visible {
  background: #F2F0ED;
  color: var(--aureum-navy, #172033);
  outline: 0;
}

/* Toast readability: solid (never see-through) background and high-contrast
   text in BOTH themes. In dark mode the white toast used to show light text
   on a light surface; in light mode the near-white toast blended into the
   white page and looked transparent. */
.gk-toast-title { color: #172033; }
.gk-toast-message { color: #3a4150; }

/* Light theme (and default/unset): give each level a clearly opaque, tinted
   surface plus a stronger border/shadow so the toast reads as a solid card. */
html:not([data-theme="dark"]) .gk-toast {
  background: #ffffff;
  border-color: #d7d1c4;
  box-shadow: 0 16px 40px rgba(23, 32, 51, 0.24);
}
html:not([data-theme="dark"]) .gk-toast-success { background: #eef9f6; border-color: rgba(15, 118, 110, 0.5); }
html:not([data-theme="dark"]) .gk-toast-error   { background: #fdf1f0; border-color: rgba(180, 35, 24, 0.5); }
html:not([data-theme="dark"]) .gk-toast-warning { background: #fdf7e9; border-color: rgba(199, 154, 43, 0.55); }
html:not([data-theme="dark"]) .gk-toast-info    { background: #f2f5fa; border-color: rgba(30, 42, 69, 0.45); }

html[data-theme="dark"] .gk-toast,
html[data-theme="dark"] .gk-toast-success,
html[data-theme="dark"] .gk-toast-error,
html[data-theme="dark"] .gk-toast-warning,
html[data-theme="dark"] .gk-toast-info {
  background: #1f2530;
  border-color: rgba(255, 255, 255, 0.16);
}
html[data-theme="dark"] .gk-toast-title { color: #ffffff; }
html[data-theme="dark"] .gk-toast-message { color: #cdd5e0; }
html[data-theme="dark"] .gk-toast-close { color: #cdd5e0; }
html[data-theme="dark"] .gk-toast-close:hover,
html[data-theme="dark"] .gk-toast-close:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.gk-field-help {
  color: var(--aureum-text-secondary, #667085);
  display: block;
  font-size: 0.74rem;
  margin-top: 5px;
}

.gk-field-help.is-error {
  color: var(--aureum-red, #B42318);
}

.form-control.gk-invalid,
input.gk-invalid,
select.gk-invalid,
textarea.gk-invalid {
  border-color: var(--aureum-red, #B42318) !important;
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.14) !important;
}

.gk-table-wrap {
  position: relative;
}

.gk-table-wrap::before,
.gk-table-wrap::after {
  content: "";
  inset-block: 0;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  transition: opacity 160ms ease;
  width: 18px;
  z-index: 2;
}

.gk-table-wrap::before {
  background: linear-gradient(90deg, rgba(23, 32, 51, 0.12), transparent);
  inset-inline-start: 0;
}

.gk-table-wrap::after {
  background: linear-gradient(270deg, rgba(23, 32, 51, 0.12), transparent);
  inset-inline-end: 0;
}

.gk-table-wrap.has-left-shadow::before,
.gk-table-wrap.has-right-shadow::after {
  opacity: 1;
}

.gk-table-enhanced thead th {
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 3;
}

.gk-table-enhanced tbody tr:nth-child(even) {
  background-color: rgba(23, 32, 51, 0.018);
}

.gk-table-enhanced tbody tr:hover {
  background-color: rgba(199, 154, 43, 0.08);
}

.gk-table-enhanced .gk-num,
.gk-table-enhanced td[data-num],
.gk-table-enhanced td.gk-numeric {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.gk-table-enhanced tfoot tr,
.gk-table-enhanced tr.gk-total-row {
  background: #F7F4EF;
  bottom: 0;
  font-weight: 800;
  position: sticky;
  z-index: 2;
}

.gk-empty-state {
  align-items: center;
  background: #FAF9F7;
  border: 1px dashed var(--aureum-card-border, #E4DED2);
  border-radius: 8px;
  color: var(--aureum-text-secondary, #667085);
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
  min-height: 96px;
  padding: 18px;
  text-align: center;
}

tr.gk-empty-row > td {
  background: #FAF9F7 !important;
  padding: 0 !important;
}

.gk-empty-state i {
  color: var(--aureum-gold, #C79A2B);
  font-size: 1.7rem;
}

.gk-empty-state strong {
  color: var(--aureum-text, #172033);
  font-size: 0.9rem;
}

@media (max-width: 575.98px) {
  .gk-ui-nav-btn span,
  .gk-ui-nav-btn kbd {
    display: none;
  }

  .gk-ui-nav-btn {
    justify-content: center;
    padding: 0;
    width: 36px;
  }

}

@media (max-width: 767.98px) {
  .gk-mobile-ui .gk-table-wrap,
  .gk-mobile-ui .table-responsive {
    display: block;
    max-width: 100%;
    overflow-x: auto !important;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
  }

  .gk-mobile-ui .gk-table-wrap > table.table,
  .gk-mobile-ui .table-responsive > table.table {
    margin-bottom: 0;
    min-width: 100%;
    width: max-content;
  }

  .gk-mobile-ui .gk-table-wrap > table.table th,
  .gk-mobile-ui .gk-table-wrap > table.table td,
  .gk-mobile-ui .table-responsive > table.table th,
  .gk-mobile-ui .table-responsive > table.table td {
    white-space: nowrap;
  }

  .gk-mobile-ui .gk-table-enhanced thead th,
  .gk-mobile-ui .gk-table-enhanced tfoot tr,
  .gk-mobile-ui .gk-table-enhanced tr.gk-total-row {
    position: static;
  }
}

@media print {
  .gk-loading-bar,
  .gk-command-backdrop,
  .gk-recent-menu,
  .gk-toast-stack,
  .gk-ui-nav-btn {
    display: none !important;
  }

  .gk-table-enhanced thead th,
  .gk-table-enhanced tfoot tr,
  .gk-table-enhanced tr.gk-total-row {
    position: static;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gk-loading-bar,
  .gk-ui-nav-btn,
  .gk-table-wrap::before,
  .gk-table-wrap::after {
    transition: none;
  }
}
