:root {
  --cu-navy: #213769;
  --cu-navy-dark: #17264d;
  --cu-navy-light: rgba(33, 55, 105, 0.08);
  --bg-gray: #f4f7f9;
  --navbar-height: 150px; /* Adjust this to match the actual site header height */
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Poppins", sans-serif;
  background-color: var(--bg-gray);
  overflow: hidden; /* Prevents body scrolling on desktop */
}

.navbar-spacer {
  height: var(--navbar-height);
  width: 100%;
}

.page-container {
  height: calc(100vh - var(--navbar-height));
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.wide-payment-card {
  background: #ffffff;
  width: 100%;
  max-width: 560px;
  padding: 36px 44px 40px;
  border-radius: 16px;
  box-shadow: 0 20px 45px rgba(33, 55, 105, 0.12), 0 2px 8px rgba(0, 0, 0, 0.04);
  border-top: 6px solid var(--cu-navy);
  position: relative;
}

/* Header Styles */
.card-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 28px;
  border-bottom: 1px solid #eef1f4;
  padding-bottom: 20px;
}

.form-logo {
  height: 48px;
}

.header-text h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--cu-navy);
  margin: 0;
}

.header-text p {
  font-size: 13px;
  color: #8892a0;
  margin-top: 2px;
}

/* Form Layout */
.payment-form {
  display: flex;
  flex-direction: column;
}

.name-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.form-group {
  margin-bottom: 18px;
}

label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  margin-bottom: 7px;
  color: var(--cu-navy);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #dfe4ea;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  color: #2c3444;
  outline: none;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input::placeholder {
  color: #b3bac4;
}

input:focus,
select:focus {
  border-color: var(--cu-navy);
  box-shadow: 0 0 0 4px var(--cu-navy-light);
}

/* Amount Styling */
.amount-field {
  margin-top: 4px;
  margin-bottom: 26px;
  text-align: center;
}

.amount-field label {
  text-align: center;
}

.amount-group {
  display: flex;
  max-width: 320px;
  margin: 0 auto;
  border: 1.5px solid #dfe4ea;
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.amount-group:focus-within {
  border-color: var(--cu-navy);
  box-shadow: 0 0 0 4px var(--cu-navy-light);
}

.amount-group input {
  border: none;
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  color: var(--cu-navy);
}

.amount-group input:focus {
  box-shadow: none;
}

.amount-group select {
  width: 112px;
  padding: 12px 8px;
  border: none;
  border-left: 1.5px solid #dfe4ea;
  background: #f7f8fa;
  border-radius: 0;
  font-weight: 600;
  font-size: 13px;
  color: var(--cu-navy);
}

.amount-group select:focus {
  box-shadow: none;
}

/* Button & Footer Area */
.action-area {
  margin-top: 6px;
}

.pay-btn {
  background: linear-gradient(135deg, var(--cu-navy), var(--cu-navy-dark));
  color: white;
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(33, 55, 105, 0.28);
  transition: transform 0.2s, box-shadow 0.2s;
}

.pay-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(33, 55, 105, 0.34);
}

.pay-btn:active {
  transform: translateY(0);
}

.button-link {
  display: block;
  text-align: center;
  text-decoration: none;
}

.bank-choice-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin-top: 10px;
}

.bank-choice-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 255px;
  overflow: hidden;
  text-align: center;
  text-decoration: none;
  color: #273247;
  padding: 28px 22px 22px;
  background: linear-gradient(155deg, #fff 0%, #f8fafc 100%);
  border: 1px solid #e1e6ed;
  border-radius: 22px;
  box-shadow: 0 15px 34px rgba(33, 55, 105, 0.12), 0 3px 9px rgba(19, 30, 54, 0.05);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.bank-choice-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 5px;
  background: var(--cu-navy);
}

.bank-choice-card-zanaco::before {
  background: linear-gradient(90deg, #d9a12e 0 32%, #c71920 32% 100%);
}

.bank-choice-card-absa::before {
  background: #ed174c;
}

.bank-choice-card:hover {
  transform: translateY(-6px);
  border-color: #ccd5e1;
  box-shadow: 0 24px 46px rgba(33, 55, 105, 0.18), 0 5px 14px rgba(19, 30, 54, 0.07);
}

.bank-choice-card:active {
  transform: translateY(-2px);
}

.bank-choice-card:focus-visible {
  outline: 3px solid rgba(33, 55, 105, 0.25);
  outline-offset: 4px;
}

.bank-logo {
  display: block;
  flex: 0 0 auto;
  width: 150px;
  height: 76px;
  margin-bottom: 16px;
  background-position: center;
  background-repeat: no-repeat;
}

.bank-logo-zanaco {
  background-size: 100% auto;
}

.bank-logo-absa {
  background-size: 72px 72px;
}

.bank-choice-name {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: var(--cu-navy);
}

.bank-choice-action {
  display: block;
  margin-top: auto;
  padding-top: 13px;
  color: #7b8797;
  font-size: 11.5px;
  font-weight: 550;
}

.bank-choice-card:hover .bank-choice-action {
  color: var(--cu-navy);
}

.bank-selection-shell {
  max-width: 760px;
  padding: 38px 44px 32px;
}

.bank-selection-header {
  justify-content: center;
}

.bank-selection-note {
  margin-top: 25px;
  color: #8b95a3;
  font-size: 11.5px;
  text-align: center;
}

.secure-tag {
  text-align: center;
  font-size: 11.5px;
  color: #a1a8b3;
  margin-top: 12px;
}

/* --- RESPONSIVITY --- */

/* 24-inch Monitor (Wide spacing) */
@media screen and (min-width: 1600px) {
  .wide-payment-card {
    max-width: 620px;
    padding: 44px 56px 48px;
  }
}

/* Small Laptops (Thinkpad/Asus) */
@media screen and (max-height: 800px) {
  .navbar-spacer {
    height: 120px;
  }
  .wide-payment-card {
    padding: 24px 32px 28px;
  }
  .card-header {
    margin-bottom: 18px;
    padding-bottom: 14px;
  }
  .form-group {
    margin-bottom: 12px;
  }
  .amount-field {
    margin-bottom: 18px;
  }
}

/* Mobile (Back to vertical + allow scrolling) */
@media screen and (max-width: 768px) {
  body {
    overflow: auto;
  }
  .page-container {
    height: auto;
  }
  .name-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .card-header {
    flex-direction: column;
    text-align: center;
  }
  .wide-payment-card {
    margin: 20px 0;
  }
  .bank-choice-list {
    grid-template-columns: 1fr;
    gap: 18px;
  }
  .bank-selection-shell {
    max-width: 520px;
    padding: 28px 22px 26px;
  }
  .bank-choice-card {
    min-height: 235px;
  }
}

/* --- DJANGO FORM ADDITIONS --- */

.field-error {
  color: #c0392b;
  font-size: 11.5px;
  margin-top: 5px;
  font-weight: 500;
}

.field-help {
  color: #667085;
  font-size: 11.5px;
  margin-top: 5px;
}

.form-alert {
  background: #fdecea;
  border-left: 4px solid #c0392b;
  color: #922b21;
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 18px;
}

/* Django adds no class on invalid fields by default; these are set in forms.py
   via the errors loop wrapper, so we target the group instead. */
.form-group input.has-error,
.form-group select.has-error {
  border-color: #c0392b;
}

/* Read-only summary rows used on the checkout + receipt pages */
.summary-list {
  border: 1px solid #eef1f4;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 24px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  font-size: 13.5px;
  border-bottom: 1px solid #eef1f4;
}

.summary-row:last-child {
  border-bottom: none;
}

.summary-row .label {
  color: #8892a0;
  font-weight: 500;
}

.summary-row .value {
  color: #2c3444;
  font-weight: 600;
  text-align: right;
}

.summary-row.total {
  background: var(--cu-navy-light);
}

.summary-row.total .value {
  color: var(--cu-navy);
  font-size: 17px;
}

/* Unified Checkout launch card and focused card-entry modal */
.checkout-payment-card {
  padding: 17px;
  border: 1px solid #e3e8ef;
  border-radius: 12px;
  background: linear-gradient(145deg, #fff, #f8fafc);
  box-shadow: 0 8px 22px rgba(33, 55, 105, 0.08);
}

.checkout-payment-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid #e9edf2;
}

.checkout-payment-icon {
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--cu-navy-light);
  font-size: 19px;
}

.checkout-payment-heading h2 {
  color: var(--cu-navy);
  font-size: 16px;
  font-weight: 650;
}

.checkout-payment-heading p {
  margin-top: 2px;
  color: #7c8797;
  font-size: 11.5px;
}

.checkout-launch {
  min-height: 54px;
}

.payment-modal-open {
  overflow: hidden !important;
}

.secure-payment-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 20px;
}

.secure-payment-modal[hidden] {
  display: none;
}

.secure-payment-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 19, 41, 0.68);
  backdrop-filter: blur(5px);
}

.secure-payment-panel {
  position: relative;
  width: min(640px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(4, 12, 32, 0.35);
  border-top: 5px solid var(--cu-navy);
}

.secure-payment-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 20px 22px;
  border-bottom: 1px solid #e9edf2;
  background: linear-gradient(180deg, #fff, #fafbfd);
}

.secure-payment-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--cu-navy-light);
  font-size: 18px;
}

.secure-payment-header h2 {
  color: var(--cu-navy);
  font-size: 18px;
  font-weight: 650;
}

.secure-payment-header p {
  color: #7c8797;
  font-size: 12px;
  margin-top: 2px;
}

.secure-payment-amount {
  text-align: right;
}

.secure-payment-amount span {
  display: block;
  color: #8b95a3;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.secure-payment-amount strong {
  color: var(--cu-navy);
  font-size: 15px;
}

.secure-payment-body {
  padding: 18px 20px 6px;
}

#embedded-payment {
  min-height: 390px;
  width: 100%;
}

.secure-payment-footer {
  display: flex;
  justify-content: center;
  gap: 7px;
  padding: 12px 18px 15px;
  color: #818b99;
  font-size: 11.5px;
  border-top: 1px solid #f0f2f5;
}

@media screen and (max-width: 640px) {
  .secure-payment-modal {
    padding: 0;
  }

  .secure-payment-panel {
    width: 100%;
    max-height: 100vh;
    min-height: 100vh;
    border-radius: 0;
  }

  .secure-payment-header {
    grid-template-columns: auto 1fr;
    padding: 16px;
  }

  .secure-payment-amount {
    grid-column: 2;
    text-align: left;
  }

  .secure-payment-body {
    padding: 12px 10px 4px;
  }
}

.back-link {
  display: inline-block;
  margin-top: 14px;
  font-size: 12.5px;
  color: #8892a0;
  text-decoration: none;
}

.back-link:hover {
  color: var(--cu-navy);
}

.status-badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-badge.authorized { background: #e8f6ee; color: #1e7d47; }
.status-badge.pending    { background: #fdf3e2; color: #9a6b12; }
.status-badge.processing { background: #e8f0fb; color: #245b96; }
.status-badge.failed     { background: #fdecea; color: #c0392b; }
.status-badge.declined   { background: #fdecea; color: #c0392b; }

/* Printable payment receipt */
.receipt-page-wrap {
  width: 100%;
  max-width: 720px;
  margin: 24px auto;
}

.receipt-document {
  overflow: hidden;
  background: #fff;
  border: 1px solid #e3e8ef;
  border-top: 6px solid var(--cu-navy);
  border-radius: 16px;
  box-shadow: 0 20px 45px rgba(33, 55, 105, 0.12);
}

.receipt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 28px;
  padding: 28px 32px;
  border-bottom: 1px solid #e9edf2;
}

.receipt-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.receipt-brand img {
  width: auto;
  height: 50px;
}

.receipt-brand h1 {
  color: var(--cu-navy);
  font-size: 17px;
  font-weight: 650;
}

.receipt-brand p,
.receipt-number span,
.receipt-result-label,
.receipt-total span {
  color: #8490a0;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.receipt-number {
  text-align: right;
}

.receipt-number span,
.receipt-total span {
  display: block;
  margin-bottom: 4px;
}

.receipt-number strong {
  display: block;
  color: #354052;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.receipt-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 24px 32px;
  background: #f8fafc;
  border-bottom: 1px solid #e9edf2;
}

.receipt-result-label {
  display: block;
  margin-bottom: 7px;
}

.receipt-result-authorized {
  background: linear-gradient(100deg, #f0faf4, #f8fbfa);
}

.receipt-result-failed,
.receipt-result-declined {
  background: linear-gradient(100deg, #fff5f4, #fffafa);
}

.receipt-total {
  text-align: right;
}

.receipt-total strong {
  color: var(--cu-navy);
  font-size: 25px;
  font-weight: 700;
}

.receipt-details {
  padding: 27px 32px 30px;
}

.receipt-details h2 {
  margin-bottom: 18px;
  color: var(--cu-navy);
  font-size: 14px;
  font-weight: 650;
}

.receipt-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px 32px;
}

.receipt-detail-grid > div {
  min-width: 0;
}

.receipt-detail-grid dt {
  margin-bottom: 4px;
  color: #8a95a3;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.receipt-detail-grid dd {
  color: #2c3444;
  font-size: 13px;
  font-weight: 550;
  overflow-wrap: anywhere;
}

.receipt-detail-grid .receipt-detail-wide {
  grid-column: 1 / -1;
  padding-top: 14px;
  border-top: 1px dashed #dce2e9;
}

.receipt-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 17px 32px;
  background: var(--cu-navy);
  color: #fff;
}

.receipt-footer-mark {
  display: grid;
  place-items: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
}

.receipt-footer strong {
  font-size: 11.5px;
}

.receipt-footer p {
  margin-top: 1px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 10.5px;
}

.receipt-message,
.receipt-actions {
  margin-top: 18px;
}

.receipt-actions {
  text-align: center;
}

@media screen and (max-width: 640px) {
  .receipt-page-wrap {
    margin: 12px auto;
  }

  .receipt-header,
  .receipt-result {
    align-items: flex-start;
    flex-direction: column;
    padding: 21px;
  }

  .receipt-number,
  .receipt-total {
    text-align: left;
  }

  .receipt-details {
    padding: 23px 21px;
  }

  .receipt-detail-grid {
    grid-template-columns: 1fr;
  }

  .receipt-detail-grid .receipt-detail-wide {
    grid-column: auto;
  }

  .receipt-footer {
    padding: 16px 21px;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 16mm;
  }

  html,
  body,
  body.scrollable {
    width: auto;
    height: auto;
    overflow: visible !important;
    background: #fff;
  }

  .navbar-spacer,
  .receipt-actions,
  .receipt-message {
    display: none !important;
  }

  .page-container {
    display: block;
    width: auto;
    height: auto;
    min-height: 0 !important;
    padding: 0;
  }

  .receipt-page-wrap {
    max-width: none;
    margin: 0;
  }

  .receipt-document {
    border-radius: 0;
    box-shadow: none;
    break-inside: avoid;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}

/* The checkout page can grow taller than the viewport once the card iframe
   loads, so scrolling must be allowed there. */
body.scrollable {
  overflow: auto;
}

body.scrollable .page-container {
  height: auto;
  min-height: calc(100vh - var(--navbar-height));
}
