/* ═══════════════════════════════════════════════════════════════
   QTSI — forms.css
   Premium dark modal forms — Consultation, Proposal, Procurement
   Design by NEXORA (nexorayyc.io)
═══════════════════════════════════════════════════════════════ */

/* ── Modal backdrop ──────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(5, 5, 10, 0.85);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms var(--ease-expo);
}

.modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* ── Modal panel ─────────────────────────────────────────── */
.modal-panel {
  background: rgba(12, 12, 22, 0.96);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: var(--r-2xl);
  width: 100%;
  max-width: 680px;
  max-height: 92dvh;
  overflow-y: auto;
  box-shadow:
    0 0 0 1px rgba(255,255,255,.04),
    0 32px 80px rgba(0,0,0,.80),
    0 0 80px rgba(0,112,243,.12);
  transform: translateY(20px) scale(0.97);
  transition:
    transform 380ms cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity   280ms var(--ease-expo);
  opacity: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.10) transparent;
}

.modal-backdrop.is-open .modal-panel {
  transform: none;
  opacity: 1;
}

/* Gradient top strip */
.modal-panel::before {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg, #0070F3 0%, #5DB937 100%);
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
}

/* ── Booking / Calendly modal variant ───────────────────── */
.modal-panel--booking {
  max-width: 900px;
  overflow: hidden;           /* Calendly iframe manages its own scroll */
}
.modal-panel--booking .modal-header {
  border-bottom: 1px solid rgba(255,255,255,.07);
}

/* ── Modal header ────────────────────────────────────────── */
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-8) var(--sp-8) var(--sp-5);
}

.modal-title-group { flex: 1; }

.modal-eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--blue-light);
  margin-bottom: 6px;
  display: block;
}

.modal-title {
  font-size: clamp(1.4rem, 3vw, 1.75rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  line-height: 1.15;
}

.modal-close {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-md);
  background: var(--bg-surface);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 4px;
  transition: background 150ms, color 150ms, border-color 150ms;
}
.modal-close:hover {
  background: var(--bg-surface-md);
  color: var(--text-primary);
  border-color: var(--border-hi);
}

/* ── Form body ───────────────────────────────────────────── */
.modal-form {
  padding: 0 var(--sp-8) var(--sp-8);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

/* 2-column field grid */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}

@media (max-width: 560px) {
  .form-row { grid-template-columns: 1fr; }
  .modal-form { padding: 0 var(--sp-5) var(--sp-6); }
  .modal-header { padding: var(--sp-6) var(--sp-5) var(--sp-4); }
}

/* ── Field ───────────────────────────────────────────────── */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.form-label .required {
  color: var(--blue-light);
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: var(--r-md);
  padding: 11px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color 200ms, background 200ms, box-shadow 200ms;
  appearance: none;
  -webkit-appearance: none;
  min-height: 44px;
}

.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-muted); }

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: rgba(0,112,243,.55);
  background: rgba(255,255,255,.07);
  box-shadow: 0 0 0 3px rgba(0,112,243,.12);
}

.form-input.is-error,
.form-select.is-error,
.form-textarea.is-error {
  border-color: rgba(239,68,68,.55);
  box-shadow: 0 0 0 3px rgba(239,68,68,.10);
}

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

.form-select option {
  background: #141421;
  color: var(--text-primary);
}

.form-textarea {
  resize: vertical;
  min-height: 110px;
  line-height: 1.6;
}

/* Error message */
.form-error {
  font-size: 0.75rem;
  color: #F87171;
  display: none;
}

.form-field.has-error .form-error { display: block; }

/* ── Section divider within form ─────────────────────────── */
.form-divider {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.form-divider::before,
.form-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Submit button ───────────────────────────────────────── */
.form-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  width: 100%;
  padding: 15px 28px;
  border-radius: var(--r-full);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: var(--blue);
  color: #fff;
  border: 1px solid var(--blue-dark);
  cursor: pointer;
  min-height: 52px;
  margin-top: var(--sp-3);
  transition:
    background   200ms var(--ease-expo),
    transform    150ms cubic-bezier(0.34,1.56,0.64,1),
    box-shadow   200ms var(--ease-expo);
  box-shadow: 0 0 24px rgba(0,112,243,.30), 0 2px 8px rgba(0,0,0,.5);
}

.form-submit:hover {
  background: var(--blue-light);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,112,243,.45), 0 2px 8px rgba(0,0,0,.5);
}

.form-submit:active { transform: scale(0.97); }

.form-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Loading spinner inside submit */
.form-submit .btn-spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spinFast 0.7s linear infinite;
  display: none;
  flex-shrink: 0;
}

.form-submit.is-loading .btn-spinner { display: block; }
.form-submit.is-loading .btn-label   { opacity: 0.7; }

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

/* Privacy note */
.form-privacy {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.55;
}

/* ── Success state ───────────────────────────────────────── */
.form-success {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-16) var(--sp-8);
  gap: var(--sp-5);
  animation: fadeUp 0.5s var(--ease-expo) both;
}

.form-success.is-visible { display: flex; }

.form-success-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: rgba(93,185,55,.15);
  border: 2px solid rgba(93,185,55,.35);
  display: flex; align-items: center; justify-content: center;
  color: var(--green-light);
}

.form-success-title {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.form-success-sub {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 380px;
}

/* ── Booking CTA (Calendly / Microsoft Bookings) on the success screen ── */
.form-success-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
  margin-top: 2px;
}

.form-book-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 13px 22px;
  border-radius: var(--r-full);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  color: #fff;
  background: var(--green, #5DB937);
  border: 1px solid var(--green-dark, #4a9e2c);
  cursor: pointer;
  box-shadow: 0 0 22px rgba(93,185,55,.28), 0 2px 8px rgba(0,0,0,.4);
  transition: transform 150ms cubic-bezier(0.34,1.56,0.64,1), box-shadow 200ms, background 200ms;
}
.form-book-btn:hover {
  background: var(--green-light, #6cc943);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(93,185,55,.42), 0 2px 8px rgba(0,0,0,.4);
}
.form-book-btn:active { transform: scale(0.97); }

/* ── Honeypot (anti-spam) — visually hidden, off-screen, untabbable ──── */
.form-hp {
  position: absolute !important;
  left: -9999px !important;
  top: auto;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ── Inline error state — retry + pre-filled email fallback ──────────── */
.form-error-state {
  margin-top: var(--sp-3);
  border: 1px solid rgba(239,68,68,.35);
  background: rgba(239,68,68,.08);
  border-radius: var(--r-lg, 14px);
  padding: 14px 16px;
  animation: fadeUp 0.35s var(--ease-expo) both;
}

.form-error-state-head {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #fca5a5;
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.4;
}

.form-error-state-sub {
  margin: 7px 0 12px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.55;
}

.form-error-state-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.form-retry-btn,
.form-mail-btn {
  flex: 1;
  min-width: 130px;
  text-align: center;
  padding: 10px 16px;
  border-radius: var(--r-full);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 150ms, background 180ms, border-color 180ms;
}
.form-retry-btn {
  background: var(--blue, #0070F3);
  color: #fff;
  border: 1px solid var(--blue-dark, #0357c7);
}
.form-mail-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.06);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,.16);
}
.form-retry-btn:hover,
.form-mail-btn:hover { transform: translateY(-1px); }
.form-retry-btn:active,
.form-mail-btn:active { transform: scale(0.97); }

/* ── Mobile form UX ──────────────────────────────────────────────────
   Full-screen, scrollable modal on phones; 16px inputs so iOS Safari never
   auto-zooms on focus; safe-area padding for notch / home indicator. */
@media (max-width: 560px) {
  .modal-backdrop {
    padding: 0;
    align-items: stretch;
  }
  .modal-panel {
    max-width: 100%;
    width: 100%;
    min-height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-panel::before { border-radius: 0; }
  .modal-header { padding-top: max(var(--sp-6), env(safe-area-inset-top)); }

  /* 16px = no auto-zoom on focus (iOS) */
  .form-input,
  .form-select,
  .form-textarea {
    font-size: 16px;
    min-height: 46px;
  }
  .form-submit { font-size: 1rem; min-height: 54px; }
  .form-error-state-actions { flex-direction: column; }
  .form-success-actions { max-width: 100%; }
}
