/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: radial-gradient(1200px 600px at 10% -10%, rgba(239, 68, 68, 0.15), transparent 40%), linear-gradient(135deg, #0f0f12 0%, #1a1a1f 100%);
    min-height: 100vh;
    color: #e5e7eb;
}

.app {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.cabecalho {
    background: rgba(17, 17, 19, 0.65);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.conteudo-cabecalho h1 {
    font-size: 2rem;
    font-weight: 700;
    color: #e5e7eb;
    margin-bottom: 8px;
}

.conteudo-cabecalho p {
    color: #9ca3af;
    font-size: 1rem;
}

.indicador-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(24, 24, 27, 0.6);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.bolinha-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    animation: pulse 2s infinite;
}

.bolinha-status.connected { background: #10b981; }

.texto-status {
    font-size: 0.875rem;
    font-weight: 500;
    color: #e5e7eb;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Main content */
.conteudo-principal {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 20px;
    flex: 1;
}

/* Chat container */
.caixa-conversa {
    background: rgba(17, 17, 19, 0.65);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.lista-mensagens {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    max-height: 600px;
    min-height: 400px;
}

.mensagem-boasvindas {
    text-align: center;
    padding: 40px 20px;
    color: #9ca3af;
}

.mensagem-boasvindas h3 {
    font-size: 1.5rem;
    color: #e5e7eb;
    margin-bottom: 8px;
}

.message {
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.06);
    color: #e5e7eb;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.message.user .message-avatar { background: rgba(255, 255, 255, 0.06); color: #e5e7eb; }

.message.ai .message-avatar { background: rgba(239, 68, 68, 0.15); color: #ef4444; border-color: rgba(239, 68, 68, 0.5); }

.message-content {
    max-width: 70%;
    padding: 16px 20px;
    border-radius: 18px;
    position: relative;
}

.message.user .message-content {
    background: linear-gradient(180deg, rgba(239, 68, 68, 0.16), rgba(239, 68, 68, 0.10));
    color: #f3f4f6;
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-bottom-right-radius: 6px;
}

.message.ai .message-content {
    background: rgba(10, 10, 12, 0.7);
    color: #e5e7eb;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom-left-radius: 6px;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-top: 4px;
}

/* Markdown-friendly styles for dark theme */
.message-content h1, .message-content h2, .message-content h3,
.message-content h4, .message-content h5, .message-content h6 {
    color: #e5e7eb;
}
.message-content a { color: #f87171; text-decoration: underline; }
.message-content a:hover { color: #ef4444; }
.message-content hr { border: none; border-top: 1px solid #27272a; margin: 12px 0; }
.message-content pre {
    background: #0b0d12;
    color: #e5e7eb;
    border: 1px solid #1f2937;
    padding: 12px;
    border-radius: 10px;
    overflow: auto;
}
.message-content code {
    background: #0b0d12;
    color: #fca5a5;
    border: 1px solid #1f2937;
    padding: 2px 6px;
    border-radius: 6px;
}
.message-content blockquote {
    border-left: 3px solid #ef4444;
    margin: 8px 0;
    padding-left: 10px;
    color: #d1d5db;
}
.message-content ul, .message-content ol { margin-left: 20px; }

/* Typing indicator inside chat */
.message.ai.typing .message-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.typing-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #a0aec0; /* neutral on dark */
    opacity: 0.6;
    animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dots .dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dots .dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    40% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* Input container */
.caixa-entrada {
    padding: 20px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(17, 17, 19, 0.65);
}

.linha-entrada {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#messageInput {
    flex: 1;
    border: 2px solid #3f3f46;
    border-radius: 12px;
    padding: 12px 16px;
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    min-height: 48px;
    max-height: 120px;
    transition: all 0.2s ease;
    background: #0b0d12;
    color: #e5e7eb;
}

#messageInput:focus {
    outline: none;
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.botao-enviar {
    min-width: 48px;
    height: 48px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0 14px;
}

.botao-enviar:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.botao-enviar:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.info-entrada {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.75rem;
    color: #9ca3af;
}

/* Sidebar */
.lateral {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.painel-ajustes,
.painel-estatisticas,
.painel-acoes {
    background: rgba(17, 17, 19, 0.65);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.painel-ajustes h3,
.painel-estatisticas h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #e5e7eb;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.grupo-ajuste {
    margin-bottom: 16px;
}

.grupo-ajuste label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #e5e7eb;
    margin-bottom: 6px;
}

.grupo-ajuste input {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #3f3f46;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: border-color 0.2s ease;
    background: #0b0d12;
    color: #e5e7eb;
}

.grupo-ajuste input:focus {
    outline: none;
    border-color: #ef4444;
}

.grupo-ajuste input[type="range"] {
    padding: 0;
}

.valor-faixa {
    font-size: 0.875rem;
    color: #f87171;
    font-weight: 500;
    margin-left: 8px;
}

.botao-testar,
.botao-acao {
    width: 100%;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.botao-testar {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    margin-top: 8px;
}

.botao-testar:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.botao-acao {
    background: #0b0d12;
    color: #e5e7eb;
    border: 1px solid #27272a;
    margin-bottom: 8px;
}

.botao-acao:hover {
    background: #111315;
    border-color: #3f3f46;
}

.botao-acao:last-child {
    margin-bottom: 0;
}

/* Stats panel */
.item-estatistica {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #27272a;
}

.item-estatistica:last-child {
    border-bottom: none;
}

.rotulo-estatistica {
    font-size: 0.875rem;
    color: #9ca3af;
}

.valor-estatistica {
    font-size: 0.875rem;
    font-weight: 600;
    color: #e5e7eb;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    background: white;
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.loading-spinner p {
    color: #4a5568;
    font-weight: 500;
}

/* Responsive design */
@media (max-width: 1024px) {
    .conteudo-principal {
        grid-template-columns: 1fr;
    }
    
    .lateral {
        order: -1;
    }
}

@media (max-width: 768px) {
    .app {
        padding: 10px;
    }
    
    .cabecalho {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .conteudo-cabecalho h1 {
        font-size: 1.5rem;
    }
    
    .lista-mensagens {
        max-height: 400px;
        min-height: 300px;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .lateral {
        flex-direction: row;
        overflow-x: auto;
        gap: 16px;
    }
    
    .painel-ajustes,
    .painel-estatisticas,
    .painel-acoes {
        min-width: 280px;
        flex-shrink: 0;
    }
}

/* Scrollbar styling */
.lista-mensagens::-webkit-scrollbar {
    width: 6px;
}

.lista-mensagens::-webkit-scrollbar-track {
    background: #111827;
    border-radius: 3px;
}

.lista-mensagens::-webkit-scrollbar-thumb {
    background: #374151;
    border-radius: 3px;
}

.lista-mensagens::-webkit-scrollbar-thumb:hover {
    background: #4b5563;
}
