﻿/* ========== CO-AUTORE CHAT ========== */

/* Overlay chat */
.coautore-chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent; /* Trasparente per trascinamento */
    pointer-events: none; /* Permette click attraverso */
    z-index: 9999;
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    padding-top: 80px; /* Sotto la testatina */
    padding-right: 20px;
}

/* Container chat */
.coautore-chat-container {
    width: 380px;
    height: 570px;
    background: white;
    border-radius: 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideIn 0.3s ease;
    position: absolute; /* Importante per trascinamento */
    top: 0; /* Posizione iniziale */
    left: 0;
    pointer-events: auto; /* Solo la chat riceve click */
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.coautore-chat-header {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    user-select: none;
}

.coautore-chat-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.coautore-chat-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.coautore-chat-stato {
    font-size: 0.8rem;
    opacity: 0.9;
}

.coautore-chat-header-right {
    display: flex;
    gap: 0.5rem;
}

.coautore-chat-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

    .coautore-chat-btn:hover {
        background: rgba(255, 255, 255, 0.3);
    }

/* Area messaggi */
.coautore-chat-messages {
    flex: 1;
    padding: 1.25rem;
    overflow-y: auto;
    background: #f8fafc;
    overflow-y: auto;
    height: 300px;
}

.message {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

    .message.user {
        flex-direction: row-reverse;
    }

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: #2563eb;
    color: white;
}

.message.ai .message-avatar {
    background: #10b981;
    color: white;
}

.message-content {
    max-width: 70%;
}

.message.user .message-content {
    margin-left: auto;
}

.message-text {
    background: white;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    line-height: 1.4;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-size: 0.8rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.message.user .message-text {
    background: #2563eb;
    color: white;
    border-bottom-right-radius: 0.25rem;
    font-size: 0.8rem;
}

.message.ai .message-text {
    background: white;
    border-bottom-left-radius: 0.25rem;
    border: 1px solid #e2e8f0;
    font-size: 0.8rem;
}

.message-time {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.25rem;
    text-align: right;
}

.message.user .message-time {
    text-align: left;
    font-size: 0.8rem;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 1rem;
}

    .typing-indicator span {
        width: 8px;
        height: 8px;
        background: #94a3b8;
        border-radius: 50%;
        animation: typing 1.4s infinite;
    }

        .typing-indicator span:nth-child(2) {
            animation-delay: 0.2s;
        }

        .typing-indicator span:nth-child(3) {
            animation-delay: 0.4s;
        }

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-8px);
    }
}

/* Input */
.coautore-chat-input {
    border-top: 1px solid #e2e8f0;
    padding: 1rem;
    display: flex;
    gap: 0.75rem;
    font-family: inherit;
    font-size: 0.8rem;
    background: white;
}

    .coautore-chat-input textarea {
        flex: 1;
        border: 1px solid #e2e8f0;
        border-radius: 0.75rem;
        padding: 0.75rem;
        font-family: inherit;
        font-size: 0.95rem;
        resize: none;
        height: 160px;
        max-height: 100px;
        background:#e3e8f6;
    }

        .coautore-chat-input textarea:focus {
            outline: none;
            border-color: #2563eb;
            box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
        }

.coautore-chat-invia {
    background: #2563eb;
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

    .coautore-chat-invia:hover:not(:disabled) {
        background: #1d4ed8;
        transform: scale(1.05);
    }

    .coautore-chat-invia:disabled {
        background: #94a3b8;
        cursor: not-allowed;
    }

/* Responsive */
@media (max-width: 768px) {
    .coautore-chat-overlay {
        padding: 80px 10px 10px;
        justify-content: center;
    }

    .coautore-chat-container {
        width: 100%;
        max-width: 400px;
        height: 70vh;
    }

    .coautore-btn-text {
        display: none;
    }

    .crea-subnav-coautore-btn {
        padding: 0.5rem;
    }
}

/* FORZA STESSA ALTEZZA */
.crea-subnav-home-btn {
    height: 40px !important;
    line-height: 40px !important;
    padding: 0 1rem !important;
}

.message.ai .message-content {
    max-width: 90%; /* Molto più largo */
    width: 100%; /* Occupa tutto lo spazio disponibile */
}

.message.ai .message-text {
    max-width: none; /* Rimuovi limite */
    width: 100%; /* Occupa tutto il contenitore */
}

