/**
 * Frontend CSS for Custom Form Builder with File Upload Support
 */

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

.cfb-form {
    background: #ffffff;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
}

/* Form Title */
.cfb-form-title {
    margin: 0 0 20px 0;
    font-size: 24px;
    font-weight: 600;
    color: #333;
}

/* Form Fields */
.cfb-form-fields {
    margin-bottom: 20px;
}

.cfb-field-wrapper {
    margin-bottom: 20px;
    position: relative;
}

.cfb-field-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.cfb-required {
    color: #dc3545;
    margin-left: 3px;
}

.cfb-field-input {
    position: relative;
}

/* Input Styles */
.cfb-input,
.cfb-textarea,
.cfb-select,
.cfb-file {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    line-height: 1.5;
    background-color: #ffffff;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
}

.cfb-input:focus,
.cfb-textarea:focus,
.cfb-select:focus,
.cfb-file:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
}

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

.cfb-select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
    appearance: none;
}

/* Enhanced File Upload Styling */
.cfb-file {
    padding: 20px 15px;
    cursor: pointer;
    border: 2px dashed #ddd;
    text-align: center;
    background: #fafafa;
    position: relative;
    transition: all 0.3s ease;
}

.cfb-file:hover {
    border-color: #007cba;
    background: #f0f8ff;
}

.cfb-file:focus {
    border-color: #007cba;
    background: #f0f8ff;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

/* File drag and drop styling */
.cfb-field-wrapper.cfb-drag-over .cfb-file {
    border-color: #007cba !important;
    background: #e3f2fd !important;
    transform: scale(1.02);
}

/* File confirmation message */
.cfb-file-confirm {
    margin-top: 8px;
    padding: 8px 12px;
    background: #e8f5e8;
    border: 1px solid #4caf50;
    border-radius: 4px;
    font-size: 12px;
    color: #2e7d32;
    display: none;
}

.cfb-file-confirm::before {
    content: "✓ ";
    font-weight: bold;
    color: #4caf50;
}

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

.cfb-radio-label,
.cfb-checkbox-label {
    display: flex;
    align-items: center;
    font-weight: normal;
    cursor: pointer;
    margin-bottom: 0;
}

.cfb-radio,
.cfb-checkbox {
    margin-right: 10px;
    width: auto;
    cursor: pointer;
}

.cfb-radio-label:hover,
.cfb-checkbox-label:hover {
    color: #007cba;
}

/* Hidden Fields */
.cfb-hidden {
    display: none;
}

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

.cfb-submit-btn {
    background-color: #007cba;
    color: #ffffff;
    border: none;
    padding: 15px 30px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.cfb-submit-btn:hover {
    background-color: #005a87;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 124, 186, 0.2);
}

.cfb-submit-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loading Indicator */
.cfb-loading {
    display: inline-block;
    margin-left: 10px;
    color: #666;
    font-style: italic;
}

.cfb-loading:after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ccc;
    border-top-color: #007cba;
    border-radius: 50%;
    animation: cfb-spin 1s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

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

/* Messages */
.cfb-form-messages {
    margin-top: 20px;
}

.cfb-success-message {
    background-color: #d4edda;
    color: #155724;
    padding: 12px 15px;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    margin-bottom: 15px;
}

.cfb-error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: 12px 15px;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin-bottom: 15px;
}

/* Field Errors */
.cfb-field-error {
    color: #dc3545;
    font-size: 14px;
    margin-top: 5px;
    padding: 8px 12px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    display: none;
}

.cfb-field-has-error .cfb-input,
.cfb-field-has-error .cfb-textarea,
.cfb-field-has-error .cfb-select,
.cfb-field-has-error .cfb-file {
    border-color: #dc3545;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.1);
}

.cfb-field-has-error .cfb-field-label {
    color: #dc3545;
}

/* File Upload Error States */
.cfb-field-has-error .cfb-file {
    border-color: #dc3545;
    background: #fdf2f2;
}

.cfb-field-has-error .cfb-file:hover,
.cfb-field-has-error .cfb-file:focus {
    border-color: #dc3545;
    background: #fdf2f2;
}

/* Responsive Design */
@media (max-width: 768px) {
    .cfb-form-container {
        padding: 0 15px;
    }
    
    .cfb-input,
    .cfb-textarea,
    .cfb-select,
    .cfb-file {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .cfb-submit-btn {
        width: 100%;
        padding: 15px;
    }
    
    .cfb-radio-group,
    .cfb-checkbox-group {
        gap: 15px;
    }
    
    .cfb-file {
        padding: 15px 10px;
    }
}

/* Accessibility */
.cfb-input:focus,
.cfb-textarea:focus,
.cfb-select:focus,
.cfb-file:focus,
.cfb-radio:focus,
.cfb-checkbox:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .cfb-input,
    .cfb-textarea,
    .cfb-select,
    .cfb-file {
        border-width: 2px;
    }
    
    .cfb-submit-btn {
        border: 2px solid #007cba;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .cfb-form {
        background: #1a1a1a;
        color: #ffffff;
    }
    
    .cfb-field-label {
        color: #ffffff;
    }
    
    .cfb-input,
    .cfb-textarea,
    .cfb-select,
    .cfb-file {
        background-color: #2d2d2d;
        border-color: #444;
        color: #ffffff;
    }
    
    .cfb-file {
        background: #2a2a2a;
    }
    
    .cfb-file:hover,
    .cfb-file:focus {
        background: #3a3a3a;
        border-color: #4a9eff;
    }
    
    .cfb-input:focus,
    .cfb-textarea:focus,
    .cfb-select:focus,
    .cfb-file:focus {
        border-color: #4a9eff;
        box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.1);
    }
    
    .cfb-success-message {
        background-color: #1e3a2e;
        color: #7ec699;
        border-color: #2d5a3d;
    }
    
    .cfb-error-message {
        background-color: #3d1e20;
        color: #f5b7b1;
        border-color: #5a2d2f;
    }
    
    .cfb-field-error {
        background-color: #3d1e20;
        color: #f5b7b1;
        border-color: #5a2d2f;
    }
}

/* Animation for form appearance */
.cfb-form-container {
    animation: cfb-fadeIn 0.5s ease-in-out;
}

@keyframes cfb-fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Field Width Classes */
.cfb-half-width {
    display: inline-block;
    width: calc(50% - 10px);
    margin-right: 20px;
}

.cfb-half-width:nth-child(even) {
    margin-right: 0;
}

.cfb-third-width {
    display: inline-block;
    width: calc(33.33% - 14px);
    margin-right: 20px;
}

.cfb-third-width:nth-child(3n) {
    margin-right: 0;
}

/* reCAPTCHA Badge */
.cfb-recaptcha-badge {
    font-size: 12px;
    color: #666;
    margin-top: 10px;
    line-height: 1.4;
}

.cfb-recaptcha-badge a {
    color: #007cba;
    text-decoration: none;
}

.cfb-recaptcha-badge a:hover {
    text-decoration: underline;
}

/* Auto-fill indicator */
.cfb-input.cfb-auto-filled,
.cfb-textarea.cfb-auto-filled {
    background-color: #f0f8ff;
    border-color: #b3d9ff;
}

/* Responsive adjustments for width classes */
@media (max-width: 768px) {
    .cfb-half-width,
    .cfb-third-width {
        display: block;
        width: 100%;
        margin-right: 0;
        margin-bottom: 20px;
    }
}

/* Loading overlay for forms */
.cfb-form-container.cfb-loading-overlay {
    position: relative;
}

.cfb-form-container.cfb-loading-overlay::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* Enhanced file upload visual cues */
.cfb-file::before {
    content: "📎 Choose files or drag and drop here";
    display: block;
    color: #666;
    font-size: 14px;
    margin-bottom: 5px;
}

.cfb-file[multiple]::before {
    content: "📎 Choose files or drag and drop here (multiple files allowed)";
}

.cfb-field-wrapper.cfb-drag-over::after {
    content: "Drop files here";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 124, 186, 0.9);
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: bold;
    z-index: 10;
    pointer-events: none;
}

/* Premium form styling */
.cfb-form.cfb-premium {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.cfb-form.cfb-premium .cfb-field-label {
    color: #ffffff;
    font-weight: 600;
}

.cfb-form.cfb-premium .cfb-input,
.cfb-form.cfb-premium .cfb-textarea,
.cfb-form.cfb-premium .cfb-select,
.cfb-form.cfb-premium .cfb-file {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 8px;
    padding: 15px;
}

.cfb-form.cfb-premium .cfb-submit-btn {
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    border: none;
    border-radius: 25px;
    padding: 15px 40px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease;
}

.cfb-form.cfb-premium .cfb-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
}
