/* ============= UX ENHANCEMENTS ============= */

/* 1. VALIDAZIONE REAL-TIME */
.form-control.is-validating {
    border-color: var(--brand-warning);
    animation: pulse-border 1.5s ease-in-out infinite;
}

@keyframes pulse-border {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.validation-message {
    font-size: 0.875rem;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: slideDown 0.3s ease;
}

.validation-message.success {
    color: var(--brand-success);
}

.validation-message.error {
    color: var(--brand-danger);
}

.validation-message.warning {
    color: var(--brand-warning);
}

.validation-icon {
    width: 16px;
    height: 16px;
    animation: fadeIn 0.3s ease;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 2. TOOLTIPS INTERATTIVI */
.tooltip-rich {
    position: relative;
    display: inline-block;
    cursor: help;
    margin-left: 0.25rem;
}

.tooltip-rich .tooltip-content {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--surface);
    color: var(--text-primary);
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 300px;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    border: 1px solid var(--border-color);
}

.tooltip-rich:hover .tooltip-content {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.tooltip-content h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
}

.tooltip-content p {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    line-height: 1.5;
}

.tooltip-example {
    background: var(--bg-secondary);
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    margin: 0.5rem 0;
}

.tooltip-link {
    color: var(--brand-primary);
    text-decoration: none;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.tooltip-link:hover {
    text-decoration: underline;
}

/* 6. MESSAGGI ERRORE AMICHEVOLI */
.friendly-error-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.friendly-error-modal.show {
    opacity: 1;
}

.error-content {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalBounce 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes modalBounce {
    0% {
        transform: scale(0.7);
        opacity: 0;
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.error-content h3 {
    margin: 0 0 1rem 0;
    font-size: 1.25rem;
}

.error-content p {
    margin: 0 0 1.5rem 0;
    color: #6b7280;
    line-height: 1.6;
}

.error-action {
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-dark) 100%);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.error-action:hover {
    transform: translateY(-2px);
}

.error-content.warning {
    border-left: 4px solid var(--brand-warning);
}

.error-content.error {
    border-left: 4px solid var(--brand-danger);
}

.error-content.info {
    border-left: 4px solid var(--brand-primary);
}

/* 7. MICRO-ANIMAZIONI */
.btn {
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.form-control:focus {
    transform: scale(1.01);
    transition: all 0.3s ease;
}

.detail-card {
    transition: all 0.3s ease;
}

.detail-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-5px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(5px);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

.shake {
    animation: shake 0.5s ease;
}

/* Success checkmark animation */
@keyframes checkmark {
    0% {
        transform: scale(0) rotate(45deg);
    }

    50% {
        transform: scale(1.2) rotate(45deg);
    }

    100% {
        transform: scale(1) rotate(45deg);
    }
}

.checkmark {
    animation: checkmark 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Loading spinner */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading {
    animation: spin 1s linear infinite;
}

/* Count up animation */
@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.count-up {
    animation: countUp 0.5s ease;
}

/* Smooth transitions for all interactive elements */
.form-control,
.form-select,
.btn,
.card,
.detail-card,
.radio-card-label {
    transition: all 0.3s ease;
}

/* Hover effects enhancement */
.radio-card:hover .radio-card-label {
    transform: translateY(-4px) scale(1.02);
}

.toggle-switch {
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Input focus glow */
.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 4px var(--brand-primary-light),
        0 4px 12px rgba(91, 99, 245, 0.2);
}