/**
 * Nexus Forms - Frontend Styles
 *
 * @package NexusForms
 * All classes prefixed with .nxf- to avoid conflicts
 */

/* CSS Custom Properties */
:root {
    --nxf-primary-color: #667eea;
    --nxf-primary-hover: #5a6fd6;
    --nxf-primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --nxf-success-color: #27ae60;
    --nxf-error-color: #e74c3c;
    --nxf-border-color: #ddd;
    --nxf-border-radius: 6px;
    --nxf-input-padding: 12px 14px;
    --nxf-input-font-size: 15px;
    --nxf-transition: all 0.2s ease;
}

/* Form Container */
.nxf-form {
    max-width: 100%;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.nxf-form-fields {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Field Wrapper */
.nxf-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Field Label */
.nxf-field-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 2px;
}

.nxf-required-indicator {
    color: var(--nxf-error-color);
    font-weight: bold;
}

/* Input Fields */
.nxf-input {
    width: 100%;
    padding: var(--nxf-input-padding);
    font-size: var(--nxf-input-font-size);
    border: 2px solid var(--nxf-border-color);
    border-radius: var(--nxf-border-radius);
    background-color: #fff;
    transition: var(--nxf-transition);
    outline: none;
    box-sizing: border-box;
}

.nxf-input:focus {
    border-color: var(--nxf-primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.nxf-input::placeholder {
    color: #999;
}

/* Input States */
.nxf-input:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

.nxf-field.nxf-field-error .nxf-input {
    border-color: var(--nxf-error-color);
}

.nxf-field.nxf-field-error .nxf-input:focus {
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.15);
}

/* Field Error Message */
.nxf-field-error[role="alert"] {
    font-size: 13px;
    color: var(--nxf-error-color);
    min-height: 20px;
    display: none;
}

.nxf-field.nxf-field-error .nxf-field-error[role="alert"] {
    display: block;
}

/* Phone Input - intl-tel-input overrides */
.nxf-field-phone .iti {
    width: 100%;
}

.nxf-field-phone .iti__flag-container {
    padding: 1px;
}

.nxf-field-phone .iti__selected-flag {
    padding: 0 10px 0 14px;
    background: #f8f8f8;
    border-right: 1px solid var(--nxf-border-color);
    border-radius: var(--nxf-border-radius) 0 0 var(--nxf-border-radius);
}

.nxf-field-phone .iti--separate-dial-code .iti__selected-flag {
    background: #f8f8f8;
}

.nxf-field-phone .nxf-phone-input {
    padding-left: 100px;
}

/* Submit Button Wrapper */
.nxf-submit-wrapper {
    margin-top: 8px;
}

.nxf-submit-full-width {
    width: 100%;
}

.nxf-submit-full-width .nxf-submit-button {
    width: 100%;
}

/* Submit Button */
.nxf-submit-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--nxf-primary-gradient);
    color: #fff;
    border: none;
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    border-radius: var(--nxf-border-radius);
    cursor: pointer;
    transition: var(--nxf-transition);
    position: relative;
    overflow: hidden;
}

.nxf-submit-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.nxf-submit-button:active:not(:disabled) {
    transform: translateY(0);
}

.nxf-submit-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Button Loading State */
.nxf-submit-button.nxf-loading .nxf-button-text {
    opacity: 0;
}

.nxf-submit-button .nxf-button-spinner {
    display: none;
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: nxf-spin 0.8s linear infinite;
}

.nxf-submit-button.nxf-loading .nxf-button-spinner {
    display: block;
}

@keyframes nxf-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Form Message */
.nxf-form-message {
    margin-top: 20px;
    padding: 16px;
    border-radius: var(--nxf-border-radius);
    font-size: 14px;
    text-align: center;
    display: none;
}

.nxf-form-message.nxf-message-success {
    display: block;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.nxf-form-message.nxf-message-error {
    display: block;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* RTL Support */
[dir="rtl"] .nxf-field-phone .iti__selected-flag {
    border-right: none;
    border-left: 1px solid var(--nxf-border-color);
    border-radius: 0 var(--nxf-border-radius) var(--nxf-border-radius) 0;
}

[dir="rtl"] .nxf-field-phone .nxf-phone-input {
    padding-left: 14px;
    padding-right: 100px;
}

/* Responsive */
@media (max-width: 480px) {
    .nxf-submit-button {
        width: 100%;
        padding: 14px 20px;
    }

    .nxf-input {
        font-size: 16px;
        /* Prevent zoom on iOS */
    }
}

/* Textarea Field */
.nxf-textarea {
    resize: vertical;
    min-height: 100px;
}

/* Select Field */
.nxf-select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
    cursor: pointer;
}

[dir="rtl"] .nxf-select {
    background-position: left 12px center;
    padding-right: var(--nxf-input-padding);
    padding-left: 40px;
}

/* Checkbox & Radio Groups */
.nxf-checkbox-group,
.nxf-radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 5px;
}

.nxf-field-inline .nxf-checkbox-group,
.nxf-field-inline .nxf-radio-group {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 15px;
}

.nxf-checkbox-item,
.nxf-radio-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.nxf-checkbox,
.nxf-radio {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--nxf-primary-color);
}

.nxf-checkbox-label,
.nxf-radio-label {
    font-size: 14px;
    color: #333;
}