/* ============================================================
   Contrail — Modal System (contrail-modals.css)
   PCI-DSS SAQ A compliant payment & sales modals
   ============================================================ */

/* ── Overlay ─────────────────────────────────────────────────── */
.cm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px 40px;
  overflow-y: auto;
}

/* ── Modal container ─────────────────────────────────────────── */
.cm-modal {
  background: rgba(10, 15, 26, 0.98);
  border: 1px solid rgba(51, 65, 85, 0.7);
  border-radius: 20px;
  width: 100%;
  max-width: 560px;
  margin: auto 0;
  position: relative;
  box-shadow:
    0 32px 72px -10px rgba(0, 0, 0, 0.8),
    0 0 0 1px rgba(14, 165, 233, 0.05),
    inset 0 1px 0 rgba(255,255,255,0.04);
}

/* ── Header ──────────────────────────────────────────────────── */
.cm-header {
  padding: 22px 22px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.cm-header-text { flex: 1; min-width: 0; }

.cm-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #f8fafc;
  margin: 0 0 6px;
  line-height: 1.3;
}

.cm-subtitle {
  font-size: 0.78rem;
  color: #475569;
  margin: 0;
  line-height: 1.5;
}

.cm-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(51, 65, 85, 0.35);
  border: 1px solid rgba(51, 65, 85, 0.55);
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  padding: 0;
}

.cm-close:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.cm-close:focus-visible {
  outline: 2px solid #0ea5e9;
  outline-offset: 2px;
}

/* ── Plan badge ──────────────────────────────────────────────── */
.cm-plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 8px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-top: 6px;
}

.cm-plan-badge.starter {
  background: rgba(71, 85, 105, 0.25);
  border: 1px solid rgba(71, 85, 105, 0.45);
  color: #94a3b8;
}

.cm-plan-badge.professional {
  background: rgba(14, 165, 233, 0.1);
  border: 1px solid rgba(14, 165, 233, 0.3);
  color: #38bdf8;
}

/* ── Divider ─────────────────────────────────────────────────── */
.cm-divider {
  height: 1px;
  background: rgba(51, 65, 85, 0.45);
  margin: 18px 22px 0;
}

/* ── Order summary ───────────────────────────────────────────── */
.cm-order-summary {
  padding: 16px 22px;
  background: rgba(14, 165, 233, 0.03);
  border-top: 1px solid rgba(51, 65, 85, 0.35);
  border-bottom: 1px solid rgba(51, 65, 85, 0.35);
}

.cm-order-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.cm-order-plan  { font-size: 0.9rem;  font-weight: 600; color: #e2e8f0; }
.cm-order-price { font-size: 1.05rem; font-weight: 800; color: #38bdf8; white-space: nowrap; }
.cm-order-per   { font-size: 0.72rem; font-weight: 400; color: #475569; margin-left: 2px; }

.cm-order-features {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cm-order-features li {
  font-size: 0.75rem;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cm-order-features li::before {
  content: '✓';
  color: #4ade80;
  font-size: 0.68rem;
  font-weight: 700;
}

.cm-guarantee {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  font-size: 0.7rem;
  color: #4ade80;
  background: rgba(74, 222, 128, 0.06);
  border: 1px solid rgba(74, 222, 128, 0.2);
  padding: 3px 9px;
  border-radius: 6px;
}

/* ── Form body ───────────────────────────────────────────────── */
.cm-form-body { padding: 0 22px 22px; }

/* ── Section ─────────────────────────────────────────────────── */
.cm-section { padding-top: 20px; }

.cm-section-title {
  font-size: 0.67rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0 0 13px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.4);
}

/* ── Grid ────────────────────────────────────────────────────── */
.cm-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.cm-full   { grid-column: span 2; }

@media (max-width: 480px) {
  .cm-grid { grid-template-columns: 1fr; }
  .cm-full { grid-column: span 1; }
}

/* ── Form group ──────────────────────────────────────────────── */
.cm-group { display: flex; flex-direction: column; gap: 5px; }

.cm-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: #94a3b8;
  line-height: 1;
}

.cm-required { color: #f87171; margin-left: 2px; }

/* ── Inputs ──────────────────────────────────────────────────── */
.cm-input,
.cm-select,
.cm-textarea {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(51, 65, 85, 0.6);
  border-radius: 10px;
  color: #f8fafc;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.855rem;
  padding: 10px 13px;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
  line-height: 1.4;
}

.cm-input::placeholder,
.cm-textarea::placeholder { color: #334155; }

.cm-input:focus,
.cm-select:focus,
.cm-textarea:focus {
  outline: none;
  border-color: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.14);
}

.cm-input.cm-err,
.cm-select.cm-err {
  border-color: #f87171;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.11);
}

.cm-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
  cursor: pointer;
}

.cm-select option { background: #0f172a; color: #f8fafc; }

.cm-textarea {
  resize: vertical;
  min-height: 90px;
}

/* ── Field error ─────────────────────────────────────────────── */
.cm-ferr {
  font-size: 0.7rem;
  color: #f87171;
  display: none;
  align-items: center;
  gap: 4px;
  margin-top: 1px;
  line-height: 1.4;
}

.cm-ferr.on { display: flex; }

/* ── Stripe Element container ────────────────────────────────── */
.cm-stripe-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
  background: rgba(14, 165, 233, 0.04);
  border: 1px solid rgba(14, 165, 233, 0.14);
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 0.74rem;
  color: #475569;
  line-height: 1.55;
}

.cm-stripe-note svg { flex-shrink: 0; margin-top: 1px; }
.cm-stripe-note strong { color: #94a3b8; }

.cm-stripe-box {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(51, 65, 85, 0.6);
  border-radius: 10px;
  padding: 12px 13px;
  min-height: 44px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cm-stripe-box.focused {
  border-color: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.14);
}

.cm-stripe-box.cm-err {
  border-color: #f87171;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.11);
}

/* ── Checkbox & radio ────────────────────────────────────────── */
.cm-checks { display: flex; flex-direction: column; gap: 7px; margin-top: 6px; }
.cm-radios { display: flex; flex-direction: column; gap: 7px; margin-top: 6px; }

.cm-check-row,
.cm-radio-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 0.81rem;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1.45;
}

.cm-check-row input[type="checkbox"],
.cm-radio-row  input[type="radio"] {
  width: 15px;
  height: 15px;
  accent-color: #0ea5e9;
  flex-shrink: 0;
  margin-top: 1px;
  cursor: pointer;
}

/* ── Agreement ───────────────────────────────────────────────── */
.cm-agree {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.79rem;
  color: #94a3b8;
  line-height: 1.55;
  cursor: pointer;
}

.cm-agree input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: #0ea5e9;
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
}

.cm-agree a { color: #38bdf8; text-decoration: none; }
.cm-agree a:hover { text-decoration: underline; }

/* ── Global error banner ─────────────────────────────────────── */
.cm-banner {
  display: none;
  margin: 14px 22px 0;
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.09);
  border: 1px solid rgba(239, 68, 68, 0.28);
  border-radius: 10px;
  font-size: 0.79rem;
  color: #f87171;
  line-height: 1.5;
}

.cm-banner.on { display: block; }

/* ── Submit button ───────────────────────────────────────────── */
.cm-submit {
  width: 100%;
  margin-top: 18px;
  padding: 14px 24px;
  border-radius: 12px;
  border: none;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.93rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition: background 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.cm-submit-pay {
  background: #0ea5e9;
  color: #fff;
  box-shadow: 0 0 28px -8px rgba(14, 165, 233, 0.45);
}

.cm-submit-pay:hover:not(:disabled) {
  background: #38bdf8;
  box-shadow: 0 0 36px -8px rgba(14, 165, 233, 0.65);
}

.cm-submit-sales {
  background: transparent;
  color: #a78bfa;
  border: 1.5px solid rgba(139, 92, 246, 0.45);
}

.cm-submit-sales:hover:not(:disabled) {
  background: rgba(139, 92, 246, 0.09);
  border-color: rgba(139, 92, 246, 0.65);
}

.cm-submit:disabled { opacity: 0.55; cursor: not-allowed; }

.cm-submit:focus-visible {
  outline: 2px solid #0ea5e9;
  outline-offset: 2px;
}

/* ── Spinner ─────────────────────────────────────────────────── */
.cm-spin {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: rgba(255,255,255,0.85);
  border-radius: 50%;
  display: none;
  flex-shrink: 0;
  animation: cm-rotate 0.65s linear infinite;
}

.cm-submit.busy .cm-spin   { display: block; }
.cm-submit.busy .cm-lbl    { opacity: 0.7; }

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

/* ── Security footer ─────────────────────────────────────────── */
.cm-sec-bar {
  padding: 13px 22px;
  border-top: 1px solid rgba(51, 65, 85, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
}

.cm-sec-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.69rem;
  color: #334155;
  white-space: nowrap;
}

/* ── Success state ───────────────────────────────────────────── */
.cm-success {
  padding: 44px 24px 36px;
  text-align: center;
}

.cm-success-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: rgba(74, 222, 128, 0.09);
  border: 1px solid rgba(74, 222, 128, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.cm-success-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #f1f5f9;
  margin: 0 0 10px;
}

.cm-success-msg {
  font-size: 0.84rem;
  color: #475569;
  line-height: 1.7;
  margin: 0 0 22px;
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
}

.cm-done {
  padding: 10px 28px;
  border-radius: 10px;
  border: 1px solid rgba(51, 65, 85, 0.55);
  background: transparent;
  color: #94a3b8;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.cm-done:hover { background: rgba(51, 65, 85, 0.3); color: #f1f5f9; }

.cm-done:focus-visible {
  outline: 2px solid #0ea5e9;
  outline-offset: 2px;
}

/* ── Mobile full-screen sheet ────────────────────────────────── */
@media (max-width: 600px) {
  .cm-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .cm-modal {
    border-radius: 20px 20px 0 0;
    max-width: 100%;
    margin: 0;
    max-height: 92svh;
    overflow-y: auto;
  }
}

/* ── Reduced motion ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .cm-spin { animation: none; }
  .cm-overlay,
  .cm-modal,
  .cm-input,
  .cm-submit,
  .cm-close { transition: none; }
}
