/* Reimbursement itemized-expense table styling for HESK 3.7.11 (hesk3 theme) */

/* HESK constrains each field's .form-group to a narrow column (~570px). Let the
   field that hosts our table span the full form width instead. Two mechanisms:
   (1) a class the JS adds to the parent .form-group (reliable everywhere), and
   (2) a :has() fallback for browsers where the JS parent walk is unavailable. */
.form-group.reimb-fullwidth,
.form-group:has(.reimb-table-wrap) {
  width: 100% !important;
  max-width: 100% !important;
  flex: 1 1 100% !important;
}

.reimb-table-wrap {
  margin: 6px 0 4px;
  max-width: 100%;
}

.reimb-table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: #fff;
  table-layout: fixed; /* share available width; prevents overflow scrollbar */
}

.reimb-table th,
.reimb-table td {
  border: 1px solid #d5d9df;
  padding: 6px 8px;
  vertical-align: middle;
  overflow-wrap: break-word;
  word-break: break-word;
}

.reimb-table thead th {
  background: #f2f4f7;
  text-align: left;
  font-weight: 600;
  white-space: normal;
}

/* Column widths: Date | Merchant | Amount | Purpose | remove-btn */
.reimb-table th:nth-child(1),
.reimb-table td:nth-child(1) { width: 15%; }
.reimb-table th:nth-child(2),
.reimb-table td:nth-child(2) { width: 24%; }
.reimb-table th:nth-child(3),
.reimb-table td:nth-child(3) { width: 13%; }
.reimb-table th:nth-child(4),
.reimb-table td:nth-child(4) { width: 40%; }
.reimb-table th:nth-child(5),
.reimb-table td:nth-child(5) { width: 8%; }

.reimb-table input {
  width: 100%;
  box-sizing: border-box;
  padding: 5px 6px;
  border: 1px solid #cfd4da;
  border-radius: 4px;
  font-size: 0.9rem;
}

.reimb-table input.reimb-amount {
  text-align: right;
}

.reimb-table input.reimb-invalid {
  border-color: #d9534f;
  background: #fdf3f2;
}

.reimb-actions-col {
  width: 36px;
  text-align: center;
}

.reimb-remove-btn {
  border: none;
  background: transparent;
  color: #d9534f;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}

.reimb-remove-btn:hover {
  color: #a94442;
}

.reimb-add-btn {
  margin-top: 8px;
  padding: 6px 12px;
  border: 1px solid #4a90d9;
  background: #4a90d9;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

.reimb-add-btn:hover {
  background: #3a7bc0;
}

.reimb-table tfoot .reimb-total-label {
  text-align: right;
  font-weight: 600;
  background: #f9fafb;
}

.reimb-table tfoot .reimb-total-value {
  text-align: right;
  font-weight: 700;
  background: #f9fafb;
}

/* View-side read-only rendering (ticket / print pages) */
.reimb-view-table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 4px 0;
  table-layout: fixed; /* share available width instead of overflowing */
}

.reimb-view-table th,
.reimb-view-table td {
  border: 1px solid #d5d9df;
  padding: 6px 8px;
  text-align: left;
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: normal;
}

/* Column width hints: Date | Merchant | Amount | Purpose (widest) */
.reimb-view-table th:nth-child(1),
.reimb-view-table td:nth-child(1) { width: 14%; }
.reimb-view-table th:nth-child(2),
.reimb-view-table td:nth-child(2) { width: 24%; }
.reimb-view-table th:nth-child(3),
.reimb-view-table td:nth-child(3) { width: 14%; }
.reimb-view-table th:nth-child(4),
.reimb-view-table td:nth-child(4) { width: 48%; }

.reimb-view-table thead th {
  background: #f2f4f7;
  font-weight: 600;
}

.reimb-view-table td.reimb-view-amount,
.reimb-view-table th.reimb-view-amount {
  text-align: right;
}

.reimb-view-table tfoot td {
  font-weight: 700;
  background: #f9fafb;
  text-align: right;
}
