/* ============================================================
   Global Interpreting Service — Invoice Payment Portal
   ============================================================ */

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Design Tokens */
:root {
  --primary:        #115198;
  --primary-dark:   #11296B;
  --primary-light:  #116ACA;
  --accent:         #FFDE26;
  --accent-dark:    #F5C400;
  --black:          #000000;
  --white:          #ffffff;
  --gray-bg:        #f0f4f8;
  --gray-light:     #EDEDED;
  --gray-mid:       #c8c8c8;
  --gray-text:      #5a6472;
  --text:           #1a1f27;
  --error:          #c0392b;
  --error-bg:       #fdf2f2;
  --error-border:   #f5c6c6;
  --success:        #1a7a4a;
  --radius-sm:      6px;
  --radius:         10px;
  --radius-lg:      14px;
  --shadow:         0 2px 16px rgba(17, 41, 107, 0.10), 0 1px 4px rgba(0,0,0,0.06);
  --transition:     0.18s ease;
}

/* Typography */
body {
  font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--gray-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
  line-height: 1.25;
}

/* ============================================================
   Header
   ============================================================ */

.site-header {
  background: var(--primary);
  border-bottom: 4px solid var(--accent);
  padding: 14px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(17, 41, 107, 0.25);
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
}

.logo {
  height: 52px;
  width: auto;
  display: block;
}

/* ============================================================
   Main / Layout
   ============================================================ */

.main-content {
  flex: 1;
  padding: 40px 16px 56px;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
}

/* ============================================================
   Steps
   ============================================================ */

.step {
  display: none;
}

.step.active {
  display: block;
  animation: stepIn 0.3s ease both;
}

@keyframes stepIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   Card
   ============================================================ */

.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 40px 44px;
  border-top: 4px solid var(--accent);
}

/* Card header (step 1) */
.card-header {
  text-align: center;
  margin-bottom: 32px;
}

.card-header h1 {
  font-size: 26px;
  color: var(--primary);
  margin-bottom: 8px;
}

.card-header p {
  color: var(--gray-text);
  font-size: 15px;
  max-width: 380px;
  margin: 0 auto;
}

/* ============================================================
   Form Elements
   ============================================================ */

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

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 13.5px;
  color: #374151;
  margin-bottom: 7px;
  letter-spacing: 0.01em;
}

input[type="text"] {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid #d1d5db;
  border-radius: var(--radius-sm);
  font-family: 'Open Sans', sans-serif;
  font-size: 16px;
  color: var(--text);
  background: #fafbfc;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  appearance: none;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(17, 106, 202, 0.15);
  background: var(--white);
}

input[type="text"]::placeholder {
  color: #9ca3af;
}

/* Stripe card element host */
.stripe-element {
  padding: 11px 14px;
  border: 1.5px solid #d1d5db;
  border-radius: var(--radius-sm);
  background: #fafbfc;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  min-height: 44px;
}

.stripe-element.StripeElement--focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(17, 106, 202, 0.15);
  background: var(--white);
}

.stripe-element.StripeElement--invalid {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.1);
}

/* Turnstile widget container */
.turnstile-wrap {
  margin-bottom: 14px;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 13px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Roboto', sans-serif;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  position: relative;
  letter-spacing: 0.01em;
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none !important;
}

/* Primary — blue */
.btn-primary {
  background: var(--primary);
  color: var(--white);
  margin-top: 6px;
  box-shadow: 0 2px 8px rgba(17, 81, 152, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(17, 41, 107, 0.3);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

/* Pay button — accent yellow */
.btn-pay {
  background: var(--accent);
  color: var(--primary-dark);
  margin-top: 6px;
  box-shadow: 0 2px 8px rgba(255, 222, 38, 0.35);
}

.btn-pay:hover:not(:disabled) {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 196, 0, 0.4);
}

/* Back link */
.btn-back {
  background: none;
  border: none;
  color: var(--primary-light);
  font-size: 13.5px;
  font-family: 'Open Sans', sans-serif;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--transition);
}

.btn-back:hover {
  color: var(--primary);
}

/* Loading spinner */
.btn-loader {
  width: 19px;
  height: 19px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.btn-pay .btn-loader {
  border-color: rgba(17, 41, 107, 0.25);
  border-top-color: var(--primary-dark);
}

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

/* ============================================================
   Error Messages
   ============================================================ */

.error-message {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 14px;
  line-height: 1.5;
}

/* ============================================================
   Invoice Details (Step 2 — top section)
   ============================================================ */

.invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}

.invoice-header h2 {
  color: var(--primary);
  font-size: 19px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 24px;
  margin-bottom: 22px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.detail-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.detail-value {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

/* Amount breakdown box */
.amount-breakdown {
  background: var(--gray-bg);
  border: 1px solid var(--gray-light);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 4px;
}

.amount-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 15px;
  color: var(--text);
}

.fee-row {
  color: var(--gray-text);
  font-size: 14px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--gray-mid);
}

.total-row {
  font-weight: 700;
  font-size: 18px;
  color: var(--primary);
  padding-top: 9px;
}

/* Divider between invoice details and payment form */
.divider {
  border: none;
  border-top: 1px solid var(--gray-light);
  margin: 28px 0;
}

/* ============================================================
   Payment Form Section (Step 2 — bottom)
   ============================================================ */

.payment-form-section h2 {
  color: var(--primary);
  font-size: 19px;
  margin-bottom: 20px;
}

.secure-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  color: var(--gray-text);
  margin-top: 14px;
}

.lock-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  color: var(--gray-text);
}

/* ============================================================
   Success Card (Step 3)
   ============================================================ */

.success-card {
  text-align: center;
  padding-top: 12px;
}

.success-icon {
  width: 76px;
  height: 76px;
  margin: 0 auto 22px;
}

.success-icon svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Draw-in animation for the checkmark */
.success-circle {
  stroke-dasharray: 160;
  stroke-dashoffset: 160;
  animation: drawCircle 0.55s ease forwards;
  stroke: var(--primary);
}

.success-check {
  stroke-dasharray: 50;
  stroke-dashoffset: 50;
  animation: drawCheck 0.4s ease 0.5s forwards;
  stroke: var(--accent-dark);
}

@keyframes drawCircle {
  to { stroke-dashoffset: 0; }
}

@keyframes drawCheck {
  to { stroke-dashoffset: 0; }
}

.success-card h2 {
  color: var(--primary);
  font-size: 26px;
  margin-bottom: 10px;
}

.success-card > p {
  color: var(--gray-text);
  font-size: 15px;
  margin-bottom: 24px;
}

.success-details {
  background: var(--gray-bg);
  border: 1px solid var(--gray-light);
  border-radius: var(--radius);
  padding: 14px 24px;
  margin: 0 auto 18px;
  max-width: 360px;
}

.success-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 15px;
}

.success-detail-row + .success-detail-row {
  border-top: 1px solid var(--gray-mid);
}

.success-detail-row span:first-child {
  color: var(--gray-text);
  font-size: 14px;
}

.success-detail-row span:last-child {
  font-weight: 600;
  color: var(--primary);
}

.receipt-note {
  font-size: 13px;
  color: var(--gray-text);
}

/* ============================================================
   Footer
   ============================================================ */

.site-footer {
  background: var(--primary-dark);
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
  padding: 16px 24px;
  font-size: 13px;
  line-height: 1.6;
}

.site-footer p {
  margin: 2px 0;
}

.footer-secure {
  color: rgba(255, 255, 255, 0.4);
  font-size: 12px;
}

/* ============================================================
   Utility
   ============================================================ */

.hidden {
  display: none !important;
}

/* ============================================================
   Responsive — Tablet (≤ 720px)
   ============================================================ */

@media (max-width: 720px) {
  .card {
    padding: 28px 24px;
  }
}

/* ============================================================
   Responsive — Mobile (≤ 540px)
   ============================================================ */

@media (max-width: 540px) {
  /* Layout */
  .main-content {
    padding: 0 0 48px;
  }

  /* Card goes edge-to-edge on small phones */
  .card {
    padding: 24px 16px;
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow: none;
    border-top: 4px solid var(--accent);
  }

  /* Header */
  .site-header {
    padding: 12px 16px;
  }

  .logo {
    height: 40px;
  }

  /* Step 1 */
  .card-header {
    margin-bottom: 24px;
  }

  .card-header h1 {
    font-size: 22px;
  }

  .card-header p {
    font-size: 14px;
  }

  /* Inputs — 16px prevents iOS auto-zoom */
  input[type="text"] {
    font-size: 16px;
    padding: 13px 12px;
  }

  /* Step 2 — invoice details */
  .invoice-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 16px;
  }

  .invoice-header h2 {
    font-size: 17px;
  }

  .detail-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
    margin-bottom: 16px;
  }

  .detail-label {
    font-size: 10px;
  }

  .detail-value {
    font-size: 14px;
  }

  /* Amount breakdown — shorten fee label on narrow screens */
  .amount-breakdown {
    padding: 12px 14px;
  }

  .amount-row {
    font-size: 14px;
    gap: 8px;
  }

  .amount-row span:first-child {
    flex: 1;
  }

  .amount-row span:last-child {
    white-space: nowrap;
    font-weight: 600;
  }

  .fee-row {
    font-size: 13px;
  }

  .total-row {
    font-size: 16px;
  }

  /* Divider */
  .divider {
    margin: 20px 0;
  }

  /* Payment form */
  .payment-form-section h2 {
    font-size: 17px;
    margin-bottom: 16px;
  }

  /* Buttons — larger tap targets */
  .btn {
    padding: 15px 20px;
    font-size: 16px;
  }

  /* Success */
  .success-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
  }

  .success-card h2 {
    font-size: 22px;
  }

  .success-details {
    padding: 12px 16px;
    max-width: 100%;
  }

  /* Footer */
  .site-footer {
    padding: 14px 16px;
    font-size: 12px;
  }
}

/* ============================================================
   Responsive — Very small phones (≤ 360px)
   ============================================================ */

@media (max-width: 360px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .card-header h1 {
    font-size: 20px;
  }
}
