/* assets/css/frontend.css */

/* Base Form Styles */
.afb-form {
    max-width: 600px;
    margin: 0 auto;
    padding: 30px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
}

.afb-form * {
    box-sizing: border-box;
}

/* Form Header */
.afb-form-header {
    margin-bottom: 30px;
    text-align: center;
    border-bottom: 1px solid #e1e4e8;
    padding-bottom: 20px;
}

.afb-form-title {
    font-size: 28px;
    font-weight: 700;
    color: #24292e;
    margin: 0 0 10px 0;
}

.afb-form-description {
    font-size: 16px;
    color: #586069;
    margin: 0;
}

/* Field Groups */
.afb-field-group,
.afb-form-group {
    margin-bottom: 25px;
    position: relative;
}

.afb-field-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #24292e;
    font-size: 14px;
}

.afb-field-label.required::after {
    content: '*';
    color: #d73a49;
    margin-left: 4px;
}

/* Input Styles */
.afb-field-input,
.afb-form input[type="text"],
.afb-form input[type="email"],
.afb-form input[type="tel"],
.afb-form input[type="url"],
.afb-form input[type="password"],
.afb-form input[type="number"],
.afb-form input[type="date"],
.afb-form input[type="time"],
.afb-form input[type="datetime-local"],
.afb-form textarea,
.afb-form select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 16px;
    background: #fff;
    transition: all 0.2s ease;
    font-family: inherit;
}

.afb-field-input:focus,
.afb-form input:focus,
.afb-form textarea:focus,
.afb-form select:focus {
    outline: none;
    border-color: #0366d6;
    box-shadow: 0 0 0 3px rgba(3, 102, 214, 0.1);
}

/* Textarea Specific */
.afb-form textarea {
    resize: vertical;
    min-height: 100px;
}

/* Select Specific */
.afb-form select {
    cursor: pointer;
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 5"><path fill="%23666" d="m0 0 2 2 2-2z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    appearance: none;
}

/* File Upload */
.afb-form input[type="file"] {
    padding: 10px 12px;
    border: 2px dashed #d1d5db;
    background: #f8f9fa;
    cursor: pointer;
    transition: all 0.2s ease;
}

.afb-form input[type="file"]:hover {
    border-color: #0366d6;
    background: #f1f8ff;
}

.afb-form input[type="file"]:focus {
    border-style: solid;
    border-color: #0366d6;
}

/* File Upload Container */
.afb-file-upload-container {
    position: relative;
}

.afb-file-upload-container.afb-drag-over {
    background: #f1f8ff;
    border-radius: 6px;
}

.afb-file-upload-container.afb-drag-over input[type="file"] {
    border-color: #0366d6;
    background: #e6f3ff;
}

.afb-file-preview {
    margin-top: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e1e4e8;
}

.afb-file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid #e1e4e8;
}

.afb-file-item:last-child {
    border-bottom: none;
}

.afb-file-name {
    font-weight: 500;
    color: #24292e;
}

.afb-file-size {
    font-size: 12px;
    color: #586069;
}

/* Radio Buttons and Checkboxes */
.afb-form input[type="radio"],
.afb-form input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
    margin-top: 2px;
}

.afb-radio-group,
.afb-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.afb-radio-option,
.afb-checkbox-option {
    display: flex;
    align-items: flex-start;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.afb-radio-option:hover,
.afb-checkbox-option:hover {
    background: #f6f8fa;
}

.afb-radio-option input,
.afb-checkbox-option input {
    margin-top: 2px;
    margin-right: 10px;
    cursor: pointer;
}

.afb-option-label {
    cursor: pointer;
    font-weight: normal;
    margin: 0;
}

/* Field Descriptions */
.afb-field-description {
    font-size: 13px;
    color: #586069;
    margin-top: 6px;
    line-height: 1.4;
}

/* Character Counter */
.afb-character-counter {
    font-size: 12px;
    color: #586069;
    text-align: right;
    margin-top: 5px;
}

.afb-character-counter.afb-counter-warning {
    color: #f66a0a;
}

.afb-character-counter.afb-counter-limit {
    color: #d73a49;
    font-weight: 600;
}

/* Validation Styles */
.afb-field-invalid {
    border-color: #d73a49 !important;
    box-shadow: 0 0 0 3px rgba(215, 58, 73, 0.1) !important;
}

.afb-field-error {
    color: #d73a49;
    font-size: 13px;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.afb-field-error::before {
    content: '⚠';
    font-size: 14px;
}

/* Submit Button */
.afb-form input[type="submit"],
.afb-form button[type="submit"],
.afb-submit-button {
    background: #0366d6;
    color: #fff;
    border: none;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s ease;
    margin-top: 10px;
}

.afb-form input[type="submit"]:hover,
.afb-form button[type="submit"]:hover,
.afb-submit-button:hover {
    background: #0256c1;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(3, 102, 214, 0.2);
}

.afb-form input[type="submit"]:disabled,
.afb-form button[type="submit"]:disabled,
.afb-submit-button:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Success and Error Messages */
.afb-success-message {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: #fff;
    padding: 30px;
    border-radius: 8px;
    text-align: center;
    margin: 20px 0;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.afb-success-icon {
    font-size: 48px;
    margin-bottom: 15px;
    animation: afb-bounce 0.6s ease-out;
}

.afb-success-message h3 {
    margin: 0 0 10px 0;
    font-size: 24px;
    font-weight: 700;
}

.afb-success-message p {
    margin: 0;
    font-size: 16px;
    opacity: 0.9;
}

.afb-error-message {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 15px 20px;
    border-radius: 6px;
    margin: 20px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.afb-error-icon {
    font-size: 18px;
    color: #d73a49;
}

/* Multi-step Form Styles */
.afb-form-step {
    display: none;
}

.afb-form-step.active {
    display: block;
}

.afb-progress-bar {
    background: #e1e4e8;
    height: 8px;
    border-radius: 4px;
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
}

.afb-progress-fill {
    background: linear-gradient(90deg, #0366d6, #0256c1);
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
    position: relative;
}

.afb-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3));
    animation: afb-shimmer 1.5s infinite;
}

.afb-progress-text {
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #586069;
    margin-top: 8px;
}

.afb-step-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    gap: 15px;
}

.afb-prev-step,
.afb-next-step {
    padding: 12px 24px;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #586069;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.afb-prev-step:hover {
    background: #f6f8fa;
    border-color: #586069;
}

.afb-next-step {
    background: #0366d6;
    color: #fff;
    border-color: #0366d6;
}

.afb-next-step:hover {
    background: #0256c1;
    border-color: #0256c1;
}

/* Auto-save Indicator */
.afb-auto-save-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #28a745;
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    z-index: 1000;
    animation: afb-slide-in 0.3s ease-out;
}

/* Loading States */
.afb-form.loading {
    position: relative;
    pointer-events: none;
}

.afb-form.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(2px);
    border-radius: 8px;
}

.afb-form.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0366d6;
    border-radius: 50%;
    animation: afb-spin 1s linear infinite;
    z-index: 1;
}

/* Animations */
@keyframes afb-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes afb-bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translate3d(0, 0, 0);
    }
    40%, 43% {
        transform: translate3d(0, -15px, 0);
    }
    70% {
        transform: translate3d(0, -8px, 0);
    }
    90% {
        transform: translate3d(0, -2px, 0);
    }
}

@keyframes afb-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

@keyframes afb-slide-in {
    0% {
        transform: translateX(100%);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .afb-form {
        padding: 20px;
        margin: 10px;
        box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1);
    }
    
    .afb-form-title {
        font-size: 24px;
    }
    
    .afb-form-description {
        font-size: 14px;
    }
    
    .afb-field-input,
    .afb-form input,
    .afb-form textarea,
    .afb-form select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .afb-step-navigation {
        flex-direction: column;
    }
    
    .afb-prev-step,
    .afb-next-step {
        width: 100%;
        justify-content: center;
    }
    
    .afb-radio-group,
    .afb-checkbox-group {
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .afb-form {
        padding: 15px;
    }
    
    .afb-form-title {
        font-size: 20px;
    }
    
    .afb-field-input,
    .afb-form input,
    .afb-form textarea,
    .afb-form select {
        padding: 10px 12px;
    }
    
    .afb-submit-button {
        padding: 12px 20px;
        font-size: 14px;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .afb-form {
        border: 2px solid #000;
    }
    
    .afb-field-input,
    .afb-form input,
    .afb-form textarea,
    .afb-form select {
        border: 2px solid #000;
    }
    
    .afb-field-input:focus,
    .afb-form input:focus,
    .afb-form textarea:focus,
    .afb-form select:focus {
        border-color: #0366d6;
        box-shadow: 0 0 0 3px #0366d6;
    }
    
    .afb-submit-button {
        border: 2px solid #000;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .afb-form {
        background: #2d2d2d;
        color: #e1e1e1;
        border: 1px solid #4d4d4d;
    }
    
    .afb-form-title {
        color: #f1f1f1;
    }
    
    .afb-form-description {
        color: #b1b1b1;
    }
    
    .afb-field-label {
        color: #e1e1e1;
    }
    
    .afb-field-input,
    .afb-form input,
    .afb-form textarea,
    .afb-form select {
        background: #3d3d3d;
        border-color: #5d5d5d;
        color: #e1e1e1;
    }
    
    .afb-field-input:focus,
    .afb-form input:focus,
    .afb-form textarea:focus,
    .afb-form select:focus {
        border-color: #4a9eff;
        box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.2);
    }
    
    .afb-file-preview {
        background: #3d3d3d;
        border-color: #5d5d5d;
    }
    
    .afb-radio-option:hover,
    .afb-checkbox-option:hover {
        background: #4d4d4d;
    }
    
    .afb-submit-button {
        background: #4a9eff;
    }
    
    .afb-submit-button:hover {
        background: #2d8cff;
    }
    
    .afb-progress-bar {
        background: #4d4d4d;
    }
    
    .afb-progress-fill {
        background: linear-gradient(90deg, #4a9eff, #2d8cff);
    }
    
    .afb-prev-step,
    .afb-next-step {
        background: #3d3d3d;
        border-color: #5d5d5d;
        color: #e1e1e1;
    }
    
    .afb-prev-step:hover {
        background: #4d4d4d;
        border-color: #6d6d6d;
    }
    
    .afb-next-step {
        background: #4a9eff;
        border-color: #4a9eff;
    }
    
    .afb-next-step:hover {
        background: #2d8cff;
        border-color: #2d8cff;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .afb-field-input,
    .afb-form input,
    .afb-form textarea,
    .afb-form select,
    .afb-submit-button,
    .afb-prev-step,
    .afb-next-step,
    .afb-progress-fill {
        transition: none;
    }
    
    .afb-success-icon {
        animation: none;
    }
    
    .afb-form.loading::before {
        animation: none;
        border: 3px solid #6c757d;
    }
    
    .afb-auto-save-indicator {
        animation: none;
    }
}

/* Print Styles */
@media print {
    .afb-form {
        box-shadow: none;
        border: 1px solid #000;
        background: #fff;
        color: #000;
        max-width: none;
        margin: 0;
        padding: 20px;
    }
    
    .afb-submit-button,
    .afb-step-navigation,
    .afb-progress-bar,
    .afb-auto-save-indicator {
        display: none !important;
    }
    
    .afb-field-input,
    .afb-form input,
    .afb-form textarea,
    .afb-form select {
        border: 1px solid #000;
        background: #fff;
        color: #000;
    }
    
    .afb-form-step {
        display: block !important;
        page-break-inside: avoid;
    }
    
    .afb-field-group {
        page-break-inside: avoid;
    }
}

/* Custom Form Themes */
.afb-form.afb-theme-minimal {
    background: none;
    box-shadow: none;
    border: none;
    padding: 20px 0;
}

.afb-form.afb-theme-minimal .afb-form-header {
    border-bottom: 2px solid #e1e4e8;
}

.afb-form.afb-theme-minimal .afb-field-input,
.afb-form.afb-theme-minimal input,
.afb-form.afb-theme-minimal textarea,
.afb-form.afb-theme-minimal select {
    border: none;
    border-bottom: 2px solid #d1d5db;
    border-radius: 0;
    padding: 8px 4px;
    background: transparent;
}

.afb-form.afb-theme-minimal .afb-field-input:focus,
.afb-form.afb-theme-minimal input:focus,
.afb-form.afb-theme-minimal textarea:focus,
.afb-form.afb-theme-minimal select:focus {
    border-bottom-color: #0366d6;
    box-shadow: none;
}

.afb-form.afb-theme-rounded {
    border-radius: 20px;
    padding: 40px;
}

.afb-form.afb-theme-rounded .afb-field-input,
.afb-form.afb-theme-rounded input,
.afb-form.afb-theme-rounded textarea,
.afb-form.afb-theme-rounded select {
    border-radius: 25px;
    padding: 15px 20px;
}

.afb-form.afb-theme-rounded .afb-submit-button {
    border-radius: 25px;
    padding: 15px 30px;
}

.afb-form.afb-theme-modern {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
}

.afb-form.afb-theme-modern .afb-form-title,
.afb-form.afb-theme-modern .afb-field-label {
    color: #fff;
}

.afb-form.afb-theme-modern .afb-form-description {
    color: rgba(255, 255, 255, 0.8);
}

.afb-form.afb-theme-modern .afb-field-input,
.afb-form.afb-theme-modern input,
.afb-form.afb-theme-modern textarea,
.afb-form.afb-theme-modern select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    backdrop-filter: blur(10px);
}

.afb-form.afb-theme-modern .afb-field-input::placeholder,
.afb-form.afb-theme-modern input::placeholder,
.afb-form.afb-theme-modern textarea::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.afb-form.afb-theme-modern .afb-field-input:focus,
.afb-form.afb-theme-modern input:focus,
.afb-form.afb-theme-modern textarea:focus,
.afb-form.afb-theme-modern select:focus {
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.afb-form.afb-theme-modern .afb-submit-button {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.afb-form.afb-theme-modern .afb-submit-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Accessibility Enhancements */
.afb-form:focus-within {
    outline: 2px solid transparent; /* Removes browser default outline */
}

.afb-form .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip links for keyboard navigation */
.afb-form .afb-skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #0366d6;
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    z-index: 1000;
    transition: top 0.3s;
}

.afb-form .afb-skip-link:focus {
    top: 6px;
}

/* Focus indicators for better accessibility */
.afb-form *:focus {
    outline: 2px solid #0366d6;
    outline-offset: 2px;
}

.afb-form input[type="radio"]:focus,
.afb-form input[type="checkbox"]:focus {
    outline-offset: 1px;
}

/* High motion preference animations */
@media (prefers-reduced-motion: no-preference) {
    .afb-form {
        animation: afb-fade-in 0.5s ease-out;
    }
    
    .afb-field-group {
        animation: afb-slide-up 0.3s ease-out;
        animation-fill-mode: both;
    }
    
    .afb-field-group:nth-child(1) { animation-delay: 0.1s; }
    .afb-field-group:nth-child(2) { animation-delay: 0.2s; }
    .afb-field-group:nth-child(3) { animation-delay: 0.3s; }
    .afb-field-group:nth-child(4) { animation-delay: 0.4s; }
    .afb-field-group:nth-child(5) { animation-delay: 0.5s; }
    .afb-field-group:nth-child(n+6) { animation-delay: 0.6s; }
}

@keyframes afb-fade-in {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes afb-slide-up {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Form field focus ring animations */
@media (prefers-reduced-motion: no-preference) {
    .afb-field-input:focus,
    .afb-form input:focus,
    .afb-form textarea:focus,
    .afb-form select:focus {
        animation: afb-focus-ring 0.2s ease-out;
    }
}

@keyframes afb-focus-ring {
    0% {
        box-shadow: 0 0 0 0 rgba(3, 102, 214, 0.3);
    }
    100% {
        box-shadow: 0 0 0 3px rgba(3, 102, 214, 0.1);
    }
}

/* Custom scrollbar for webkit browsers */
.afb-form::-webkit-scrollbar {
    width: 8px;
}

.afb-form::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.afb-form::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.afb-form::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Form validation summary */
.afb-validation-summary {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 15px 20px;
    border-radius: 6px;
    margin-bottom: 20px;
    display: none;
}

.afb-validation-summary.visible {
    display: block;
}

.afb-validation-summary h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
}

.afb-validation-summary ul {
    margin: 0;
    padding-left: 20px;
}

.afb-validation-summary li {
    margin-bottom: 5px;
}

/* RTL Language Support */
[dir="rtl"] .afb-form {
    text-align: right;
}

[dir="rtl"] .afb-form select {
    background-position: left 12px center;
    padding-left: 40px;
    padding-right: 16px;
}

[dir="rtl"] .afb-field-label.required::after {
    margin-left: 0;
    margin-right: 4px;
}

[dir="rtl"] .afb-form input[type="radio"],
[dir="rtl"] .afb-form input[type="checkbox"] {
    margin-right: 0;
    margin-left: 8px;
}

[dir="rtl"] .afb-radio-option input,
[dir="rtl"] .afb-checkbox-option input {
    margin-right: 0;
    margin-left: 10px;
}

[dir="rtl"] .afb-character-counter {
    text-align: left;
}

/* Utility Classes */
.afb-form .afb-hidden {
    display: none !important;
}

.afb-form .afb-visible {
    display: block !important;
}

.afb-form .afb-text-center {
    text-align: center !important;
}

.afb-form .afb-text-left {
    text-align: left !important;
}

.afb-form .afb-text-right {
    text-align: right !important;
}

.afb-form .afb-mb-0 { margin-bottom: 0 !important; }
.afb-form .afb-mb-1 { margin-bottom: 8px !important; }
.afb-form .afb-mb-2 { margin-bottom: 16px !important; }
.afb-form .afb-mb-3 { margin-bottom: 24px !important; }

.afb-form .afb-mt-0 { margin-top: 0 !important; }
.afb-form .afb-mt-1 { margin-top: 8px !important; }
.afb-form .afb-mt-2 { margin-top: 16px !important; }
.afb-form .afb-mt-3 { margin-top: 24px !important; }
        background: