/**
 * PS Contact Form Block Styles - Figma Design Implementation
 *
 * Exact implementation of Figma design specifications with Inter font,
 * precise colors, dimensions, and spacing according to the design system.
 *
 * @package PS5_Theme
 * @since 1.0.0
 */

/* ==========================================================================
   Contact Form Container
   ========================================================================== */

.wp-block-ps5-theme-contact-form {
  max-width: 100%;
  margin: 0 auto;
}

.ps5-contact-form-container {
  width: 740px;
  max-width: 100%;
  margin: 0 auto;
  padding: 0;
  box-sizing: border-box;
}

.ps5-contact-form-title {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-style: normal;
  font-weight: 600;
  font-size: 24px;
  line-height: 29px;
  color: #111113;
  margin: 0 0 32px 0;
  text-align: center;
}

/* ==========================================================================
   Success/Error Messages - Exact Figma Implementation
   ========================================================================== */

.ps5-contact-form-success,
.ps5-contact-form-error {
  box-sizing: border-box;
  display: none;
  flex-direction: row;
  align-items: center;
  padding: 20px 16px;
  gap: 8px;
  width: 740px;
  height: 59px;
  border: 1px solid #ECECEC;
  border-radius: 8px;
  margin-bottom: 24px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-style: normal;
  font-weight: 500;
  font-size: 16px;
  line-height: 19px;
  text-align: center;
}

.ps5-contact-form-success {
  background: #F0FDEC;
  color: #1CCA13;
}

.ps5-contact-form-error {
  background: #FDF7EC;
  color: #E4A718;
}

.ps5-contact-form-success.show,
.ps5-contact-form-error.show {
  display: flex !important;
}

.ps5-success-icon,
.ps5-error-icon {
  width: 16px;
  height: 16px;
  flex: none;
  order: 0;
  flex-grow: 0;
}

.ps5-success-text,
.ps5-error-text {
  flex: none;
  order: 1;
  flex-grow: 0;
}

/* ==========================================================================
   Form Structure - Figma Layout
   ========================================================================== */

.ps5-contact-form {
  width: 740px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0;
  gap: 24px;
}

.ps5-form-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  padding: 0;
  gap: 24px;
  width: 740px;
  min-height: 75px;
}

/* Adjust height when fields have errors */
.ps5-form-row:has(.ps5-input-field.has-error) {
  min-height: 94px;
}

/* ==========================================================================
   Input Fields - Exact Figma Implementation
   ========================================================================== */

.ps5-input-field {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0;
  gap: 8px;
  width: 358px;
  height: 75px;
  flex: none;
  order: 0;
  flex-grow: 0;
}

.ps5-input-field-full {
  width: 740px;
  height: 123px;
  order: 3;
  align-self: stretch;
}

.ps5-field-label {
  width: 100%;
  height: 19px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-style: normal;
  font-weight: 400;
  font-size: 16px;
  line-height: 19px;
  color: #111113;
  flex: none;
  order: 0;
  align-self: stretch;
  flex-grow: 0;
  margin: 0;
  display: block;
  text-align: left;
}

.ps5-field-frame {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0;
  gap: 4px;
  width: 100%;
  height: 48px;
  flex: none;
  order: 1;
  align-self: stretch;
  flex-grow: 0;
}

.ps5-input-field-full .ps5-field-frame {
  height: 96px;
}

/* When there's an error, show the error message */
.ps5-input-field.has-error .ps5-field-frame {
  height: 67px;
}

.ps5-field-input,
.ps5-field-textarea {
  box-sizing: border-box;
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 10px 16px;
  gap: 8px;
  width: 100%;
  height: 48px;
  background: #F3F6F9;
  border: none;
  border-radius: 8px;
  flex: none;
  order: 0;
  align-self: stretch;
  flex-grow: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-style: normal;
  font-weight: 500;
  font-size: 16px;
  line-height: 19px;
  color: #111113;
  outline: none;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.ps5-field-input:focus,
.ps5-field-textarea:focus {
  border: 1px solid #036666;
  box-shadow: 0 0 0 2px rgba(3, 102, 102, 0.1);
}

.ps5-field-textarea {
  height: 96px;
  align-items: flex-start;
  resize: none;
  overflow-y: auto;
}

.ps5-field-input::placeholder,
.ps5-field-textarea::placeholder {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-style: normal;
  font-weight: 500;
  font-size: 16px;
  line-height: 19px;
  color: #4F4F55;
  flex: none;
  order: 0;
  flex-grow: 1;
}

/* Error states - Red border as per Figma */
.ps5-field-input.error,
.ps5-field-textarea.error {
  border: 1px solid #FF0000;
}

.ps5-field-error {
  width: 100%;
  height: 15px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-style: normal;
  font-weight: 400;
  font-size: 12px;
  line-height: 15px;
  color: #FF0000;
  flex: none;
  order: 1;
  align-self: stretch;
  flex-grow: 0;
  margin: 0;
  display: none;
  text-align: left;
}

.ps5-field-error.show {
  display: block !important;
}

/* Error state adjustment for field height */
.ps5-input-field.has-error {
  height: 94px;
}

.ps5-input-field.has-error .ps5-field-frame {
  height: 67px;
}

/* ==========================================================================
   Submit Button - Exact Figma Implementation
   ========================================================================== */

.ps5-form-submit {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  gap: 10px;
  width: 100%;
  height: 48px;
  border-radius: 8px;
  flex: none;
  order: 4;
  flex-grow: 0;
  margin-top: 16px;
}

.ps5-submit-button {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  padding: 8px 16px;
  gap: 4px;
  width: 175px;
  height: 48px;
  background: #59AC36;
  border-radius: 32px;
  border: none;
  cursor: pointer;
  flex: none;
  order: 0;
  flex-grow: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-style: normal;
  font-weight: 600;
  font-size: 20px;
  line-height: 24px;
  color: #FFFFFF;
  transition: all 0.2s ease;
}

.ps5-submit-button:hover {
  background: #59AC36;
  transform: translateY(-1px);
}

.ps5-submit-button:active {
  transform: translateY(0);
}

.ps5-submit-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.ps5-contact-form-container.loading .ps5-submit-button {
  color: transparent;
  position: relative;
}

.ps5-contact-form-container.loading .ps5-submit-button::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid transparent;
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* ==========================================================================
   Responsive Design - Mobile Adjustments
   ========================================================================== */

@media (max-width: 768px) {
  .ps5-contact-form-container,
  .ps5-contact-form,
  .ps5-form-row,
  .ps5-contact-form-success,
  .ps5-contact-form-error {
    width: 100%;
    max-width: 100%;
  }
  
  .ps5-form-row {
    flex-direction: column;
    min-height: auto;
    gap: 16px;
  }
  
  .ps5-input-field,
  .ps5-input-field-full {
    width: 100%;
  }
  
  .ps5-submit-button {
    width: 100%;
    max-width: 300px;
  }
  
  .ps5-contact-form {
    padding: 0 16px;
  }
  
  .ps5-contact-form-container {
    padding: 0 16px;
  }
}

/* ==========================================================================
   Block Editor Specific Styles
   ========================================================================== */

.wp-block-ps5-theme-contact-form .block-editor-inner-blocks,
.wp-block-ps5-theme-contact-form .block-editor-block-list__layout {
  margin: 0;
}

/* Editor preview styling */
.editor-styles-wrapper .ps5-contact-form-container {
  margin: 1rem 0;
}

.editor-styles-wrapper .ps5-field-input,
.editor-styles-wrapper .ps5-field-textarea {
  border: 1px dashed #ccc;
}

.editor-styles-wrapper .ps5-submit-button {
  pointer-events: none;
}