/**
 * Authentication UX Enhancements
 * Enhanced error messages, loading states, validation feedback
 */

/* Enhanced Error Message Container */
.error-message {
    display: none;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(220, 38, 38, 0.1));
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    animation: slideDown 0.3s ease-out;
}

.error-message.show {
    display: block;
}

.error-content {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.error-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.error-details {
    flex: 1;
}

.error-title {
    font-weight: 600;
    color: #fca5a5;
    font-size: 16px;
    margin-bottom: 4px;
}

.error-message-text,
.error-message {
    color: #fecaca;
    font-size: 14px;
    line-height: 1.5;
}

.error-suggestions {
    margin: 12px 0 0 0;
    padding-left: 20px;
    list-style: disc;
}

.error-suggestions li {
    color: #fcd34d;
    font-size: 13px;
    margin-bottom: 6px;
    line-height: 1.4;
}

/* Success Message */
.success-message {
    display: none;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(5, 150, 105, 0.1));
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    color: #6ee7b7;
    animation: slideDown 0.3s ease-out;
}

.success-message.show {
    display: flex;
    align-items: center;
    gap: 12px;
}

.success-message::before {
    content: "✓";
    font-size: 24px;
    color: #10b981;
}

/* Validation Feedback */
.validation-feedback {
    display: none;
    font-size: 12px;
    margin-top: 6px;
    padding-left: 4px;
    transition: all 0.2s;
}

.validation-feedback.valid {
    color: #10b981;
    display: block;
}

.validation-feedback.invalid {
    color: #f59e0b;
    display: block;
}

/* Password Strength Meter */
.password-strength-container {
    margin-top: 8px;
    display: none;
}

.password-strength-container.show {
    display: block;
}

.password-strength-bar {
    height: 4px;
    background: rgba(148, 163, 184, 0.2);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 6px;
}

.password-strength-fill {
    height: 100%;
    width: 0%;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.password-strength-text {
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.password-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.password-check {
    font-size: 11px;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 4px;
}

.password-check.met {
    color: #10b981;
}

.password-check::before {
    content: "○";
}

.password-check.met::before {
    content: "✓";
}

/* Password Toggle Button */
.password-input-wrapper {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    z-index: 10;
}

.password-toggle:hover {
    color: #94a3b8;
}

.password-toggle:focus {
    outline: none;
    color: #6366f1;
}

/* Enhanced Input States */
.form-input.error {
    border-color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.05);
}

.form-input.success {
    border-color: #10b981 !important;
    background: rgba(16, 185, 129, 0.05);
}

.form-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Loading State */
.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spinner 0.6s linear infinite;
}

@keyframes spinner {
    to {
        transform: rotate(360deg);
    }
}

/* Shake Animation for Errors */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-10px); }
    20%, 40%, 60%, 80% { transform: translateX(10px); }
}

.shake {
    animation: shake 0.5s;
}

/* Slide Down Animation */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading Spinner in Button */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spinner 0.6s linear infinite;
}

/* Form Field Focus States */
.form-group {
    margin-bottom: 20px;
    position: relative;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #e2e8f0;
    transition: color 0.2s;
}

.form-input:focus + .form-label {
    color: #6366f1;
}

/* Info Tooltips */
.info-tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
    color: #64748b;
    margin-left: 6px;
}

.info-tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

.tooltip-text {
    visibility: hidden;
    background-color: #1e293b;
    color: #e2e8f0;
    text-align: left;
    border-radius: 8px;
    padding: 12px;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    width: 240px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 12px;
    line-height: 1.5;
    border: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #1e293b transparent transparent transparent;
}

/* Progress Indicator for Multi-step Forms */
.progress-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 32px;
}

.progress-step {
    flex: 1;
    text-align: center;
    position: relative;
}

.progress-step::before {
    content: "";
    position: absolute;
    top: 15px;
    left: 50%;
    right: -50%;
    height: 2px;
    background: rgba(148, 163, 184, 0.2);
    z-index: 0;
}

.progress-step:last-child::before {
    display: none;
}

.progress-step-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(148, 163, 184, 0.2);
    border: 2px solid rgba(148, 163, 184, 0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    position: relative;
    z-index: 1;
    transition: all 0.3s;
}

.progress-step.active .progress-step-circle {
    background: linear-gradient(135deg, #6366f1, #a855f7);
    border-color: #6366f1;
    color: white;
}

.progress-step.completed .progress-step-circle {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

.progress-step-label {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    color: #64748b;
}

.progress-step.active .progress-step-label {
    color: #6366f1;
    font-weight: 600;
}

/* Smooth Transitions */
.form-input,
.btn,
.password-toggle {
    transition: all 0.2s ease;
}

/* Focus Visible for Accessibility */
*:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* Better Button States */
.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Remember Me Checkbox Enhanced */
.remember-me {
    display: flex;
    align-items: center;
    gap: 8px;
}

.remember-me input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #6366f1;
}

.remember-me label {
    cursor: pointer;
    user-select: none;
    font-size: 14px;
    color: #94a3b8;
}

/* Auto-fill Styles */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: #e2e8f0;
    -webkit-box-shadow: 0 0 0px 1000px rgba(15, 23, 42, 0.9) inset;
    transition: background-color 5000s ease-in-out 0s;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .error-content {
        flex-direction: column;
        gap: 8px;
    }

    .error-suggestions {
        margin-left: 0;
        padding-left: 16px;
    }

    .password-checks {
        font-size: 10px;
    }

    .tooltip-text {
        width: 200px;
        font-size: 11px;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .form-input {
        border-width: 2px;
    }

    .validation-feedback {
        font-weight: 600;
    }
}

/* Reduce Motion for Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
