/**
 * FlipSecure Form Validation and User Feedback Styles
 * Requirements: 9.3, 9.7 - Form validation and progress indicators
 */

/* ===== FORM VALIDATION STYLES ===== */

/* Base Form Styles */
.form-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #2c3e50;
    font-size: 0.9rem;
}

.form-label.required::after {
    content: ' *';
    color: #dc3545;
    font-weight: bold;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background-color: #ffffff;
    color: #2c3e50;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background-color: #ffffff;
}

/* Validation States */
.form-control.is-valid {
    border-color: #28a745;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%2328a745' d='m2.3 6.73.94-.94 2.94 2.94L8.5 6.4l.94.94L6.5 10.27z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    padding-right: calc(1.5em + 0.75rem);
}

.form-control.is-valid:focus {
    border-color: #28a745;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.15);
}

.form-control.is-invalid {
    border-color: #dc3545;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath d='m5.8 4.6 2.4 2.4M8.2 4.6l-2.4 2.4'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    padding-right: calc(1.5em + 0.75rem);
}

.form-control.is-invalid:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15);
}

/* Validation Feedback */
.valid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: #28a745;
}

.invalid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: #dc3545;
}

.form-control.is-valid~.valid-feedback {
    display: block;
}

.form-control.is-invalid~.invalid-feedback {
    display: block;
}

/* Field Help Text */
.form-help {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: #6c757d;
    line-height: 1.4;
}

/* ===== ALERT SYSTEM ===== */

.alert {
    position: fixed;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.5;
    z-index: 999;
    margin: 10px;
    bottom: 0;
    width: 100%;
}

.alert-dismissible {
    padding-right: 4rem;
}

.alert button.alert-close {
    position: absolute;
    right: 20px;
    padding: 8px;
    border: none;
    background: none;
    font-size: 28px;
    top: 0;
    outline: none;
}

.alert-dismissible .btn-close {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 2;
    padding: 1.25rem 1rem;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.alert-dismissible .btn-close:hover {
    opacity: 1;
}

/* Alert Variants */
.alert-success {
    color: #0f5132;
    background-color: #d1edff;
    border-color: #badbcc;
}

.alert-info {
    color: #055160;
    background-color: #cff4fc;
    border-color: #b6effb;
}

.alert-warning {
    color: #664d03;
    background-color: #fff3cd;
    border-color: #ffecb5;
}

.alert-danger {
    color: #842029;
    background-color: #f8d7da;
    border-color: #f5c2c7;
}

/* Alert Icons */
.alert-icon {
    display: inline-block;
    margin-right: 0.5rem;
    font-size: 1.1rem;
    vertical-align: middle;
}

/* ===== PROGRESS INDICATORS ===== */

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border 0.75s linear infinite;
}

.spinner-sm {
    width: 0.875rem;
    height: 0.875rem;
    border-width: 1px;
}

.spinner-lg {
    width: 2rem;
    height: 2rem;
    border-width: 3px;
}

@keyframes spinner-border {
    to {
        transform: rotate(360deg);
    }
}

/* Progress Bar */
.progress {
    display: flex;
    height: 1rem;
    overflow: hidden;
    font-size: 0.75rem;
    background-color: #e9ecef;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.progress-bar {
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    background-color: #667eea;
    transition: width 0.6s ease;
}

.progress-bar-striped {
    background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
    background-size: 1rem 1rem;
}

.progress-bar-animated {
    animation: progress-bar-stripes 1s linear infinite;
}

@keyframes progress-bar-stripes {
    0% {
        background-position-x: 1rem;
    }
}

/* Progress Variants */
.progress-bar-success {
    background-color: #28a745;
}

.progress-bar-info {
    background-color: #17a2b8;
}

.progress-bar-warning {
    background-color: #ffc107;
}

.progress-bar-danger {
    background-color: #dc3545;
}

/* ===== LOADING STATES ===== */

.loading-overlay {
    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: 10;
    border-radius: inherit;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
}

.loading-text {
    color: #6c757d;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Button Loading States */
.btn.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.65;
}

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

.btn.loading .btn-text {
    opacity: 0;
}

/* ===== TOAST NOTIFICATIONS ===== */

.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1080;
    max-width: 350px;
}

.toast {
    background-color: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-bottom: 0.5rem;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-header {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 7px 7px 0 0;
}

.toast-title {
    font-weight: 600;
    color: #2c3e50;
    margin-right: auto;
}

.toast-time {
    font-size: 0.8rem;
    color: #6c757d;
    margin-right: 0.5rem;
}

.toast-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.toast-close:hover {
    opacity: 1;
}

.toast-body {
    padding: 1rem;
    color: #2c3e50;
    line-height: 1.4;
}

/* Toast Variants */
.toast-success .toast-header {
    background-color: #d1edff;
    color: #0f5132;
}

.toast-info .toast-header {
    background-color: #cff4fc;
    color: #055160;
}

.toast-warning .toast-header {
    background-color: #fff3cd;
    color: #664d03;
}

.toast-danger .toast-header {
    background-color: #f8d7da;
    color: #842029;
}

/* ===== FORM VALIDATION ANIMATIONS ===== */

.form-control.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-5px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(5px);
    }
}

.form-group.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== RESPONSIVE DESIGN ===== */

@media (max-width: 576px) {
    .toast-container {
        top: 0.5rem;
        right: 0.5rem;
        left: 0.5rem;
        max-width: none;
    }

    .toast {
        margin-bottom: 0.25rem;
    }

    .alert {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }

    .alert-dismissible {
        padding-right: 3rem;
    }

    .alert-dismissible .btn-close {
        padding: 1rem 0.75rem;
    }
}

/* ===== ACCESSIBILITY ENHANCEMENTS ===== */

/* Focus indicators */
.form-control:focus,
.btn:focus,
.alert .btn-close:focus,
.toast .toast-close:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Screen reader only content */
.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;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .form-control {
        border-width: 3px;
    }

    .alert {
        border-width: 2px;
    }

    .toast {
        border-width: 2px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {

    .spinner,
    .progress-bar-animated,
    .form-control.shake,
    .form-group.fade-in,
    .toast {
        animation: none !important;
        transition: none !important;
    }
}