/* =========================================================
   Live Leads Solution - Immersive Overhauled Form & Modal
   ========================================================= */

:root {
  --modal-bg: #090D16;
  --modal-card: rgba(13, 18, 30, 0.94);
  --modal-border: rgba(56, 189, 248, 0.22);
  --modal-border-hover: rgba(56, 189, 248, 0.5);
  
  --input-bg: rgba(15, 23, 42, 0.75);
  --input-border: rgba(255, 255, 255, 0.1);
  --input-border-focus: #0088cc;
  --input-focus-glow: rgba(0, 136, 204, 0.28);
  
  --text-pure: #FFFFFF;
  --text-head: #F8FAFC;
  --text-muted: #94A3B8;
  --text-dim: #64748B;
  
  --accent-cyan: #38BDF8;
  --accent-blue: #0088cc;
  --accent-indigo: #2563EB;
  --accent-emerald: #10B981;
  
  --glow-shadow: 0 0 50px -10px rgba(0, 136, 204, 0.3), 0 30px 80px -20px rgba(0, 0, 0, 0.85);
  --font-modal: 'Plus Jakarta Sans', 'Open Sans', -apple-system, sans-serif;
}

/* =========================================================
   Modal Backdrop & Container
   ========================================================= */
.lead-modal-backdrop {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(3, 7, 18, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
}

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

.lead-modal-dialog {
  position: relative;
  width: 100%;
  max-width: 780px;
  max-height: 92vh;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--modal-card);
  border: none !important;
  border-radius: 24px;
  box-shadow: 0 25px 70px -10px rgba(0, 0, 0, 0.95);
  transform: translateY(24px) scale(0.96);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: var(--font-modal);
  color: var(--text-head);
  padding: 32px 36px;
  scrollbar-width: thin;
  scrollbar-color: rgba(56, 189, 248, 0.3) transparent;
}

.lead-modal-backdrop.is-open .lead-modal-dialog {
  transform: translateY(0) scale(1);
}

/* Custom Scrollbar */
.lead-modal-dialog::-webkit-scrollbar {
  width: 6px;
}
.lead-modal-dialog::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.3);
  border-radius: 10px;
}

/* Standalone Page Mode (e.g. Form.html) */
.standalone-mode {
  min-height: 100vh;
  background-color: #030712;
  background-image: 
    radial-gradient(at 0% 0%, rgba(0, 136, 204, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(37, 99, 235, 0.12) 0px, transparent 50%),
    radial-gradient(#1E293B 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 28px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  position: relative;
  overflow-x: hidden;
}

.standalone-mode .lead-modal-dialog {
  max-height: none;
  overflow: visible;
  transform: none;
}

/* Close Button */
.modal-close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 10;
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-pure);
  border-color: var(--accent-cyan);
  transform: rotate(90deg) scale(1.05);
}

/* =========================================================
   Modal Header & Brand
   ========================================================= */
.modal-header-section {
  position: relative;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: rgba(0, 136, 204, 0.12);
  border: 1px solid rgba(0, 136, 204, 0.3);
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.glow-dot {
  width: 7px;
  height: 7px;
  background: var(--accent-emerald);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-emerald);
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.modal-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.modal-title {
  font-family: var(--font-modal);
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text-pure);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.modal-title-gradient {
  background: linear-gradient(135deg, #FFFFFF 30%, #38BDF8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.modal-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.security-capsule {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #34D399;
}

/* =========================================================
   Section Titles & Grid
   ========================================================= */
.form-section-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 20px 0 14px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-cyan);
}

.form-section-bar:first-of-type {
  margin-top: 2px;
  padding-right: 48px;
}

.form-section-bar::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.25), transparent);
}

.immersive-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  column-gap: 20px;
  row-gap: 16px;
}

.grid-col-full {
  grid-column: 1 / -1;
}

/* Form Group & Controls */
.modal-form-group {
  display: flex;
  flex-direction: column;
  position: relative;
}

.modal-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #E2E8F0;
  margin-bottom: 6px;
}

.label-required {
  color: #F43F5E;
  margin-left: 2px;
}

.label-optional {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 7px;
  border-radius: 4px;
}

/* Modern Glass Input */
.modal-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.modal-input-icon {
  position: absolute;
  left: 14px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  pointer-events: none;
  transition: color 0.2s ease;
  z-index: 2;
}

.modal-input-control {
  width: 100%;
  height: 44px;
  padding: 0 14px 0 42px;
  font-family: var(--font-modal);
  font-size: 0.875rem;
  color: var(--text-pure);
  background: var(--input-bg);
  border: 1.5px solid var(--input-border);
  border-radius: 12px;
  outline: none;
  transition: all 0.2s ease;
}

.modal-input-control::placeholder {
  color: var(--text-dim);
  font-size: 0.825rem;
}

.modal-input-control:hover {
  background: rgba(15, 23, 42, 0.88);
  border-color: var(--modal-border-hover);
}

.modal-input-control:focus {
  background: #0B1220;
  border-color: var(--input-border-focus);
  box-shadow: 0 0 0 4px var(--input-focus-glow), 0 0 20px rgba(0, 136, 204, 0.2);
}

.modal-input-wrap:focus-within .modal-input-icon {
  color: var(--accent-cyan);
}

/* Select Control */
.modal-select-control {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  padding-right: 38px;
}

.modal-select-control option {
  background: #0F172A;
  color: #F8FAFC;
}

.modal-select-chevron {
  position: absolute;
  right: 14px;
  color: var(--text-dim);
  pointer-events: none;
  transition: transform 0.2s ease;
}

.modal-input-wrap:focus-within .modal-select-chevron {
  color: var(--accent-cyan);
  transform: rotate(180deg);
}

/* Quick DOB Filter Chips */
.dob-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.quick-filter-chips {
  display: flex;
  align-items: center;
  gap: 5px;
}

.quick-chip-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9999px;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.quick-chip-btn:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent-cyan);
  color: var(--text-pure);
}

.quick-chip-btn.active {
  background: var(--accent-blue);
  border-color: var(--accent-cyan);
  color: #FFFFFF;
  box-shadow: 0 0 10px rgba(0, 136, 204, 0.4);
}

.calendar-action-icon {
  pointer-events: auto;
  cursor: pointer;
}

.calendar-action-icon:hover {
  color: var(--accent-cyan);
}

.age-display-text {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-cyan);
  margin-left: auto;
}

/* =========================================================
   Interactive Dark Map Integration
   ========================================================= */
.immersive-map-box {
  margin-top: 4px;
}

.map-header-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.775rem;
}

.map-label-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.map-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.map-status-pill .status-indicator-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--text-dim);
}

.map-status-pill.is-located {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.4);
  color: #34D399;
}

.map-status-pill.is-located .status-indicator-dot {
  background: #10B981;
  box-shadow: 0 0 8px #10B981;
}

.map-status-pill.is-loading {
  background: rgba(0, 136, 204, 0.12);
  border-color: rgba(0, 136, 204, 0.4);
  color: var(--accent-cyan);
}

.map-status-pill.is-loading .status-indicator-dot {
  background: var(--accent-cyan);
  animation: pulseDot 1s infinite;
}

.map-canvas-wrapper {
  position: relative;
  width: 100%;
  height: 200px;
  border-radius: 14px;
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  background: #0B1120;
  overflow: hidden;
}

.map-canvas {
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Map Empty Placeholder */
.map-canvas-overlay {
  position: absolute;
  inset: 0;
  background: rgba(11, 17, 32, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  z-index: 2;
  text-align: center;
  padding: 16px;
  transition: opacity 0.3s ease, visibility 0.3s;
}

.map-canvas-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.map-canvas-overlay svg {
  color: var(--accent-cyan);
}

.map-overlay-title {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-head);
}

.map-overlay-desc {
  font-size: 0.75rem;
  color: var(--text-dim);
  max-width: 280px;
}

/* Dark Map Loader */
.map-canvas-loader {
  position: absolute;
  inset: 0;
  background: rgba(11, 17, 32, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  z-index: 4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-cyan);
}

.map-canvas-loader.is-active {
  opacity: 1;
  pointer-events: auto;
}

/* =========================================================
   Terms Checkbox & Actions
   ========================================================= */
.terms-agreement-row {
  margin-top: 10px;
}

.immersive-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.immersive-checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.custom-dark-checkbox {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  background: rgba(15, 23, 42, 0.8);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  transition: all 0.2s ease;
}

.custom-dark-checkbox svg {
  opacity: 0;
  transform: scale(0.6);
  transition: all 0.15s ease;
  color: #FFFFFF;
}

.immersive-checkbox-label input[type="checkbox"]:checked + .custom-dark-checkbox {
  background: var(--accent-blue);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 136, 204, 0.4);
}

.immersive-checkbox-label input[type="checkbox"]:checked + .custom-dark-checkbox svg {
  opacity: 1;
  transform: scale(1);
}

.terms-hyperlink {
  color: var(--accent-cyan);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px dashed rgba(56, 189, 248, 0.5);
}

.terms-hyperlink:hover {
  border-bottom-style: solid;
}

/* Validation Feedback */
.input-error-msg {
  font-size: 0.75rem;
  color: #FB7185;
  font-weight: 500;
  margin-top: 4px;
  display: none;
  animation: fadeIn 0.2s ease;
}

.modal-form-group.has-error .modal-input-control {
  border-color: #F43F5E;
  background: rgba(244, 63, 94, 0.05);
}

.modal-form-group.has-error .modal-input-icon {
  color: #F43F5E;
}

.modal-form-group.has-error .input-error-msg {
  display: block;
}

/* Modal Actions Strip */
.modal-footer-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  gap: 14px;
}

.btn-dark-reset {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
  border-radius: 12px;
  padding: 11px 20px;
  font-family: var(--font-modal);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-dark-reset:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-pure);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-gradient-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #0088cc 0%, #2563EB 50%, #06b6d4 100%);
  color: #FFFFFF;
  border: none;
  border-radius: 12px;
  padding: 12px 28px;
  font-family: var(--font-modal);
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 136, 204, 0.4);
  transition: all 0.2s ease;
}

.btn-gradient-submit:hover {
  box-shadow: 0 8px 25px rgba(0, 136, 204, 0.6);
  transform: translateY(-1px);
}

.btn-gradient-submit:active {
  transform: scale(0.98);
}

.btn-spinner-icon {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: spinLoader 0.7s linear infinite;
}

.btn-gradient-submit.is-submitting .btn-submit-text,
.btn-gradient-submit.is-submitting .btn-submit-icon {
  display: none;
}

.btn-gradient-submit.is-submitting .btn-spinner-icon {
  display: inline-block;
}

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

/* =========================================================
   Celebratory Success Modal State
   ========================================================= */
.modal-success-screen {
  display: none;
  text-align: center;
  padding: 20px 10px;
  animation: fadeIn 0.3s ease;
}

.modal-success-screen.is-active {
  display: block;
}

.success-glow-ring {
  width: 76px;
  height: 76px;
  background: rgba(16, 185, 129, 0.15);
  border: 2px solid var(--accent-emerald);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.4);
}

.success-modal-heading {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-pure);
  margin-bottom: 6px;
}

.success-modal-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto 24px;
}

.success-lead-highlight {
  color: var(--accent-cyan);
  font-weight: 700;
}

.success-action-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  margin: 0 auto;
}

.btn-ceo-sync {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: var(--accent-cyan);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.btn-ceo-sync:hover {
  background: rgba(56, 189, 248, 0.22);
  border-color: var(--accent-cyan);
  color: #FFFFFF;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.3);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 640px) {
  .lead-modal-dialog {
    padding: 24px 18px;
    border-radius: 20px;
  }

  .immersive-grid {
    grid-template-columns: 1fr;
    row-gap: 14px;
  }

  .modal-title {
    font-size: 1.35rem;
  }

  .modal-footer-strip {
    flex-direction: column-reverse;
  }

  .btn-dark-reset,
  .btn-gradient-submit {
    width: 100%;
  }
}
