/* ============================================================
   PROXC Payment Page — Shared Styles
   Sprint: PROXC-PAY-001
   Palette: #003366 navy, #ffffff white, #f5f7fa light bg
   ============================================================ */

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

:root {
  --navy:        #003366;
  --navy-dark:   #00234a;
  --navy-mid:    #004080;
  --navy-light:  #e8eef5;
  --accent:      #0066cc;
  --accent-hover:#0055aa;
  --green:       #1a7a4a;
  --green-light: #e8f5ee;
  --red:         #c0392b;
  --red-light:   #fdf2f1;
  --gold:        #b8922a;
  --text-primary:#0d1a2e;
  --text-muted:  #5a6778;
  --text-light:  #8a96a4;
  --border:      #d4dce8;
  --border-light:#edf0f5;
  --bg:          #f5f7fa;
  --bg-card:     #ffffff;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow-sm:   0 1px 3px rgba(0,51,102,0.08), 0 1px 2px rgba(0,51,102,0.04);
  --shadow-md:   0 4px 12px rgba(0,51,102,0.10), 0 2px 4px rgba(0,51,102,0.06);
  --shadow-lg:   0 12px 32px rgba(0,51,102,0.12), 0 4px 8px rgba(0,51,102,0.06);
  --font-sans:   'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:   'DM Mono', 'Courier New', monospace;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.55;
}

/* ── Typography ── */
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 1rem;    font-weight: 600; }
p  { color: var(--text-muted); }

/* ── Layout ── */
.page-wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Header ── */
.site-header {
  background: var(--navy);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.site-header .page-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-header img.logo {
  height: 36px;
  width: auto;
  display: block;
}
.secure-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.20);
  border-radius: 20px;
  padding: 5px 13px 5px 10px;
  color: rgba(255,255,255,0.90);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.secure-badge svg { flex-shrink: 0; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-light);
}
.card-header h2 { color: var(--text-primary); font-size: 1rem; }
.card-body { padding: 20px 24px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--navy);
  color: #fff;
  padding: 13px 24px;
  width: 100%;
  font-size: 1rem;
  box-shadow: 0 2px 8px rgba(0,51,102,0.25);
}
.btn-primary:hover:not(:disabled) {
  background: var(--navy-dark);
  box-shadow: 0 4px 14px rgba(0,51,102,0.35);
}
.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--navy-light);
  color: var(--navy);
  padding: 10px 18px;
}
.btn-secondary:hover { background: #d8e4f0; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 8px 12px;
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text-primary); }

.btn-danger-ghost {
  background: transparent;
  color: var(--red);
  padding: 6px 10px;
  border: 1px solid transparent;
  font-size: 0.82rem;
}
.btn-danger-ghost:hover { background: var(--red-light); }

/* ── Form Elements ── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 5px;
  letter-spacing: 0.01em;
}
.form-label .req { color: var(--red); margin-left: 2px; }

.form-input, .form-select, .form-textarea {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  appearance: none;
}
.form-input::placeholder { color: var(--text-light); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(0,51,102,0.10);
}
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235a6778' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}
.form-textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ── Section headers ── */
.section-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 14px 24px 10px;
  border-bottom: 1px solid var(--border-light);
  background: var(--navy-light);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* ── Tables ── */
.inv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.inv-table th {
  background: var(--navy-light);
  color: var(--navy);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.inv-table th.num { text-align: right; }
.inv-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
}
.inv-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.inv-table tr:last-child td { border-bottom: none; }
.inv-table .total-row td {
  font-weight: 600;
  background: var(--bg);
  border-top: 2px solid var(--border);
}
.inv-table .grand-total td {
  font-weight: 700;
  font-size: 1rem;
  background: var(--navy-light);
  color: var(--navy);
}

/* ── Totals block ── */
.totals-block {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.88rem;
}
.totals-row:last-child { border-bottom: none; }
.totals-row .label { color: var(--text-muted); }
.totals-row .amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.totals-row.grand {
  background: var(--navy);
  color: #fff;
  padding: 13px 16px;
}
.totals-row.grand .label { color: rgba(255,255,255,0.80); font-weight: 600; }
.totals-row.grand .amount { color: #fff; font-size: 1.1rem; }

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-error { background: var(--red-light); color: var(--red); border: 1px solid #f5c6c2; }
.alert-success { background: var(--green-light); color: var(--green); border: 1px solid #b8dfc9; }
.alert-info { background: var(--navy-light); color: var(--navy); border: 1px solid #c0d4e8; }

/* ── Loading spinner ── */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner-navy {
  border-color: rgba(0,51,102,0.2);
  border-top-color: var(--navy);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Copy field ── */
.copy-field {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}
.copy-field input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-primary);
  outline: none;
}
.copy-field .copy-btn {
  background: var(--navy);
  color: #fff;
  border: none;
  padding: 0 18px;
  height: 100%;
  min-height: 42px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.copy-field .copy-btn:hover { background: var(--navy-dark); }
.copy-field .copy-btn.copied { background: var(--green); }

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  margin-top: 48px;
  color: var(--text-light);
  font-size: 0.8rem;
  text-align: center;
}
.site-footer a { color: var(--text-muted); text-decoration: none; }
.site-footer a:hover { color: var(--navy); }

/* ── Line item rows (admin) ── */
.line-item-row {
  display: grid;
  grid-template-columns: 1fr 80px 110px 40px;
  gap: 8px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}
.line-item-row:last-child { border-bottom: none; }
.line-item-row .remove-btn {
  color: var(--text-light);
  background: none;
  border: none;
  cursor: pointer;
  padding: 9px 4px;
  font-size: 1rem;
  line-height: 1;
  transition: color 0.15s;
}
.line-item-row .remove-btn:hover { color: var(--red); }

/* ── Add line button ── */
.add-line-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--navy);
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 9px 14px;
  cursor: pointer;
  width: 100%;
  margin-top: 10px;
  transition: background 0.15s, border-color 0.15s;
}
.add-line-btn:hover { background: var(--navy-light); border-color: var(--navy); }

/* ── History list ── */
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}
.history-item:last-child { border-bottom: none; }
.history-meta { font-size: 0.80rem; color: var(--text-muted); margin-top: 2px; }
.history-num { font-weight: 600; font-size: 0.88rem; }
.history-amount { font-weight: 700; font-size: 0.92rem; color: var(--navy); white-space: nowrap; }
.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 4px;
  padding: 2px 7px;
}
.badge-paid    { background: var(--green-light); color: var(--green); }
.badge-unpaid  { background: var(--navy-light);  color: var(--navy); }
.badge-expired { background: #f0f0f0;             color: var(--text-muted); }

/* ── Password gate ── */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.auth-header {
  background: var(--navy);
  padding: 28px 32px 24px;
  text-align: center;
}
.auth-header img { height: 40px; }
.auth-body { padding: 32px; }
.auth-title { font-size: 1rem; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.auth-sub   { font-size: 0.84rem; color: var(--text-muted); margin-bottom: 24px; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60%  { transform: translateX(-6px); }
  40%, 80%  { transform: translateX(6px); }
}
.shake { animation: shake 0.45s ease; }

/* ── Stripe element mount ── */
#stripe-element-mount {
  padding: 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  transition: border-color 0.15s;
}
#stripe-element-mount.StripeElement--focus { border-color: var(--navy); }

/* ── Success state ── */
.success-page {
  max-width: 560px;
  margin: 60px auto;
  text-align: center;
  padding: 0 24px;
}
.success-icon {
  width: 72px; height: 72px;
  background: var(--green-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
}
.success-icon svg { color: var(--green); }
.success-inv-number {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 14px;
  margin: 12px 0 28px;
  color: var(--text-muted);
}

/* ── Error page ── */
.error-page {
  max-width: 500px;
  margin: 80px auto;
  text-align: center;
  padding: 0 24px;
}
.error-icon {
  width: 64px; height: 64px;
  background: var(--red-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

/* ── Two-column pay layout ── */
.pay-layout {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 24px;
  align-items: start;
  padding: 32px 0 60px;
}

/* ── Admin layout ── */
.admin-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 24px;
  align-items: start;
  padding: 28px 0 60px;
}
.admin-left { display: flex; flex-direction: column; gap: 20px; }
.admin-right { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 20px; }

/* ── Invoice preview (admin) ── */
.inv-preview {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  font-size: 0.78rem;
  font-family: Helvetica, Arial, sans-serif;
  line-height: 1.45;
  color: #111;
}
.inv-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}
.inv-preview table { width: 100%; border-collapse: collapse; font-size: 0.76rem; }
.inv-preview th { background: #ccc; padding: 5px 8px; text-align: center; font-weight: 700; }
.inv-preview td { padding: 5px 8px; border: 1px solid #ddd; text-align: center; vertical-align: top; }
.inv-preview .inv-from { font-size: 0.74rem; }
.inv-preview .inv-title { font-size: 1.1rem; font-weight: 700; }
.inv-preview .inv-copy { font-size: 0.6rem; }

/* ── Responsive ── */
@media (max-width: 760px) {
  .pay-layout, .admin-layout {
    grid-template-columns: 1fr;
  }
  .admin-right { position: static; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .line-item-row { grid-template-columns: 1fr 70px 100px 36px; }
  h1 { font-size: 1.4rem; }
}
@media (max-width: 480px) {
  .site-header .page-wrap { padding: 0 16px; }
  .page-wrap { padding: 0 16px; }
  .card-body { padding: 16px; }
}
