/* HARPS V2 — GL Export feature styles, scoped to the .ar-glx container.
 *
 * Mirrors the GL Export rules from v2/harps-gl-export.html but namespaced so
 * they cannot leak into the Order/Deal table, and so the AR card's own rules
 * (fixed card height, flex column, .tab-item, .badge) cannot distort GL.
 * The standalone page keeps its own inline copy and is untouched.
 */

/* Local-view visibility. Needs !important because the hidden regions carry
   display:flex/block from the page's own rules. */
.ar-view-hidden { display: none !important; }

/* ── Container ─────────────────────────────────────────────────────────── */
.ar-glx {
  padding: 12px var(--ar-card-inset-x, 23px) 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1 1 auto;
  min-height: 0;
  box-sizing: border-box;
}

/* Flatten any leftover nested card so GL Export uses the outer AR surface. */
.ar-glx .overview-card.orders-card {
  width: 100%;
  height: auto;
  display: block;
  border: 0;
  border-radius: 0;
  overflow: visible;
  background: transparent;
  box-shadow: none;
}

.ar-glx .card-header,
.ar-glx .gl-subtabs {
  flex: none;
  width: 100%;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  box-sizing: border-box;
}

/* ads-theme.css paints every `.card-header` with a dashboard strip border.
   That is the extra line under Revenue / Adjustments. GL subtabs are not a
   card header, so the border is removed here rather than covered up. */
html[data-theme="ads"] .ar-glx .card-header,
html[data-theme="ads"] .ar-glx .gl-subtabs {
  border-bottom: 0;
  background: transparent;
}

/* ── Header text ───────────────────────────────────────────────────────── */
.ar-glx .page-subtitle {
  font-family: var(--font-family);
  font-size: var(--t20-size);
  line-height: var(--t20-line);
  font-weight: var(--weight-regular);
  color: var(--gray-50);
  margin: 0 0 16px 0;
}

.ar-glx .page-title-period {
  font-family: var(--font-family);
  font-size: var(--t20-size);
  line-height: var(--t20-line);
  font-weight: var(--weight-medium);
  color: var(--gray-50);
  white-space: nowrap;
}

/* ── KPI summary row ───────────────────────────────────────────────────── */
.ar-glx .gl-kpi-row,
.glx .gl-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
  flex: 0 0 auto;
}

@media (max-width: 1200px) {
  .ar-glx .gl-kpi-row { grid-template-columns: repeat(2, 1fr); }
}

/* KPI cards share the ADS Card Elevation None treatment from v2-ar.css.
   Status colour stays on .dash-kpi-value--brand / --warning / --red. */
.ar-glx .dash-kpi-card {
  background: #ffffff;
  border: 1px solid rgba(15, 18, 20, 0.1);
  border-radius: 8px;
  box-shadow: none;
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-sizing: border-box;
}

.ar-glx .dash-kpi-label,
html[data-theme="ads"] .ar-glx .dash-kpi-label {
  font-family: "Open Sans", var(--font-family), sans-serif;
  font-size: 12px;
  font-weight: 600;
  line-height: 18px;
  color: #3b4347;
  margin-bottom: 8px;
}

.ar-glx .dash-kpi-sub,
html[data-theme="ads"] .ar-glx .dash-kpi-sub {
  font-family: "Open Sans", var(--font-family), sans-serif;
  font-size: 12px;
  font-weight: 400;
  line-height: 18px;
  color: #51585b;
  margin-top: auto;
}

.overview-card.gl-card > .gl-kpi-row,
.overview-card.gl-card > .gl-export-main {
  padding-left: var(--ar-card-inset-x, 23px);
  padding-right: var(--ar-card-inset-x, 23px);
  box-sizing: border-box;
}

.ar-glx .gl-export-main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ── Inner tab panels ──────────────────────────────────────────────────── */
.ar-glx .gl-tab-panel {
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1 1 auto;
  min-height: 0;
}
.ar-glx .gl-tab-panel[hidden] { display: none; }

.ar-glx .gl-table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

/* Revenue / Adjustments is a segmented control in the table header, not a
   second tab row. ADS has no segmented-control component, so this is built
   from secondary/tertiary button tokens: 36px height, 6px radius, selected
   brand-tint fill + brand text. */
.ar-glx .gl-segmented,
.glx .gl-segmented {
  display: inline-flex;
  align-items: stretch;
  height: 38px;
  min-height: 38px;
  box-sizing: border-box;
  border: 1px solid var(--ads-divider, var(--gray-20, #e0e0e0));
  border-radius: 6px;
  background: var(--ads-card-bg, var(--white, #fff));
  flex: 0 0 auto;
}

.ar-glx .gl-segmented-btn,
.glx .gl-segmented-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 0;
  padding: 8px 16px;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--ads-gray-100, var(--gray-70, #51585b));
  font: var(--ads-font-body-md-sem, 600 14px/20px "Open Sans", sans-serif);
  cursor: pointer;
  white-space: nowrap;
  box-sizing: border-box;
}

.ar-glx .gl-segmented-btn:first-child,
.glx .gl-segmented-btn:first-child {
  border-radius: 5px 0 0 5px;
}

.ar-glx .gl-segmented-btn:last-child,
.glx .gl-segmented-btn:last-child {
  border-radius: 0 5px 5px 0;
}

.ar-glx .gl-segmented-btn + .gl-segmented-btn,
.glx .gl-segmented-btn + .gl-segmented-btn {
  border-left: 1px solid var(--ads-divider, var(--gray-20, #e0e0e0));
}

.ar-glx .gl-segmented-btn[aria-selected="true"],
.glx .gl-segmented-btn[aria-selected="true"] {
  background: var(--ads-brand-wash, var(--ads-indigo-50, #e2e3f2));
  color: var(--ads-brand, #4045c2);
}

.ar-glx .gl-segmented-btn:hover:not([aria-selected="true"]),
.glx .gl-segmented-btn:hover:not([aria-selected="true"]) {
  background: var(--ads-gray-50, #eceeee);
  color: var(--ads-gray-200, var(--gray-80, #3b4347));
}

/* ── Table header row ──────────────────────────────────────────────────── */
.ar-glx .gl-table-header,
.glx .gl-table-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  min-height: 38px;
  column-gap: 16px;
  margin: 0 0 16px;
  padding: 0;
  box-sizing: border-box;
  flex: 0 0 auto;
  border: 0;
  background: transparent;
}

@media (max-width: 1100px) {
  .ar-glx .gl-table-header,
  .glx .gl-table-header {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 8px;
  }
  .ar-glx .gl-action-btn,
  .glx .gl-action-btn {
    justify-self: start;
  }
}

.ar-glx .gl-table-header-left,
.glx .gl-table-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  justify-self: start;
}

.ar-glx .gl-table-title {
  font-family: "Open Sans", var(--font-family);
  font-size: 16px;
  line-height: 24px;
  font-weight: 600;
  color: var(--ar-text-strong, var(--gray-95, #1e2528));
}

.ar-glx .gl-table-count,
.glx .gl-table-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  border-radius: 12px;
  background: var(--indigo-10, #e8e9f7);
  border: 1px solid var(--indigo-20, #c5c7ea);
  box-sizing: border-box;
  font-size: 12px;
  line-height: 18px;
  font-weight: 600;
  color: var(--ar-indigo, #4045c2);
  font-variant-numeric: tabular-nums;
}

.ar-glx .gl-table-meta {
  font-family: var(--font-family);
  font-size: var(--t10-size);
  line-height: var(--t10-line);
  color: var(--gray-70);
  margin-bottom: 16px;
}

.ar-glx .gl-action-btn,
.glx .gl-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: end;
  gap: 6px;
  white-space: nowrap;
}

.ar-glx .gl-action-btn svg,
.glx .gl-action-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.ar-glx .gl-action-btn:disabled,
.glx .gl-action-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.ar-glx button.gl-file-link,
.glx button.gl-file-link {
  border: 0;
  padding: 0;
  background: none;
  color: var(--ads-indigo-700, #2d2f8c);
  font: 600 14px/20px "Open Sans", var(--font-family), sans-serif;
  cursor: pointer;
  text-align: left;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.ar-glx button.gl-file-link:hover,
.glx button.gl-file-link:hover { text-decoration: underline; color: var(--ads-indigo-800, #282a7c); }
.ar-glx button.gl-file-link:focus-visible,
.glx button.gl-file-link:focus-visible {
  outline: 2px solid var(--ads-brand, #4045c2);
  outline-offset: 2px;
}

/* ── Data tables (wide tables scroll inside their panel) ───────────────── */
.ar-glx .gl-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  table-layout: fixed;
}

#glAdjustmentsTable.gl-table th:nth-child(2),
#glAdjustmentsTable.gl-table td:nth-child(2) {
  width: 76px;
  max-width: 80px;
}

#glAdjustmentsTable.gl-table th:nth-child(3),
#glAdjustmentsTable.gl-table td:nth-child(3) {
  padding-right: 20px;
}

.ar-glx .gl-table th,
html[data-theme="ads"] .ar-glx .gl-table thead th {
  height: var(--ar-head-h, 32px);
  padding: 0 8px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  border-bottom: 1px solid var(--ar-divider, #d4dee3);
  background: #fff;
}

.ar-glx .gl-table td,
html[data-theme="ads"] .ar-glx .gl-table tbody td {
  height: var(--ar-row-h, 56px);
  padding: 8px;
  font-family: "Open Sans", var(--font-family), sans-serif;
  font-size: 14px;
  line-height: 21px;
  font-weight: 400;
  color: var(--ar-text-strong, var(--gray-95, #1e2528));
  vertical-align: middle;
  border-bottom: 1px solid var(--ar-divider, #d4dee3);
}

.ar-glx .gl-table tbody tr:last-child td { border-bottom: 1px solid var(--ar-divider, #d4dee3); }

.ar-glx .gl-num,
.ar-glx .gl-table th.gl-num,
.ar-glx .gl-table td.gl-num,
.ar-glx .gl-table th.gl-th-num,
.gl-table th.gl-th-num,
html[data-theme="ads"] .ar-glx .gl-table .gl-num,
html[data-theme="ads"] .ar-glx .gl-table thead th.gl-num,
html[data-theme="ads"] .ar-glx .gl-table tbody td.gl-num,
html[data-theme="ads"] .ar-glx .gl-table tfoot td.gl-num,
html[data-theme="ads"] .gl-table th.gl-th-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ar-glx .gl-table th.gl-num .sort-trigger {
  justify-content: flex-end;
}

html:not([data-theme="wireframe"]) .ar-glx .gl-table thead th,
html:not([data-theme="wireframe"]) .ar-glx .gl-table thead th .sort-label {
  color: #666d70 !important;
  font-family: var(--font-family, "Open Sans") !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  line-height: 18px !important;
  letter-spacing: 0 !important;
}

.ar-glx .gl-file {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ar-glx .gl-export-now.is-exporting,
.glx .gl-export-now.is-exporting {
  min-width: 5.75em;
  min-height: 20px;
  display: inline-flex;
  align-items: center;
  pointer-events: none;
  color: var(--ads-indigo-700, #2d2f8c);
}

.ar-glx .gl-ads-spinner,
.glx .gl-ads-spinner {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  display: inline-block;
  vertical-align: middle;
  animation: gl-ads-spin 0.7s linear infinite;
}

.ar-glx .gl-ads-spinner circle,
.glx .gl-ads-spinner circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 28 10;
}

@keyframes gl-ads-spin {
  to { transform: rotate(360deg); }
}

.ar-glx .gl-table tfoot td,
html[data-theme="ads"] .ar-glx .gl-table tfoot td {
  height: 48px;
  font-weight: 600;
  background: transparent;
  border-top: 1px solid var(--ar-divider, #d4dee3);
  border-bottom: none;
}

/* .gl-file-link colour, type, and states come from the shared table-link
   style in v2-table-link.css. This descendant selector used to out-rank it. */

/* ── Sortable headers ──────────────────────────────────────────────────── */
.ar-glx .sort-trigger {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  width: 100%;
}

.ar-glx .sort-trigger:focus-visible {
  outline: 2px solid var(--ads-brand, var(--indigo-70, #4045c2));
  outline-offset: 2px;
}

.ar-glx .sort-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-50);
}

.ar-glx .sort-icon path { fill: var(--gray-50); transition: fill 0.15s; }

/* Status chips inside GL tables come from the shared ADS Chip in
   assets/v2-chip.css. These descendant rules used to out-rank it. */

/* ── Loading / empty / error states ────────────────────────────────────── */
.ar-glx-state {
  padding: 32px 16px;
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 20px;
  color: var(--gray-70, #4B5F73);
  text-align: center;
}

.ar-glx-state.is-error { color: #9A4452; }

/* ── Dark theme ────────────────────────────────────────────────────────── */
html[data-theme="dark"] .ar-glx .gl-table th { color: var(--gray-50); }
html[data-theme="dark"] .ar-glx .gl-table-count { background: var(--white); }
html[data-theme="dark"] .ar-glx .gl-action-btn { background: var(--white); border-color: var(--indigo-30); }
