/**
 * Contact Form Spacing & Positioning Optimization
 * Fixes spacing hierarchy, alignment, and visual balance
 */

/* =============================================================================
   Form Container - Proper Centering & Spacing
   ============================================================================= */

.contact-form-container {
    max-width: 800px;
    margin: 3rem auto 0;
    background: #ffffff;
    border-radius: 12px;
    padding: 2.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid #e0e0e0;
}

/* =============================================================================
   Form Structure - Consistent Spacing Hierarchy
   ============================================================================= */

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 2.5rem; /* Space between major sections */
}

/* Form Sections - Visual Grouping */
.form-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem; /* Space between section title and content */
    padding-bottom: 2rem;
    border-bottom: 1px solid #f0f0f0;
}

.form-section:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}

/* Section Titles - Clear Hierarchy */
.form-section-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #f8f9fa;
}

/* =============================================================================
   Form Rows & Groups - Optimal Spacing
   ============================================================================= */

/* Form Rows - Grid Layout */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem; /* Horizontal gap between columns */
    margin-bottom: 0; /* Remove extra margin */
}

/* Single Column Rows */
.form-row:has(> .form-group:only-child) {
    grid-template-columns: 1fr;
}

/* Form Groups - Field Containers */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem; /* Space between label and input */
    margin-bottom: 0; /* Controlled by form-row gap */
}

/* Last form-group in a section should not have bottom margin */
.form-section > .form-group:last-child {
    margin-bottom: 0;
}

/* =============================================================================
   Form Labels - Proper Positioning
   ============================================================================= */

.form-label {
    font-weight: 600;
    color: #1a1a1a;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0;
}

.form-label .required {
    color: #dc2626;
    font-size: 1rem;
    line-height: 1;
}

/* =============================================================================
   Form Inputs - Consistent Sizing & Spacing
   ============================================================================= */

.form-input,
.form-select,
.form-textarea {
    padding: 0.75rem 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #ffffff;
    width: 100%;
    box-sizing: border-box;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: #1a1a1a;
    box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 150px;
    line-height: 1.6;
}

/* =============================================================================
   Form Errors - Proper Spacing
   ============================================================================= */

.form-error {
    color: #dc2626;
    font-size: 0.875rem;
    font-weight: 500;
    display: none;
    margin-top: 0.375rem;
    line-height: 1.4;
}

.form-error.show {
    display: block;
}

/* Character Counter - Aligned */
.form-character-count {
    text-align: right;
    font-size: 0.8125rem;
    color: #666666;
    margin-top: 0.375rem;
    line-height: 1;
}

/* =============================================================================
   Form Actions - Button Positioning
   ============================================================================= */

.form-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding-top: 2rem;
    border-top: 1px solid #f0f0f0;
    margin-top: 0.5rem;
}

.form-actions button[type="submit"] {
    min-width: 200px;
}

/* Form Note - Centered & Spaced */
.form-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #666666;
    text-align: center;
    line-height: 1.5;
}

.form-note svg {
    flex-shrink: 0;
    color: #0066cc;
}

/* =============================================================================
   Form Messages - Proper Spacing
   ============================================================================= */

.form-messages {
    margin-top: 1.5rem;
}

.form-message {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 8px;
    font-weight: 500;
    margin-bottom: 1rem;
}

.form-message svg {
    flex-shrink: 0;
    margin-top: 2px;
}

.form-message-success {
    background: rgba(34, 197, 94, 0.1);
    color: #059669;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.form-message-error {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* =============================================================================
   Mobile Responsive Spacing
   ============================================================================= */

@media (max-width: 768px) {
    .contact-form-container {
        padding: 2rem;
        margin-top: 2rem;
    }

    .contact-form {
        gap: 2rem;
    }

    .form-section {
        gap: 1.25rem;
        padding-bottom: 1.5rem;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .form-section-title {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .contact-form-container {
        padding: 1.5rem;
        margin-top: 1.5rem;
        border-radius: 8px;
    }

    .contact-form {
        gap: 1.5rem;
    }

    .form-section {
        gap: 1rem;
        padding-bottom: 1.25rem;
    }

    .form-row {
        gap: 1rem;
    }

    .form-group {
        gap: 0.375rem;
    }

    .form-input,
    .form-select,
    .form-textarea {
        padding: 0.625rem 0.875rem;
        font-size: 16px; /* Prevents iOS zoom */
    }

    .form-actions {
        padding-top: 1.5rem;
    }

    .form-actions button[type="submit"] {
        width: 100%;
        min-width: auto;
    }
}

@media (max-width: 360px) {
    .contact-form-container {
        padding: 1.25rem;
        margin-top: 1rem;
    }

    .contact-form {
        gap: 1.25rem;
    }

    .form-section {
        gap: 0.875rem;
        padding-bottom: 1rem;
    }

    .form-row {
        gap: 0.875rem;
    }
}

/* =============================================================================
   Accessibility & UX Improvements
   ============================================================================= */

/* Focus visible for keyboard navigation */
.form-input:focus-visible,
.form-select:focus-visible,
.form-textarea:focus-visible {
    outline: 2px solid #1a1a1a;
    outline-offset: 2px;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .form-input,
    .form-select,
    .form-textarea,
    .form-error {
        transition: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .form-input,
    .form-select,
    .form-textarea {
        border-width: 2px;
    }

    .form-section {
        border-bottom-width: 2px;
    }
}
