/* Frontend CSS for Advanced Form Builder */

.afb-form-container {
    max-width: 100%;
    margin: 30px 0;
}

.afb-form {
    background: #ffffff;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* Field Wrapper */
.afb-field-wrapper {
    margin-bottom: 28px;
}

.afb-field-wrapper.afb-hidden {
    display: none;
}

.afb-field-label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 15px;
    line-height: 1.4;
}

.afb-required {
    color: #e74c3c;
    margin-left: 3px;
    font-weight: 700;
}

.afb-field-description {
    margin: 8px 0 0;
    font-size: 13px;
    color: #7f8c8d;
    line-height: 1.5;
}

/* Input Fields */
.afb-input,
.afb-form select,
.afb-form textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.2s ease;
    background: #fafafa;
}

.afb-input:focus,
.afb-form select:focus,
.afb-form textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    background: #ffffff;
}

/* Date Picker - Flatpickr (Modern) */
.afb-form input[type="date"] {
    padding: 14px 16px;
    font-size: 15px;
    cursor: pointer;
    min-height: 48px;
    background-color: white;
}

.afb-form input[type="date"]::-webkit-calendar-picker-indicator {
    display: none !important; /* Hide native picker icon since we use Flatpickr */
}

/* Flatpickr custom styling to match form design */
.flatpickr-calendar {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    border-radius: 8px !important;
    border: none !important;
    font-family: inherit !important;
}

.flatpickr-day.selected,
.flatpickr-day.selected:hover {
    background: #3498db !important;
    border-color: #3498db !important;
    color: white !important;
}

.flatpickr-day.today {
    border-color: #3498db !important;
    color: #3498db !important;
}

.flatpickr-day:hover {
    background: #ecf0f1 !important;
    border-color: #ecf0f1 !important;
}

.flatpickr-months .flatpickr-month {
    background: #3498db !important;
    color: white !important;
}

.flatpickr-current-month .flatpickr-monthDropdown-months {
    background: #3498db !important;
    color: white !important;
}

.flatpickr-current-month input.cur-year {
    color: white !important;
}

.flatpickr-weekdays {
    background: #f8f9fa !important;
}

.flatpickr-weekday {
    color: #7f8c8d !important;
}

/* NUCLEAR OPTION - Completely obliterate jQuery UI datepicker */
#ui-datepicker-div,
.ui-datepicker,
.ui-datepicker-inline,
.ui-datepicker-header,
.ui-datepicker-calendar,
div#ui-datepicker-div,
.hasDatepicker + .ui-datepicker-trigger,
.ui-datepicker-trigger {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 0 !important;
    height: 0 !important;
    z-index: -1 !important;
}

/* Make sure our date inputs don't get jQuery UI styling */
.afb-form input[type="date"].hasDatepicker {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    left: 0 !important;
    top: 0 !important;
}

/* Ensure Flatpickr calendar is always on top */
.flatpickr-calendar.open {
    z-index: 99999 !important;
}

/* Select Dropdown */
.afb-form select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.afb-form input[type="file"] {
    padding: 12px;
    background: #ffffff;
}

/* Radio and Checkbox */
.afb-radio-group,
.afb-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.afb-radio-label,
.afb-checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.afb-radio-label:hover,
.afb-checkbox-label:hover {
    background: #f8f9fa;
    border-color: #e9ecef;
}

.afb-radio-label input,
.afb-checkbox-label input {
    margin-right: 12px;
    cursor: pointer;
    width: 18px;
    height: 18px;
}

/* File Upload */
.afb-file-note {
    margin: 5px 0 0;
    font-size: 12px;
    color: #666;
}

/* Submit Button */
.afb-form-submit {
    margin-top: 30px;
    text-align: left;
}

.afb-submit-button {
    padding: 16px 40px;
    background: #3498db;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.2);
    min-width: 150px;
}

.afb-submit-button:hover {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

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

.afb-submit-button:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loading */
.afb-loading {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-left: 15px;
    color: #666;
}

.afb-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #2271b1;
    border-radius: 50%;
    animation: afb-spin 0.8s linear infinite;
}

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

/* Messages */
.afb-form-message {
    margin-top: 20px;
    padding: 15px;
    border-radius: 4px;
    font-size: 14px;
}

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

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

/* Field Errors */
.afb-field-error {
    margin-top: 5px;
    color: #dc3232;
    font-size: 13px;
}

.afb-field-wrapper.has-error .afb-input,
.afb-field-wrapper.has-error select,
.afb-field-wrapper.has-error textarea {
    border-color: #dc3232;
}

/* reCAPTCHA */
.afb-recaptcha-container {
    margin: 20px 0;
}

/* Error State */
.afb-error {
    padding: 15px;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
}

/* Responsive */
@media (max-width: 768px) {
    .afb-form {
        padding: 20px;
    }
    
    .afb-submit-button {
        width: 100%;
    }
    
    .afb-loading {
        display: block;
        margin: 10px 0 0;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .afb-form {
        background: #1a1a1a;
        color: #e0e0e0;
    }
    
    .afb-field-label {
        color: #e0e0e0;
    }
    
    .afb-input,
    .afb-form select,
    .afb-form textarea {
        background: #2a2a2a;
        border-color: #444;
        color: #e0e0e0;
    }
    
    .afb-input:focus,
    .afb-form select:focus,
    .afb-form textarea:focus {
        border-color: #4a9eff;
    }
}

/* Field Width Layouts */
.afb-form-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.afb-field-wrapper {
    box-sizing: border-box;
}

.afb-field-width-full {
    width: 100%;
    flex: 0 0 100%;
}

.afb-field-width-half {
    width: calc(50% - 10px);
    flex: 0 0 calc(50% - 10px);
}

/* Responsive - stack on mobile */
@media (max-width: 768px) {
    .afb-field-width-half {
        width: 100%;
        flex: 0 0 100%;
    }
}
