/**
 * FORM VALIDATION STYLES
 * Professional validation feedback with smooth animations
 * mailedofirm.pl - 2025
 */

/* ========================================
   PRO TIPS
   ======================================== */

.pro-tip {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-left: 4px solid #0ea5e9;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.5;
    color: #0c4a6e;
}

.pro-tip .tip-icon {
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

.pro-tip .tip-text {
    flex: 1;
}

.pro-tip .tip-text strong {
    color: #0369a1;
    font-weight: 600;
}

/* ========================================
   FIELD HINTS (Helper Text)
   ======================================== */

.field-hint,
small.field-hint {
    display: block;
    font-size: 12px;
    color: #6c757d;
    margin-top: 4px;
    line-height: 1.4;
    font-style: italic;
}

.field-hint::before {
    content: 'ℹ️ ';
    margin-right: 4px;
}

/* ========================================
   TEXTAREA SPECIFIC STYLES
   ======================================== */

textarea {
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
}

/* Textarea validation states inherit from input styles */

/* ========================================
   VALIDATION STATES - INPUT FIELDS
   ======================================== */

/* Error state */
input.error,
textarea.error,
select.error {
    border-color: #dc3545 !important;
    background-color: #fff5f5 !important;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1) !important;
    animation: shake 0.3s ease-in-out;
}

input.error:focus,
textarea.error:focus,
select.error:focus {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 4px rgba(220, 53, 69, 0.15) !important;
}

/* Success state */
input.success,
textarea.success,
select.success {
    border-color: #28a745 !important;
    background-color: #f0fff4 !important;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1) !important;
}

input.success:focus,
textarea.success:focus,
select.success:focus {
    border-color: #28a745 !important;
    box-shadow: 0 0 0 4px rgba(40, 167, 69, 0.15) !important;
}

/* Success checkmark icon */
input.success::after,
textarea.success::after {
    content: '✓';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #28a745;
    font-weight: bold;
    font-size: 18px;
}

/* ========================================
   VALIDATION MESSAGES
   ======================================== */

.validation-message {
    font-size: 13px;
    line-height: 1.4;
    margin-top: 6px;
    padding: 8px 12px;
    border-radius: 6px;
    display: none;
    animation: slideDown 0.3s ease-out;
}

.validation-message.error {
    display: block;
    color: #dc3545;
    background-color: #fff5f5;
    border: 1px solid #ffcdd2;
    border-left: 4px solid #dc3545;
}

.validation-message.error::before {
    content: '⚠ ';
    font-weight: bold;
    margin-right: 4px;
}

.validation-message.success {
    display: block;
    color: #28a745;
    background-color: #f0fff4;
    border: 1px solid #c3e6cb;
    border-left: 4px solid #28a745;
}

.validation-message.success::before {
    content: '✓ ';
    font-weight: bold;
    margin-right: 4px;
}

/* ========================================
   FORM-LEVEL ERROR MESSAGE
   ======================================== */

.form-error-message {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
    padding: 16px 20px;
    border-radius: 10px;
    margin-bottom: 24px;
    font-weight: 500;
    display: none;
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.25);
    animation: slideDown 0.4s ease-out;
}

.form-error-message::before {
    content: '⚠️ ';
    margin-right: 8px;
    font-size: 18px;
}

/* ========================================
   PROVINCE CHECKBOXES VALIDATION
   ======================================== */

.provinces-grid.error {
    border: 2px solid #dc3545;
    border-radius: 8px;
    padding: 16px;
    background-color: #fff5f5;
}

.provinces-grid.success {
    border: 2px solid #28a745;
    border-radius: 8px;
    padding: 16px;
    background-color: #f0fff4;
}

/* ========================================
   REAL-TIME VALIDATION INDICATORS
   ======================================== */

/* Character counter for fields with maxlength */
.char-counter {
    font-size: 12px;
    color: #666;
    text-align: right;
    margin-top: 4px;
    transition: color 0.2s;
}

.char-counter.warning {
    color: #ff9800;
    font-weight: 600;
}

.char-counter.danger {
    color: #dc3545;
    font-weight: 700;
}

/* Field validation icon (positioned absolutely) */
.form-group {
    position: relative;
}

.validation-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

input.success + .validation-icon.success {
    opacity: 1;
    color: #28a745;
}

input.error + .validation-icon.error {
    opacity: 1;
    color: #dc3545;
}

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(220, 53, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

/* ========================================
   TOOLTIP FOR FIELD REQUIREMENTS
   ======================================== */

.field-requirements {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
    padding: 8px 12px;
    background-color: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #007bff;
}

.field-requirements ul {
    margin: 0;
    padding-left: 20px;
}

.field-requirements li {
    line-height: 1.6;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */

@media (max-width: 768px) {
    .validation-message {
        font-size: 12px;
        padding: 6px 10px;
    }

    .form-error-message {
        font-size: 14px;
        padding: 12px 16px;
    }
}

/* ========================================
   ACCESSIBILITY ENHANCEMENTS
   ======================================== */

/* Focus states for keyboard navigation */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid #007bff;
    outline-offset: 2px;
}

input.error:focus-visible {
    outline-color: #dc3545;
}

input.success:focus-visible {
    outline-color: #28a745;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .validation-message.error {
        border-width: 2px;
    }
    
    .validation-message.success {
        border-width: 2px;
    }
    
    input.error,
    input.success {
        border-width: 2px;
    }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .validation-message,
    .form-error-message,
    input.error,
    input.success {
        animation: none;
        transition: none;
    }
}

/* ========================================
   LOADING STATE (during validation)
   ======================================== */

.form-group.validating input {
    background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgMCAyMCAyMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48Y2lyY2xlIGN4PSIxMCIgY3k9IjEwIiByPSI4IiBmaWxsPSJub25lIiBzdHJva2U9IiM2NjYiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWRhc2hhcnJheT0iMjAgNTAiPjxhbmltYXRlVHJhbnNmb3JtIGF0dHJpYnV0ZU5hbWU9InRyYW5zZm9ybSIgYXR0cmlidXRlVHlwZT0iWE1MIiB0eXBlPSJyb3RhdGUiIGZyb209IjAgMTAgMTAiIHRvPSIzNjAgMTAgMTAiIGR1cj0iMXMiIHJlcGVhdENvdW50PSJpbmRlZmluaXRlIi8+PC9jaXJjbGU+PC9zdmc+');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px 20px;
}
