/* Quote Payment Panel — all selectors namespaced with .payment-* */

/* ============================================================================
   PANEL CONTAINER
   ============================================================================ */
.payment-panel {
  font-size: 0.875rem;
  font-family: inherit;
}

/* ============================================================================
   SECTION CARDS
   ============================================================================ */
.payment-card {
  border: none;
  border-radius: 0.75rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  margin-bottom: 1rem;
  overflow: hidden;
  background: #fff;
  transition: box-shadow 0.2s ease;
}

.payment-card:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.11);
}

.payment-card-header {
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid rgba(255,255,255,0.2);
}

.payment-card-header--status {
  background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
  color: #fff;
}

.payment-card-header--add {
  background: linear-gradient(135deg, #198754 0%, #146c43 100%);
  color: #fff;
  cursor: pointer;
  user-select: none;
}

.payment-card-header--add:hover {
  background: linear-gradient(135deg, #146c43 0%, #0f5132 100%);
}

.payment-card-header--list {
  background: linear-gradient(135deg, #495057 0%, #343a40 100%);
  color: #fff;
}

.payment-card-body {
  padding: 1rem;
}

/* ============================================================================
   STATUS SECTION
   ============================================================================ */
.payment-status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
}

@media (max-width: 480px) {
  .payment-status-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.payment-stat-box {
  background: #f8f9fa;
  border-radius: 0.5rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid #e9ecef;
}

.payment-stat-box--order-total .payment-order-total-edit-btn {
  line-height: 1;
  min-width: auto;
  flex-shrink: 0;
}

.payment-stat-box--order-total .payment-order-total-edit-btn:hover .fa-pencil-alt {
  color: #0d6efd !important;
}

.payment-stat-box--order-total .payment-order-total-input {
  max-width: 100%;
}

.payment-stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6c757d;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.payment-stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: #212529;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.payment-stat-value--positive {
  color: #198754;
}

.payment-stat-value--negative {
  color: #dc3545;
}

.payment-stat-value--neutral {
  color: #6c757d;
}

.payment-overpaid-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 0.5rem;
  background: linear-gradient(135deg, #fff4f0 0%, #ffd4c4 100%);
  border: 2px solid #ea580c;
  box-shadow: 0 0 0 1px rgba(234, 88, 12, 0.15), 0 2px 8px rgba(234, 88, 12, 0.12);
  font-size: 0.88rem;
  font-weight: 600;
  color: #7c2d12;
}

.payment-overpaid-banner i {
  color: #c2410c;
  font-size: 1.05rem;
}

.payment-overpaid-banner strong {
  color: #9a3412;
  font-weight: 800;
}

.payment-order-now-wrap {
  margin-top: 0.75rem;
}

.payment-order-now-btn {
  border-radius: 0.5rem;
  font-weight: 600;
  padding: 0.45rem 0.75rem;
}

/* ============================================================================
   BADGE
   ============================================================================ */
.payment-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.payment-badge--not_paid {
  background: #fde68a;
  color: #78350f;
}

.payment-badge--partially_paid {
  background: #fff3cd;
  color: #856404;
}

.payment-badge--paid_in_full {
  background: #d1e7dd;
  color: #0f5132;
}

.payment-badge--overpaid {
  background: #cfe2ff;
  color: #084298;
}

/* Badge dot indicator */
.payment-badge::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.payment-badge--not_paid::before { background: #ffc107; }
.payment-badge--partially_paid::before { background: #ffc107; }
.payment-badge--paid_in_full::before { background: #198754; }
.payment-badge--overpaid::before { background: #0d6efd; }

/* Company custom colors use inline background; hide dot for pill badges */
.payment-badge.rounded-pill::before {
  display: none;
}

/* Small variant used in table rows */
.payment-badge.payment-row-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.4rem 0.95rem;
  line-height: 1.35;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border-radius: 999px;
}

.payment-row-badge:hover {
  opacity: .88;
  transition: opacity .15s;
}

/* ============================================================================
   ADD TOGGLE BUTTON (inside header)
   ============================================================================ */
.payment-add-toggle-icon {
  margin-left: auto;
  transition: transform 0.25s ease;
  display: inline-block;
}

.payment-add-toggle-icon.rotated {
  transform: rotate(45deg);
}

/* ============================================================================
   FORMS
   ============================================================================ */
.payment-form-inner {
  padding: 0.75rem 1rem 1rem;
  background: #f8fff9;
  border-top: 1px solid #d1e7dd;
}

.payment-edit-form-inner {
  padding: 0.75rem 1rem 1rem;
  background: #f8f9fa;
  border-top: 1px solid #dee2e6;
}

.payment-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6c757d;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

/* Ensure all form controls inside the payment form share the same height */
.payment-form-inner .form-control-sm,
.payment-form-inner .form-select-sm,
.payment-edit-form-inner .form-control-sm,
.payment-edit-form-inner .form-select-sm {
  height: 2rem;
  min-height: 2rem;
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
  box-sizing: border-box;
}

/* Textarea keeps its auto height */
.payment-form-inner textarea.form-control-sm,
.payment-edit-form-inner textarea.form-control-sm {
  height: auto;
  min-height: 4rem;
}

.payment-form-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

/* Rounder, padded action buttons */
.payment-form-actions .btn {
  border-radius: 1.5rem;
  padding-left: 1.1rem;
  padding-right: 1.1rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.payment-form-error {
  font-size: 0.8rem;
  color: #dc3545;
  margin-top: 0.5rem;
}

/* ============================================================================
   PAYMENT LIST
   ============================================================================ */

/* Let Bootstrap table-responsive handle horizontal scroll; just round the bottom corners */
.payment-history-table-wrap {
  border-radius: 0 0 0.75rem 0.75rem;
}
.payment-list-table {
  width: 100%;
  font-size: 0.8rem;
  border-collapse: separate;
  border-spacing: 0;
}

.payment-list-table thead th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6c757d;
  font-weight: 700;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid #e9ecef;
  background: #f8f9fa;
  white-space: nowrap;
}

.payment-list-table thead th:first-child { border-radius: 0.5rem 0 0 0; }
.payment-list-table thead th:last-child  { border-radius: 0 0.5rem 0 0; }

.payment-list-table tbody tr.payment-row {
  transition: background 0.15s ease;
}

.payment-list-table tbody tr.payment-row:hover {
  background: #f0f4ff;
}

.payment-list-table tbody td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
  color: #212529;
}

.payment-list-table tbody tr:last-child td {
  border-bottom: none;
}

.payment-amount-cell {
  font-weight: 700;
  color: #198754;
}

.payment-credit-cell {
  font-weight: 700;
  color: #0d6efd;
}

.payment-notes-cell {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #6c757d;
}

.payment-proof-link {
  font-size: 0.75rem;
  font-weight: 600;
  color: #0d6efd;
  text-decoration: none;
  border: 1px solid #0d6efd;
  padding: 0.1rem 0.45rem;
  border-radius: 0.375rem;
  transition: all 0.15s ease;
}

.payment-proof-link:hover {
  background: #0d6efd;
  color: #fff;
}

.payment-edit-row td {
  padding: 0;
  background: #f8f9fa;
}

.payment-action-btn {
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 0.375rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.4;
}

.payment-action-btn--edit {
  color: #0d6efd;
  border-color: #0d6efd;
  background: transparent;
}

.payment-action-btn--edit:hover {
  background: #0d6efd;
  color: #fff;
}

.payment-action-btn--delete {
  color: #dc3545;
  border-color: #dc3545;
  background: transparent;
}

.payment-action-btn--delete:hover {
  background: #dc3545;
  color: #fff;
}

/* ============================================================================
   EMPTY STATE
   ============================================================================ */
.payment-empty-state {
  text-align: center;
  padding: 1.75rem 1rem;
  color: #adb5bd;
}

.payment-empty-state i {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  display: block;
}

.payment-empty-state p {
  margin: 0;
  font-size: 0.85rem;
}

/* ============================================================================
   PROGRESS BAR
   ============================================================================ */
.payment-progress-wrap {
  margin-top: 0.75rem;
}

.payment-progress-bar-track {
  height: 6px;
  background: #e9ecef;
  border-radius: 999px;
  overflow: hidden;
}

.payment-progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #0d6efd, #198754);
  transition: width 0.4s ease;
  max-width: 100%;
}

/* Client account credit (payment panel) */
.payment-client-credit-header {
  background: linear-gradient(135deg, #0f766e 0%, #14b8a6 100%);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}
.payment-client-credit-balance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.35rem 0.5rem;
  background: #f0fdfa;
  border-radius: 0.5rem;
  border: 1px solid #99f6e4;
}
.payment-client-credit-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #0f766e;
}
.payment-client-credit-value {
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  color: #0f172a;
}

.payment-progress-bar-fill--overpaid {
  background: linear-gradient(90deg, #0d6efd, #6f42c1);
}

.payment-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: #6c757d;
  margin-top: 0.25rem;
}

/* Payment terms card: collapsible body (header always visible) */
.payment-terms-card .payment-terms-card-header {
  flex-wrap: wrap;
}

.payment-terms-card .payment-terms-body-toggle {
  flex-shrink: 0;
  padding: 0.2rem 0.45rem;
  line-height: 1;
}

.payment-terms-card .payment-terms-chevron {
  display: inline-block;
  transition: transform 0.2s ease;
  font-size: 0.75rem;
}

.payment-terms-card .payment-terms-body-toggle[aria-expanded="true"] .payment-terms-chevron {
  transform: rotate(180deg);
}
