/**
 * public/assets/css/ai-helper.css
 * Stili per l'icona IA nell'header e la modale di selezione azione / upload.
 */

/* ========================================================
   PULSANTE IA NELL'HEADER (#header-actions)
   ======================================================== */
.ai-header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    border: 1px solid rgba(59, 130, 246, 0.35);
    cursor: pointer;
    background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
    white-space: nowrap;
}
.ai-header-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(37, 99, 235, 0.35);
}
.ai-header-btn:active {
    transform: translateY(0);
}
.ai-header-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.ai-header-btn::after {
    content: 'IA';
}

/* Nasconde il vecchio FAB fisso (non più usato) */
#ai-fab.ai-fab-btn { display: none !important; }

/* ========================================================
   MODALE IA
   ======================================================== */
.ai-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 950;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    animation: aiFadeIn 0.2s forwards ease;
}

.ai-modal {
    background: var(--bg-card, #fff);
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.ai-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    flex-shrink: 0;
}

.ai-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary, #1f2937);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-modal-header h3 svg {
    width: 20px;
    height: 20px;
    color: #3B82F6;
}

.ai-modal-close {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted, #6b7280);
    padding: 0.25rem;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.ai-modal-close:hover {
    background: rgba(0,0,0,0.05);
    color: var(--text-primary, #1f2937);
}

.ai-modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.ai-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
    flex-shrink: 0;
}

/* ========================================================
   GRIGLIA AZIONI
   ======================================================== */
.ai-action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.ai-action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    border: 1.5px solid var(--border-color, #e5e7eb);
    border-radius: 10px;
    background: var(--bg-body, #f9fafb);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
    text-align: center;
    color: var(--text-primary, #1f2937);
}

.ai-action-card:hover {
    border-color: #3B82F6;
    background: rgba(59, 130, 246, 0.06);
    transform: translateY(-1px);
}

.ai-action-card svg {
    width: 28px;
    height: 28px;
    color: #3B82F6;
}

.ai-action-card span {
    font-size: 0.85rem;
    font-weight: 500;
}

/* ========================================================
   AREA UPLOAD
   ======================================================== */
.ai-upload-zone {
    border: 2px dashed var(--border-color, #d1d5db);
    border-radius: 10px;
    padding: 2rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    color: var(--text-muted, #6b7280);
    position: relative;
}

.ai-upload-zone:hover {
    border-color: #3B82F6;
    background: rgba(59, 130, 246, 0.04);
}

.ai-upload-zone.dragover {
    border-color: #2563EB;
    background: rgba(37, 99, 235, 0.08);
}

.ai-upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.ai-upload-zone svg {
    display: block;
    margin: 0 auto 0.75rem;
    width: 40px;
    height: 40px;
    color: #9CA3AF;
}

.ai-upload-zone p {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 500;
}

.ai-upload-zone small {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.75rem;
}

/* Anteprima immagine selezionata */
.ai-upload-preview {
    margin-top: 1rem;
    text-align: center;
}

.ai-upload-preview img {
    max-width: 100%;
    max-height: 220px;
    border-radius: 8px;
    border: 1px solid var(--border-color, #e5e7eb);
    object-fit: contain;
}

/* ========================================================
   STATI DELLA MODALE (analisi in corso, risultato)
   ======================================================== */
.ai-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem 0;
}

.ai-status .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(59, 130, 246, 0.2);
    border-top-color: #3B82F6;
    border-radius: 50%;
    animation: aiSpin 0.8s linear infinite;
}

.ai-status-text {
    font-size: 0.9rem;
    color: var(--text-muted, #6b7280);
    text-align: center;
}

.ai-error-text {
    color: #DC2626;
    font-size: 0.85rem;
    text-align: center;
    line-height: 1.5;
}

.ai-success-text {
    color: #16A34A;
    font-size: 0.85rem;
    text-align: center;
}

/* ========================================================
   BARRA DI PROGRESSO
   ======================================================== */
.ai-progress-bar {
    width: 100%;
    height: 6px;
    background: #E5E7EB;
    border-radius: 3px;
    margin-top: 0.75rem;
    overflow: hidden;
}

.ai-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3B82F6, #2563EB);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

/* ========================================================
   ANIMAZIONI
   ======================================================== */
@keyframes aiFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

/* ========================================================
   RESPONSIVE
   ======================================================== */
@media (max-width: 480px) {
    .ai-modal {
        max-width: 100%;
        border-radius: 10px;
    }
    .ai-action-grid {
        grid-template-columns: 1fr 1fr;
    }
}
