/**
 * Form Validation Styles
 */

/* Validation error styling for fields */
.form-group {
    position: relative;
    margin-bottom: 20px;
}

input[type="text"].has-error,
input[type="email"].has-error,
input[type="password"].has-error,
input[type="url"].has-error,
input[type="file"].has-error,
textarea.has-error,
select.has-error {
    border-color: #e53e3e !important;
    background-color: rgba(229, 62, 62, 0.05) !important;
}

/* Light mode */
[data-theme="light"] input[type="text"].has-error,
[data-theme="light"] input[type="email"].has-error,
[data-theme="light"] input[type="password"].has-error,
[data-theme="light"] input[type="url"].has-error,
[data-theme="light"] input[type="file"].has-error,
[data-theme="light"] textarea.has-error,
[data-theme="light"] select.has-error {
    border-color: #dc2626 !important;
    background-color: rgba(220, 38, 38, 0.05) !important;
}

/* Error message styling */
.field-error {
    display: block;
    font-size: 13px;
    color: #e53e3e;
    margin-top: 6px;
    padding: 6px 8px;
    background-color: rgba(229, 62, 62, 0.1);
    border-radius: 4px;
    animation: slideIn 0.2s ease-out;
}

[data-theme="light"] .field-error {
    color: #dc2626;
    background-color: rgba(220, 38, 38, 0.1);
}

.field-error strong {
    font-weight: 600;
}

/* Valid field styling */
input[type="text"].has-success,
input[type="email"].has-success,
input[type="password"].has-success,
input[type="url"].has-success,
input[type="file"].has-success,
textarea.has-success,
select.has-success {
    border-color: #38a169 !important;
    background-color: rgba(56, 161, 105, 0.05) !important;
}

[data-theme="light"] input[type="text"].has-success,
[data-theme="light"] input[type="email"].has-success,
[data-theme="light"] input[type="password"].has-success,
[data-theme="light"] input[type="url"].has-success,
[data-theme="light"] input[type="file"].has-success,
[data-theme="light"] textarea.has-success,
[data-theme="light"] select.has-success {
    border-color: #16a34a !important;
    background-color: rgba(22, 163, 74, 0.05) !important;
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    margin-right: 6px;
    vertical-align: middle;
}

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

/* Form submit button disabled state */
button[type="submit"]:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Field wrapper */
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

/* Required field indicator */
.form-group label .required {
    color: #e53e3e;
    margin-left: 4px;
}

[data-theme="light"] .form-group label .required {
    color: #dc2626;
}

/* File input styling */
input[type="file"] {
    cursor: pointer;
}

input[type="file"]::file-selector-button {
    background-color: rgba(168, 127, 255, 0.15);
    border: 1px solid rgba(168, 127, 255, 0.3);
    border-radius: 8px;
    padding: 8px 16px;
    color: var(--rc-accent);
    cursor: pointer;
    transition: all 0.3s ease;
}

input[type="file"]::file-selector-button:hover {
    background-color: rgba(168, 127, 255, 0.25);
}

/* Accessible form validation */
.form-group[aria-invalid="true"] label {
    color: #e53e3e;
}

[data-theme="light"] .form-group[aria-invalid="true"] label {
    color: #dc2626;
}

/* Helper text */
.field-help {
    display: block;
    font-size: 12px;
    color: var(--rc-muted);
    margin-top: 4px;
    font-style: italic;
}

/* Character counter */
.char-count {
    display: inline-block;
    font-size: 12px;
    color: var(--rc-muted);
    margin-top: 4px;
}

.char-count.warning {
    color: #f59e0b;
}

.char-count.danger {
    color: #e53e3e;
}

[data-theme="light"] .char-count.warning {
    color: #d97706;
}

[data-theme="light"] .char-count.danger {
    color: #dc2626;
}

/* Responsive */
@media (max-width: 768px) {
    .field-error {
        font-size: 12px;
        margin-top: 4px;
        padding: 4px 6px;
    }

    .spinner {
        width: 12px;
        height: 12px;
        border-width: 2px;
    }
}
