﻿:root {
    --bot-bg: #ffffff;
    --bot-border: #e2e8f0;
    --user-bg: #00a884;
    --user-bg-hover: #029071;
    --body-bg: #f0f2f5;
    --text-color: #111b21;
}

body {
    background-color: var(--body-bg);
    height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    overflow: hidden;
    color: var(--text-color);
}

/* Chat Window */
#chat-window {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background-color: #efeae2; /* Colore sfondo stile WhatsApp Light */
    background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 20px 20px;
}

.msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.msg-user {
    align-self: flex-end;
    background-color: var(--user-bg);
    color: #ffffff;
    border-top-right-radius: 0;
    white-space: pre-wrap;
}

    .msg-user img.attached-img {
        max-width: 100%;
        max-height: 250px;
        border-radius: 6px;
        margin-bottom: 8px;
        display: block;
        object-fit: contain;
    }

.msg-bot {
    align-self: flex-start;
    background-color: var(--bot-bg);
    color: var(--text-color);
    border: 1px solid var(--bot-border);
    border-top-left-radius: 0;
    word-break: break-word;
}

    .msg-bot p {
        margin-bottom: 0.75rem;
    }

        .msg-bot p:last-child {
            margin-bottom: 0;
        }

    /* Stili Codice in Markdown (Tema Light) */
    .msg-bot pre {
        background: #f8fafc;
        padding: 12px;
        border-radius: 6px;
        overflow-x: auto;
        border: 1px solid #e2e8f0;
        position: relative;
    }

    .msg-bot code {
        font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
        background: #f1f5f9;
        padding: 2px 5px;
        border-radius: 4px;
        color: #0f766e;
        font-size: 0.88em;
    }

    .msg-bot pre code {
        background: none;
        padding: 0;
        color: inherit;
    }

    .msg-bot table {
        width: 100%;
        margin-bottom: 1rem;
        border-collapse: collapse;
        font-size: 0.9rem;
    }

        .msg-bot table th, .msg-bot table td {
            padding: 0.5rem;
            border: 1px solid #e2e8f0;
        }

        .msg-bot table th {
            background-color: #f8fafc;
        }

/* Typing Cursor */
.cursor {
    display: inline-block;
    width: 3px;
    height: 15px;
    background: var(--user-bg);
    margin-left: 5px;
    vertical-align: middle;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% {
        opacity: 0;
    }

    50% {
        opacity: 1;
    }
}

/* Input Area */
.input-area {
    background: #f0f2f5;
    padding: 15px;
    border-top: 1px solid #e2e8f0;
}

    .input-area .form-control {
        background-color: #ffffff;
        border: 1px solid #cbd5e1;
        color: var(--text-color);
    }

        .input-area .form-control:focus {
            background-color: #ffffff;
            color: var(--text-color);
            border-color: var(--user-bg);
        }

/* Anteprime Immagini Allegate */
.preview-thumb-wrapper {
    position: relative;
    display: inline-block;
}

.preview-thumb {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
}

.preview-remove-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

#sendBtn {
    background-color: var(--user-bg);
    border-color: var(--user-bg);
    color: white;
}

    #sendBtn:hover {
        background-color: var(--user-bg-hover);
        border-color: var(--user-bg-hover);
        color: white;
    }

#speed-tag {
    font-size: 0.75rem;
    font-weight: 600;
}

.status-aborted {
    color: #dc3545;
    font-weight: bold;
    font-size: 0.8rem;
    margin-top: 5px;
    display: block;
}

/* Offcanvas Cronologia */
.history-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

    .history-item:hover {
        background-color: #f8fafc;
    }

    .history-item.active {
        background-color: #f1f5f9;
        border-left: 4px solid var(--user-bg);
    }

.history-info {
    overflow: hidden;
    flex-grow: 1;
    margin-right: 10px;
}

.history-title {
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    color: #1e293b;
}

.history-date {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 2px;
}

.delete-chat-btn {
    color: #94a3b8;
    background: none;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

    .delete-chat-btn:hover {
        color: #dc3545;
        background-color: rgba(220, 53, 69, 0.1);
    }

/* Spinner Generazione Codice (Light) */
.code-generating-box {
    background-color: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 5px;
    padding: 10px 14px;
    margin: 10px 0;
    color: #64748b;
    font-family: monospace;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
    0% {
        border-color: #cbd5e1;
    }

    50% {
        border-color: var(--user-bg);
    }

    100% {
        border-color: #cbd5e1;
    }
}

/* Pulsante Copia Codice */
.copy-code-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: #ffffff;
    color: #64748b;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    padding: 3px 8px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

    .copy-code-btn:hover {
        background-color: #f8fafc;
        color: #0f172a;
    }

    .copy-code-btn.copied {
        background-color: #198754;
        color: white;
        border-color: #198754;
    }

/* Timestamp a piè di messaggio */
.msg-time {
    font-size: 0.68rem;
    display: block;
    margin-top: 4px;
    text-align: right;
    opacity: 0.75;
}

.msg-user .msg-time {
    color: rgba(255, 255, 255, 0.9);
}

.msg-bot .msg-time {
    color: #64748b;
}

/* Toggle Verità Assolute (Mondino Globale/Chat) */
.truth-globe-btn {
    border: none;
    background: transparent;
    padding: 0 4px;
    font-size: 0.9rem;
    color: #94a3b8; /* Semi-trasparente / Grigio */
    opacity: 0.6;
    transition: all 0.2s ease;
}

    .truth-globe-btn:hover {
        opacity: 1;
    }

    .truth-globe-btn.active {
        color: #198754; /* Verde pieno (Success) */
        opacity: 1;
    }