/* Quiz AI Helper Styles */

/* Pulsante AI */
.btn-ai {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: none; /* Nascosto di default, mostrato solo se autorizzato */
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.btn-ai:hover {
    background: linear-gradient(135deg, #5a6fd6 0%, #6a4190 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

/* Modal AI */
.ai-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 3000;
    justify-content: center;
    align-items: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.ai-modal.active {
    display: flex;
}

.ai-modal-content {
    background: white;
    border-radius: 16px;
    max-width: 700px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.ai-modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 25px;
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-modal-header h3 {
    margin: 0;
    font-size: 1.3em;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Toggle provider Claude/Gemini */
.ai-provider-toggle {
    display: flex;
    gap: 0;
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    overflow: hidden;
}

.ai-provider-btn {
    padding: 6px 14px;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
}

.ai-provider-btn.active {
    background: rgba(255,255,255,0.25);
    color: white;
}

.ai-provider-btn:hover:not(.active) {
    color: rgba(255,255,255,0.85);
}

.ai-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.ai-modal-body {
    padding: 25px;
}

.ai-question {
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
    padding: 18px;
    border-radius: 12px;
    margin-bottom: 20px;
    border-left: 4px solid #7c3aed;
}

.ai-question h4 {
    margin: 0 0 8px 0;
    color: #6d28d9;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ai-question p {
    margin: 0;
    color: #4c1d95;
    font-size: 1em;
    line-height: 1.5;
}

.ai-response {
    background: #f8fafc;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.ai-response h4 {
    margin: 0 0 15px 0;
    color: #334155;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-response h4::before {
    content: '🤖';
}

#aiResponseContent {
    color: #1e293b;
    font-size: 1em;
    line-height: 1.7;
}

#aiResponseContent strong {
    color: #7c3aed;
}

#aiResponseContent br + br {
    display: block;
    margin-top: 10px;
}

/* Loading */
.ai-loading {
    text-align: center;
    padding: 40px 20px;
}

.ai-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e2e8f0;
    border-top-color: #7c3aed;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.ai-loading p {
    color: #64748b;
    margin: 0;
    font-size: 1em;
}

/* Error */
.ai-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.ai-error p {
    color: #dc2626;
    margin: 0;
    font-size: 1em;
}

/* Footer */
.ai-modal-footer {
    padding: 15px 25px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    border-radius: 0 0 16px 16px;
    text-align: center;
}

.ai-footer-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

/* Pulsante Segnala Errore */
.ai-report-btn {
    display: none;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-report-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

/* Pulsante Rigenera (solo admin) */
.ai-regenerate-btn {
    display: none;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-regenerate-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.ai-modal-footer small {
    color: #94a3b8;
    font-size: 0.8em;
}

/* Badge cache/nuova */
.ai-badge {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
    margin-bottom: 15px;
    letter-spacing: 0.5px;
}

.ai-badge-cache {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.ai-badge-new {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.ai-badge-regenerated {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* Responsive */
@media (max-width: 600px) {
    .ai-modal-content {
        max-height: 90vh;
        border-radius: 12px;
    }

    .ai-modal-header {
        border-radius: 12px 12px 0 0;
        padding: 15px 20px;
    }

    .ai-modal-body {
        padding: 20px;
    }

    .ai-question,
    .ai-response {
        padding: 15px;
    }
}
