﻿/* ============================================
   CO-AUTORE CHAT - STILE TEMA BLU PETROLIO
   Versione con sfondo solido
   ============================================ */

/* CONTAINER PRINCIPALE */
.coautore-chat-container {
    position: fixed;
    width: 380px;
    background: #0f1a24 !important; /* Blu petrolio scuro solido */
    border: 1px solid #4EC9B0;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    z-index: 10001;
}

/* HEADER */
.coautore-chat-header {
    background: #1a2a3a !important; /* Blu medio solido */
    padding: 0.75rem 1rem;
    border-radius: 12px 12px 0 0;
    cursor: grab;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #4EC9B0;
    user-select: none;
}

    .coautore-chat-header:active {
        cursor: grabbing;
    }

.coautore-chat-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

    .coautore-chat-header-left i {
        font-size: 1.4rem;
        color: #4EC9B0;
    }

    .coautore-chat-header-left h3 {
        margin: 0;
        font-size: 1rem;
        font-weight: 600;
        color: #e6e6e6;
    }

.coautore-chat-stato {
    font-size: 0.7rem;
    color: #4EC9B0;
    background: rgba(78, 201, 176, 0.2);
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
}

.coautore-chat-header-right {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.coautore-chat-btn {
    background: transparent;
    border: none;
    color: #b0b0b0;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 1rem;
}

    .coautore-chat-btn:hover {
        background: rgba(255, 255, 255, 0.1);
        color: #e6e6e6;
    }

    .coautore-chat-btn.chiudi:hover {
        background: rgba(255, 107, 107, 0.2);
        color: #ff6b6b;
    }

/* AREA MESSAGGI */
.coautore-chat-messages {
    flex: 1;
    min-height: 400px;
    max-height: 500px;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: #0f1a24 !important; /* Sfondo solido */
}

    /* Scrollbar */
    .coautore-chat-messages::-webkit-scrollbar {
        width: 5px;
    }

    .coautore-chat-messages::-webkit-scrollbar-track {
        background: #1a2a3a;
        border-radius: 3px;
    }

    .coautore-chat-messages::-webkit-scrollbar-thumb {
        background: #4EC9B0;
        border-radius: 3px;
    }

/* MESSAGGI */
.message {
    display: flex;
    gap: 0.75rem;
    animation: fadeIn 0.2s ease;
}

    .message.user {
        flex-direction: row-reverse;
    }

/* AVATAR */
.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: #4EC9B0;
    color: #0a1a2a;
}

.message.ai .message-avatar {
    background: #4EC9B0;
    color: #0a1a2a;
}

.message-avatar i {
    font-size: 1rem;
}

/* CONTENUTO MESSAGGIO */
.message-content {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.message.user .message-content {
    align-items: flex-end;
}

.message-text {
    padding: 0.6rem 1rem;
    border-radius: 18px;
    font-size: 0.85rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

.message.user .message-text {
    background: #4EC9B0;
    color: #0a1a2a;
    border-bottom-right-radius: 4px;
}

.message.ai .message-text {
    background: #2a3a4a;
    color: #e6e6e6;
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 0.65rem;
    color: #b0b0b0;
}

/* TYPING INDICATOR */
.message.ai.typing .message-text {
    padding: 0.6rem 1rem;
    background: #2a3a4a;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
}

    .typing-indicator span {
        width: 8px;
        height: 8px;
        background: #4EC9B0;
        border-radius: 50%;
        animation: typingBounce 1.4s infinite ease-in-out;
    }

        .typing-indicator span:nth-child(1) {
            animation-delay: 0s;
        }

        .typing-indicator span:nth-child(2) {
            animation-delay: 0.2s;
        }

        .typing-indicator span:nth-child(3) {
            animation-delay: 0.4s;
        }

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* AREA INPUT */
.coautore-chat-input {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    background: #1a2a3a !important;
    border-top: 1px solid #4EC9B0;
    border-radius: 0 0 12px 12px;
    align-items: flex-end;
}

    .coautore-chat-input textarea {
        flex: 1;
        background: #0f1a24;
        border: 1px solid #4EC9B0;
        border-radius: 20px;
        padding: 0.6rem 1rem;
        color: #e6e6e6;
        font-family: inherit;
        font-size: 0.85rem;
        resize: none;
        min-height: 38px;
        max-height: 100px;
    }

        .coautore-chat-input textarea:focus {
            outline: none;
            border-color: #FFB300;
            box-shadow: 0 0 0 2px rgba(255, 179, 0, 0.2);
        }

        .coautore-chat-input textarea::placeholder {
            color: #b0b0b0;
        }

.coautore-chat-invia {
    background: #4EC9B0;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0a1a2a;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

    .coautore-chat-invia:hover:not(:disabled) {
        background: #FFB300;
        transform: scale(1.05);
    }

    .coautore-chat-invia:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

/* RESPONSIVE */
@media (max-width: 768px) {
    .coautore-chat-container {
        width: 320px;
        right: 10px !important;
        bottom: 10px !important;
        top: auto !important;
        left: auto !important;
    }

    .coautore-chat-messages {
        min-height: 350px;
        max-height: 450px;
    }

    .message-content {
        max-width: 85%;
    }
}


/* SPINNER */
.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #2a3a4a;
    border-top-color: #4EC9B0;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* RESPONSIVE HOMEPAGE */
@media (max-width: 768px) {
    .home-chat-panel {
        width: 320px;
        right: 10px;
        bottom: 10px;
    }

    .home-chat-interface {
        height: 450px;
    }

    .home-chat-message {
        max-width: 90%;
    }
}



/* OVERLAY PER TRASCINAMENTO HOMEPAGE */
.home-chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10000;
}

/* PANNELLO CHAT HOMEPAGE - STESSO STILE DI CACCEAUTORE */
.home-chat-panel {
    position: fixed;
    width: 380px;
    background: #0f1a24;
    border: 1px solid #4EC9B0;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    z-index: 10001;
}

/* HEADER TRASCINABILE */
.home-chat-header {
    background: #1a2a3a;
    padding: 0.75rem 1rem;
    border-radius: 12px 12px 0 0;
    cursor: grab;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #4EC9B0;
    user-select: none;
}

.home-chat-header:active {
    cursor: grabbing;
}

.home-chat-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #e6e6e6;
    font-weight: 600;
}

.home-chat-title i {
    font-size: 1.4rem;
    color: #4EC9B0;
}

.home-chat-close {
    background: transparent;
    border: none;
    color: #b0b0b0;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.home-chat-close:hover {
    background: rgba(255, 107, 107, 0.2);
    color: #ff6b6b;
}

/* AREA MESSAGGI */
.home-chat-interface {
    display: flex;
    flex-direction: column;
    height: 500px;
}

.home-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: #0f1a24;
}

/* Scrollbar */
.home-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.home-chat-messages::-webkit-scrollbar-track {
    background: #1a2a3a;
    border-radius: 3px;
}

.home-chat-messages::-webkit-scrollbar-thumb {
    background: #4EC9B0;
    border-radius: 3px;
}

/* MESSAGGI */
.home-chat-message {
    max-width: 80%;
    padding: 0.6rem 1rem;
    border-radius: 18px;
    font-size: 0.85rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

.home-chat-message.user {
    background: #4EC9B0;
    color: #0a1a2a;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.home-chat-message.bot {
    background: #2a3a4a;
    color: #e6e6e6;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

/* AREA INPUT */
.home-chat-input-area {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    background: #1a2a3a;
    border-top: 1px solid #4EC9B0;
    border-radius: 0 0 12px 12px;
    align-items: center;
}

.home-chat-input {
    flex: 1;
    background: #0f1a24;
    border: 1px solid #4EC9B0;
    border-radius: 20px;
    padding: 0.6rem 1rem;
    color: #e6e6e6;
    font-family: inherit;
    font-size: 0.85rem;
}

.home-chat-input:focus {
    outline: none;
    border-color: #FFB300;
    box-shadow: 0 0 0 2px rgba(255, 179, 0, 0.2);
}

.home-chat-input::placeholder {
    color: #b0b0b0;
}

.home-chat-send {
    background: #4EC9B0;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0a1a2a;
    cursor: pointer;
    transition: all 0.2s ease;
}

.home-chat-send:hover {
    background: #FFB300;
    transform: scale(1.05);
}

/* SPINNER */
.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #2a3a4a;
    border-top-color: #4EC9B0;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .home-chat-panel {
        width: 320px;
    }
    
    .home-chat-interface {
        height: 450px;
    }
    
    .home-chat-message {
        max-width: 90%;
    }
}