* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* === TEMAS === */
.tema-claro {
    background-color: #f8f9fa;
    color: #212529;
}

.tema-escuro {
    background-color: #1a1a1a;
    color: #e9ecef;
}

/* === LAYOUT PRINCIPAL === */
.chat-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 20px 20px 270px;
    transition: padding-left 0.3s ease;
    min-height: 100vh;
    width: 100%;
}

/* === SIDEBAR DE HISTÓRICO === */
.sidebar-container {
    position: fixed;
    left: 20px;
    top: 20px;
    width: 250px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

#toggle-historico {
    background: linear-gradient(135deg, #5c67f2, #4a53c6);
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(92, 103, 242, 0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#toggle-historico:hover {
    background: linear-gradient(135deg, #4a53c6, #3a429a);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(92, 103, 242, 0.4);
}

#toggle-historico::after {
    content: "☰";
    font-size: 1.2em;
}

#historico-sidebar {
    display: none;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    padding: 16px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    animation: slideIn 0.3s ease-out;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.tema-escuro #historico-sidebar {
    background-color: #2a2a3a;
    border: 1px solid #444;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* === LISTA DE HISTÓRICO === */
#lista-historico {
    list-style: none;
    margin-top: 10px;
}

#lista-historico li {
    padding: 12px 14px;
    margin: 6px 0;
    background-color: #f8f9fa;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.92rem;
    border-left: 3px solid transparent;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#lista-historico li:hover {
    background-color: #e9ecef;
    border-left-color: #5c67f2;
    transform: translateX(2px);
}

.tema-escuro #lista-historico li {
    background-color: #3a3a4a;
    color: #e0e0e0;
}

.tema-escuro #lista-historico li:hover {
    background-color: #4a4a5a;
    border-left-color: #7b6df2;
}

/* === BOTÃO NOVA CONVERSA === */
#btn-nova-conversa {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 15px;
    background: linear-gradient(135deg, #5c67f2, #4a53c6);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(92, 103, 242, 0.3);
}

#btn-nova-conversa:hover {
    background: linear-gradient(135deg, #4a53c6, #3a429a);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(92, 103, 242, 0.4);
}

#historico-sidebar > button:hover {
    background: linear-gradient(135deg, #4a53c6, #3a429a);
    transform: translateY(-1px);
}

/* === HEADER === */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

.tema-escuro header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

h1 {
    font-size: 1.875rem;
    font-weight: 700;
    background: linear-gradient(135deg, #5c67f2, #7b6df2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tema-escuro h1 {
    background: linear-gradient(135deg, #7b6df2, #9b8df2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-buttons {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

/* === BOTÕES DO HEADER === */
.header-buttons .btn {
    background: linear-gradient(135deg, #17a2b8, #138496);
    color: white;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(108, 117, 125, 0.3);
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    white-space: nowrap;
}

.header-buttons .btn:hover {
    background: linear-gradient(135deg, #138496, #117a8b);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.4);
}

.header-buttons .btn-relatorio {
    background: linear-gradient(135deg, #17a2b8, #138496);
}

.header-buttons .btn-relatorio:hover {
    background: linear-gradient(135deg, #138496, #117a8b);
}

#tema-btn {
    background: linear-gradient(135deg, #5c67f2, #4a53c6);
    color: white;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(92, 103, 242, 0.3);
}

#tema-btn:hover {
    background: linear-gradient(135deg, #4a53c6, #3a429a);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(92, 103, 242, 0.4);
}

.logout-btn {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
}

.logout-btn:hover {
    background: linear-gradient(135deg, #c82333, #bd2130);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
}

/* === ÁREA DO CHAT === */
#chat-box {
    flex: 1;
    padding: 20px;
    border-radius: 12px;
    overflow-y: auto;
    overflow-x: hidden;
    margin-bottom: 20px;
    background-color: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    scrollbar-width: thin;
    scrollbar-color: #5c67f2 transparent;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

#chat-box::-webkit-scrollbar {
    width: 6px;
}

#chat-box::-webkit-scrollbar-track {
    background: transparent;
}

#chat-box::-webkit-scrollbar-thumb {
    background: #5c67f2;
    border-radius: 3px;
}

.tema-escuro #chat-box {
    background-color: rgba(42, 42, 58, 0.6);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.2);
}

/* === BALÕES DE CONVERSA MELHORADOS === */
.mensagem {
    margin-bottom: 16px;
    padding: 14px 18px;
    border-radius: 18px;
    max-width: 70%;
    word-wrap: break-word;
    line-height: 1.5;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.3s ease;
}

.mensagem.usuario {
    background: linear-gradient(135deg, #5c67f2, #4a53c6);
    color: white;
    margin-left: auto;
    margin-right: 0;
    border-bottom-right-radius: 6px;
}

.mensagem.bot {
    background-color: #ffffff;
    color: #2d3748;
    margin-left: 0;
    margin-right: auto;
    border-bottom-left-radius: 6px;
    border-left: 4px solid #48bb78;
}

.tema-escuro .mensagem.bot {
    background-color: #2d3748;
    color: #e2e8f0;
    border-left-color: #68d391;
}

.mensagem-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.85rem;
    opacity: 0.8;
}

.mensagem-tempo {
    font-size: 0.75rem;
}

.mensagem-conteudo {
    font-size: 1rem;
    line-height: 1.5;
}

/* Mensagem de boas-vindas */
.mensagem-boas-vindas {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 16px;
    margin-bottom: 20px;
}

.mensagem-boas-vindas h3 {
    font-size: 1.5rem;
    margin-bottom: 8px;
    font-weight: 600;
}

.mensagem-boas-vindas p {
    font-size: 1rem;
    opacity: 0.9;
}

/* === LAYOUT DO FOOTER (ÁREA DE MENSAGENS) === */
footer.input-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    width: 100%;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 20px;
}

.input-container {
    display: flex;
    gap: 12px;
    width: 100%;
    align-items: center;
}

input[type="text"] {
    flex: 1;
    padding: 14px 18px;
    border-radius: 12px;
    border: 2px solid #e9ecef;
    font-size: 1rem;
    transition: all 0.3s ease;
    background-color: #ffffff;
    outline: none;
    min-height: 50px;
}

input[type="text"]:focus {
    border-color: #5c67f2;
    box-shadow: 0 0 0 3px rgba(92, 103, 242, 0.1);
}

.tema-escuro input[type="text"] {
    background-color: #2a2a3a;
    border-color: #495057;
    color: #e9ecef;
}

.tema-escuro input[type="text"]:focus {
    border-color: #7b6df2;
    box-shadow: 0 0 0 3px rgba(123, 109, 242, 0.1);
}

#btn-enviar {
    padding: 14px 24px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #5c67f2, #4a53c6);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(92, 103, 242, 0.3);
    min-height: 50px;
    white-space: nowrap;
}

#btn-enviar:hover:not(:disabled) {
    background: linear-gradient(135deg, #4a53c6, #3a429a);
    transform: translateY(-2px);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

/* === UPLOAD SECTION - BOTÃO REDUZIDO === */
.file-upload-section {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    justify-content: center;
}

.file-upload-label {
    background: linear-gradient(135deg, #5d4ecb, #7b6df2);
    color: white;
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(93, 78, 203, 0.3);
    font-size: 0.9rem;
    min-height: 40px;
    white-space: nowrap;
}

.file-upload-label:hover {
    background: linear-gradient(135deg, #7b6df2, #9b8df2);
    transform: translateY(-2px);
}

#file-name {
    font-size: 0.85rem;
    color: #6c757d;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 8px 0;
}

.tema-escuro #file-name {
    color: #adb5bd;
}

/* === RESPONSIVIDADE === */
@media (max-width: 768px) {
    .chat-wrapper {
        padding: 15px 15px 15px 15px;
    }
    
    .sidebar-container {
        position: relative;
        left: 0;
        top: 0;
        width: 100%;
        margin-bottom: 15px;
    }
    
    header {
        flex-direction: column;
        text-align: center;
    }
    
    .header-buttons {
        justify-content: center;
    }
    
    footer.input-area {
        padding: 0 10px;
    }
    
    .input-container {
        flex-direction: column;
        gap: 10px;
    }
    
    #btn-enviar {
        width: 100%;
    }
    
    .file-upload-section {
        flex-direction: column;
        gap: 8px;
    }
    
    #file-name {
        max-width: 100%;
        text-align: center;
    }
    
    .header-buttons {
        flex-direction: column;
        gap: 8px;
    }
    
    .header-buttons .btn,
    #tema-btn,
    .logout-btn {
        width: 100%;
        justify-content: center;
    }
}

/* === ANIMAÇÕES === */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Loading dots */
.loading-dots {
    display: inline-flex;
    align-items: center;
}

.dots::after {
    content: '';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* === NOTIFICAÇÕES === */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    padding: 16px 20px;
    border-radius: 12px;
    color: white;
    font-weight: 500;
    max-width: 350px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    animation: slideInRight 0.3s ease-out;
    backdrop-filter: blur(10px);
}

.notification-success { background: linear-gradient(135deg, #28a745, #20c997); }
.notification-error { background: linear-gradient(135deg, #dc3545, #fd7e14); }
.notification-info { background: linear-gradient(135deg, #17a2b8, #6f42c1); }
.notification-warning { background: linear-gradient(135deg, #ffc107, #fd7e14); }

.notification-close {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.8;
}

.notification-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}