/* Forms and Validation CSS - Racing Future Academy */

/* === FORM VALIDATION STYLES === */

/* Validation messages */
.validation-message {
  display: block;
  color: var(--primary-red);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  margin-top: 4px;
  animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Form control states */
.form-control {
  transition: all 0.3s ease;
  border: 1px solid #d0d0d0;
}

select.form-control {
  padding: 0;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-red);
  box-shadow: 0 0 0 2px rgba(230, 34, 66, 0.1);
}

.form-control.valid {
  border: 0;
  border-bottom: 1px solid var(--success-green);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%234baa58' d='m2.3 6.73.94-.94 2.94 2.94-1.06 1.06z'/%3e%3cpath fill='%234baa58' d='m.55 4.54 1.41-1.41 1.06 1.06L1.61 5.6z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right calc(0.375em + 0.1875rem) center;
  background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.form-control.invalid {
  border: 0;
  border-bottom: 1px solid var(--primary-red);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23e62242'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath d='m5.5 5.5 1 1m0-1-1 1'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right calc(0.375em + 0.1875rem) center;
  background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

/* Enhanced Contact Form Styles */
.contact-form {
  width: 100%;
  /* Usunięto max-width: 840px - teraz używa globalnej klasy .container */
}

/* Force border-box dla formularza i jego elementów */
.contact-form,
.contact-form *,
.contact-form *::before,
.contact-form *::after {
  box-sizing: border-box !important;
}

.form-header {
  text-align: center;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid #e0e0e0;
}

.form-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 48px;
  margin-bottom: 16px;
}

/* SVG Logo styling */
.form-logo-svg {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.form-title {
  font-family: var(--font-headings);
  font-weight: 700;
  font-size: 24px;
  line-height: 30px;
  color: var(--dark-gray);
  margin: 0 0 8px 0;
}

.form-subtitle {
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 16px;
  line-height: 24px;
  color: var(--text-gray);
  margin: 0;
}

.form-row {
  display: flex;
  flex-direction: column; /* Mobile first */
  gap: 24px;
  margin-bottom: 24px;
}

/* Desktop - side by side */
@media (min-width: 1400px) {
  .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group--full {
  grid-column: 1 / -1; /* Span full width in grid */
}

.form-group label {
  font-family: var(--font-headings);
  font-weight: 600;
  font-size: 14px;
  line-height: 20px;
  color: var(--dark-gray);
  margin-bottom: 8px;
}

.form-group label::after {
  content: "*";
  color: var(--primary-red);
  margin-left: 4px;
}

.form-group label[for="phone"]::after,
.form-group label[for="message"]::after,
.form-group label[for="marketingConsent"]::after {
  display: none; /* These fields are optional */
}

.form-control,
.form-control--textarea {
  width: 100%;
  padding: 12px 16px;
  border: 0;
  border-bottom: 1px solid #d0d0d0;
  border-radius: 4px;
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 16px;
  line-height: 24px;
  color: var(--dark-gray);
  background-color: var(--white);
  transition: all 0.3s ease;
}

.form-control--textarea {
  resize: vertical;
  min-height: 96px;
}

.form-control::placeholder {
  color: #999;
  font-style: italic;
}

/* Enhanced GDPR Section */
.gdpr-section {
  margin: 32px 0;
  padding: 24px;
}

.gdpr-title {
  font-family: var(--font-headings);
  font-weight: 600;
  font-size: 16px;
  line-height: 24px;
  color: var(--dark-gray);
  margin: 0 0 16px 0;
}

.gdpr-text {
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 14px;
  line-height: 20px;
  color: var(--text-gray);
  margin-bottom: 24px;
}

.checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.checkbox-group:last-child {
  margin-bottom: 0;
}

.form-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--primary-red);
  margin-top: 2px;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.form-checkbox:invalid,
.form-checkbox.invalid {
  outline: 2px solid var(--primary-red);
  outline-offset: 2px;
}

.checkbox-group label {
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 14px;
  line-height: 20px;
  color: var(--dark-gray);
  cursor: pointer;
  flex-grow: 1;
}

.checkbox-group label::after {
  display: none; /* Remove asterisk from checkbox labels */
}

/* Checkbox validation message styling */
.checkbox-group + .validation-message {
  margin-left: 30px; /* Align with checkbox label */
  margin-top: -12px; /* Reduce spacing */
  margin-bottom: 12px;
}

/* ========================================
   CAPTCHA MODAL STYLES
   ======================================== */

/* Force border-box dla modala captcha */
.captcha-modal-overlay,
.captcha-modal-overlay *,
.captcha-modal-overlay *::before,
.captcha-modal-overlay *::after {
  box-sizing: border-box !important;
}

.captcha-modal-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background-color: rgba(0, 0, 0, 0.7) !important;
  backdrop-filter: blur(4px);
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 9999 !important;
  padding: 20px;
  opacity: 1 !important; /* Always visible, no animation */
  transform: none !important;
  margin: 0 !important;
  pointer-events: auto !important;
  /* Prevent flickering */
  will-change: auto !important;
  backface-visibility: hidden !important;
}

@keyframes fadeIn {
  to { opacity: 1; }
}

/* Prevent body scroll when modal is open */
body.modal-open {
  overflow: hidden !important;
  /* Remove position: fixed to prevent jumping */
}

/* Prevent any transforms or movements inside modal */
.captcha-modal-overlay *,
.captcha-modal-content,
.captcha-modal-content *,
.captcha-modal-overlay *:hover,
.captcha-modal-content:hover,
.captcha-modal-content *:hover {
  transform: none !important;
  transition: none !important;
  animation: none !important;
}

/* Specific rules for content inside modal */
.captcha-modal-content *:not(.captcha-modal-overlay) {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
}

.captcha-modal-content {
  background: white;
  border-radius: 16px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  position: relative !important;
  pointer-events: auto !important;
  /* Remove animations that might cause jumping */
  transform: none !important;
  animation: none !important;
  /* Force stable positioning */
  top: 0 !important;
  left: 0 !important;
  margin: 0 !important;
  float: none !important;
}

@keyframes slideUp {
  to { transform: translateY(0); }
}

.captcha-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 24px 16px;
  border-bottom: 1px solid #e5e7eb;
}

.captcha-modal-header h3 {
  margin: 0;
  font-family: "League Spartan", sans-serif;
  font-size: 20px;
  font-weight: 600;
  color: #262728;
}

.captcha-modal-close {
  background: none;
  border: none;
  color: #6b7280;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

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

.captcha-modal-body {
  padding: 24px;
}

.captcha-description {
  margin: 0 0 24px;
  color: #6b7280;
  font-size: 14px;
  line-height: 1.5;
}

.captcha-container-modal {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
  min-height: 78px; /* hCaptcha standard height */
}

.captcha-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  color: #6b7280;
  font-size: 14px;
}

.captcha-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid #e5e7eb;
  border-top: 2px solid #e62242;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.captcha-error {
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.captcha-error::before {
  content: "⚠️";
  font-size: 16px;
}

.captcha-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px 24px;
  border-top: 1px solid #e5e7eb;
}

/* Mobile responsiveness */
@media (max-width: 640px) {
  .captcha-modal-overlay {
    padding: 16px;
  }
  
  .captcha-modal-content {
    max-height: 95vh;
  }
  
  .captcha-modal-header,
  .captcha-modal-body {
    padding: 20px 16px;
  }
  
  .captcha-modal-footer {
    padding: 16px;
    flex-direction: column-reverse;
  }
  
  .captcha-modal-footer .btn {
    width: 100%;
    justify-content: center;
  }
}

.privacy-link {
  color: var(--primary-red);
  text-decoration: underline;
  transition: color 0.3s ease;
}

.privacy-link:hover {
  color: #d91e3e;
}

/* hCaptcha Container */
.captcha-container {
  margin: 32px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.h-captcha {
  transform-origin: 0 0;
}

/* Mobile scaling for hCaptcha */
@media (max-width: 320px) {
  .h-captcha {
    transform: scale(0.85);
  }
}

/* Form Submit Section */
.form-submit {
  text-align: center;
  margin-top: 32px;
}

.contact-form-submit {
  min-width: 200px;
  margin-bottom: 16px;
}

.form-note {
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 16px;
  color: var(--text-gray);
  margin: 0;
}

/* Status Messages */
.status-message {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-radius: 8px;
  margin-top: 24px;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 14px;
  line-height: 20px;
  animation: slideDown 0.4s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.status-message.success {
  background-color: rgba(75, 170, 88, 0.1);
  color: var(--success-green);
  border: 1px solid var(--success-green);
}

.status-message.error {
  background-color: rgba(230, 34, 66, 0.1);
  color: var(--primary-red);
  border: 1px solid var(--primary-red);
}

.status-message svg {
  flex-shrink: 0;
}

/* Loading States */
.contact-form-submit[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Form Validation Enhancement */
.form-group.has-error .form-control {
  border-color: var(--primary-red);
  background-color: rgba(230, 34, 66, 0.05);
}

.form-group.has-success .form-control {
  border-color: var(--success-green);
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  .validation-message,
  .status-message,
  .form-control {
    animation: none;
    transition: none;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .form-control:focus {
    border-color: var(--dark-gray);
    box-shadow: 0 0 0 2px var(--dark-gray);
  }
  
  .validation-message {
    background-color: var(--white);
    padding: 4px 8px;
    border: 1px solid var(--primary-red);
  }
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
  .form-header {
    margin-bottom: 24px;
  }
  
  .form-title {
    font-size: 20px;
    line-height: 26px;
  }
  
  .form-subtitle {
    font-size: 14px;
    line-height: 20px;
  }
  
  .gdpr-section {
    padding: 16px;
    margin: 24px 0;
  }
  
  .form-submit {
    margin-top: 24px;
  }
  
  .contact-form-submit {
    width: 100%;
  }
}
