/* ==========================================
   TowerHouse Studio - Modal System Styles
   ========================================== */

/* Modal Overlay */
.ths-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

/* Modal Background Overlay */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Modal Container */
.modal-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 10000;
}

/* Modal Box */
.modal-box {
  position: relative;
  background: white;
  border-radius: 1rem;
  max-width: 90%;
  max-height: 90vh;
  width: 100%;
  overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

.ths-modal.active .modal-box {
  transform: scale(1);
}

/* Modal sizes */
.modal-box.modal-sm {
  max-width: 500px;
}

.modal-box.modal-md {
  max-width: 700px;
}

.modal-box.modal-lg {
  max-width: 900px;
}

.modal-box.modal-xl {
  max-width: 1200px;
}

/* Modal Header */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  background: linear-gradient(to right, rgba(59, 130, 246, 0.05), rgba(147, 51, 234, 0.05));
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #111827;
  margin: 0;
  background: linear-gradient(to right, #2563eb, #9333ea);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Close Button */
.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  background: transparent;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #6b7280;
}

.modal-close:hover {
  background: #f3f4f6;
  color: #111827;
}

.modal-close:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.modal-close svg {
  width: 1.5rem;
  height: 1.5rem;
}

/* Modal Body */
.modal-body {
  padding: 2rem;
  overflow-y: auto;
  max-height: calc(90vh - 140px);
}

.modal-body::-webkit-scrollbar {
  width: 8px;
}

.modal-body::-webkit-scrollbar-track {
  background: #f3f4f6;
}

.modal-body::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Modal Footer */
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.5rem;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
}

/* Loading State */
.modal-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: #6b7280;
}

.modal-loading .spinner {
  width: 3rem;
  height: 3rem;
  border: 3px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

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

/* Error State */
.modal-error {
  padding: 2rem;
  text-align: center;
  color: #ef4444;
}

/* ==========================================
   Contact Form 7 Styling Inside Modal
   ========================================== */

.modal-body .wpcf7 {
  max-width: 100%;
}

.modal-body .wpcf7-form p {
  margin-bottom: 1.5rem;
}

.modal-body .wpcf7-form label {
  display: block;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

/* Input and Textarea Styles */
.modal-body .wpcf7-form input[type="text"],
.modal-body .wpcf7-form input[type="email"],
.modal-body .wpcf7-form input[type="tel"],
.modal-body .wpcf7-form input[type="url"],
.modal-body .wpcf7-form input[type="number"],
.modal-body .wpcf7-form textarea,
.modal-body .wpcf7-form select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid #e5e7eb;
  border-radius: 0.5rem;
  font-size: 1rem;
  color: #111827;
  background: #ffffff;
  transition: all 0.2s ease;
  font-family: inherit;
}

.modal-body .wpcf7-form input[type="text"]:focus,
.modal-body .wpcf7-form input[type="email"]:focus,
.modal-body .wpcf7-form input[type="tel"]:focus,
.modal-body .wpcf7-form input[type="url"]:focus,
.modal-body .wpcf7-form input[type="number"]:focus,
.modal-body .wpcf7-form textarea:focus,
.modal-body .wpcf7-form select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.modal-body .wpcf7-form textarea {
  min-height: 120px;
  resize: vertical;
}

/* Submit Button */
.modal-body .wpcf7-form input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  color: #ffffff;
  background: linear-gradient(to right, #f97316, #ec4899);
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.modal-body .wpcf7-form input[type="submit"]:hover {
  background: linear-gradient(to right, #ea580c, #db2777);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  transform: translateY(-1px);
}

.modal-body .wpcf7-form input[type="submit"]:active {
  transform: translateY(0);
}

.modal-body .wpcf7-form input[type="submit"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Loading Spinner on Submit Button */
.modal-body .wpcf7-form .wpcf7-spinner {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 0.5rem;
  vertical-align: middle;
}

/* Validation Messages */
.modal-body .wpcf7-form .wpcf7-not-valid-tip {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: #ef4444;
}

.modal-body .wpcf7-form .wpcf7-validation-errors,
.modal-body .wpcf7-form .wpcf7-acceptance-missing {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border: 2px solid #fecaca;
  background: #fef2f2;
  border-radius: 0.5rem;
  color: #991b1b;
  font-size: 0.95rem;
}

.modal-body .wpcf7-form .wpcf7-mail-sent-ok {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border: 2px solid #bbf7d0;
  background: #f0fdf4;
  border-radius: 0.5rem;
  color: #166534;
  font-size: 0.95rem;
}

/* Invalid field highlight */
.modal-body .wpcf7-form .wpcf7-not-valid {
  border-color: #ef4444;
}

.modal-body .wpcf7-form .wpcf7-not-valid:focus {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Response Output */
.modal-body .wpcf7-response-output {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  font-size: 0.95rem;
}

/* Hide screen reader only content */
.modal-body .wpcf7 .screen-reader-response {
  position: absolute;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  height: 1px;
  width: 1px;
  margin: 0;
  padding: 0;
  border: 0;
}

/* Akismet hidden field */
.modal-body .wpcf7 .akismet-fields-container {
  display: none !important;
}

/* Form Control Wrapper */
.modal-body .wpcf7-form-control-wrap {
  display: block;
}

/* Checkbox and Radio Styling */
.modal-body .wpcf7-form input[type="checkbox"],
.modal-body .wpcf7-form input[type="radio"] {
  width: auto;
  margin-right: 0.5rem;
  cursor: pointer;
}

.modal-body .wpcf7-list-item {
  margin: 0.5rem 0;
}

.modal-body .wpcf7-list-item label {
  display: inline-flex;
  align-items: center;
  font-weight: 400;
  cursor: pointer;
}

/* Select Dropdown */
.modal-body .wpcf7-form select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5rem 1.5rem;
  padding-right: 2.5rem;
  appearance: none;
}

/* Responsive */
@media (max-width: 640px) {
  .modal-container {
    padding: 0;
  }
  
  .modal-box {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
  
  .modal-body {
    max-height: calc(100vh - 140px);
    padding: 1.5rem;
  }
  
  .modal-body .wpcf7-form input[type="submit"] {
    width: 100%;
  }
}

