/*
 * Shared member-history layout.
 * The history pages are data screens first: keep the information readable,
 * preserve the account context and turn wide tables into mobile cards.
 */

:root {
  --history-blue: var(--mediums-faq-blue, #23466f);
  --history-blue-strong: var(--mediums-faq-blue-strong, #173f6b);
  --history-muted: var(--mediums-faq-muted, #486186);
  --history-accent: var(--mediums-faq-accent, #7899cc);
  --history-border: var(--mediums-faq-border, #dbe5f0);
  --history-border-strong: var(--mediums-faq-border-strong, #a8c5ea);
  --history-surface: #fbfdff;
  --history-space-1: .5rem;
  --history-space-2: .75rem;
  --history-space-3: 1rem;
  --history-space-4: 1.5rem;
}

/* The legacy shell hides all useful page context on small screens. */
.history-page .row.verbergen-xs:has(.kl-title-block .tbk__title) {
  display: block !important;
}

.history-page .row.verbergen-xs:has(.m_title) {
  display: block !important;
}

.history-page .row.verbergen-xs:has(.kl-title-block .tbk__title) .tbk__title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .35rem .55rem;
  max-width: 100%;
  margin: 0 !important;
  font-size: clamp(1.25rem, 4.5vw, 1.75rem) !important;
  line-height: 1.2 !important;
}

.history-page .row.verbergen-xs:has(.kl-title-block .tbk__title) .tbk__title > img,
.history-page .row.verbergen-xs:has(.kl-title-block .tbk__title) .tbk__title > i {
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  margin: 0 !important;
  object-fit: contain;
}

.history-page .row.verbergen-xs:has(.kl-title-block .tbk__title) .tbk__title > i {
  width: 2.25rem;
  font-size: 2.25rem !important;
  line-height: 1;
}

.history-page .row.verbergen-xs:has(.kl-title-block .tbk__title) .tbk__title > b {
  margin-left: 0 !important;
}

.history-page .row.verbergen-xs:has(.kl-title-block .tbk__title) .tbk__title > b.verbergen-xs {
  display: inline !important;
}

.history-page .kl-title-block .tbk__title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .35rem .55rem;
  max-width: 100%;
}

.history-page .kl-title-block .tbk__title > img {
  flex: 0 0 auto;
  max-width: 2.75rem;
  max-height: 2.75rem;
  object-fit: contain;
}

.history-page .kl-title-block .tbk__title > b {
  margin-left: 0 !important;
}

.history-page h3.m_title {
  max-width: 72ch;
  margin-bottom: var(--history-space-4);
  color: var(--history-muted);
  font-size: 1rem;
  line-height: 1.65;
}

.history-page h3.m_title > .fw-thin > .verbergen-xs {
  display: inline !important;
}

.history-page h3.m_title .fw-semibold {
  color: var(--history-blue-strong);
  font-weight: 700;
}

.history-page p[align="justify"] {
  text-align: left !important;
}

.history-mobile-toolbar {
  display: none;
}

.history-mobile-toolbar a {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  color: var(--history-blue-strong);
  font-size: .95rem;
  font-weight: 700;
  text-decoration: none;
}

.history-mobile-toolbar a:focus-visible {
  outline: 3px solid rgba(120, 153, 204, .72);
  outline-offset: 2px;
}

/* Give a data table a predictable desktop rhythm before it becomes cards. */
.history-data-table {
  width: 100%;
  margin: 0 !important;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--history-blue);
}

.history-data-table thead th,
.history-data-table thead td {
  padding: .75rem .85rem;
  border-top: 1px solid var(--history-border);
  border-bottom: 1px solid var(--history-border);
  color: var(--history-blue-strong);
  font-size: .875rem;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
}

.history-data-table tbody td {
  padding: 1rem .85rem;
  border-bottom: 1px solid var(--history-border);
  vertical-align: middle;
  font-size: 1rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.history-data-table tbody tr:last-child td {
  border-bottom: 0;
}

.history-data-table tbody tr:hover {
  background: #f7faff;
}

.history-data-table td:first-child,
.history-data-table th:first-child {
  padding-left: .25rem;
}

.history-data-table td:last-child,
.history-data-table th:last-child {
  padding-right: .25rem;
}

.history-data-table a {
  color: var(--history-blue-strong);
}

.history-data-table img {
  max-width: 3.75rem;
  height: auto;
}

.history-data-table .history-cell--primary {
  color: var(--history-blue-strong);
}

.history-data-table .history-row-action {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  gap: .6rem;
  padding: .35rem 0;
  border: 0;
  background: transparent;
  color: var(--history-blue-strong);
  font: inherit;
  font-weight: 700;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}

.history-data-table .history-row-action:focus-visible,
.history-data-table a:focus-visible {
  outline: 3px solid rgba(120, 153, 204, .72);
  outline-offset: 2px;
}

.history-data-table .history-muted {
  color: var(--history-muted);
  font-size: .875rem;
}

.history-data-table .history-payment-value {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: .45rem;
  text-align: right;
}

.history-data-table .history-payment-value .kl-icon {
  flex: 0 0 auto;
  margin-right: 0 !important;
}

.history-data-table .history-payment-value b {
  overflow-wrap: anywhere;
}

.history-empty-state {
  margin: 0;
  padding: 1rem 1.1rem;
  border: 1px solid var(--history-border);
  background: var(--history-surface);
  color: var(--history-muted);
  font-size: 1rem;
  line-height: 1.6;
}

.history-empty-state a {
  color: var(--history-blue-strong);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: .15em;
}

.history-empty-cell {
  padding: 1.25rem !important;
  color: var(--history-muted);
  text-align: left;
}

.history-request-status {
  color: var(--history-muted);
}

.history-chat-frame {
  display: block;
  width: 100%;
  min-height: 32rem;
  height: min(750px, 75vh);
  border: 1px solid var(--history-border);
  background: var(--history-surface);
}

.history-navigation-grid {
  row-gap: 2rem;
}

.history-navigation-grid > .post > a.hoverBorder {
  display: block;
}

.history-navigation-grid > .post > em {
  display: block;
  margin-top: .65rem;
}

.history-navigation-grid > .post > em > a {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  color: var(--history-muted);
  line-height: 1.4;
}

@media (max-width: 767px) {
  /* The desktop title block sits behind the fixed mobile header; the intro below
     already provides the page context on small screens. */
  .history-page .row.verbergen-xs:has(.kl-title-block .tbk__title) {
    display: none !important;
  }

  .history-page .hg_section {
    padding-top: 1.25rem !important;
    padding-bottom: 1.25rem !important;
  }

  .history-mobile-toolbar {
    display: block;
    margin: 0 0 .5rem;
  }

  .history-page .history-data-table {
    display: block;
  }

  .history-page .history-data-table thead {
    display: none;
  }

  .history-page .history-data-table tbody,
  .history-page .history-data-table tr,
  .history-page .history-data-table td {
    display: block;
    width: 100%;
  }

  .history-page .history-data-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .2rem 1rem;
    margin: 0 0 .75rem;
    padding: .9rem 1rem;
    border: 1px solid var(--history-border);
    border-radius: 12px;
    background: var(--history-surface);
  }

  .history-page .history-data-table tbody tr:last-child {
    margin-bottom: 0;
  }

  .history-page .history-data-table tbody tr:has(> .history-empty-cell) {
    display: block;
  }

  .history-page .history-data-table tbody td,
  .history-page .history-data-table td:first-child,
  .history-page .history-data-table td:last-child {
    display: flex;
    width: auto;
    min-width: 0;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: .4rem 0;
    border: 0;
    font-size: 1rem;
    line-height: 1.45;
    text-align: right;
  }

  .history-page .history-data-table tbody td::before {
    flex: 0 0 auto;
    color: var(--history-muted);
    content: attr(data-label);
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .035em;
    line-height: 1.35;
    text-align: left;
    text-transform: uppercase;
  }

  .history-page .history-data-table tbody td.history-cell--primary {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-bottom: .7rem;
    border-bottom: 1px solid var(--history-border);
    text-align: left;
  }

  .history-page .history-data-table tbody td.history-cell--primary::before {
    display: none;
  }

  .history-page .history-data-table tbody td.history-actions-cell {
    grid-column: 1 / -1;
    display: block;
    padding-top: .7rem;
    text-align: left;
  }

  .history-page .history-data-table tbody td.history-actions-cell::before {
    display: none;
  }

  .history-page .history-data-table tbody td.history-empty-cell {
    display: block;
    text-align: left;
  }

  .history-page .history-data-table tbody td.history-empty-cell::before {
    display: none;
  }

  .history-page .history-data-table .history-row-action {
    width: 100%;
  }

  .history-page .history-data-table--payment tbody tr {
    grid-template-columns: minmax(0, 1fr);
  }

  .history-page .history-data-table--payment tbody td {
    grid-column: 1;
  }

  .history-page .history-data-table--payment .history-payment-value {
    max-width: 70%;
    align-items: flex-start;
  }

  .history-page .history-chat-frame {
    min-height: 28rem;
    height: 65vh;
  }

  .history-navigation-grid {
    row-gap: 1.5rem;
  }

  .history-navigation-grid > .post > em > a {
    min-height: 2.75rem;
  }
}

@media (max-width: 380px) {
  .history-page .row.verbergen-xs:has(.kl-title-block .tbk__title) .tbk__title {
    font-size: 1.18rem !important;
  }

  .history-page .history-data-table tbody tr {
    padding: .8rem;
  }

  .history-page .history-data-table tbody td,
  .history-page .history-data-table td:first-child,
  .history-page .history-data-table td:last-child {
    gap: .65rem;
    font-size: .95rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .history-page *,
  .history-page *::before,
  .history-page *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
