/**
 * Custom Form Builder - Frontend Styles
 */

.cfb-form-wrapper {
    box-sizing: border-box;
    max-width: 640px;
    margin: 25px auto;
    font-family: inherit;
}

.cfb-form-wrapper *,
.cfb-form-wrapper *::before,
.cfb-form-wrapper *::after {
    box-sizing: inherit;
}

/* Field Groups */
.cfb-field-group {
    margin-bottom: 20px;
    position: relative;
}

.cfb-field-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 15px;
    color: #2c3338;
}

.cfb-required-star {
    color: #dc3545;
    font-weight: bold;
    margin-left: 2px;
}

/* Form Inputs */
.cfb-input {
    display: block;
    width: 100%;
    padding: 10px 14px;
    font-size: 15px;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    background-clip: padding-box;
    border: 1.5px solid #ced4da;
    border-radius: 5px;
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

.cfb-input:focus {
    color: #495057;
    background-color: #fff;
    border-color: #0073aa;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 115, 170, 0.18);
}

.cfb-textarea {
    resize: vertical;
    min-height: 110px;
}

.cfb-select {
    height: 44px;
}

/* Checkboxes & Radios */
.cfb-checkbox-item,
.cfb-radio-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    cursor: pointer;
}

.cfb-checkbox,
.cfb-radio {
    margin-right: 8px !important;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.cfb-checkbox-label {
    font-weight: 500;
    font-size: 15px;
    cursor: pointer;
}

/* Error States */
.cfb-has-error .cfb-input {
    border-color: #dc3545 !important;
    background-color: #fffafa !important;
}

.cfb-has-error .cfb-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.2) !important;
}

.cfb-field-error {
    position: absolute;
    color: #dc3545;
    font-size: 13.5px;
    margin-top: 6px;
    font-weight: 500;
    line-height: 1.3;
    animation: cfbFadeIn 0.25s ease-in-out;
}

/* Alert Notification Boxes */
.cfb-alert-box {
    padding: 14px 18px;
    margin-top: 20px;
    margin-bottom: 10px;
    border-radius: 6px;
    font-size: 15px;
    line-height: 1.4;
    animation: cfbFadeIn 0.3s ease-in-out;
}

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

.cfb-alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Submit Button & Outside Loading Spinner */
.cfb-submit-wrapper {
    margin-top: 25px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.cfb-submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 28px;
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    background-color: #0073aa;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color .2s ease-in-out, transform .1s ease;
}

.cfb-submit-btn:hover {
    background-color: #005a87;
}

.cfb-submit-btn:active {
    transform: scale(0.99);
}

.cfb-submit-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    background-color: #6c757d;
}

/* Loading Spinner - positioned outside the button */
.cfb-spinner {
    display: inline-block;
    width: 22px;
    height: 22px;
    border: 3px solid #dcdcde;
    border-radius: 50%;
    border-top-color: #0073aa;
    animation: cfbSpin 0.75s infinite linear;
    flex-shrink: 0;
}

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

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

/* Honeypot Spam Trap (Hidden from visitors & browser autofill) */
.cfb-hp-field {
    display: none !important;
    visibility: hidden !important;
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 0 !important;
    height: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* International Telephone Input (Country Flag & Code Dropdown) */
.iti {
    width: 100%;
    display: block;
}

.iti input.cfb-input.cfb-tel {
    width: 100%;
}

.iti--separate-dial-code .iti__selected-flag {
    background-color: #f8f9fa;
    border-right: 1.5px solid #ced4da;
    border-radius: 5px 0 0 5px;
    padding: 0 10px 0 12px;
}

.iti__country-list {
    z-index: 9999;
    max-height: 230px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
    border-radius: 5px;
    border: 1px solid #ced4da;
    font-size: 14px;
    font-family: inherit;
}

.iti__country {
    padding: 8px 12px;
}

.iti__country:hover,
.iti__country.iti__highlight {
    background-color: #f0f6fc;
}

.iti__dial-code {
    color: #6c757d;
}

/* Bulletproof Flag Sprite Rules (Protects against theme background-size: cover/contain resets) */
.cfb-form-wrapper .iti__flag,
.iti__flag {
    display: inline-block !important;
    height: 15px !important;
    box-shadow: 0 0 1px 0 rgba(0, 0, 0, 0.4) !important;
    background-repeat: no-repeat !important;
    background-color: transparent !important;
    background-size: 5652px 15px !important;
    box-sizing: content-box !important;
    max-width: none !important;
    max-height: 15px !important;
    vertical-align: middle !important;
}

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .cfb-form-wrapper .iti__flag,
    .iti__flag {
        background-size: 5652px 15px !important;
    }
}
