/**
 * IBNP Form Validator Styles
 *
 * Visual feedback for client-side form validation
 *
 * @package InBanchina_Network_Platform
 * @since 0.4.0
 */

/* ============================================
   Field States
   ============================================ */

/* Valid State */
.ib-auth__field.has-success input:not([type="checkbox"]):not([type="radio"]),
.ib-auth__field.has-success select,
.ib-auth__field.has-success textarea,
input.is-valid:not([type="checkbox"]):not([type="radio"]),
select.is-valid,
textarea.is-valid {
    border-color: #10b981 !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Error State */
.ib-auth__field.has-error input:not([type="checkbox"]):not([type="radio"]),
.ib-auth__field.has-error select,
.ib-auth__field.has-error textarea,
input.is-invalid:not([type="checkbox"]):not([type="radio"]),
select.is-invalid,
textarea.is-invalid {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Warning State */
.ib-auth__field.has-warning input:not([type="checkbox"]):not([type="radio"]),
.ib-auth__field.has-warning select,
.ib-auth__field.has-warning textarea {
    border-color: #f59e0b !important;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

/* Validating State (with animation) */
input.is-validating:not([type="checkbox"]):not([type="radio"]),
select.is-validating,
textarea.is-validating {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Focus states - override browser defaults */
input.is-valid:focus,
select.is-valid:focus,
textarea.is-valid:focus {
    outline: none;
    border-color: #10b981 !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

input.is-invalid:focus,
select.is-invalid:focus,
textarea.is-invalid:focus {
    outline: none;
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

/* ============================================
   Feedback Messages
   ============================================ */

.ib-field-feedback {
    display: block;
    margin-top: 6px;
    font-size: 0.875rem;
    line-height: 1.4;
    transition: all 0.2s ease;
}

.ib-field-feedback svg {
    vertical-align: middle;
    flex-shrink: 0;
}

/* Success Feedback */
.ib-field-feedback--success {
    color: #10b981;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ib-field-feedback--success svg {
    color: #10b981;
}

/* Error Feedback */
.ib-field-feedback--error {
    color: #dc2626;
    font-weight: 500;
}

.ib-field-feedback--error::before {
    content: "⚠ ";
    display: inline-block;
    margin-right: 4px;
    font-weight: 700;
}

/* Warning Feedback */
.ib-field-feedback--warning {
    color: #d97706;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ib-field-feedback--warning svg {
    color: #d97706;
}

/* Validating Feedback */
.ib-field-feedback--validating {
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Spinner animation for validating state */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   Global Form Alerts
   ============================================ */

.ib-form-alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    animation: slideDown 0.3s ease-out;
}

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

.ib-form-alert--error {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.ib-form-alert--error svg {
    color: #dc2626;
    margin-top: 2px;
}

.ib-form-alert--success {
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.ib-form-alert--success svg {
    color: #22c55e;
    margin-top: 2px;
}

.ib-form-alert--warning {
    background-color: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.ib-form-alert--warning svg {
    color: #f59e0b;
    margin-top: 2px;
}

/* ============================================
   Checkbox & Radio Validation
   ============================================ */

.ib-auth__field.has-error input[type="checkbox"],
.ib-auth__field.has-error input[type="radio"],
input[type="checkbox"].is-invalid,
input[type="radio"].is-invalid {
    outline: 2px solid #ef4444;
    outline-offset: 2px;
}

.ib-auth__field.has-success input[type="checkbox"],
.ib-auth__field.has-success input[type="radio"],
input[type="checkbox"].is-valid,
input[type="radio"].is-valid {
    outline: 2px solid #10b981;
    outline-offset: 2px;
}

/* ============================================
   Accessibility Improvements
   ============================================ */

/* Ensure good contrast for error messages */
.ib-field-feedback--error {
    color: #991b1b; /* Darker red for better contrast */
}

/* 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-width: 0;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 640px) {
    .ib-field-feedback {
        font-size: 0.8125rem;
    }

    .ib-form-alert {
        padding: 10px 12px;
        font-size: 0.875rem;
    }

    .ib-form-alert svg {
        width: 18px;
        height: 18px;
    }
}

/* ============================================
   Dark Mode Support (Optional)
   ============================================ */

@media (prefers-color-scheme: dark) {
    .ib-field-feedback--success {
        color: #34d399;
    }

    .ib-field-feedback--error {
        color: #f87171;
    }

    .ib-field-feedback--warning {
        color: #fbbf24;
    }

    .ib-form-alert--error {
        background-color: rgba(239, 68, 68, 0.1);
        border-color: rgba(239, 68, 68, 0.3);
        color: #fca5a5;
    }

    .ib-form-alert--success {
        background-color: rgba(16, 185, 129, 0.1);
        border-color: rgba(16, 185, 129, 0.3);
        color: #6ee7b7;
    }

    .ib-form-alert--warning {
        background-color: rgba(245, 158, 11, 0.1);
        border-color: rgba(245, 158, 11, 0.3);
        color: #fcd34d;
    }
}

/* ============================================
   Integration with existing ib-auth styles
   ============================================ */

/* Override existing error styles if present */
.ib-auth__error,
.ib-auth__field .ib-auth__error {
    color: #991b1b;
    font-size: 0.875rem;
    margin-top: 6px;
    display: block;
}

/* Ensure compatibility with password policy feedback */
.ib-pass-feedback {
    margin-top: 8px;
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .ib-field-feedback,
    .ib-form-alert {
        display: none;
    }
}

/* ============================================
   Password Policy (client-side)
   ============================================ */

.ib-pass-feedback .ib-pass-wrap {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
}

.ib-pass-meter__label {
    font-weight: 600;
}

.ib-pass-msg {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #991b1b;
}

.ib-pass-msg__title {
    font-weight: 700;
    margin-bottom: 4px;
}

.ib-pass-msg__intro {
    margin-bottom: 6px;
    opacity: 0.95;
}

.ib-pass-msg__list {
    margin: 0;
    padding-left: 18px;
}

.ib-pass-msg__list li {
    margin: 2px 0;
}

.ib-pass-msg__tip {
    margin-top: 8px;
    font-size: 0.875rem;
    opacity: 0.95;
}

.ib-pass-req li {
    margin: 2px 0;
}
