/* assets/css/validation.css */

/* Сообщения об ошибках - с правильным оформлением */
.error-message {
    color: #ef4444 !important;
    font-size: 14px !important;
    margin-top: 8px !important; /* Отступ сверху */
    margin-bottom: 20px !important; /* Отступ снизу */
    min-height: 20px !important;
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transition: all 0.3s ease !important;
    padding: 10px 14px !important; /* Внутренние отступы */
    background: rgba(239, 68, 68, 0.1) !important; /* Легкий красный фон */
    border: 1px solid rgba(239, 68, 68, 0.3) !important; /* Граница */
    border-radius: var(--radius-sm) !important; /* Скругленные углы */
    line-height: 1.4 !important;
    position: relative !important;
    overflow: hidden !important;
}

/* Показываем только если есть содержимое */
.error-message:not(:empty) {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    animation: fadeInUp 0.3s ease-out !important;
}

/* Анимация появления */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Иконка ошибки перед текстом */
.error-message::before {
    content: "⚠️" !important; /* Можно заменить на иконку Font Awesome */
    margin-right: 8px !important;
    font-size: 12px !important;
}

/* Альтернатива с Font Awesome */
.error-message.has-icon::before {
    content: "\f06a" !important; /* Font Awesome exclamation-circle */
    font-family: "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
    margin-right: 8px !important;
}

/* Очищаем padding/margin для пустых элементов */
.error-message:empty {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    border: none !important;
    background: transparent !important;
}

/* Стили для полей с ошибками */
.form-input.error,
.form-textarea.error,
.form-group input.error,
.form-group textarea.error {
    border-color: #ef4444 !important;
    background-color: rgba(239, 68, 68, 0.05) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

.form-input.success,
.form-textarea.success,
.form-group input.success,
.form-group textarea.success {
    border-color: var(--primary) !important;
    background-color: rgba(99, 102, 241, 0.05) !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1) !important;
}

/* Добавляем стрелочку к сообщению об ошибке (опционально) */
.error-message::after {
    content: '' !important;
    position: absolute !important;
    top: -6px !important;
    left: 20px !important;
    width: 0 !important;
    height: 0 !important;
    border-left: 6px solid transparent !important;
    border-right: 6px solid transparent !important;
    border-bottom: 6px solid rgba(239, 68, 68, 0.3) !important;
}

/* Для лучшего соответствия дизайну можно добавить эти стили */
.error-message {
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.15) !important;
    backdrop-filter: blur(10px) !important;
}

/* Loading indicator */
.loading {
    text-align: center !important;
    padding: 20px !important;
    color: var(--primary) !important;
    font-weight: 500 !important;
    margin-top: 20px !important;
    background: var(--gradient-glass) !important;
    backdrop-filter: blur(10px) !important;
    border-radius: var(--radius-md) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    display: none !important;
}

/* Button states */
.btn:disabled {
    opacity: 0.6 !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
}

.btn:disabled:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* Checkbox styling */
.checkbox-group {
    display: flex !important;
    align-items: flex-start !important;
    margin: 20px 0 !important;
    padding: 15px !important;
    background: rgba(15, 23, 42, 0.5) !important;
    border-radius: var(--radius-md) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.checkbox-group label {
    display: flex !important;
    align-items: flex-start !important;
    cursor: pointer !important;
    font-size: 14px !important;
    color: var(--gray) !important;
    line-height: 1.5 !important;
}

.checkbox-group input[type="checkbox"] {
    margin-right: 10px !important;
    margin-top: 3px !important;
    width: 18px !important;
    height: 18px !important;
    cursor: pointer !important;
    accent-color: var(--primary) !important;
}

.checkbox-group a {
    color: var(--primary-light) !important;
    text-decoration: none !important;
    margin: 0 5px !important;
    font-weight: 500 !important;
}

.checkbox-group a:hover {
    text-decoration: underline !important;
}

/* Focus styles for accessibility */
.form-input:focus,
.form-textarea:focus {
    outline: none !important;
    border-color: var(--primary) !important;
    box-shadow: var(--glow-primary) !important;
}

/* Phone hint styling */
.phone-hint {
    display: block !important;
    margin-top: 8px !important; /* Согласуем с error-message */
    color: var(--gray) !important;
    font-size: 13px !important;
    line-height: 1.4 !important;
    padding: 6px 10px !important;
    background: rgba(99, 102, 241, 0.05) !important;
    border: 1px solid rgba(99, 102, 241, 0.1) !important;
    border-radius: var(--radius-sm) !important;
}

/* Animation for error display */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.form-group input.error:focus,
.form-group textarea.error:focus {
    animation: shake 0.5s ease-in-out !important;
}

/* Success message styling */
.success-message {
    color: #22c55e !important;
    background: rgba(34, 197, 94, 0.1) !important;
    padding: 15px !important;
    border-radius: var(--radius-md) !important;
    margin: 15px 0 !important;
    border: 1px solid rgba(34, 197, 94, 0.3) !important;
    display: none !important;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.15) !important;
}

/* Анимация появления сообщений */
.error-message:not(:empty),
.success-message,
.loading {
    animation: fadeIn 0.3s ease-out !important;
}

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

/* Стили для обязательных полей */
.form-group.required label {
    position: relative !important;
}

.form-group.required label::after {
    content: " *" !important;
    color: #ef4444 !important;
    font-weight: bold !important;
    margin-left: 3px !important;
}

/* Общие сообщения об ошибках и успехе */
#general_error, #success_message {
    margin: 15px 0 !important;
    padding: 15px !important;
    border-radius: var(--radius-md) !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    display: none !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    backdrop-filter: blur(10px) !important;
}

#general_error:not(:empty),
#success_message:not(:empty) {
    display: block !important;
    animation: fadeIn 0.3s ease-out !important;
}

#general_error {
    background: rgba(239, 68, 68, 0.1) !important;
    border: 1px solid rgba(239, 68, 68, 0.3) !important;
    color: #ef4444 !important;
}

#general_error::before {
    content: "⚠️" !important;
    margin-right: 10px !important;
    font-size: 14px !important;
}

#success_message {
    background: rgba(34, 197, 94, 0.1) !important;
    border: 1px solid rgba(34, 197, 94, 0.3) !important;
    color: #22c55e !important;
}

#success_message::before {
    content: "✅" !important;
    margin-right: 10px !important;
    font-size: 14px !important;
}

/* Spinner animation */
.spinner {
    border: 3px solid rgba(99, 102, 241, 0.1) !important;
    border-top: 3px solid var(--primary) !important;
    border-radius: 50% !important;
    width: 40px !important;
    height: 40px !important;
    animation: spin 1s linear infinite !important;
    margin: 0 auto 15px !important;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .checkbox-group {
        padding: 12px !important;
        margin: 15px 0 !important;
    }
    
    .checkbox-group label {
        font-size: 13px !important;
    }
    
    .loading {
        padding: 15px !important;
        margin-top: 15px !important;
    }
    
    .error-message {
        font-size: 13px !important;
        padding: 8px 12px !important;
        margin-top: 6px !important;
    }
    
    .error-message:empty {
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        padding: 0 !important;
    }
    
    .phone-hint {
        font-size: 12px !important;
        padding: 5px 8px !important;
        margin-top: 6px !important;
    }
}

/* Animation for notifications */
@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

.form-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    max-width: 400px;
    z-index: 9999;
    animation: slideIn 0.3s ease-out;
}

.form-notification.success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.form-notification button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0;
    margin: 0;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Специальный класс для красивых ошибок */
.error-message.enhanced {
    padding: 12px 16px !important;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(239, 68, 68, 0.05) 100%) !important;
    border-left: 4px solid #ef4444 !important;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0 !important;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.1) !important;
    margin-top: 10px !important;
}

.error-message.enhanced::before {
    content: "!" !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 20px !important;
    height: 20px !important;
    background: #ef4444 !important;
    color: white !important;
    border-radius: 50% !important;
    margin-right: 10px !important;
    font-size: 12px !important;
    font-weight: bold !important;
}
