﻿:root {
    --bot-bg: #ffffff;
    --user-bg: #fd7e14;
}

body {
    background-color: #f0f2f5;
    height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: system-ui, -apple-system, sans-serif;
}

/* Chat Window */
#chat-window {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    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: white;
    border-bottom-right-radius: 2px;
    white-space: pre-wrap;
}

.msg-bot {
    align-self: flex-start;
    background-color: var(--bot-bg);
    color: #1c1e21;
    border: 1px solid #dee2e6;
    border-bottom-left-radius: 4px;
    word-break: break-word;
}

    .msg-bot p {
        margin-bottom: 0.75rem;
    }

        .msg-bot p:last-child {
            margin-bottom: 0;
        }

    .msg-bot pre {
        background: #f8f9fa;
        padding: 10px;
        border-radius: 5px;
        overflow-x: auto;
        border: 1px solid #e9ecef;
    }

    .msg-bot code {
        font-family: monospace;
        background: #e9ecef;
        padding: 2px 4px;
        border-radius: 3px;
        color: #d63384;
    }

    .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.4rem;
            border: 1px solid #dee2e6;
        }

        .msg-bot table th {
            background-color: #f8f9fa;
            font-weight: 600;
        }

/* 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: white;
    padding: 20px;
    border-top: 1px solid #dee2e6;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.03);
}

.form-control:focus {
    box-shadow: none;
    border-color: var(--user-bg);
}

#sendBtn {
    background-color: var(--user-bg);
    border-color: var(--user-bg);
    color: white;
    border-top-right-radius: 0.375rem !important;
    border-bottom-right-radius: 0.375rem !important;
}

    #sendBtn:hover {
        background-color: #e86e04;
        border-color: #e86e04;
        color: white;
    }

#speed-tag {
    font-size: 0.7rem;
    letter-spacing: 0.5px;
}

.status-aborted {
    color: #dc3545;
    font-weight: bold;
    font-size: 0.8rem;
    margin-top: 5px;
    display: block;
}

/* Stili per gli allegati */
#attachBtn {
    border-color: #dee2e6;
    color: #6c757d;
}

    #attachBtn.has-files {
        color: var(--user-bg);
        border-color: var(--user-bg);
    }

#file-preview {
    padding-left: 10px;
    font-size: 0.8rem;
}

/* --- Anteprime Immagini nei Messaggi --- */
.image-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.image-preview {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background-color: rgba(255, 255, 255, 0.1);
}

/* --- Offcanvas Cronologia --- */
.history-item {
    padding: 12px 16px;
    border-bottom: 1px solid #495057;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

    .history-item:hover {
        background-color: #343a40;
    }

    .history-item.active {
        background-color: #495057;
        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;
}

.history-date {
    font-size: 0.75rem;
    color: #adb5bd;
    margin-top: 2px;
}

.delete-chat-btn {
    color: #adb5bd;
    background: none;
    border: none;
    padding: 5px 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 --- */
.code-generating-box {
    background-color: #f8f9fa;
    border: 1px dashed #ced4da;
    border-radius: 5px;
    padding: 12px 15px;
    margin: 10px 0;
    color: #495057;
    font-family: monospace;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
    0% {
        border-color: #ced4da;
    }

    50% {
        border-color: var(--user-bg);
    }

    100% {
        border-color: #ced4da;
    }
}