/* ACF Form Builder Frontend Styles */

/* Form Wrapper */
.acf-form-builder-wrapper {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Form Styles */
.acf-form-builder-form {
    width: 100%;
}

/* Form Fields */
.form-field {
    margin-bottom: 20px;
    position: relative;
}

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

.form-field.required label::after {
    content: ' *';
    color: #dc3232;
}

/* Input Styles */
.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="number"],
.form-field input[type="date"],
.form-field input[type="tel"],
.form-field input[type="url"],
.form-field textarea,
.form-field select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    line-height: 1.5;
    transition: all 0.2s ease;
    background: #fff;
    box-sizing: border-box;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0,115,170,0.1);
}

.form-field textarea {
    min-height: 120px;
    resize: vertical;
    font-family: inherit;
}

/* File Upload Styles */
.form-field input[type="file"] {
    padding: 8px;
    border: 2px dashed #ddd;
    border-radius: 6px;
    background: #fafafa;
    cursor: pointer;
    transition: all 0.2s ease;
}

.form-field input[type="file"]:hover {
    border-color: #0073aa;
    background: #f0f8ff;
}

.form-field input[type="file"]:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0,115,170,0.1);
}

/* File Preview */
.file-preview {
    margin-top: 10px;
    padding: 15px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
}

.file-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.file-name {
    font-weight: 600;
    color: #333;
    word-break: break-all;
}

.file-size {
    color: #666;
    font-size: 12px;
}

.image-preview {
    max-width: 200px;
    max-height: 200px;
    border-radius: 4px;
    margin: 10px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.remove-file {
    background: #dc3232;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin-top: 10px;
    transition: background 0.2s ease;
}

.remove-file:hover {
    background: #c62d2d;
}

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

.checkbox-label,
.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal !important;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.checkbox-label:hover,
.radio-label:hover {
    background: #f8f9fa;
}

.checkbox-label input,
.radio-label input {
    width: auto !important;
    margin: 0;
}

/* Select Styles */
.form-field select {
    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 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
    appearance: none;
    cursor: pointer;
}

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

.acf-form-submit-btn {
    background: #0073aa;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
    position: relative;
}

.acf-form-submit-btn:hover {
    background: #005a87;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,115,170,0.3);
}

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

.acf-form-submit-btn:disabled::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

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

.form-message {
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 10px;
    font-weight: 500;
}

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

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

.form-message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Field Validation */
.form-field.error input,
.form-field.error textarea,
.form-field.error select {
    border-color: #dc3232;
    box-shadow: 0 0 0 3px rgba(220,50,50,0.1);
}

.field-error {
    color: #dc3232;
    font-size: 13px;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.field-error::before {
    content: '⚠';
    font-size: 12px;
}

/* Character Counter */
.char-counter {
    font-size: 12px;
    color: #666;
    text-align: right;
    margin-top: 5px;
}

.char-counter.warning {
    color: #f57c00;
    font-weight: 600;
}

/* Progress Indicator */
.form-progress {
    margin-bottom: 30px;
    background: #f8f9fa;
    border-radius: 6px;
    overflow: hidden;
}

.progress-bar {
    height: 4px;
    background: linear-gradient(90deg, #0073aa, #00a0d2);
    transition: width 0.3s ease;
}

.step-indicator {
    padding: 10px 15px;
    font-size: 12px;
    color: #666;
    text-align: center;
}

/* Auto-save Indicator */
.auto-save-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 9999;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.auto-save-indicator.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Draft Message */
.draft-loaded-message {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    padding: 12px 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.clear-draft {
    background: #ffc107;
    color: #212529;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.clear-draft:hover {
    background: #e0a800;
}

/* Responsive Design */
@media (max-width: 768px) {
    .acf-form-builder-wrapper {
        margin: 10px;
        padding: 15px;
        border-radius: 6px;
    }
    
    .form-field {
        margin-bottom: 15px;
    }
    
    .form-field input,
    .form-field textarea,
    .form-field select {
        padding: 10px 14px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .checkbox-group,
    .radio-group {
        gap: 12px;
    }
    
    .checkbox-label,
    .radio-label {
        padding: 12px;
    }
    
    .acf-form-submit-btn {
        width: 100%;
        padding: 15px;
        font-size: 18px;
    }
    
    .auto-save-indicator {
        top: 10px;
        right: 10px;
        left: 10px;
        text-align: center;
    }
    
    .image-preview {
        max-width: 100%;
        max-height: 150px;
    }
}

@media (max-width: 480px) {
    .acf-form-builder-wrapper {
        margin: 5px;
        padding: 10px;
    }
    
    .form-field input,
    .form-field textarea,
    .form-field select {
        padding: 8px 12px;
    }
    
    .file-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .acf-form-builder-wrapper {
        background: #1e1e1e;
        color: #e0e0e0;
        box-shadow: 0 2px 10px rgba(255,255,255,0.1);
    }
    
    .form-field label {
        color: #e0e0e0;
    }
    
    .form-field input,
    .form-field textarea,
    .form-field select {
        background: #2d2d2d;
        border-color: #444;
        color: #e0e0e0;
    }
    
    .form-field input:focus,
    .form-field textarea:focus,
    .form-field select:focus {
        border-color: #4fc3f7;
        box-shadow: 0 0 0 3px rgba(79,195,247,0.1);
    }
    
    .form-field input[type="file"] {
        background: #2d2d2d;
        border-color: #444;
    }
    
    .checkbox-label:hover,
    .radio-label:hover {
        background: #2d2d2d;
    }
    
    .file-preview {
        background: #2d2d2d;
        border-color: #444;
    }
    
    .file-name {
        color: #e0e0e0;
    }
    
    .file-size {
        color: #aaa;
    }
    
    .acf-form-submit-btn {
        background: #4fc3f7;
        color: #1e1e1e;
    }
    
    .acf-form-submit-btn:hover {
        background: #29b6f6;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .form-field input,
    .form-field textarea,
    .form-field select {
        border-width: 2px;
    }
    
    .acf-form-submit-btn {
        border: 2px solid currentColor;
    }
    
    .form-message {
        border-width: 2px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .acf-form-submit-btn:hover {
        transform: none;
    }
}

/* Focus Visible Support */
.form-field input:focus-visible,
.form-field textarea:focus-visible,
.form-field select:focus-visible,
.acf-form-submit-btn:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Loading State for Form */
.acf-form-builder-form.loading {
    position: relative;
    pointer-events: none;
}

.acf-form-builder-form.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.8);
    z-index: 999;
    border-radius: inherit;
}

/* Conditional Fields */
.form-field[data-conditional] {
    transition: opacity 0.3s ease, height 0.3s ease;
}

.form-field[data-conditional]:not(.visible) {
    opacity: 0.5;
    pointer-events: none;
}

/* Multi-step Forms */
.form-step {
    display: none;
}

.form-step.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.form-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

.form-nav-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.form-nav-btn:hover {
    background: #5a6268;
}

.form-nav-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Print Styles */
@media print {
    .acf-form-builder-wrapper {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .form-submit,
    .auto-save-indicator,
    .draft-loaded-message {
        display: none !important;
    }
    
    .form-field {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .form-field input,
    .form-field textarea,
    .form-field select {
        border: 1px solid #000 !important;
        background: white !important;
    }
}