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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #ffffff;
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    line-height: 1.6;
    display: flex;
}

/* Sidebar Lateral */
.sidebar {
    width: 260px;
    height: 100vh;
    background: #F9FAFB;
    border-right: 1px solid #E5E7EB;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #E5E7EB;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-logo {
    width: 32px;
    height: 32px;
    background: #2563EB;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.875rem;
}

/* Ocultar elementos até serem carregados pelo JavaScript */
#sidebarTitle:empty,
#disclaimerAgentName:empty,
#assistantName:empty,
#welcomeMessage:empty {
    opacity: 0;
    min-height: 1.2em;
}

#sidebarTitle:not(:empty),
#disclaimerAgentName:not(:empty),
#assistantName:not(:empty),
#welcomeMessage:not(:empty) {
    opacity: 1;
    transition: opacity 0.2s ease-in;
}

.sidebar-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1F2937;
    flex: 1;
}


.sidebar-new-chat {
    margin: 0.5rem;
    padding: 0.75rem 1rem;
    background: #ffffff;
    border: 1px solid #E5E7EB;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
    color: #1F2937;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.sidebar-new-chat:hover {
    background: #F3F4F6;
    border-color: #D1D5DB;
}

.sidebar-history {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.sidebar-history-title {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.2s;
}

.sidebar-history-title:hover {
    color: #2563EB;
    background: #f8fafc;
}

.sidebar-history-item {
    padding: 0.75rem;
    margin: 0.25rem 0;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: #374151;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s;
    word-break: break-word;
}

.sidebar-history-item-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.sidebar-history-item-content span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-delete-btn {
    background: transparent;
    border: none;
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: all 0.2s;
    opacity: 0;
    flex-shrink: 0;
}

.sidebar-history-item:hover .sidebar-delete-btn {
    opacity: 0.6;
}

.sidebar-delete-btn:hover {
    opacity: 1 !important;
    background: #fee2e2;
    transform: scale(1.1);
}

.sidebar-delete-btn:active {
    transform: scale(0.95);
}

.sidebar-history-item:hover {
    background: #F3F4F6;
}

.sidebar-history-item.active {
    background: #EFF6FF;
    color: #2563EB;
}

.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid #E5E7EB;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-shrink: 0;
    background: #F9FAFB;
}

.sidebar-footer-item {
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s;
    background: none;
    border: none;
    text-align: left;
    width: 100%;
}

.sidebar-footer-item:hover {
    background: #F3F4F6;
}

/* Área de Chat */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: #ffffff;
    position: relative;
}

.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: #ffffff;
    border: 1px solid #E5E7EB;
    border-radius: 0.5rem;
    padding: 0.5rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
}

.mobile-menu-btn:hover {
    background: #F9FAFB;
}

.mobile-menu-btn svg {
    width: 20px;
    height: 20px;
    stroke: #374151;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-messages.empty-state {
    justify-content: center;
    align-items: center;
    text-align: center;
}

.empty-state-content {
    max-width: 600px;
    padding: 2rem;
}

.empty-state-logo {
    width: 64px;
    height: 64px;
    background: #2563EB;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.5rem;
    margin: 0 auto 1.5rem;
}

.empty-state-greeting {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1F2937;
    margin-bottom: 2rem;
}

.suggestion-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.suggestion-card {
    padding: 1.25rem;
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.suggestion-card:hover {
    background: #F3F4F6;
    border-color: #D1D5DB;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.suggestion-card-title {
    font-weight: 600;
    color: #1F2937;
    margin-bottom: 0.5rem;
    font-size: 0.9375rem;
}

.suggestion-card-description {
    font-size: 0.8125rem;
    color: #6B7280;
}

.message {
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;
    max-width: 85%;
    animation: slideIn 0.3s ease;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.6;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bot-message {
    background: #F3F4F6;
    color: #1F2937;
    margin-right: auto;
    align-self: flex-start;
}

.user-message {
    background: #2563EB;
    color: #ffffff;
    margin-left: auto;
    align-self: flex-end;
}

/* Input Fixo na Parte Inferior */
.chat-input-container {
    position: sticky;
    bottom: 0;
    background: #ffffff;
    border-top: 1px solid #E5E7EB;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    z-index: 10;
}

.chat-input-wrapper {
    width: 100%;
    max-width: 768px;
    position: relative;
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid #D1D5DB;
    border-radius: 1.5rem;
    padding: 0.75rem 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.2s;
}

.chat-input-wrapper:focus-within {
    border-color: #2563EB;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.chat-input-icon {
    color: #6B7280;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    transition: color 0.2s;
}

.chat-input-icon:hover {
    color: #374151;
}

.chat-input-wrapper input,
.chat-input-wrapper textarea {
    flex: 1;
    border: none;
    outline: none;
    padding: 0.5rem 0.75rem;
    font-size: 0.9375rem;
    color: #1F2937;
    background: transparent;
    resize: none;
    overflow-y: auto;
    max-height: 200px;
    min-height: 44px;
    font-family: inherit;
    line-height: 1.5;
}

.chat-input-wrapper input::placeholder,
.chat-input-wrapper textarea::placeholder {
    color: #9CA3AF;
}

/* Estilo para textarea desabilitado (aguardando resposta) */
.chat-input-wrapper textarea:disabled,
.chat-input-wrapper textarea.waiting-response {
    background-color: #F9FAFB;
    cursor: not-allowed;
    opacity: 0.7;
}

.chat-input-send {
    background: #2563EB;
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}

.chat-input-send:hover {
    background: #1E40AF;
}

.chat-input-send:disabled {
    background: #D1D5DB;
    cursor: not-allowed;
}

/* Estilo para botão em modo cancelar */
.chat-input-send.cancel-mode {
    background: #DC2626;
    width: auto;
    min-width: 80px;
    padding: 0 0.75rem;
}

.chat-input-send.cancel-mode:hover {
    background: #B91C1C;
}

.chat-input-send.cancel-mode span {
    font-size: 0.875rem;
    font-weight: 500;
}

.chat-input-disclaimer {
    font-size: 0.75rem;
    color: #6B7280;
    text-align: center;
    max-width: 768px;
}

.prompt-bubbles {
    display: none;
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2563EB;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsividade Mobile */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: -260px;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height para mobile */
        max-height: 100vh;
        max-height: 100dvh;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }
    
    .sidebar-overlay.open {
        display: block;
    }
    
    .suggestion-cards {
        grid-template-columns: 1fr;
    }
    
    .message {
        max-width: 90%;
    }
    
    .chat-messages {
        padding: 1rem;
        padding-bottom: 220px; /* Aumentado significativamente para evitar corte das mensagens */
        margin-bottom: 0;
    }
    
    .chat-input-container {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 1rem;
        padding-bottom: max(1rem, env(safe-area-inset-bottom)); /* Suporte para safe area no iOS */
        z-index: 100;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    }
    
    .empty-state-content {
        padding: 1rem;
        padding-bottom: 220px; /* Aumentado significativamente para evitar corte */
        padding-top: 2rem; /* Espaço superior para logo e mensagem */
    }
    
    .chat-messages.empty-state {
        justify-content: flex-start; /* Alinhar no topo ao invés de centralizar */
        padding-top: 2rem; /* Espaço superior */
    }
    
    .empty-state-logo {
        width: 56px; /* Ligeiramente menor no mobile */
        height: 56px;
        margin: 0 auto 1rem; /* Reduzir margem inferior */
        font-size: 1.25rem; /* Ajustar tamanho da fonte se for texto */
    }
    
    .empty-state-greeting {
        font-size: 1.125rem; /* Reduzir tamanho da fonte no mobile */
        margin-bottom: 1.5rem; /* Reduzir margem inferior */
    }
    
    .sidebar-header {
        flex-shrink: 0;
    }
    
    .sidebar-new-chat {
        flex-shrink: 0;
    }
    
    .sidebar-history {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .sidebar-footer {
        flex-shrink: 0;
        background: #F9FAFB;
        border-top: 1px solid #E5E7EB;
        padding: 0.75rem;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        min-height: fit-content;
        position: relative;
        z-index: 10;
    }
    
    .sidebar-footer-item {
        flex-shrink: 0;
    }
}

/* Scrollbar personalizado */
.sidebar-history::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.sidebar-history::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-history::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 3px;
}

.sidebar-history::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #9CA3AF;
}

/* Loading spinner para logos */
.sidebar-logo.loading,
.empty-state-logo.loading {
    background: transparent;
    color: transparent;
    position: relative;
}

.sidebar-logo.loading::after,
.empty-state-logo.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid #E5E7EB;
    border-top-color: #2563EB;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.empty-state-logo.loading::after {
    width: 32px;
    height: 32px;
    border-width: 4px;
}

/* Estilos para documentos anexados */
.attached-documents-preview {
    width: 100%;
    max-width: 768px;
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 0.75rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}

.attached-document-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: #ffffff;
    border: 1px solid #E5E7EB;
    border-radius: 0.5rem;
    font-size: 0.875rem;
}

.attached-document-item .doc-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.attached-document-item .doc-name {
    flex: 1;
    color: #1F2937;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.attached-document-item .doc-size {
    color: #6B7280;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.attached-document-item .doc-status {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    flex-shrink: 0;
}

.attached-document-item .doc-status.status-pending,
.attached-document-item .doc-status.status-uploading,
.attached-document-item .doc-status.status-processing {
    background: #FEF3C7;
    color: #92400E;
}

.attached-document-item .doc-status.status-completed {
    background: #D1FAE5;
    color: #065F46;
}

.attached-document-item .doc-status.status-stored_only {
    background: #DBEAFE;
    color: #1E40AF;
}

.attached-document-item .doc-status.status-error {
    background: #FEE2E2;
    color: #991B1B;
}

.attached-document-item .doc-remove {
    background: none;
    border: none;
    color: #6B7280;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

.attached-document-item .doc-remove:hover {
    background: #F3F4F6;
    color: #1F2937;
}

