﻿* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #DAA520 0%, #B8860B 100%);
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    box-shadow: 0 0 30px rgba(0,0,0,0.3);
    position: relative;
}

/* Pulsante toggle sidebar */
.sidebar-toggle {
    position: absolute;
    top: 25px;
    left: 315px;
    z-index: 1000;
    width: 40px;
    height: 40px;
    background: #34495e;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

    .sidebar-toggle:hover {
        background: #2c3e50;
        transform: scale(1.05);
    }

    .sidebar-toggle.sidebar-hidden {
        left: 20px;
        background: #DAA520;
    }

        .sidebar-toggle.sidebar-hidden:hover {
            background: #B8860B;
        }

/* Sidebar cronologia */
.sidebar {
    width: 300px;
    background: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
    border-right: 3px solid #34495e;
    transition: all 0.3s ease;
    transform: translateX(0);
}

    .sidebar.hidden {
        transform: translateX(-100%);
        width: 0;
        min-width: 0;
        overflow: hidden;
    }

.sidebar-header {
    padding: 20px;
    background: #34495e;
    border-bottom: 1px solid #4a5f7a;
}

    .sidebar-header h2 {
        font-size: 18px;
        margin-bottom: 15px;
        color: #ecf0f1;
    }

.sidebar-controls {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: #3498db;
    color: white;
}

    .btn-primary:hover {
        background: #2980b9;
        transform: translateY(-1px);
    }

.btn-danger {
    background: #e74c3c;
    color: white;
}

    .btn-danger:hover {
        background: #c0392b;
        transform: translateY(-1px);
    }

.btn-settings {
    background: #f39c12;
    color: white;
}

    .btn-settings:hover {
        background: #e67e22;
    }

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.chat-item {
    padding: 12px;
    margin: 5px 0;
    background: #34495e;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
    position: relative;
}

    .chat-item:hover {
        background: #4a5f7a;
        border-left-color: #3498db;
        transform: translateX(5px);
    }

    .chat-item.active {
        background: #3498db;
        border-left-color: #2980b9;
    }

    .chat-item.limit-exceeded {
        border-left-color: #e74c3c;
        background: #4a3439;
    }

.chat-item-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    opacity: 0;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.chat-item:hover .chat-item-delete {
    opacity: 1;
}

.chat-item-delete:hover {
    background: #c0392b;
    transform: scale(1.1);
}

.chat-item-title {
    font-weight: 500;
    margin-bottom: 5px;
    font-size: 14px;
}

.chat-item-preview {
    font-size: 12px;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-date {
    font-size: 10px;
    opacity: 0.5;
    margin-top: 5px;
}

.chat-item-tokens {
    font-size: 10px;
    opacity: 0.8;
    margin-top: 2px;
    color: #f39c12;
}

/* Area chat principale */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
}

.chat-header {
    background: #DAA520;
    border-bottom: 2px solid #e9ecef;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding-left: 20px;
    transition: all 0.3s ease;
}

    .chat-header.sidebar-hidden {
        padding-left: 80px;
    }

    .chat-header h1 {
        color: #2c3e50;
        font-size: 24px;
        font-weight: 300;
    }

.token-info {
    display: flex;
    gap: 20px;
    margin-top: 10px;
    font-size: 12px;
}

.token-counter {
    padding: 4px 8px;
    border-radius: 12px;
    background: #e9ecef;
    color: #495057;
}

    .token-counter.warning {
        background: #fff3cd;
        color: #856404;
    }

    .token-counter.danger {
        background: #c82333;
        color: #aaa;
    }

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: linear-gradient(to bottom, #f8f9fa, #e9ecef);
}

.message {
    margin-bottom: 20px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-user {
    display: flex;
    justify-content: flex-end;
}

.message-bot {
    display: flex;
    justify-content: flex-start;
}

.message-content {
    max-width: 70%;
    padding: 15px 20px;
    border-radius: 20px;
    word-wrap: break-word;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: relative;
}

.message-user .message-content {
    background: linear-gradient(135deg, #DAA520, #B8860B);
    color: white;
    border-bottom-right-radius: 5px;
}

.message-bot .message-content {
    background: white;
    color: #2c3e50;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 5px;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

.message-user .message-time {
    color: rgba(255,255,255,0.8);
}

.message-tokens {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 4px;
    text-align: right;
}

.message-user .message-tokens {
    color: rgba(255,255,255,0.7);
}

.message-error {
    background: #f8d7da !important;
    color: #721c24 !important;
    border: 1px solid #f5c6cb !important;
    margin-top: 10px;
    font-size: 13px;
    padding: 10px 15px;
    border-radius: 15px;
}

.message-warning {
    background: #fff3cd !important;
    color: #856404 !important;
    border: 1px solid #ffeaa7 !important;
    margin-top: 10px;
    font-size: 13px;
    padding: 10px 15px;
    border-radius: 15px;
}

/* Stili per l'empty state e i prompt suggeriti */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #495057;
}

    .empty-state h3 {
        font-size: 24px;
        margin-bottom: 10px;
        color: #495057;
    }

    .empty-state p {
        font-size: 16px;
        line-height: 1.5;
        margin-bottom: 30px;
    }

.suggested-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    max-width: 600px;
    margin: 0 auto;
}

.prompt-suggestion {
    background: linear-gradient(135deg, #DAA520, #B8860B);
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    border: none;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.2);
    min-width: 200px;
    text-align: center;
}

    .prompt-suggestion:hover {
        transform: translateY(-2px);
        box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
        background: linear-gradient(135deg, #B8860B, #DAA520);
    }

    .prompt-suggestion:active {
        transform: translateY(0);
    }

/* Area input */
.input-area {
    padding: 20px;
    background: white;
    border-top: 2px solid #e9ecef;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

    .input-area.disabled {
        opacity: 0.6;
        pointer-events: none;
    }

.input-container {
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

.input-wrapper {
    flex: 1;
    position: relative;
}

#messageInput {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    font-size: 16px;
    resize: none;
    min-height: 50px;
    max-height: 120px;
    font-family: inherit;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

    #messageInput:focus {
        outline: none;
        border-color: #DAA520;
        background: white;
        box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    }

    #messageInput.warning {
        border-color: #ffc107;
    }

    #messageInput.error {
        border-color: #dc3545;
    }

.character-counter {
    position: absolute;
    font-size: 11px;
    opacity: 0.6;
}

    .character-counter.warning {
        color: #ffc107;
        opacity: 1;
    }

    .character-counter.error {
        color: #dc3545;
        opacity: 1;
        font-weight: bold;
    }

.file-upload {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.file-input-wrapper {
    position: relative;
    display: inline-block;
    cursor: pointer;
}

.file-input {
    position: absolute;
    left: -9999px;
}

.file-input-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 20px;
    color: #6c757d;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

    .file-input-label:hover {
        border-color: #DAA520;
        color: #DAA520;
        background: rgba(102, 126, 234, 0.05);
    }

.file-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #e9ecef;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    color: #495057;
}

.file-item-remove {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

    .file-item-remove:hover {
        background: #c82333;
    }

.loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 20px;
    background: white;
    border-radius: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.loading-dots {
    display: flex;
    gap: 4px;
}

.loading-dot {
    width: 8px;
    height: 8px;
    background: #DAA520;
    border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite both;
}

    .loading-dot:nth-child(1) {
        animation-delay: -0.32s;
    }

    .loading-dot:nth-child(2) {
        animation-delay: -0.16s;
    }

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

.streaming-response {
    position: relative;
}

    .streaming-response::after {
        content: '▋';
        color: #DAA520;
        animation: blink 1s infinite;
        margin-left: 2px;
    }

@keyframes blink {
    0%, 50% {
        opacity: 1;
    }

    51%, 100% {
        opacity: 0;
    }
}

.message-bot .message-content:has(.streaming-response) {
    border-left: 3px solid #DAA520;
}

/* Modal per le impostazioni */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    overflow-y: auto;
    padding: 20px 0;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    position: relative;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

    .modal-header h2 {
        color: #2c3e50;
        margin: 0;
    }

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

    .close:hover {
        color: #000;
    }

.setting-group {
    margin-bottom: 20px;
}

    .setting-group label {
        display: block;
        margin-bottom: 5px;
        font-weight: 500;
        color: #2c3e50;
    }

    .setting-group input {
        width: 100%;
        padding: 10px;
        border: 2px solid #e9ecef;
        border-radius: 8px;
        font-size: 14px;
    }

        .setting-group input:focus {
            outline: none;
            border-color: #DAA520;
        }

.setting-description {
    font-size: 12px;
    color: #6c757d;
    margin-top: 5px;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 999;
        transform: translateY(-100%);
    }

        .sidebar.hidden {
            transform: translateY(-100%);
        }

        .sidebar:not(.hidden) {
            transform: translateY(0);
        }

    .chat-area {
        height: 100vh;
        padding-top: 0;
    }

    .chat-header {
        padding-left: 80px;
    }

    .sidebar-toggle {
        position: fixed;
        top: 20px;
        right: 0px;
    }

    .suggested-prompts {
        flex-direction: column;
        align-items: center;
    }

    .prompt-suggestion {
        min-width: 280px;
    }
}

.voice-controls {
    display: flex;
    gap: 10px;
}

    .voice-controls button {
        background: #f8f9fa;
        border: 1px solid #ccc;
        border-radius: 6px;
        padding: 2px 2px;
        cursor: pointer;
        font-size: 14px;
    }
.highlight-message {
    animation: highlight-fade 3s ease-in-out;
    border-left: 4px solid #ffc107 !important;
}

@keyframes highlight-fade {
    0% {
        background-color: rgba(255, 193, 7, 0.3);
    }

    50% {
        background-color: rgba(255, 193, 7, 0.2);
    }

    100% {
        background-color: transparent;
    }
}