/**
 * Quantum Field Inc. — Modal Contact Form Styles
 * Professional popup contact form with Web3Forms integration
 */

/* ===========================================
   MODAL OVERLAY & CONTAINER
   =========================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 500;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

html[data-theme="dark"] .modal-backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.modal-container {
  position: fixed;
  inset: 0;
  z-index: 501;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-container.active {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
}

/* ===========================================
   MODAL CONTENT
   =========================================== */
.modal {
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 48px);
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  box-shadow: 
    0 25px 50px -12px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(255, 255, 255, 0.05);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(0.98);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-container.active .modal {
  transform: translateY(0) scale(1);
}

html[data-theme="dark"] .modal {
  box-shadow: 
    0 25px 50px -12px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* ===========================================
   MODAL HEADER
   =========================================== */
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 0;
  flex-shrink: 0;
}

.modal-header-content {
  flex: 1;
  min-width: 0;
}

.modal-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-primary);
  margin-bottom: 8px;
}

.modal-label .indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s ease infinite;
}

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

.modal-title {
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
  margin: 0;
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border-primary);
  background: var(--bg-card);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.modal-close svg {
  width: 18px;
  height: 18px;
}

/* ===========================================
   MODAL BODY
   =========================================== */
.modal-body {
  padding: 20px 24px 24px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.modal-intro {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-primary);
}

/* ===========================================
   CONTACT FORM STYLES
   =========================================== */
.modal-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

@media (max-width: 500px) {
  .modal-form-row {
    grid-template-columns: 1fr;
  }
}

.modal-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

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

.modal-form-input,
.modal-form-select,
.modal-form-textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.modal-form-input:focus,
.modal-form-select:focus,
.modal-form-textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

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

.modal-form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
  cursor: pointer;
}

html[data-theme="dark"] .modal-form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

.modal-form-textarea {
  min-height: 100px;
  resize: vertical;
}

/* Validation States */
.modal-form-group.error .modal-form-input,
.modal-form-group.error .modal-form-select,
.modal-form-group.error .modal-form-textarea {
  border-color: var(--error);
}

.modal-form-group.error .modal-form-input:focus,
.modal-form-group.error .modal-form-select:focus,
.modal-form-group.error .modal-form-textarea:focus {
  box-shadow: 0 0 0 3px var(--error-subtle);
}

.modal-form-error {
  font-size: 12px;
  color: var(--error);
  display: none;
}

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

/* Checkbox */
.modal-form-checkbox-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.modal-form-checkbox {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  accent-color: var(--accent-primary);
  flex-shrink: 0;
  cursor: pointer;
}

.modal-form-checkbox-label {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  cursor: pointer;
}

/* ===========================================
   MODAL FOOTER / FORM ACTIONS
   =========================================== */
.modal-form-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 8px;
}

.modal-form-submit {
  width: 100%;
  height: 48px;
  padding: 0 24px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent-primary);
  color: #FFFFFF;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-form-submit:hover {
  background: var(--accent-secondary);
}

.modal-form-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.modal-form-submit svg {
  width: 18px;
  height: 18px;
}

/* Loading State */
.modal-form-submit.loading {
  position: relative;
  color: transparent;
}

.modal-form-submit.loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.modal-form-note {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* ===========================================
   FORM MESSAGES
   =========================================== */
.modal-form-message {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  display: none;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.modal-form-message.show {
  display: flex;
}

.modal-form-message.success {
  background: var(--success-subtle);
  color: var(--success);
  border: 1px solid var(--success);
}

.modal-form-message.error {
  background: var(--error-subtle);
  color: var(--error);
  border: 1px solid var(--error);
}

.modal-form-message svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ===========================================
   SUCCESS STATE
   =========================================== */
.modal-success {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 0;
}

.modal-success.show {
  display: flex;
}

.modal-success-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--success-subtle);
  border: 2px solid var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.modal-success-icon svg {
  width: 28px;
  height: 28px;
  color: var(--success);
}

.modal-success h3 {
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.modal-success p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 320px;
  margin-bottom: 24px;
}

.modal-success-btn {
  height: 44px;
  padding: 0 24px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-primary);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-success-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--text-muted);
}

/* ===========================================
   CONTACT TRIGGER BUTTONS
   =========================================== */
.contact-trigger {
  cursor: pointer;
}

/* Floating Contact Button (Optional) */
.contact-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: #FFFFFF;
  border: none;
  box-shadow: 0 4px 12px rgba(30, 58, 95, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  transition: all 0.2s ease;
}

.contact-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(30, 58, 95, 0.4);
}

.contact-fab svg {
  width: 24px;
  height: 24px;
}

@media (max-width: 768px) {
  .contact-fab {
    bottom: 20px;
    right: 20px;
    width: 52px;
    height: 52px;
  }
}

/* ===========================================
   ACCESSIBILITY
   =========================================== */
.modal-container:focus {
  outline: none;
}

.modal:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Prevent body scroll when modal is open */
body.modal-open {
  overflow: hidden;
}

/* ===========================================
   RESPONSIVE ADJUSTMENTS
   =========================================== */
@media (max-width: 600px) {
  .modal-container {
    padding: 16px;
    align-items: flex-end;
  }

  .modal {
    max-height: calc(100vh - 32px);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .modal-header {
    padding: 20px 20px 0;
  }

  .modal-body {
    padding: 16px 20px 20px;
  }

  .modal-title {
    font-size: 20px;
  }
}
