/*
 * UI Parity Theme – Variant A (Hard Restore)
 * Restores the legacy main branch look & feel without design tokens.
 */

body[data-theme="legacy"].app-layout {
  background: linear-gradient(180deg, #252932 0%, #303540 55%, #1f2430 100%);
  color: #f4f7ff;
}

body[data-theme="legacy"] .app-shell,
body[data-theme="legacy"] .app-shell__form,
body[data-theme="legacy"] .app-main,
body[data-theme="legacy"] .page-surface,
body[data-theme="legacy"] .page-content {
  background: transparent;
}

body[data-theme="legacy"] .ct-header {
  background: linear-gradient(180deg, #353b47 0%, #2b303a 65%, #21252e 100%);
  color: #f6f8ff;
  border-bottom: 1px solid rgba(12, 14, 21, 0.65);
  box-shadow: 0 14px 32px rgba(8, 12, 22, 0.55);
}

body[data-theme="legacy"] .ct-header__inner {
  gap: 18px;
  padding-inline: 18px;
  min-height: 58px;
}

body[data-theme="legacy"] .ct-header__brand strong,
body[data-theme="legacy"] .ct-header__brand {
  color: #f6f8ff;
  font-weight: 600;
}

body[data-theme="legacy"] .ct-header__logout {
  background: linear-gradient(180deg, #f9fbff 0%, #dfe8ff 100%);
  color: #1f2530;
  border: 1px solid rgba(31, 37, 48, 0.35);
  border-radius: 999px;
  padding: 6px 18px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

body[data-theme="legacy"] .ct-header__logout:hover,
body[data-theme="legacy"] .ct-header__logout:focus-visible {
  background: linear-gradient(180deg, #ffffff 0%, #e8efff 100%);
  color: #10141d;
  transform: translateY(-1px);
}

body[data-theme="legacy"] #main_nav {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding-block: 4px;
  background: linear-gradient(180deg, #2f3540 0%, #262b33 100%);
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 14px 30px rgba(12, 16, 24, 0.55);
  overflow: visible;
  z-index: 1300;
}

body[data-theme="legacy"] .ct-main-nav__list,
body[data-theme="legacy"] .main-nav__list {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  white-space: nowrap;
  gap: 6px;
  margin: 0;
  padding: 0 12px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(110, 135, 168, 0.55) transparent;
}

body[data-theme="legacy"] .ct-main-nav__list::-webkit-scrollbar,
body[data-theme="legacy"] .main-nav__list::-webkit-scrollbar {
  height: 8px;
}

body[data-theme="legacy"] .ct-main-nav__list::-webkit-scrollbar-thumb,
body[data-theme="legacy"] .main-nav__list::-webkit-scrollbar-thumb {
  background: rgba(110, 135, 168, 0.55);
  border-radius: 999px;
}

body[data-theme="legacy"] .main-nav__item,
body[data-theme="legacy"] .ct-main-nav__item {
  position: relative;
}

body[data-theme="legacy"] .main-nav__link,
body[data-theme="legacy"] .main-nav__sublink,
body[data-theme="legacy"] .ct-main-nav__link,
body[data-theme="legacy"] .ct-dropdown-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 18px;
  color: #f4f7ff;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  border-radius: 999px;
  background: transparent;
  border: 1px solid transparent;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

body[data-theme="legacy"] .main-nav__link .ct-main-nav__label,
body[data-theme="legacy"] .ct-main-nav__label {
  color: inherit;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

body[data-theme="legacy"] .main-nav__link:focus-visible,
body[data-theme="legacy"] .main-nav__sublink:focus-visible,
body[data-theme="legacy"] .ct-main-nav__link:focus-visible,
body[data-theme="legacy"] .ct-dropdown-link:focus-visible {
  outline: 2px solid #7bb2ff;
  outline-offset: 3px;
}

body[data-theme="legacy"] .dropdown-toggle::after {
  content: '\25BE';
  font-size: 0.65em;
  margin-left: 6px;
  opacity: 0.75;
}

body[data-theme="legacy"] .main-nav__item.is-active > .main-nav__link,
body[data-theme="legacy"] .main-nav__link:hover,
body[data-theme="legacy"] .main-nav__link:focus-visible,
body[data-theme="legacy"] .ct-main-nav__item.is-active > .ct-main-nav__link,
body[data-theme="legacy"] .ct-main-nav__link:hover,
body[data-theme="legacy"] .ct-main-nav__link:focus-visible {
  background: linear-gradient(180deg, rgba(124, 184, 255, 0.9) 0%, rgba(90, 152, 228, 0.85) 100%);
  color: #10141d;
  border-color: rgba(124, 184, 255, 0.75);
  box-shadow: 0 8px 18px rgba(26, 64, 110, 0.45);
}

body[data-theme="legacy"] .main-nav__item.dropdown.is-open > .main-nav__link,
body[data-theme="legacy"] .ct-main-nav__item.is-open > .ct-main-nav__link {
  background: linear-gradient(180deg, rgba(124, 184, 255, 0.95) 0%, rgba(93, 156, 236, 0.92) 100%);
  color: #0b1320;
  border-color: rgba(124, 184, 255, 0.8);
}

body[data-theme="legacy"] .main-nav__submenu,
body[data-theme="legacy"] .dropdown-menu,
body[data-theme="legacy"] .ct-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  padding: 10px;
  background: linear-gradient(180deg, rgba(33, 39, 51, 0.98) 0%, rgba(26, 32, 44, 0.96) 100%);
  color: #f7f9ff;
  border-radius: 14px;
  border: 1px solid rgba(120, 140, 175, 0.55);
  box-shadow: 0 18px 36px rgba(8, 12, 22, 0.65);
  overflow: hidden;
  z-index: 1400;
}

body[data-theme="legacy"] .main-nav__submenu[hidden],
body[data-theme="legacy"] .dropdown-menu[hidden],
body[data-theme="legacy"] .ct-dropdown[hidden] {
  display: none !important;
}

body[data-theme="legacy"] .main-nav__submenu::before,
body[data-theme="legacy"] .dropdown-menu::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 26px;
  width: 12px;
  height: 12px;
  background: inherit;
  transform: rotate(45deg);
  border-left: 1px solid rgba(120, 140, 175, 0.55);
  border-top: 1px solid rgba(120, 140, 175, 0.55);
  z-index: -1;
}

body[data-theme="legacy"] .main-nav__submenu-item,
body[data-theme="legacy"] .ct-dropdown-item {
  list-style: none;
}

body[data-theme="legacy"] .main-nav__sublink,
body[data-theme="legacy"] .ct-dropdown-link {
  justify-content: flex-start;
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  color: #f7f9ff;
}

body[data-theme="legacy"] .main-nav__sublink:hover,
body[data-theme="legacy"] .main-nav__sublink:focus-visible,
body[data-theme="legacy"] .ct-dropdown-link:hover,
body[data-theme="legacy"] .ct-dropdown-link:focus-visible {
  background: rgba(124, 184, 255, 0.22);
  color: #fdfdff;
}

body[data-theme="legacy"] .main-nav__item.is-open > .main-nav__submenu,
body[data-theme="legacy"] .main-nav__submenu-item.is-open > .main-nav__submenu,
body[data-theme="legacy"] .dropdown-submenu.is-open > .main-nav__submenu,
body[data-theme="legacy"] .dropdown-submenu:hover > .main-nav__submenu {
  display: block;
}

body[data-theme="legacy"] .main-nav__submenu .dropdown-submenu > .main-nav__submenu {
  left: calc(100% - 8px);
  top: 0;
}

/* Panel & card surfaces */
body[data-theme="legacy"] .app-main .panel,
body[data-theme="legacy"] .app-main .card,
body[data-theme="legacy"] .page-surface .panel,
body[data-theme="legacy"] .page-surface .card {
  background: linear-gradient(180deg, #f5f7ff 0%, #ecf2ff 100%);
  border-radius: 16px;
  border: 1px solid rgba(37, 44, 59, 0.35);
  box-shadow: 0 16px 40px rgba(12, 16, 32, 0.38);
  overflow: hidden;
}

body[data-theme="legacy"] .panel-heading,
body[data-theme="legacy"] .card__header,
body[data-theme="legacy"] .page-surface .panel > h3,
body[data-theme="legacy"] .page-surface .card > h3 {
  margin: 0;
  padding: 12px 18px;
  background: linear-gradient(180deg, #3a4050 0%, #2d3341 100%);
  color: #f7f9ff;
  font-weight: 600;
  border-bottom: 1px solid rgba(18, 22, 32, 0.65);
}

body[data-theme="legacy"] .panel-body,
body[data-theme="legacy"] .card__body,
body[data-theme="legacy"] .page-surface .panel > div,
body[data-theme="legacy"] .page-surface .card > div {
  padding: 16px 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(227, 236, 255, 0.95) 100%);
  color: #1a2233;
}

body[data-theme="legacy"] .page-surface .panel:empty,
body[data-theme="legacy"] .page-surface .card:empty {
  display: none;
}

/* Tables */
body[data-theme="legacy"] .app-main table {
  background: transparent;
  border-collapse: separate;
  border-spacing: 0;
}

body[data-theme="legacy"] .app-main table thead th {
  background: linear-gradient(180deg, #d7e3ff 0%, #c6d6ff 100%);
  color: #152033;
  font-weight: 600;
  border-bottom: 2px solid #a9bae2;
  padding: 10px 14px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

body[data-theme="legacy"] .app-main table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(110, 135, 168, 0.45);
  color: #1a2233;
}

body[data-theme="legacy"] .app-main table tbody tr:nth-child(even) {
  background: rgba(234, 240, 255, 0.75);
}

body[data-theme="legacy"] .app-main table tbody tr:hover {
  background: rgba(110, 168, 254, 0.35);
}

body[data-theme="legacy"] .app-main table tbody tr:last-child td {
  border-bottom: none;
}

body[data-theme="legacy"] .app-main table thead th.tablesorter-headerAsc,
body[data-theme="legacy"] .app-main table thead th.tablesorter-headerDesc {
  background: linear-gradient(180deg, #bed0ff 0%, #adc4ff 100%);
  box-shadow: inset 0 -3px 0 rgba(49, 86, 140, 0.55);
}

body[data-theme="legacy"] .app-main table thead th .sort-arrow {
  color: #10203a;
}

/* Sticky execution bar */
body[data-theme="legacy"] .ct-sticky-actions {
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

body[data-theme="legacy"] .ct-sticky-actions::before,
body[data-theme="legacy"] .ct-sticky-actions::after {
  display: none !important;
}

body[data-theme="legacy"] .ct-sticky-actions > * {
  position: relative;
  z-index: 1;
}

/* Responsive keep nav single row */
@media (max-width: 1024px) {
  body[data-theme="legacy"] #main_nav {
    padding-inline: 10px;
  }

  body[data-theme="legacy"] .ct-main-nav__list,
  body[data-theme="legacy"] .main-nav__list {
    overflow-x: auto;
  }
}
