/* ============================================================
   erp_ui2.css — ERP IstaRP Design System
   Composed from:
     1. IstaRP base.css (body, navbar, buttons, page shell, rendering header)
     2. IstaRP generic_tables.css (horizontal + vertical table system)
     3. ERP-specific extensions (status chips, filter row, KPI cards, etc.)
   ============================================================ */

/* ── 1. BASE ─────────────────────────────────────────────── */

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f2f2f2;
  color: #111111;
}

.navbar {
  min-height: 47px;
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0 12px 0 10px;
  box-sizing: border-box;
  background-image: url('../img/nav/top_nav_bar_background.png');
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  position: relative;
  z-index: 40;
}

.navbar__brand {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 0 18px 0 0;
  text-decoration: none;
}

.navbar__brand-logo {
  display: block;
  height: 20px;
  width: auto;
}

.navbar__sections {
  flex: 1 1 auto;
  display: flex;
  align-items: stretch;
  list-style: none;
  margin: 0;
  padding: 0;
}

.navbar__section {
  display: flex;
  min-width: 104px;
  position: relative;
}

.navbar__section-link,
.navbar__section-label {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  height: 100%;
  padding: 0 10px 0 18px;
  box-sizing: border-box;
  color: #ffffff;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: left;
}

.navbar__section-link {
  text-decoration: none;
}

.navbar__section-label {
  cursor: default;
}

.navbar__section-label:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: -4px;
}

.navbar__section-link span,
.navbar__section-label span {
  display: inline-block;
}

.navbar__section:hover .navbar__dropdown,
.navbar__section.navbar__section--keyboard-open .navbar__dropdown {
  display: block;
}

.navbar__dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 162px;
  padding: 10px 0;
  background: #ffffff;
  box-shadow: none;
  z-index: 50;
}

.nav-tree,
.nav-tree__children {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-tree__item {
  display: block;
}

.nav-tree__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.nav-tree__link,
.nav-tree__label {
  display: block;
  flex: 1 1 auto;
  padding: 4px 12px;
  color: #111111;
  white-space: nowrap;
  font-size: 0.98rem;
  line-height: 1.25;
}

.nav-tree__link {
  text-decoration: none;
}

.nav-tree__label {
  cursor: default;
}

.nav-tree__link:hover {
  background: rgba(0, 0, 0, 0.05);
}

.nav-tree__children {
  padding-left: 18px;
}

.nav-tree__toggle {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 6px 12px 6px 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-tree__icon {
  display: block;
  width: 11px;
  height: 11px;
  object-fit: contain;
  transform: rotate(0deg);
  transition: transform 0.15s ease;
}

.nav-tree__toggle[aria-expanded='true'] .nav-tree__icon {
  transform: rotate(-90deg);
}

.navbar__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
}

.locale-dropdown {
  position: relative;
}

.locale-dropdown__summary {
  list-style: none;
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.18);
  background: #ffffff;
  color: #000000;
  border-radius: 0.35rem;
  padding: 0.3rem 1.6rem 0.3rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  position: relative;
}

.locale-dropdown__summary::-webkit-details-marker {
  display: none;
}

.locale-dropdown__summary::after {
  content: '▾';
  position: absolute;
  right: 0.55rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.72rem;
}

.locale-dropdown:not([open]) .locale-dropdown__menu {
  display: none;
}

.locale-dropdown__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 100%;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 0.45rem;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  z-index: 60;
}

.locale-dropdown__item {
  display: block;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  color: #000000;
  white-space: nowrap;
}

.locale-dropdown__item:hover {
  background: rgba(0, 0, 0, 0.04);
}

.navbar__worker-id,
.navbar__display-name {
  color: #000000;
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
}

.logout-form {
  margin: 0;
  display: flex;
  align-items: center;
}

.logout-button {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.logout-button__icon {
  display: block;
  width: 28px;
  height: 28px;
}

.page-shell {
  min-height: calc(100vh - 47px);
}

#app-content {
  min-height: calc(100vh - 47px);
}

.navbar__section--active > .navbar__section-link,
.navbar__section--active > .navbar__section-label {
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.nav-tree__item--ancestor > .nav-tree__row > .nav-tree__link,
.nav-tree__item--ancestor > .nav-tree__row > .nav-tree__label {
  font-weight: 600;
}

.nav-tree__link--current,
.nav-tree__label--ancestor {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

.breadcrumbs {
  padding: 0 0 4px;
  font-size: 0.9rem;
}

.breadcrumbs__list {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

.breadcrumbs__item {
  color: #555555;
}

.breadcrumbs__item:not(:last-child)::after {
  content: '/';
  margin-left: 4px;
  color: #777777;
}

.breadcrumbs__link {
  color: #333333;
  text-decoration: none;
}

.breadcrumbs__link:hover {
  text-decoration: underline;
}

.breadcrumbs__disabled {
  color: #8a8f98;
  cursor: default;
  text-decoration: none;
}

.breadcrumbs__current {
  color: #111111;
  font-weight: 700;
}

.app-page {
  padding: 0 24px 24px;
  box-sizing: border-box;
}

/* ── Rendering header ─────────────────────────────────────── */

.app-rendering-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0px;
  padding-bottom: 4px;
  background: transparent;
  flex-wrap: wrap;
  box-sizing: border-box;
}

.app-rendering-header__left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.app-rendering-header__title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.app-rendering-header__title {
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.1;
  color: #000000;
  min-width: 0;
  max-width: min(620px, 50vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0;
}

.app-rendering-header__left-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.app-rendering-header__right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.app-rendering-header__search-input {
  min-width: 160px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid #c9c9c9;
  font-size: 0.9rem;
  box-sizing: border-box;
  background: #ffffff;
}

.app-rendering-header__search-btn {
  width: 34px;
  min-height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.app-rendering-header__search-btn img {
  width: 14px;
  height: 14px;
  transform: rotate(-90deg);
  filter: brightness(10);
}

.page-header-bar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 0;
}

/* ── Buttons ──────────────────────────────────────────────── */

.ui-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 14px;
  box-sizing: border-box;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.ui-button--dark-grey {
  background: #8f9aa7;
  color: #ffffff;
}

.ui-button--purple {
  background: #9d8ba0;
  color: #ffffff;
}

.ui-button--red {
  background: #cb6b93;
  color: #ffffff;
}

.ui-button--green {
  background: #7fa085;
  color: #ffffff;
}

.ui-button--dark-dark-grey {
  background: #5a6270;
  color: #ffffff;
}

.ui-button--light-grey {
  background: #c9c9c9;
  color: #333333;
}

.ui-button--compact {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.9rem;
}

.ui-button--full-width {
  width: 100%;
  min-height: 30px;
  border: 0;
  border-radius: 0;
}

.ui-button--dark-grey:hover,
.ui-button--purple:hover,
.ui-button--red:hover,
.ui-button--green:hover,
.ui-button--dark-dark-grey:hover,
.ui-button--light-grey:hover {
  filter: brightness(0.97);
}

.ui-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.ui-icon-button img {
  display: block;
  width: 18px;
  height: 18px;
}

/* ── Surface ──────────────────────────────────────────────── */

.ui-section-surface {
  background: #ffffff;
  border: 1px solid #c9c9c9;
  box-sizing: border-box;
}

/* ── 2. GENERIC TABLES ───────────────────────────────────── */

.generic-horizontal-table {
  padding: 14px 18px 18px;
}

.generic-horizontal-table__header {
  min-height: 36px;
  margin-bottom: 12px;
}

.generic-horizontal-table__header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
}

.generic-horizontal-table__header-left,
.generic-horizontal-table__header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.generic-horizontal-table__header-title {
  margin: 0;
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.1;
  color: #000000;
}

.generic-horizontal-table__body {
  width: 100%;
  overflow-x: auto;
}

.generic-horizontal-table__table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.generic-horizontal-table__table tbody {
  border: 1px solid #b8bfc7;
}

.generic-horizontal-table__table thead th {
  padding: 8px 12px;
  text-align: center;
  vertical-align: middle;
  font-size: 0.95rem;
  font-weight: 700;
  color: #000000;
  background: transparent;
  border-bottom: 1px solid #b8bfc7;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.generic-horizontal-table__table tbody td {
  padding: 6px 12px;
  text-align: center;
  vertical-align: middle;
  color: #000000;
  border-right: 1px solid #b8bfc7;
}

.generic-horizontal-table__table tbody tr:nth-child(odd) {
  background: #e6eaee;
}

.generic-horizontal-table__table tbody tr:nth-child(even) {
  background: #c7ced6;
}

.generic-horizontal-table__table thead th:last-child,
.generic-horizontal-table__table tbody td:last-child {
  border-right: 0;
}

.generic-horizontal-table__th--action,
.generic-horizontal-table__td--action {
  width: 112px;
}

.generic-horizontal-table__td--action {
  padding: 0;
}

.generic-horizontal-table__td--action .ui-button {
  width: 100%;
  min-height: 30px;
  border: 0;
  border-radius: 0;
}

/* ── Generic vertical table ──────────────────────────────── */

.generic-vertical-table {
  padding: 0;
  overflow: hidden;
}

.generic-vertical-table__table {
  width: 100%;
  border-collapse: collapse;
}

.generic-vertical-table__label,
.generic-vertical-table__value {
  padding: 10px 16px;
  font-size: 1rem;
  line-height: 1.4;
  border-bottom: 1px solid #d1d1d1;
  box-sizing: border-box;
  vertical-align: middle;
}

.generic-vertical-table__label {
  width: 200px;
  min-width: 160px;
  font-weight: 700;
  color: #000;
  text-align: left;
  white-space: nowrap;
  border-right: 1px solid #d1d1d1;
}

.generic-vertical-table__value {
  color: #000;
  text-align: center;
  word-break: break-word;
}

.generic-vertical-table__row--odd .generic-vertical-table__label {
  background: #d4d8dc;
}

.generic-vertical-table__row--odd .generic-vertical-table__value {
  background: #ffffff;
}

.generic-vertical-table__row--even .generic-vertical-table__label {
  background: #c8cdd2;
}

.generic-vertical-table__row--even .generic-vertical-table__value {
  background: #f7f7f7;
}

.generic-vertical-table__row:last-child .generic-vertical-table__label,
.generic-vertical-table__row:last-child .generic-vertical-table__value {
  border-bottom: none;
}

/* ── 3. ERP-SPECIFIC EXTENSIONS ─────────────────────────── */

/* Status chips */
.erp-status-chip {
  display: inline-block;
  padding: 2px 10px;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: 2px;
  white-space: nowrap;
}

.erp-status-chip--ok {
  background: #7fa085;
  color: #ffffff;
}

.erp-status-chip--warn {
  background: #c9a84c;
  color: #ffffff;
}

.erp-status-chip--error {
  background: #cb6b93;
  color: #ffffff;
}

.erp-status-chip--idle {
  background: #b0b8c1;
  color: #333333;
}

/* Filter row */
.erp-filter-row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
}

.erp-filter-row__chip {
  display: inline-block;
  padding: 3px 12px;
  font-size: 0.9rem;
  color: #333333;
  text-decoration: none;
  border: 1px solid #c9c9c9;
  background: #f2f2f2;
  cursor: pointer;
}

.erp-filter-row__chip:hover {
  background: #e6eaee;
}

.erp-filter-row__chip--active {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  background: #ffffff;
  border-color: #8f9aa7;
  color: #111111;
}

/* KPI grid */
.erp-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 900px) {
  .erp-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.erp-kpi-card {
  background: #ffffff;
  border: 1px solid #c9c9c9;
  padding: 16px 20px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.erp-kpi-num {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: #111111;
}

.erp-kpi-label {
  font-size: 0.85rem;
  color: #555555;
}

/* Empty state */
.erp-empty {
  text-align: center;
  padding: 32px 16px;
  color: #888888;
  font-size: 0.95rem;
}

/* Monospace pre block */
.erp-pre {
  background: #2b2b2b;
  color: #e8e8e8;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.82rem;
  padding: 12px 16px;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
}

/* Realtime status bar */
.erp-realtime-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 3px 24px;
  background: #e8edf2;
  border-bottom: 1px solid #c9c9c9;
  font-size: 0.8rem;
  color: #555555;
  min-height: 24px;
  box-sizing: border-box;
}

.erp-realtime-bar__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #b0b8c1;
  flex-shrink: 0;
}

.erp-realtime-bar__dot--live {
  background: #7fa085;
}

.erp-realtime-bar__dot--error {
  background: #cb6b93;
}

/* Form row layout inside vertical table value cells */
.erp-form-input {
  width: 100%;
  max-width: 420px;
  padding: 5px 10px;
  border: 1px solid #c9c9c9;
  font-size: 0.95rem;
  box-sizing: border-box;
  background: #ffffff;
}

.erp-form-select-wrap {
  position: relative;
  display: inline-block;
  max-width: 420px;
  width: 100%;
}

.erp-form-select-wrap select {
  width: 100%;
  appearance: none;
  padding: 5px 32px 5px 10px;
  border: 1px solid #c9c9c9;
  font-size: 0.95rem;
  background: #ffffff;
  cursor: pointer;
}

.erp-form-select-wrap img {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  pointer-events: none;
}

textarea.erp-form-input {
  resize: vertical;
  min-height: 80px;
}

/* ── Mobile navbar drawer ─────────────────────────────────────────────────── */
.navbar__menu-toggle {
  display: none; /* hidden on desktop */
  background: transparent;
  border: 0;
  padding: 10px 12px;
  cursor: pointer;
  margin-left: auto;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
}

.navbar__menu-toggle-bar {
  display: block;
  width: 22px;
  height: 2px;
  background: #ffffff;
  border-radius: 1px;
}

@media (max-width: 900px) {
  .navbar {
    flex-wrap: wrap;
    min-height: 47px;
  }
  .navbar__menu-toggle {
    display: inline-flex;
  }
  .navbar__sections {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    background: rgba(15, 23, 42, 0.94);
    padding: 4px 0;
    max-height: calc(100vh - 47px);
    overflow-y: auto;
  }
  .navbar--drawer-open .navbar__sections {
    display: flex;
  }
  .navbar__section {
    width: 100%;
    min-width: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }
  .navbar__section-link,
  .navbar__section-label {
    padding: 10px 16px;
    font-size: 1rem;
  }
  .navbar__dropdown {
    position: static !important;
    background: rgba(0, 0, 0, 0.25) !important;
    box-shadow: none !important;
    border: 0 !important;
    display: block !important;
    padding: 0 0 6px 0 !important;
  }
  .nav-tree {
    padding: 0 !important;
  }
  .nav-tree__link {
    color: #e2e8f0 !important;
    padding: 8px 32px !important;
    display: block !important;
  }
  .navbar__right {
    flex-basis: 100%;
    margin: 0;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.2);
    justify-content: space-between;
  }
  .navbar__worker-id {
    font-size: 0.8rem;
  }
}
