/**
 * Frontend styles for SPAI Contact Form
 */

/* Form Container */
.spai-form-container {
    max-width: 100%;
    margin: 0 auto;
}

.spai-form {
    padding: 20px;
    border-radius: 5px;
}

/* Form Groups */
.spai-form-group {
    margin-bottom: 1em;
}

.spai-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.spai-form-group .required {
    color: #d63638;
}

/* Form Controls */
.spai-form-group input[type="text"],
.spai-form-group input[type="email"],
.spai-form-group input[type="tel"],
.spai-form-group input[type="number"],
.spai-form-group input[type="date"],
.spai-form-group select,
.spai-form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 16px;
    transition: border-color 0.3s;
    box-sizing: border-box;
}

.spai-form-group input:focus,
.spai-form-group select:focus,
.spai-form-group textarea:focus {
    outline: none;
    border-color: #2271b1;
}

/* Textarea */
.spai-form-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* Select */
.spai-form-group select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 35px;
}

/* Select wrapper for custom arrow */
.spai-select-wrapper {
    position: relative;
    width: 100%;
}

.spai-select-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #646970;
    pointer-events: none;
    transition: transform 0.2s ease, color 0.2s ease;
}

.spai-select-wrapper:focus-within .spai-select-arrow {
    color: #0073aa;
}

/* Radio and Checkbox */
.spai-form-group input[type="radio"],
.spai-form-group input[type="checkbox"] {
    margin-right: 5px;
}

.spai-form-group .radio-group,
.spai-form-group .checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.spai-form-group .radio-group.inline,
.spai-form-group .checkbox-group.inline {
    flex-direction: row;
    flex-wrap: wrap;
}

/* File Upload */
.spai-file-upload {
    position: relative;
    border: 2px dashed #ddd;
    border-radius: 5px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.spai-file-upload:hover {
    border-color: #2271b1;
    background: #f0f8ff;
}

.spai-file-upload.dragover {
    border-color: #2271b1;
    background: #e6f3ff;
}

.spai-file-list {
    margin-top: 10px;
    text-align: left;
}

.spai-file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid #eee;
}

.spai-file-remove {
    color: #d63638;
    cursor: pointer;
}

/* Help Text */
.spai-help-text {
    font-size: 14px;
    color: #666;
    margin-top: 5px;
}

/* Error Messages */
.spai-error {
    color: #d63638;
    font-size: 14px;
    margin-top: 5px;
}

/* Submit Button */
.spai-form-submit {
    margin-top: 2em;
}

.spai-submit-button {
    background-color: transparent;
    color: black;
    border: 1px solid black;
    padding: 12px 30px;
    font-size:135%;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s;
    text-transform: uppercase;

}

.spai-submit-button:hover {
    background-color: rgba(0, 0, 0, 0.25);
    color: white;
}

.spai-submit-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Delicate Spinner */
.spai-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 1px solid rgba(0, 0, 0, 0.3);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spai-spin 1s linear infinite;
    margin-left: 10px;
}

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




/* Success/Error Messages */
.spai-message {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 3px;
}

.spai-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.spai-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Responsive */
@media (max-width: 768px) {
    .spai-form {
        padding: 15px;
    }
    
    .spai-form-group {
        margin-bottom: 15px;
    }
}
/* Section Headers */
.spai-form-section {
    margin: 30px 0 20px 0;
    padding: 20px 0 10px 0;
    border-top: 2px solid #e0e0e0;
}

.spai-form-section:first-child {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}

.spai-form-section h3 {
    margin: 0 0 10px 0;
    font-size: 1.3em;
    font-weight: 600;
    color: #333;
}

.spai-form-section p {
    margin: 0;
    color: #666;
    font-size: 0.95em;
}

/* Admin form builder - section header styling */
.spai-field-item[data-field-type="section"] .spai-field-header {
    background-color: #f5f5f5;
    border-left: 4px solid #0073aa;
}

.spai-field-item[data-field-type="section"] .spai-field-label {
    font-weight: 600;
}

/* Consent checkbox styling */
.spai-form-field.consent-checkbox label {
    padding-top: 1em;
    font-size: 0.85em;
    display: flex;
    align-items: flex-start;
    color: gray;
    font-weight: 300;
}ąąą

.spai-form-field.consent-checkbox input[type="checkbox"] {
    margin-right: 8px;
    margin-top: 2px;
    accent-color: grey;
}

/* Multichoice field styling - using WordPress inheritance */
.spai-multichoice-container {
    position: relative;
    width: 100%;
    height: auto; /* Allow container to expand */
}

.spai-multichoice-input-wrapper {
    position: relative;
    height: auto; /* Allow wrapper to expand */
}

.spai-multichoice-input-area {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start; /* Keep at flex-start */
    min-height: 44px;
    height: auto; /* Allow height to grow */
    padding: 6px 35px 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    cursor: text;
    transition: border-color 0.3s;
    gap: 6px;
    position: relative;
    box-sizing: border-box;
    width: 100%;
    overflow: hidden; /* Hide overflow but allow height expansion */
}

.spai-multichoice-input-area:focus-within {
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
}

.spai-multichoice-selected-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: flex-start;
    flex: 1 1 auto; /* Allow to grow and shrink */
    width: 100%; /* Take full width to force wrapping */
}

/* Multichoice input specific override - must be after general input rules */
.spai-multichoice-container .spai-multichoice-input {
    border: none !important;
    outline: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    flex: 1;
    min-width: 120px;
    font-family: inherit;
    font-size: 16px !important;
    line-height: 20px !important; /* Match tag height */
    height: 20px !important; /* Override the 40px rule */
    vertical-align: top !important;
    box-sizing: content-box !important; /* Prevent padding from affecting height */
}

.spai-multichoice-input {
    /* Remove all borders and outlines - fixes Theme Co Pro theme interference */
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
}

.spai-multichoice-input:focus {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    height: 20px !important; /* Maintain height on focus */
}

.spai-multichoice-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #646970;
    pointer-events: none;
    transition: transform 0.2s ease, color 0.2s ease;
}

.spai-multichoice-input-area:focus-within .spai-multichoice-arrow {
    color: #0073aa;
}

.spai-multichoice-container.dropdown-open .spai-multichoice-arrow {
    transform: translateY(-50%) rotate(180deg);
}

.spai-multichoice-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.spai-multichoice-option {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f1;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    font-size: 0.75em;
}

.spai-multichoice-option:hover {
    background-color: #f6f7f7;
}

.spai-multichoice-option:last-child {
    border-bottom: none;
}

.spai-multichoice-tag {
    display: inline-flex;
    align-items: center;
    background-color: #f0f6fc;
    color: #0073aa;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #c3dbf0;
    white-space: nowrap;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.4;
    font-size: 0.75em;

}

.spai-multichoice-remove {
    margin-left: 6px;
    cursor: pointer;
    font-weight: bold;
    color: #787c82;
    font-size: 18px;
    line-height: 1;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
}

.spai-multichoice-remove:hover {
    color: #d63638;
    background-color: rgba(214, 54, 56, 0.1);
}


/* Two Column Layout for Large Screens */
@media (min-width: 768px) {
    .spai-form {
        display: grid;
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .spai-form-group.spai-half-width {
        grid-column: span 1;
    }
    
    /* Create two column grid on large screens */
    @media (min-width: 1024px) {
        .spai-form {
            grid-template-columns: 1fr 1fr;
        }
        
        /* Add right padding to half-width fields */
        .spai-form-group.spai-half-width {
            padding-right: 1em;
        }
        
        /* Full width fields should span both columns */
        .spai-form-group:not(.spai-half-width),
        .spai-form-section {
            grid-column: span 2;
        }
        
        /* Submit button always full width */
        .spai-form-submit {
            grid-column: span 2;
        }
    }
}

/* Ensure intl-tel-input takes full width */
.spai-form-group .iti {
    width: 100%;
    display: block;
}

.spai-form-group .iti input[type="tel"] {
    width: 100%;
    box-sizing: border-box;
}

/* Force phone input to match other input heights */
.spai-form-group .iti {
    height: 40px;
}

.spai-form-group .iti__tel-input,
.spai-form-group .iti input[type="tel"] {
    height: 40px !important;
    font-size: 16px !important;
    line-height: 18px !important;
    box-sizing: border-box !important;
    padding-top: 10px !important;
    padding-bottom: 10px !important;
    padding-right: 10px !important;
    /* padding-left will be set dynamically by JavaScript */
}

/* Adjust the flag/dial code container to fit the new height */
.spai-form-group .iti__selected-country {
    height: 38px; /* 40px - 2px for borders */
    padding: 0 10px;
    display: flex;
    align-items: center;
}

/* Ensure the arrow aligns properly */
.spai-form-group .iti__arrow {
    margin-top: 0;
}

/* Ensure all fields have consistent 40px height */
.spai-form-group input[type="text"],
.spai-form-group input[type="email"],
.spai-form-group input[type="tel"],
.spai-form-group input[type="number"],
.spai-form-group input[type="date"],
.spai-form-group select {
    height: 40px !important;
    line-height: 18px;
}

/* Fix multichoice to allow flexible height */
.spai-multichoice-input-area {
    min-height: 40px !important;
    height: auto !important; /* Allow height to expand with content */
    /* Remove fixed height to allow tags to wrap properly */
    padding: 10px 35px 10px 10px !important; /* Equal padding top/bottom */
}

/* Adjust multichoice tags to fit properly */
.spai-multichoice-tag {
    padding: 2px 6px !important;
    font-size: 14px !important;
    line-height: 1.2 !important;
    margin: 2px 0 !important; /* Add vertical margin for proper spacing */
}


/* Override 40px height for multichoice input specifically */
.spai-form-group .spai-multichoice-container .spai-multichoice-input {
    height: 20px !important;
    line-height: 20px !important;
}


/* Full width message styling */
.spai-message.spai-full-width {
    grid-column: 1 / -1; /* Span all columns */
    width: 100%;
}

/* Ensure submit button is also full width */
.spai-form-submit.spai-full-width {
    grid-column: 1 / -1; /* Span all columns */
}
/* Honeypot field - ensure it's hidden */
.spai-form div[aria-hidden="true"] {
    position: absolute !important;
    left: -5000px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
}

/* Additional protection for honeypot */
.spai-form input[name="spai_website"] {
    opacity: 0 !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    height: 0 !important;
    width: 0 !important;
    z-index: -1 !important;
}
