/**
 * Multistep Form Styles
 * Custom styles for the multistep form functionality
 * Works with Tailwind CSS
 */

/* ========================================
   Step Container Styles
   ======================================== */

.multistep-container {
    position: relative;
    width: 100%;
}

.multistep-step {
    transition: opacity 250ms ease-in-out, transform 250ms ease-in-out;
    opacity: 1;
    transform: translateX(0);
    will-change: opacity, transform;
}

.multistep-step.hidden {
    opacity: 0;
    pointer-events: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    transform: translateX(-10px);
}

.multistep-step.active {
    opacity: 1;
    position: relative;
    transform: translateX(0);
}

/* Fade in animation - optimized for performance (Task 8.2.1) */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.multistep-step.active {
    animation: fadeIn 250ms ease-in-out;
}

/* ========================================
   Navigation Button Styles
   ======================================== */

/* Disabled button state */
#btn-next:disabled,
#btn-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

#btn-next:disabled:hover,
#btn-submit:disabled:hover {
    opacity: 0.5;
}

/* Reset warning indicator for back button on step 2 */
button#btn-prev.btn-plain.btn-reset-warning {
    border: 2px solid #f59e0b !important;
    background-color: #fef3c7 !important;
    padding: 0.75rem 1.5rem !important;
}

button#btn-prev.btn-plain.btn-reset-warning span,
button#btn-prev.btn-plain.btn-reset-warning svg {
    color: #92400e !important;
}

button#btn-prev.btn-plain.btn-reset-warning:hover {
    background-color: #fde68a !important;
    border-color: #d97706 !important;
    opacity: 1 !important;
}

/* ========================================
   Reset Confirmation Modal Styles
   ======================================== */

#reset-form-modal .uk-modal-dialog {
    max-width: 500px;
}

#reset-form-modal .uk-modal-title {
    color: #f59e0b;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

#reset-form-modal ul {
    list-style: disc;
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

#reset-form-modal .uk-button-danger {
    background-color: #dc2626;
    color: white;
    border: none;
    transition: all 200ms ease-in-out;
}

#reset-form-modal .uk-button-danger:hover {
    background-color: #b91c1c;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(220, 38, 38, 0.2);
}

/* ========================================
   Loading Overlay Styles
   ======================================== */

#multistep-loading-overlay {
    animation: fadeInOverlay 300ms ease-in-out;
}

@keyframes fadeInOverlay {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

#multistep-loading-overlay > div {
    animation: scaleIn 300ms ease-out;
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========================================
   Progress Indicator Styles
   ======================================== */

.multistep-progress-wrapper {
    margin-bottom: 2rem;
}

.step-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.step-indicator .step-circle {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 700;
    transition: all 300ms ease-in-out;
    position: relative;
}

/* Step states - improved clarity (Task 8.3.2) */
.step-indicator.pending .step-circle {
    background-color: #e5e7eb; /* gray-200 */
    color: #9ca3af; /* gray-400 */
    border: 2px solid #d1d5db; /* gray-300 */
}

.step-indicator.active .step-circle {
    background-color: #16a34a; /* green-600 */
    color: white;
    box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.2);
    border: 2px solid #16a34a;
    transform: scale(1.1);
}

.step-indicator.completed .step-circle {
    background-color: #22c55e; /* green-500 */
    color: white;
    border: 2px solid #22c55e;
}

/* Add checkmark for completed steps */
.step-indicator.completed .step-circle::after {
    content: '✓';
    position: absolute;
    font-size: 1rem;
    font-weight: bold;
}

.step-indicator .step-label {
    font-size: 0.75rem;
    color: #6b7280; /* gray-500 */
    text-align: center;
    transition: all 200ms ease-in-out;
}

.step-indicator.active .step-label {
    color: #16a34a; /* green-600 */
    font-weight: 600;
}

.step-indicator.completed .step-label {
    color: #22c55e; /* green-500 */
    font-weight: 500;
}

/* Progress bar animation - smoother (Task 8.2.1) */
#progress-bar {
    transition: width 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   Navigation Button Styles
   ======================================== */

.multistep-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    gap: 1rem;
}

.btn-prev,
.btn-next,
.btn-submit {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 0.5rem;
    transition: all 200ms ease-in-out;
    cursor: pointer;
    border: none;
    position: relative;
}

.btn-prev {
    background-color: #f3f4f6; /* gray-100 */
    color: #374151; /* gray-700 */
    border: 1px solid #d1d5db; /* gray-300 */
}

.btn-prev:hover:not(:disabled) {
    background-color: #e5e7eb; /* gray-200 */
    border-color: #9ca3af; /* gray-400 */
}

.btn-next,
.btn-submit {
    background-color: #16a34a; /* green-600 */
    color: white;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn-next:hover:not(:disabled),
.btn-submit:hover:not(:disabled) {
    background-color: #15803d; /* green-700 */
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-next:active:not(:disabled),
.btn-submit:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* Improved disabled state (Task 8.3.3) */
.btn-prev:disabled,
.btn-next:disabled,
.btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    background-color: #9ca3af; /* gray-400 */
}

.btn-prev.hidden,
.btn-next.hidden,
.btn-submit.hidden {
    display: none;
}

/* Loading state - improved visibility (Task 8.3.3) */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 1rem;
    height: 1rem;
    top: 50%;
    left: 50%;
    margin-left: -0.5rem;
    margin-top: -0.5rem;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 600ms linear infinite;
}

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

/* ========================================
   Validation Feedback Styles
   ======================================== */

.field-valid {
    border-color: #22c55e !important; /* green-500 */
    background-color: #f0fdf4 !important; /* green-50 */
}

.field-valid:focus {
    ring-color: #22c55e !important;
    border-color: #22c55e !important;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1) !important;
}

.field-invalid {
    border-color: #ef4444 !important; /* red-500 */
    background-color: #fef2f2 !important; /* red-50 */
}

.field-invalid:focus {
    ring-color: #ef4444 !important;
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

/* Improved error message styling (Task 8.3.1) */
.field-error-message {
    color: #dc2626; /* red-600 */
    font-size: 0.875rem;
    margin-top: 0.375rem;
    padding: 0.5rem;
    background-color: #fef2f2; /* red-50 */
    border-left: 3px solid #ef4444; /* red-500 */
    border-radius: 0.25rem;
    animation: slideDown 250ms ease-in-out;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.field-error-message::before {
    content: '⚠';
    flex-shrink: 0;
    font-size: 1rem;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
        max-height: 0;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 100px;
    }
}

/* ========================================
   Responsive Styles
   ======================================== */

/* Mobile (< 640px) */
@media (max-width: 639px) {
    .step-indicator .step-label {
        display: none;
    }
    
    .multistep-navigation {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-prev,
    .btn-next,
    .btn-submit {
        width: 100%;
        justify-content: center;
    }
    
    .step-indicator .step-circle {
        width: 1.75rem;
        height: 1.75rem;
        font-size: 0.75rem;
    }
}

/* Tablet (640px - 1024px) */
@media (min-width: 640px) and (max-width: 1023px) {
    .step-indicator .step-label {
        font-size: 0.625rem;
    }
}

/* Desktop (> 1024px) */
@media (min-width: 1024px) {
    .multistep-step {
        min-height: 400px;
    }
}

/* ========================================
   Accessibility Styles
   ======================================== */

.btn-prev:focus,
.btn-next:focus,
.btn-submit:focus {
    outline: 2px solid #16a34a;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .step-indicator.active .step-circle {
        border: 2px solid currentColor;
    }
    
    .field-invalid {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .multistep-step,
    .step-indicator .step-circle,
    #progress-bar,
    .btn-prev,
    .btn-next,
    .btn-submit {
        transition: none;
        animation: none;
    }
}
