/* ============================================
   MedSupplies.com — One-Page Checkout
   ============================================ */

/* === Page wrapper (standalone, no site chrome) === */
.checkout-page-wrap {
  padding: 30px 20px 40px;
  min-height: 100vh;
  background: #fff;
}

/* === Layout === */
.checkout-wrap {
  display: flex;
  gap: 40px;
  max-width: 1100px;
  margin: 0 auto;
  align-items: flex-start;
}

.checkout-main {
  flex: 1;
  min-width: 0;
}

.checkout-sidebar {
  width: 380px;
  flex-shrink: 0;
  position: sticky;
  top: 20px;
}

/* === Page title === */
.checkout-title {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 28px;
  letter-spacing: -0.02em;
}

/* === Sections === */
.checkout-section {
  margin-bottom: 32px;
}

.checkout-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkout-section-title .section-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #1a1a1a;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

/* === Form fields === */
.checkout-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.checkout-row > .checkout-field {
  flex: 1;
}

.checkout-field {
  margin-bottom: 12px;
}

.checkout-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #555;
  margin-bottom: 5px;
}

.checkout-field input,
.checkout-field select,
.checkout-field textarea {
  width: 100%;
  height: 46px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  padding: 0 14px;
  font-size: 15px;
  font-family: inherit;
  color: #1a1a1a;
  background: #fff;
  transition: border-color 0.2s ease;
  box-sizing: border-box;
}

.checkout-field textarea {
  height: 80px;
  padding: 12px 14px;
  resize: vertical;
}

.checkout-field input:focus,
.checkout-field select:focus,
.checkout-field textarea:focus {
  border-color: #1a1a1a;
  outline: none;
}

.checkout-field input.field-error,
.checkout-field select.field-error {
  border-color: #dc2626;
}

.checkout-field .field-error-msg {
  font-size: 12px;
  color: #dc2626;
  margin-top: 4px;
}

/* === Contact section === */
.checkout-login-prompt {
  font-size: 13px;
  color: #666;
  margin-top: 8px;
}

.checkout-login-prompt a {
  color: #1a1a1a;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.checkout-login-prompt a:hover {
  color: #0066cc;
}

.login-inline {
  background: #f9f9f9;
  border: 1px solid #eaeaea;
  border-radius: 8px;
  padding: 16px;
  margin-top: 12px;
  display: none;
}

.login-inline.visible {
  display: block;
}

.login-inline .checkout-row {
  margin-bottom: 8px;
}

.login-inline .btn-login {
  margin-top: 8px;
}

.login-error {
  font-size: 13px;
  color: #dc2626;
  margin-top: 8px;
  display: none;
}

.login-success {
  font-size: 13px;
  color: #166534;
  margin-top: 8px;
  display: none;
}

/* === Shipping methods === */
.shipping-methods-loading {
  padding: 20px;
  text-align: center;
  color: #888;
  font-size: 14px;
}

.shipping-methods-loading .spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid #ddd;
  border-top-color: #1a1a1a;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

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

.shipping-method-option {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid #eaeaea;
  border-radius: 6px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.shipping-method-option:hover {
  border-color: #ccc;
  background: #fafafa;
}

.shipping-method-option.selected {
  border-color: #1a1a1a;
  background: #f9f9f9;
}

.shipping-method-option input[type="radio"] {
  margin-right: 12px;
  width: 18px;
  height: 18px;
  accent-color: #1a1a1a;
  flex-shrink: 0;
}

.shipping-method-option .method-info {
  flex: 1;
}

.shipping-method-option .method-name {
  font-weight: 500;
  font-size: 14px;
  color: #1a1a1a;
}

.shipping-method-option .method-desc {
  font-size: 13px;
  color: #888;
  margin-top: 2px;
}

.shipping-method-option .method-cost {
  font-weight: 600;
  font-size: 14px;
  color: #1a1a1a;
  flex-shrink: 0;
  margin-left: 12px;
}

.shipping-placeholder {
  padding: 20px;
  text-align: center;
  color: #999;
  font-size: 14px;
  border: 1px dashed #ddd;
  border-radius: 6px;
}

/* === Agreements section === */
.agreements-intro {
  font-size: 14px;
  color: #555;
  margin-bottom: 16px;
  line-height: 1.5;
}

.agreement-accordion {
  border: 1px solid #eaeaea;
  border-radius: 8px;
  margin-bottom: 10px;
  overflow: hidden;
}

.agreement-accordion-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  background: #fafafa;
  transition: background 0.2s ease;
  user-select: none;
}

.agreement-accordion-header:hover {
  background: #f0f0f0;
}

.agreement-accordion-chevron {
  font-size: 11px;
  color: #888;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.agreement-accordion-title {
  font-size: 14px;
  font-weight: 500;
  color: #1a1a1a;
}

.agreement-accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.agreement-accordion-body.open {
  max-height: 2000px;
  overflow-y: auto;
  border-top: 1px solid #eaeaea;
}

.agreement-doc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 8px;
  border-bottom: 1px solid #eee;
  margin-bottom: 12px;
}

.agreement-doc-logo {
  height: 40px;
  width: auto;
  object-fit: contain;
}

.agreement-doc-store {
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
}

.agreement-doc-content {
  padding: 8px 20px 20px;
  font-size: 13px;
  color: #333;
  line-height: 1.6;
}

.agreement-doc-content h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 18px 0 8px;
  color: #1a1a1a;
}

.agreement-doc-content p {
  margin: 0 0 10px;
}

.agreement-doc-content ul {
  margin: 0 0 10px;
  padding-left: 24px;
}

.agreement-doc-content li {
  margin-bottom: 4px;
}

.agreement-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 16px 0;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  line-height: 1.4;
}

.agreement-checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: #1a1a1a;
  flex-shrink: 0;
  margin-top: 1px;
}

.signature-pad-wrap {
  position: relative;
  margin-top: 8px;
}

.signature-pad-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  color: #ccc;
  font-weight: 500;
  letter-spacing: 0.05em;
  pointer-events: none;
  user-select: none;
}

.signature-pad {
  width: 100%;
  height: 160px;
  border: 2px dashed #d9d9d9;
  border-radius: 8px;
  cursor: crosshair;
  background: #fafafa;
  touch-action: none;
}

.signature-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.signature-clear-btn {
  padding: 8px 16px;
  background: #e91e8a;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s ease;
}

.signature-clear-btn:hover {
  background: #c4176f;
}

.signature-help {
  font-size: 12px;
  color: #999;
}

/* Payment lock overlay */
.agreements-lock-overlay {
  background: #f9f9f9;
  border: 1px dashed #d9d9d9;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  color: #999;
  font-size: 14px;
  margin-bottom: 16px;
}

.agreements-lock-overlay i {
  margin-right: 6px;
  color: #ccc;
}

#sectionPayment.agreements-locked .chain-tiles {
  opacity: 0.3;
  pointer-events: none;
  filter: grayscale(1);
}

/* === Payment chain tiles === */
.chain-tiles {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.chain-tile {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  border: 2px solid #eaeaea;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #fff;
}

.chain-tile:hover {
  border-color: #ccc;
  background: #fafafa;
}

.chain-tile.selected {
  border-color: #1a1a1a;
  background: #f5f5f5;
}

.chain-tile .chain-icon {
  width: 36px;
  height: 36px;
  margin-bottom: 8px;
}

.chain-tile .chain-name {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
}

.chain-tile .chain-label {
  font-size: 11px;
  color: #888;
  margin-top: 2px;
}

/* === Billing toggle === */
.billing-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  color: #555;
  cursor: pointer;
}

.billing-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #1a1a1a;
}

.billing-fields {
  display: none;
}

.billing-fields.visible {
  display: block;
}

/* === Create account toggle === */
.create-account-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  font-size: 14px;
  color: #555;
  cursor: pointer;
  padding: 12px 0;
  border-top: 1px solid #eaeaea;
}

.create-account-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #1a1a1a;
}

.create-account-fields {
  display: none;
  margin-top: 8px;
}

.create-account-fields.visible {
  display: block;
}

/* === Place Order button === */
.place-order-btn {
  width: 100%;
  height: 52px;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s ease;
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.place-order-btn:hover {
  background: #333;
}

.place-order-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.place-order-btn .btn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.place-order-btn.loading .btn-spinner {
  display: inline-block;
}

.place-order-btn.loading .btn-text {
  display: none;
}

/* === Order Summary sidebar === */
.order-summary-card {
  background: #fafafa;
  border: 1px solid #eaeaea;
  border-radius: 10px;
  padding: 24px;
}

.order-summary-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: #1a1a1a;
}

.summary-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid #eee;
}

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

.summary-item-img {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  border: 1px solid #eaeaea;
  object-fit: contain;
  background: #fff;
  padding: 4px;
  flex-shrink: 0;
}

.summary-item-info {
  flex: 1;
  min-width: 0;
}

.summary-item-name {
  font-size: 13px;
  font-weight: 500;
  color: #1a1a1a;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-item-attrs {
  font-size: 12px;
  color: #888;
  margin-top: 2px;
}

.summary-item-qty {
  font-size: 12px;
  color: #888;
  margin-top: 2px;
}

.summary-item-price {
  font-size: 14px;
  font-weight: 500;
  color: #1a1a1a;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Discount code */
.discount-code-row {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}

.discount-code-row input {
  flex: 1;
  height: 40px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  padding: 0 12px;
  font-size: 14px;
  font-family: inherit;
}

.discount-code-row button {
  height: 40px;
  padding: 0 16px;
  background: #fff;
  border: 1px solid #1a1a1a;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.discount-code-row button:hover {
  background: #1a1a1a;
  color: #fff;
}

/* Totals */
.summary-totals {
  border-top: 1px solid #ddd;
  margin-top: 16px;
  padding-top: 16px;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: #555;
  margin-bottom: 8px;
}

.summary-line.total {
  font-size: 18px;
  font-weight: 700;
  color: #1a1a1a;
  border-top: 2px solid #1a1a1a;
  padding-top: 12px;
  margin-top: 12px;
  margin-bottom: 0;
}

/* === Payment view (after order placed) === */
.payment-view {
  display: none;
  text-align: center;
  padding: 20px 0;
  max-width: 480px;
  margin: 0 auto;
}

.payment-view.visible {
  display: block;
}

.payment-view h2 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.payment-view .payment-subtitle {
  color: #666;
  font-size: 15px;
  margin-bottom: 20px;
}

/* Chain indicator — prominent, with icon */
.payment-chain-indicator {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  margin-bottom: 20px;
}

.chain-indicator-icon {
  display: flex;
  align-items: center;
}

.chain-indicator-icon .chain-icon {
  width: 24px;
  height: 24px;
  margin-bottom: 0;
}

.chain-indicator-name {
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
}

/* Details card — groups amount, QR, address together */
.payment-details-card {
  background: #fafafa;
  border: 1px solid #eaeaea;
  border-radius: 12px;
  padding: 24px 20px;
  margin-bottom: 20px;
}

.payment-amount {
  font-size: 32px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 16px;
}

.payment-qr {
  display: inline-block;
  padding: 12px;
  background: #fff;
  border: 1px solid #eaeaea;
  border-radius: 10px;
  margin-bottom: 16px;
  min-width: 224px;
  min-height: 224px;
}

.payment-qr img {
  display: block;
  width: 200px;
  height: 200px;
}

.payment-address-box {
  background: #fff;
  border: 1px solid #eaeaea;
  border-radius: 8px;
  padding: 14px 18px;
  margin: 0 auto 16px;
}

.payment-address-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #999;
  margin-bottom: 6px;
}

.payment-address-value {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 13px;
  word-break: break-all;
  color: #1a1a1a;
  line-height: 1.5;
}

.payment-copy-btn {
  margin-top: 8px;
  padding: 6px 16px;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.payment-copy-btn:hover {
  background: #333;
}

/* Network warning */
.payment-network-warning {
  font-size: 13px;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 10px 14px;
  margin: 0;
}

.payment-network-warning i {
  color: #d97706;
  margin-right: 4px;
}

.payment-timer {
  font-size: 14px;
  color: #888;
  margin-bottom: 16px;
}

.payment-timer .timer-value {
  font-weight: 600;
  color: #1a1a1a;
  font-variant-numeric: tabular-nums;
}

.payment-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  color: #888;
  padding: 14px 16px;
  background: #fffbeb;
  border-radius: 8px;
}

.payment-status .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f59e0b;
  flex-shrink: 0;
  animation: pulse 1.5s ease-in-out infinite;
}

.payment-status.confirming {
  background: #eff6ff;
  color: #1e40af;
}

.payment-status.confirming .status-dot {
  background: #3b82f6;
}

.payment-status.paid {
  background: #f0fdf4;
  color: #166534;
}

.payment-status.paid .status-dot {
  background: #22c55e;
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* USDC note in order summary */
.summary-line.usdc-note {
  font-size: 12px;
  color: #888;
  font-style: italic;
}

/* === Trust signals === */
.checkout-trust {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
  font-size: 12px;
  color: #999;
}

.checkout-trust .trust-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* === Checkout errors === */
.checkout-error {
  background: #fef2f2;
  color: #991b1b;
  border-radius: 8px;
  padding: 14px 18px;
  font-size: 14px;
  margin-bottom: 20px;
  display: none;
}

.checkout-error.visible {
  display: block;
}

/* === Section dividers === */
.checkout-divider {
  border: none;
  border-top: 1px solid #eaeaea;
  margin: 28px 0;
}

/* === Chain tile dynamic states === */
.chain-tile.tile-pending {
  border-color: #f59e0b;
  background: #fffbeb;
}

.chain-tile.tile-pending:hover {
  border-color: #d97706;
  background: #fef3c7;
}

.chain-tile.tile-confirming {
  border-color: #22c55e;
  background: #f0fdf4;
}

.chain-tile.tile-confirming:hover {
  border-color: #16a34a;
  background: #dcfce7;
}

.chain-tile.tile-paid {
  border-color: #22c55e;
  background: #f0fdf4;
  cursor: default;
  pointer-events: none;
  opacity: 0.7;
}

.chain-tile.tile-expired {
  border-color: #d1d5db;
  background: #f9fafb;
}

.chain-tile.tile-expired:hover {
  border-color: #9ca3af;
  background: #f3f4f6;
}

.chain-tile.tile-expired .chain-name {
  color: #9ca3af;
}

.chain-tile.loading {
  pointer-events: none;
  opacity: 0.6;
}

/* Tile status indicator (dot + label) */
.tile-status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
}

.tile-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tile-dot-amber {
  background: #f59e0b;
  animation: pulse 1.5s ease-in-out infinite;
}

.tile-dot-green-pulse {
  background: #22c55e;
  animation: pulse 1s ease-in-out infinite;
}

.tile-dot-green {
  background: #22c55e;
}

.tile-dot-grey {
  background: #d1d5db;
}

.tile-status-label {
  white-space: nowrap;
}

.tile-pending .tile-status-label {
  color: #92400e;
}

.tile-confirming .tile-status-label {
  color: #166534;
}

.tile-paid .tile-status-label {
  color: #166534;
}

.tile-expired .tile-status-label {
  color: #9ca3af;
}

/* Checkout notice (toast notification) */
.checkout-notice {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 14px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  transform: translateX(120%);
  transition: transform 0.3s ease;
  max-width: 360px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.checkout-notice.visible {
  transform: translateX(0);
}

.checkout-notice.notice-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.checkout-notice.notice-warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.checkout-notice.notice-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Back to order link in payment view */
.payment-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #666;
  text-decoration: none;
  margin-bottom: 16px;
  cursor: pointer;
}

.payment-back-link:hover {
  color: #1a1a1a;
}

/* === Mobile responsive === */
@media (max-width: 900px) {
  .checkout-wrap {
    flex-direction: column-reverse;
    gap: 0;
  }

  .checkout-sidebar {
    width: 100%;
    position: static;
    margin-bottom: 24px;
  }

  .order-summary-card {
    border-radius: 8px;
  }

  /* Collapsible summary on mobile */
  .summary-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 14px 0;
    border-bottom: 1px solid #eaeaea;
    margin-bottom: 0;
  }

  .summary-toggle .toggle-text {
    font-size: 14px;
    color: #0066cc;
    font-weight: 500;
  }

  .summary-toggle .toggle-total {
    font-size: 16px;
    font-weight: 700;
    color: #1a1a1a;
  }

  .summary-collapsible {
    display: none;
  }

  .summary-collapsible.open {
    display: block;
  }

  .chain-tiles {
    flex-direction: column;
  }

  .chain-tile {
    flex-direction: row;
    padding: 14px 16px;
    gap: 12px;
  }

  .chain-tile .chain-icon {
    margin-bottom: 0;
  }

  .tile-status-indicator {
    margin-top: 0;
    margin-left: auto;
  }

  .checkout-notice {
    left: 20px;
    right: 20px;
    max-width: none;
  }
}

@media (min-width: 901px) {
  .summary-toggle {
    display: none;
  }

  .summary-collapsible {
    display: block !important;
  }
}
