/* ============================================
    PROMPTJA REDESIGN
   ============================================ */

:root {
    /* Palette */
    --ds-bg-primary: #ffffff;
    --ds-bg-secondary: #f7f9fc;
    --ds-bg-sidebar: #f0f4f8;
    --ds-bg-input: #ffffff;
    --ds-bg-message-ai: #f0f7ff;
    --ds-bg-message-user: #e6f7ff;
    --ds-bg-hover: #f0f4f8;
        
    --ds-text-primary: #1a1a1a;
    --ds-text-secondary: #666666;
    --ds-text-muted: #888888;
    --ds-text-link: #0066cc;
    --ds-text-user: #1a1a1a;
    --ds-text-ai: #1a1a1a;
    
    --ds-border-color: #e0e6ed;
    --ds-border-radius: 12px;
    --ds-border-radius-sm: 8px;
    
    --ds-primary: #0066cc;
    --ds-primary-hover: #0052a3;
    --ds-success: #00a854;
    --ds-warning: #ffc107;
    --ds-error: #f5222d;
    --ds-info: #1890ff;
    
    --ds-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --ds-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
    --ds-shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    
    --ds-sidebar-width: 280px;
    --ds-header-height: 64px;
    --ds-input-height: 56px;

    /* ============ NOVAS VARIÁVEIS ============ */
    --ds-modal-backdrop: rgba(0, 0, 0, 0.6);
    --ds-modal-blur: 4px;
    --ds-modal-animation-timing: cubic-bezier(0.18, 0.89, 0.32, 1.28);
    --ds-tap-highlight: rgba(0, 102, 204, 0.1);
    /* ========================================= */

    /* Adicionando variáveis para os modais */
    --ds-border: #e0e6ed;
    --ds-bg-tertiary: #eef2f7;
    --ds-primary-dark: #0052a3;
    --ds-error-light: rgba(245, 34, 45, 0.1);
}

/* Dark Theme */
[data-theme="dark"] {
    --ds-bg-primary: #0f172a;
    --ds-bg-secondary: #1e293b;
    --ds-bg-sidebar: #1e293b;
    --ds-bg-input: #334155;
    --ds-bg-message-ai: rgba(30, 41, 59, 0.7);
    --ds-bg-message-user: rgba(30, 58, 138, 0.3);
    --ds-bg-hover: rgba(255, 255, 255, 0.05);

    --ds-modal-backdrop: rgba(0, 0, 0, 0.8);
    --ds-tap-highlight: rgba(96, 165, 250, 0.2);
    --ds-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --ds-shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
    
    --ds-text-primary: #f1f5f9;
    --ds-text-secondary: #cbd5e1;
    --ds-text-muted: #94a3b8;
    --ds-text-link: #60a5fa;
    --ds-text-user: #f1f5f9;
    --ds-text-ai: #f1f5f9;
    
    --ds-border-color: #334155;
    --ds-primary: #60a5fa;
    --ds-primary-hover: #3b82f6;
    --ds-error: #f87171;

    /* Dark theme para modais */
    --ds-border: #334155;
    --ds-bg-tertiary: #2d3748;
    --ds-primary-dark: #3b82f6;
    --ds-error-light: rgba(248, 113, 113, 0.1);

     .message-text {
        font-weight: 400;
        letter-spacing: 0.01em;
        text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
    }
    
    .message-text a {
        color: #93c5fd;
    }
    
    .message-text a:hover {
        color: #60a5fa;
        text-decoration: underline;
    }
    /* ======================================================== */
}

.message-text {
    font-weight: 400;
    letter-spacing: 0.01em;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

.message-text a {
    color: #93c5fd;
}

.message-text a:hover {
    color: #60a5fa;
    text-decoration: underline;
}


/* Reset e Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: var(--ds-bg-primary);
    color: var(--ds-text-primary);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

/* Container Principal */
.container {
    display: flex;
    height: 100vh;
    min-height: 100vh;
}

/* ============================================
   SIDEBAR 
   ============================================ */
.sidebar {
    width: var(--ds-sidebar-width);
    background: var(--ds-bg-sidebar);
    border-right: 1px solid var(--ds-border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative !important;
    z-index: 10;
    flex-shrink: 0; /* Importante para redimensionamento */
    min-width: 220px; /* Mínimo */
    max-width: 450px; /* Máximo */
}

.sidebar-top {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.sidebar-header {
    padding: 16px 12px;
    border-bottom: 1px solid var(--ds-border-color);
    margin-bottom: 16px;
}

/* ============================================
   BRAND HEADER (NOVO TOPO)
   ============================================ */

.brand-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 12px 20px;
}

.brand-icon {
    width: 44px;
    height: 44px;
    border-radius: 0px;
    background: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    flex-shrink: 0;
}

.brand-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: none;
    border-radius: 0;
    
}

.brand-icon i {
    color: #ffffff;
    font-size: 20px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-title {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    background: transparent !important;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.brand-subtitle {
    margin-top: 4px;
    font-size: 12px;
    color: var(--ds-text-muted);
    font-weight: 500;
}


/* Botão Nova Conversa -  */
.btn-new-chat {
    width: 100%;
    padding: 5px 16px;
    background: var(--ds-primary);
    color: white;
    border: none;
    border-radius: var(--ds-border-radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    margin-bottom: 24px;
    box-shadow: var(--ds-shadow-sm);
}

.btn-new-chat:hover {
    background: var(--ds-primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--ds-shadow-md);
}

.btn-new-chat:active {
    transform: translateY(0);
}

.btn-new-chat:active,
.send-btn:active,
.clear-chat-btn:active,
.footer-btn:active,
.promptja-modal-btn:active,
.chat-item:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
}

.btn-new-chat i {
    font-size: 16px;
}

/* Lista de Conversas */
.chat-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.section-title {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--ds-text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    font-weight: 600;
    padding: 0 4px;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--ds-border-radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--ds-text-secondary);
    font-size: 14px;
    border: 1px solid transparent;
}

.chat-item:hover {
    background: var(--ds-bg-hover);
    border-color: var(--ds-border-color);
}

.chat-item.active {
    background: var(--ds-bg-message-user);
    color: var(--ds-text-primary);
    border-color: var(--ds-primary);
    font-weight: 500;
}

.chat-item i {
    font-size: 14px;
    width: 16px;
    color: var(--ds-text-muted);
}

.chat-item.active i {
    color: var(--ds-primary);
}

/* Rodapé da Sidebar */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--ds-border-color);
    background: var(--ds-bg-sidebar);
}

.footer-btn {
    width: 100%;
    padding: 12px;
    margin-bottom: 8px;
    background: transparent;
    border: 1px solid var(--ds-border-color);
    border-radius: var(--ds-border-radius-sm);
    color: var(--ds-text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    transition: all 0.2s ease;
}

.footer-btn:hover {
    background: var(--ds-bg-hover);
    border-color: var(--ds-primary);
    color: var(--ds-text-primary);
}

#logoutBtn {
    color: var(--ds-error);
    border-color: rgba(245, 34, 45, 0.2);
}

#logoutBtn:hover {
    background: rgba(245, 34, 45, 0.1);
    border-color: var(--ds-error);
}

/* Botão Tema */
#themeToggle {
    border: none;
    background: transparent;
    color: var(--ds-text-secondary);
    justify-content: center;
    margin-top: 8px;
}

#themeToggle:hover {
    background: transparent;
    border: none;
    color: var(--ds-primary);
}

.theme-icon-dark,
.theme-icon-light {
    transition: all 0.3s ease;
}

[data-theme="dark"] .theme-icon-dark {
    display: none;
}

[data-theme="dark"] .theme-icon-light {
    display: inline-block;
    color: #ffca28;
}

.theme-icon-light {
    display: none;
}

[data-theme="dark"] .theme-icon-light {
    display: inline-block;
}

/* ============================================
   MAIN CONTENT 
   ============================================ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--ds-bg-primary);
    position: relative;
}

/* Cabeçalho do Chat */
.chat-header {
    height: var(--ds-header-height);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--ds-border-color);
    background: var(--ds-bg-primary);
    position: sticky;
    top: 0;
    z-index: 5;
}

.header-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.header-info h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--ds-text-primary);
}

.header-info p {
    font-size: 13px;
    color: var(--ds-text-muted);
}

/* Container das Mensagens */
.chat-container {
    flex: 1;
    padding: 16px 20px; /* Padding reduzido nas laterais */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px; /* Espaço entre mensagens reduzido */
    scroll-behavior: smooth;
    position: relative;
    -webkit-overflow-scrolling: touch;
    min-height: 0; /* Importante para flex funcionar bem */
}

/* Indicador de scroll */
.chat-container::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(transparent, var(--ds-bg-primary));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 1;
}

.chat-container.scrolled::after {
    opacity: 1;
}

/* Estilo das Mensagens */
.message {
    display: flex;
    gap: 16px;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    animation: messageAppear 0.3s ease-out;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Avatar das Mensagens */
.message .avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: white;
}

.ai-message .avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.user-message .avatar {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

/* Conteúdo das Mensagens */
.message-content {
    flex: 1;
    min-width: 0;
}

.message-text {
    padding: 16px 20px;
    border-radius: var(--ds-border-radius);
    font-size: 15px;
    line-height: 1.7;
    word-wrap: break-word;
    white-space: pre-wrap;
    
}

/* Mensagem da IA */
.ai-message .message-text {
    background: var(--ds-bg-message-ai);
    color: var(--ds-text-ai);
    border: 1px solid rgba(102, 126, 234, 0.1);
    border-top-left-radius: 4px;
}

/* Mensagem do Usuário */
.user-message {
    flex-direction: row-reverse;
}

.user-message .avatar {
    order: 1;
}

.user-message .message-content {
    order: 0;
}

.user-message .message-text {
    background: var(--ds-bg-message-user);
    color: var(--ds-text-user);
    border: 1px solid rgba(0, 102, 204, 0.1);
    border-top-right-radius: 4px;
}

/* Estilo para texto de carregamento */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ds-text-muted);
    animation: typingAnimation 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingAnimation {
    0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* ============================================
   INPUT AREA 
   ============================================ */
.input-area {
    padding: 12px 20px 8px 20px; /* Reduzido o padding */
    border-top: 1px solid var(--ds-border-color);
    background: var(--ds-bg-primary);
    position: sticky;
    bottom: 0;
    z-index: 5;
    flex-shrink: 0; /* Não expandir */
    min-height: auto; /* Altura mínima reduzida */
}

.input-wrapper {
    position: relative;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;

    border: 1.5px solid var(--ds-border-color);
    border-radius: var(--ds-border-radius);
    background: var(--ds-bg-input);
    box-shadow: var(--ds-shadow-sm);
    transition: all 0.3s ease;

    /* 🔴 CORREÇÕES CRÍTICAS */
    display: flex;
    align-items: center;
    overflow: hidden;        /* IMPEDE TEXTO SAIR */
    box-sizing: border-box;

    min-height: 48px;
    max-height: 150px;
}


.input-wrapper:focus-within {
    border-color: var(--ds-primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
    transform: translateY(-1px);
}

textarea#messageInput {
    width: 100%;
    min-height: 46px;
    max-height: 120px;
    padding: 12px 50px 12px 16px;
    border: none;
    background: transparent;
    color: var(--ds-text-primary);
    font-family: inherit;
    font-size: 16px;
    line-height: 1.5;
    resize: none;
    outline: none;

    /* 🔧 CORREÇÃO DO TEXTO SAINDO DA CAIXA */
    white-space: pre-wrap;        /* permite quebra de linha */
    word-break: break-word;       /* quebra palavras longas */
    overflow-wrap: break-word;    /* fallback moderno */
    overflow-x: hidden;           /* impede estouro lateral */

    overflow-y: auto;
}


textarea#messageInput::placeholder {
    color: var(--ds-text-muted);
    font-size: 14px;
}

/* Botão Enviar */
.send-btn {
    position: absolute;
    right: 8px; /* Mais próximo da borda */
    bottom: 8px; /* Mais próximo da borda */
    width: 36px; /* Tamanho reduzido */
    height: 36px; /* Tamanho reduzido */
    border-radius: 8px; /* Menos arredondado */
    background: var(--ds-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.send-btn:hover {
    background: var(--ds-primary-hover);
    transform: scale(1.05);
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn i {
    font-size: 14px; /* Ícone menor */
}

.send-btn:disabled {
    background: var(--ds-text-muted);
    cursor: not-allowed;
    transform: none;
}

/* ============================================
   BOTÃO LIMPAR CHAT
   ============================================ */

.clear-chat-btn {
    background: transparent;
    color: var(--ds-text-muted);
    border: 2px solid var(--ds-border-color);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500; /* Adicionei peso na fonte */
}

.clear-chat-btn:hover {
    background: var(--ds-error);
    color: white;
    border-color: var(--ds-error);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 34, 45, 0.2); /* Adicionei sombra no hover */
}

.clear-chat-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(245, 34, 45, 0.3);
}

.clear-chat-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: transparent;
    color: var(--ds-text-muted);
    border-color: var(--ds-border-color);
    box-shadow: none;
}

/* Ícone com destaque */
.clear-chat-btn i {
    font-size: 14px;
    transition: all 0.2s ease;
}

.clear-chat-btn:hover i {
    transform: rotate(-10deg); /* Pequena animação no ícone */
}

/* Dark theme adjustments */
[data-theme="dark"] .clear-chat-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--ds-error);
}

/* ============================================
   MODAL MODERNO 
   ============================================ */
.promptja-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--ds-modal-backdrop); /* ALTERADO */
    backdrop-filter: blur(var(--ds-modal-blur)); /* NOVO */
    -webkit-backdrop-filter: blur(var(--ds-modal-blur)); /* NOVO */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

@supports not (backdrop-filter: blur(1px)) {
    .promptja-modal-overlay {
        background: rgba(0, 0, 0, 0.7);
    }
}

.promptja-modal {
    background: var(--ds-bg-primary);
    border-radius: 16px;
    padding: 30px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--ds-border);
    animation: slideUp 0.4s var(--ds-modal-animation-timing); /* ALTERADO */
    transform: translateZ(0); /* NOVO */
}

.promptja-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--ds-border);
}

.promptja-modal-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: linear-gradient(135deg, var(--ds-primary), #667eea);
    color: white;
}

.promptja-modal-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--ds-text-primary);
    margin: 0;
}

.promptja-modal-body {
    margin-bottom: 30px;
}

.promptja-modal-text {
    color: var(--ds-text-primary);
    line-height: 1.6;
    margin-bottom: 20px;
}

.promptja-modal-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 25px;
}

.promptja-modal-option {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
    border-radius: 12px;
    border: 2px solid var(--ds-border);
    background: var(--ds-bg-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.promptja-modal-option:hover {
    border-color: var(--ds-primary);
    background: rgba(59, 130, 246, 0.05);
    transform: translateY(-2px);
}

.promptja-modal-option.active {
    border-color: var(--ds-primary);
    background: rgba(59, 130, 246, 0.1);
}

.promptja-modal-option-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    background: var(--ds-bg-tertiary);
    color: var(--ds-text-primary);
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.promptja-modal-option:hover .promptja-modal-option-number {
    background: var(--ds-primary);
    color: white;
}

.promptja-modal-option.active .promptja-modal-option-number {
    background: var(--ds-primary);
    color: white;
}

.promptja-modal-option-content {
    flex: 1;
}

.promptja-modal-option-title {
    font-weight: 600;
    color: var(--ds-text-primary);
    margin-bottom: 4px;
    font-size: 15px;
}

.promptja-modal-option-description {
    font-size: 13px;
    color: var(--ds-text-muted);
    line-height: 1.4;
}

.promptja-modal-option-icon {
    align-self: center;
    color: var(--ds-text-muted);
    font-size: 14px;
    transition: all 0.3s ease;
}

.promptja-modal-option:hover .promptja-modal-option-icon {
    color: var(--ds-primary);
}

.promptja-modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.promptja-modal-btn {
    padding: 12px 28px;
    border-radius: 10px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.promptja-modal-btn-primary {
    background: var(--ds-primary);
    color: white;
}

.promptja-modal-btn-primary:hover {
    background: var(--ds-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
}

.promptja-modal-btn-secondary {
    background: var(--ds-bg-secondary);
    color: var(--ds-text-primary);
    border: 1px solid var(--ds-border);
}

.promptja-modal-btn-secondary:hover {
    background: var(--ds-bg-tertiary);
    transform: translateY(-1px);
}

.promptja-modal-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.promptja-modal-btn:disabled:hover {
    background: var(--ds-primary);
    box-shadow: none;
}

/* Animações para os modais */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.fa-spinner {
    animation: spin 1s linear infinite;
}

/* Responsivo para modais */
@media (max-width: 480px) {
    .promptja-modal {
        padding: 20px;
        margin: 16px;
        width: calc(100% - 32px);
    }

    .promptja-modal-footer {
        flex-direction: column;
    }

    .promptja-modal-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================
   UTILITIES & RESPONSIVE
   ============================================ */
/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--ds-text-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--ds-text-secondary);
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 60vh;
        border-right: none;
        border-bottom: 1px solid var(--ds-border-color);
    }
    
    .sidebar-top {
        max-height: calc(60vh - 120px);
    }
    
    .chat-header {
        padding: 0 16px;
        height: 56px;
    }
    
    .chat-container {
        padding: 16px;
    }
    
    .input-area {
        padding: 16px;
    }
    
    .input-wrapper {
        border-radius: var(--ds-border-radius-sm);
    }
}

/* Loading State */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Code Blocks */
.message-text pre {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    margin: 12px 0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
}

[data-theme="dark"] .message-text pre {
    background: rgba(255, 255, 255, 0.05);
}

.message-text code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
}

[data-theme="dark"] .message-text code {
    background: rgba(255, 255, 255, 0.1);
}

/* Links */
.message-text a {
    color: var(--ds-text-link);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.message-text a:hover {
    border-bottom: 1px solid var(--ds-text-link);
}

/* Lists */
.message-text ul,
.message-text ol {
    margin-left: 20px;
    margin-bottom: 12px;
}

.message-text li {
    margin-bottom: 6px;
}

/* Blockquotes */
.message-text blockquote {
    border-left: 4px solid var(--ds-primary);
    padding-left: 16px;
    margin: 12px 0;
    color: var(--ds-text-secondary);
    font-style: italic;
}

/* Animação para o botão de limpar chat quando desabilitado */
.clear-chat-btn:disabled:hover {
    background: transparent;
    color: var(--ds-text-muted);
    border-color: var(--ds-border-color);
    transform: none;
}

/* ============================================
   MOBILE OPTIMIZATIONS
   ============================================ */

@media (max-width: 768px) {
    /* Container principal */
    .container {
        flex-direction: column;
        height: 100vh;
    }
    
    /* Sidebar otimizada para mobile */
    .sidebar {
        width: 100%;
        height: 60vh;
        max-height: 60vh;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 0 0 20px rgba(0,0,0,0.2);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    /* Botão de menu mobile mais visível */
    .mobile-menu-toggle {
        display: flex !important;
        position: fixed;
        top: 16px;
        left: 16px;
        z-index: 999;
        width: 44px;
        height: 44px;
        border-radius: 12px;
        background: var(--ds-primary);
        color: white;
        align-items: center;
        justify-content: center;
        border: none;
        font-size: 18px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    }
    
    /* Área principal ocupa tela toda */
    .main-content {
        width: 100%;
        height: 100vh;
        padding-top: 0;
    }
    
    /* Cabeçalho otimizado */
    .chat-header {
        height: 70px;
        padding: 0 16px;
        position: sticky;
        top: 0;
        background: var(--ds-bg-primary);
        z-index: 100;
        box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    }
    
    /* Container de mensagens */
    .chat-container {
        padding: 16px;
        padding-bottom: 120px; /* Espaço para input */
        height: calc(100vh - 130px);
    }
    
    /* Mensagens mais compactas */
    .message {
        max-width: 95%;
        margin: 0 auto 16px auto;
    }
    
    .message-text {
        padding: 12px 16px;
        font-size: 15px;
        line-height: 1.5;
    }
    
    /* Área de input fixa na parte inferior */
    .input-area {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 12px 16px;
        background: var(--ds-bg-primary);
        border-top: 1px solid var(--ds-border-color);
        box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
        z-index: 200;
    }
    
    .input-wrapper {
        max-width: 100%;
    }
    
    textarea#messageInput {
        min-height: 50px;
        max-height: 120px;
        padding: 14px 50px 14px 16px;
        font-size: 16px; /* Maior para mobile */
    }
    
    /* Botão enviar maior */
    .send-btn {
        width: 44px;
        height: 44px;
        right: 8px;
        bottom: 8px;
    }
    
    /* Botão de anexo melhor posicionado */
    #attachBtn {
    position: absolute;
    left: 8px; /* Mais próximo da borda */
    bottom: 8px; /* Mais próximo da borda */
    width: 36px; /* Tamanho reduzido */
    height: 36px; /* Tamanho reduzido */
    border-radius: 8px;
    background: transparent;
    color: var(--ds-text-muted);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 16px;
}

#attachBtn:hover {
    color: var(--ds-primary);
    background: var(--ds-bg-secondary);
}

/* Preview de arquivo */
.file-preview {
    padding: 4px 10px; /* Padding reduzido */
    font-size: 11px; /* Fonte menor */
    color: var(--ds-primary);
    background: var(--ds-bg-secondary);
    border-radius: 4px;
    margin-top: 4px;
    margin-bottom: 4px;
    display: none;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-preview i {
    margin-right: 4px;
    font-size: 10px;
}
    
    /* Avatar menor */
    .message .avatar {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    
    /* Esconder elementos não essenciais em mobile */
    .header-actions,
    .status-indicator {
        display: none;
    }
    
    /* Botão limpar chat mais visível */
    .clear-chat-btn {
        width: 100%;
        justify-content: center;
        padding: 12px;
        font-size: 14px;
    }
    
    /* Contador de caracteres menor */
    .input-area > div:last-child {
    margin-top: 6px; /* Margem reduzida */
    padding-top: 6px;
    border-top: 1px solid var(--ds-border-color);
    font-size: 10px; /* Fonte menor */
    color: var(--ds-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.version-badge {
    margin-bottom: 4px; /* Reduzido de 8px */
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
}


.version-badge span {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}


#versionSelect {
    background: var(--ds-bg-sidebar);
    border: 1px solid var(--ds-border-color);
    border-radius: 4px;
    font-size: 10px; /* Fonte menor */
    padding: 2px 4px;
    cursor: pointer;
    color: var(--ds-primary);
    font-weight: 600;
    height: 20px; /* Altura fixa */
}




}

/* iPhone específico */
@media (max-width: 375px) {
    .chat-container {
        padding: 12px;
    }
    
    .message-text {
        padding: 10px 14px;
        font-size: 14px;
    }
    
    textarea#messageInput {
        font-size: 15px;
        padding: 12px 45px 12px 14px;
    }
}

/* Para telas muito pequenas (smartphones antigos) */
@media (max-width: 320px) {
    .chat-header {
        padding: 0 12px;
    }
    
    .logo-text-gradient {
        font-size: 16px;
    }
    
    .input-area {
        padding: 10px 12px;
    }
}

/* Notificações mobile */
.mobile-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ds-primary);
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    z-index: 9999;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    max-width: 90%;
    text-align: center;
    animation: slideDownMobile 0.3s ease;
}

@keyframes slideDownMobile {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Ícones maiores para mobile */
@media (max-width: 768px) {
    .action-btn i,
    .footer-btn i,
    .chat-item i {
        font-size: 18px !important;
    }
    
    /* Botões com área de toque maior */
    .btn-new-chat,
    .footer-btn,
    .chat-item {
        min-height: 44px; /* Altura mínima para toque */
    }
    
    /* Espaçamento entre itens para evitar toques acidentais */
    .chat-list {
        gap: 8px;
    }
}

/* Adicionar ao seu CSS existente */

/* Responsividade para mobile */
@media (max-width: 768px) {
    .chat-container {
        width: 100%;
        height: 100vh;
        border-radius: 0;
        margin: 0;
        padding: 10px;
    }
    
    .input-field, .send-button {
        height: 50px;
        font-size: 16px; /* Evita zoom no iOS */
    }
    
    /* Botão "Limpar chat" visível */
    .clear-chat-btn {
        display: block !important;
        position: fixed;
        bottom: 80px;
        right: 20px;
        padding: 12px 20px;
        background: #ff4444;
        color: white;
        border-radius: 25px;
        z-index: 1000;
    }
}

/* ============================================
   CORREÇÕES MOBILE ESPECÍFICAS
   ============================================ */

/* Container principal mobile */
@media (max-width: 768px) {
    /* Garantir que sidebar funcione corretamente */
    .sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        width: 85% !important;
        height: 100vh !important;
        max-height: 100vh !important;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1001;
        box-shadow: 2px 0 20px rgba(0,0,0,0.2);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .sidebar.hidden {
        transform: translateX(-100%);
    }
    
    /* Botão de menu mobile */
    .mobile-menu-toggle {
        display: flex !important;
        position: fixed;
        top: 16px;
        left: 16px;
        width: 44px;
        height: 44px;
        background: var(--ds-primary);
        color: white;
        border: none;
        border-radius: 10px;
        align-items: center;
        justify-content: center;
        z-index: 1000;
        font-size: 18px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    }
    
    /* Área principal ocupa tela toda */
    .main-content {
        width: 100%;
        min-height: 100vh;
        padding-top: 0;
    }
    
    /* Cabeçalho fixo */
    .chat-header {
        position: sticky;
        top: 0;
        z-index: 100;
        background: var(--ds-bg-primary);
        padding: 0 16px;
        height: 70px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    }
    
    /* Container de mensagens com espaço para input */
    .chat-container {
        padding: 16px 16px 150px 16px !important;
        min-height: calc(100vh - 180px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* Scroll suave no iOS */
    }
    
    /* Mensagens mais compactas */
    .message {
        max-width: 90%;
        margin: 0 auto 12px auto;
    }
    
    .message-text {
        padding: 12px 14px;
        font-size: 15px;
        line-height: 1.5;
    }
    
    /* Área de input fixa no fundo */
    .input-area {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 12px 16px;
        background: var(--ds-bg-primary);
        border-top: 1px solid var(--ds-border-color);
        box-shadow: 0 -2px 15px rgba(0,0,0,0.1);
        z-index: 100;
    }
    
    .input-wrapper {
        max-width: 100%;
        border-radius: 16px;
        border: 2px solid var(--ds-border-color);
    }
    
    /* Textarea otimizado para mobile */
    textarea#messageInput {
        min-height: 48px;
        max-height: 120px;
        padding: 14px 55px 14px 16px;
        font-size: 16px;
        line-height: 1.4;
    }
    
    /* Botão enviar maior */
    .send-btn {
        width: 46px;
        height: 46px;
        right: 6px;
        bottom: 6px;
        border-radius: 12px;
    }
    
    /* Botão limpar chat - VISÍVEL E ACESSÍVEL */
    .clear-chat-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        padding: 12px 20px;
        background: var(--ds-primary);
        color: white;
        border: none;
        border-radius: 12px;
        font-size: 14px;
        font-weight: 600;
        gap: 8px;
        width: 100%;
        max-width: 200px;
        margin: 0 auto;
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
    }
    
    .clear-chat-btn:hover {
        background: var(--ds-primary-hover);
        transform: translateY(-2px);
    }
    
    .clear-chat-btn .btn-text {
        display: inline;
    }
    
    /* Controles mobile */
    .chat-controls-mobile {
        margin-top: 15px;
        padding: 15px;
        background: var(--ds-bg-secondary);
        border-radius: 12px;
        border: 1px solid var(--ds-border-color);
    }
    
    /* Status indicator mais visível */
    .status-dot.connected {
        width: 10px;
        height: 10px;
        background: #10b981;
        border: 2px solid var(--ds-bg-primary);
        box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
    }
}

/* iPhone específico */
@media (max-width: 375px) {
    .sidebar {
        width: 90% !important;
    }
    
    .message {
        max-width: 95%;
    }
    
    textarea#messageInput {
        font-size: 15px;
        padding: 12px 50px 12px 14px;
    }
    
    .clear-chat-btn {
        padding: 10px 16px;
        font-size: 13px;
    }
}

/* Para telas muito pequenas */
@media (max-width: 320px) {
    .chat-header {
        padding: 0 12px;
    }
    
    .mobile-menu-toggle {
        top: 12px;
        left: 12px;
        width: 40px;
        height: 40px;
    }
    
    .clear-chat-btn .btn-text {
        font-size: 12px;
    }
}

/* Ajuste para safe areas (iPhone X e similares) */
@supports (padding-top: env(safe-area-inset-top)) {
    .input-area {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
    
    .chat-container {
        padding-top: calc(16px + env(safe-area-inset-top));
    }
}

/* Context menu para mobile (toque longo) */
.context-menu {
    position: fixed;
    background: var(--ds-bg-primary);
    border: 1px solid var(--ds-border-color);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    z-index: 9999;
    min-width: 160px;
    overflow: hidden;
}

.menu-item {
    width: 100%;
    padding: 14px 18px;
    background: none;
    border: none;
    text-align: left;
    color: var(--ds-text-primary);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--ds-border-color);
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-item:hover {
    background: var(--ds-bg-secondary);
}

/* Melhorar scroll em mobile */
.chat-container {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Mensagens do sistema (upload, status, etc) */
.system-message .avatar {
    background: linear-gradient(135deg, #10b981, #059669) !important;
}

.system-message .message-text {
    background: var(--ds-bg-secondary);
    border: 1px solid var(--ds-border-color);
    color: var(--ds-text-secondary);
}

/* Adicione ao style.css */

.no-chats-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--ds-text-muted);
    border: 1px dashed var(--ds-border-color);
    border-radius: var(--ds-border-radius);
    margin-top: 20px;
    background: var(--ds-bg-secondary);
}

.no-chats-message i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.no-chats-message p {
    font-size: 16px;
    margin-bottom: 8px;
    font-weight: 500;
}

.no-chats-message small {
    font-size: 13px;
    opacity: 0.7;
}

/* Melhorar visualização dos itens de chat */
.chat-item {
    position: relative;
}

.chat-item small {
    font-size: 11px;
    opacity: 0.7;
    margin-left: 8px;
}

/* Indicador de chat ativo */
.chat-item.active::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 60%;
    background: var(--ds-primary);
    border-radius: 2px;
}

/* Adicione ao style.css */

.welcome-screen {
    max-width: 500px;
    margin: 60px auto;
    padding: 40px;
    text-align: center;
    background: var(--ds-bg-secondary);
    border-radius: var(--ds-border-radius);
    border: 1px solid var(--ds-border-color);
}

.welcome-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    border-radius: 20px;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: white;
}

.welcome-screen h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--ds-text-primary);
}

.welcome-screen p {
    color: var(--ds-text-secondary);
    margin-bottom: 24px;
    font-size: 16px;
}

.btn-login, .btn-new-conversation {
    padding: 14px 28px;
    background: var(--ds-primary);
    color: white;
    border: none;
    border-radius: var(--ds-border-radius-sm);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.btn-login:hover, .btn-new-conversation:hover {
    background: var(--ds-primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--ds-shadow-md);
}

.welcome-actions {
    margin: 30px 0;
}

.welcome-note {
    margin-top: 30px;
    color: var(--ds-text-muted) !important;
    font-size: 14px !important;
}

.welcome-stats {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--ds-border-color);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Melhorar foco para navegação por teclado */
*:focus-visible {
    outline: 2px solid var(--ds-primary);
    outline-offset: 2px;
    border-radius: var(--ds-border-radius-sm);
}

/* Feedback tátil para mobile */
@media (max-width: 768px) {
    button,
    .btn-new-chat,
    .send-btn,
    .mobile-menu-toggle,
    .chat-item,
    .footer-btn {
        -webkit-tap-highlight-color: var(--ds-tap-highlight);
        min-height: 44px; /* Tamanho mínimo para toque */
        min-width: 44px;
    }
}

/* Prevenir zoom automático em iOS */
@media (max-width: 768px) {
    textarea#messageInput,
    input[type="text"],
    input[type="email"],
    input[type="password"] {
        font-size: 16px !important; /* Previne zoom no iOS */
    }
}

/* Otimizar renderização GPU */
.message {
    transform: translateZ(0);
    will-change: transform;
}

.promptja-modal {
    transform: translateZ(0);
}


@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .sidebar-logo-img,
    .message .avatar {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Telas muito altas */
@media (min-height: 1000px) {
    .message-text {
        font-size: 17px;
        line-height: 1.9;
    }
}

/* Fallback para navegadores antigos */
@supports not (display: flex) {
    .container {
        display: block;
    }
    
    .sidebar {
        float: left;
        width: var(--ds-sidebar-width);
    }
    
    .main-content {
        margin-left: var(--ds-sidebar-width);
    }
}

/* Estilo para o modo Construtor v1.3 */
#v13-preview-container {
    transition: all 0.3s ease;
    border-left: 4px solid var(--ds-primary);
}

@media (max-width: 1024px) {
    #v13-preview-container {
    width: 100% !important;
    height: 600px !important; /* Altura fixa maior para não esmagar o app */
    background: #ffffff;
    border-radius: 24px; /* Bordas bem arredondadas estilo iPhone/Moderno */
    border: 8px solid #2d3748; /* Uma moldura que simula um dispositivo */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    position: relative !important;
    margin: 20px 0;
    display: flex;
    flex-direction: column;
}

#v13-iframe-preview {
    width: 100%;
    height: 100%;
    border: none;
    background: #f8fafc; /* Cor de fundo dentro do preview */
}
}

.copy-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--ds-primary);
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    cursor: pointer;
    z-index: 10;
}
.copy-btn:hover { background: var(--ds-primary-hover); }

/* Layout estilo Bolt/Replit */
.v13-container {
    display: none; /* Escondido por padrão */
    grid-template-columns: 350px 1fr;
    height: 100vh;
    width: 100vw;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
    background: white;
}

.v13-active .v13-container {
    display: grid !important;
    visibility: visible !important;
    opacity: 1 !important;
}


.v13-preview {
    background: #1e1e1e; /* Estilo Dark para o editor/preview */
    display: flex;
    flex-direction: column;
    padding: 10px;
}

#v13-iframe-preview {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
    border-radius: 8px;
}


/* ============================================
   CORREÇÃO PARA CONVIVÊNCIA v1.2 e v1.3
   ============================================ */

/* Garantir que container principal sempre mostre quando v1.3 não está ativo */
.container {
    display: flex !important;
}

/* Quando v1.3 está ativo, esconder apenas alguns elementos visuais do v1.2 */
.v13-active .chat-header,
.v13-active .chat-container,
.v13-active .input-area {
    opacity: 0;
    pointer-events: none;
    height: 0;
    overflow: hidden;
    padding: 0;
    border: none;
}

/* Mostrar workspace do v1.3 */
#v13-workspace {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: white;
    z-index: 999999;
    grid-template-columns: 350px 1fr;
}

.v13-active #v13-workspace {
    display: grid !important;
}

/* Sidebar do construtor */
.v13-sidebar {
    display: flex;
    flex-direction: column;
    /* Substituindo o fundo sólido por efeito vidro */
    background: rgba(248, 249, 250, 0.8) !important;
    backdrop-filter: blur(15px) saturate(160%);
    -webkit-backdrop-filter: blur(15px) saturate(160%);
    border-right: 1px solid rgba(0, 0, 0, 0.08) !important;
    height: 100vh;
    position: relative; /* Necessário para o handle de redimensionamento */
}

.v13-header {
    padding: 15px;
    border-bottom: 1px solid #ddd;
    background: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.v13-header-title {
    color: #4f46e5;
    font-size: 16px;
    font-weight: bold;
}

.v13-exit-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}

.v13-exit-btn:hover {
    background: #dc2626;
}

.v13-chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.v13-message-user {
    align-self: flex-end;
    background: #4f46e5;
    color: white;
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.v13-message-ai {
    align-self: flex-start;
    background: white;
    border: 1px solid #e5e7eb;
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.v13-input-area {
    padding: 15px;
    border-top: 1px solid #ddd;
    background: white;
}

.v13-input-wrapper {
    display: flex;
    gap: 10px;
}

#v13-messageInput {
    flex: 1;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
}

#v13-messageInput:focus {
    outline: none;
    border-color: #4f46e5;
}

#v13-create-btn {
    background: #4f46e5;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

#v13-create-btn:hover {
    background: #4338ca;
}

#v13-create-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Preview area */
.v13-preview-area {
    display: flex;
    flex-direction: column;
    background: #1f2937;
}

.v13-preview-header {
    padding: 8px 15px;
    background: #111827;
    color: white;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#v13-iframe-preview {
    flex: 1;
    border: none;
    background: white;
}

#v13-status {
    color: #10b981;
    font-weight: bold;
}

/* Typing indicator */
.v13-typing-indicator {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 12px 16px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    max-width: 100px;
    align-self: flex-start;
}

.v13-typing-dot {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: bounce 1.4s infinite;
}

.v13-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.v13-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

/* Estilos para aplicações geradas */
.app-response {
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.response-content {
    margin-top: 15px;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin: 15px 0;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert-info {
    background: #e8f4fd;
    border: 1px solid #b6e0fe;
    color: #0066cc;
}

.alert i {
    font-size: 18px;
    margin-top: 2px;
}

/* Estilos para código dentro do preview */
.generated-content pre {
    background: #f5f5f5;
    border-radius: 8px;
    padding: 15px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.generated-content code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

/* ============================================
   SISTEMA DE REDIMENSIONAMENTO DO CONSTRUTOR v1.3
   ============================================ */

#v13-workspace {
    display: none;
    grid-template-columns: 350px 1fr;
    height: 100vh;
    width: 100vw;
    position: fixed;
    top: 0;
    left: 0;
    background: var(--ds-bg-primary);
    z-index: 10000;
}

.v13-active #v13-workspace {
    display: grid !important;
}

/* Sidebar do v1.3 com redimensionamento */
.v13-sidebar {
    position: relative;
    background: var(--ds-bg-sidebar);
    border-right: 1px solid var(--ds-border-color);
    height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 250px;
    max-width: 600px;
    width: 350px;
    transition: width 0.1s ease;
    overflow: hidden;
}

/* Handle de redimensionamento ESPECÍFICO para v1.3 */
.v13-resize-handle {
    position: absolute;
    top: 0;
    right: -3px;
    width: 10px; /* Área maior para clicar */
    height: 100%;
    cursor: col-resize;
    z-index: 100000;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

/* Visual do handle (apenas uma linha vertical) */
.v13-resize-handle::before {
    content: '';
    width: 2px;
    height: 40px;
    background: var(--ds-primary);
    border-radius: 1px;
    opacity: 0.5;
    transition: all 0.2s;
}

/* Feedback visual ao passar o mouse */
.v13-resize-handle:hover::before {
    opacity: 1;
    width: 3px;
    background: var(--ds-primary);
}

/* Feedback visual ao clicar */
.v13-resize-handle.active::before {
    opacity: 1;
    width: 4px;
    background: var(--ds-primary);
    box-shadow: 0 0 10px var(--ds-primary);
}

/* Quando estiver redimensionando */
.resizing-active {
    cursor: col-resize !important;
}

.resizing-active * {
    pointer-events: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}

.resizing-active .v13-resize-handle {
    background: rgba(0, 102, 204, 0.1);
}

/* Preview area */
.v13-preview-area {
    display: flex;
    flex-direction: column;
    background: var(--ds-bg-secondary);
    overflow: hidden;
}

.v13-preview-header {
    padding: 12px 20px;
    background: var(--ds-bg-primary);
    border-bottom: 1px solid var(--ds-border-color);
    color: var(--ds-text-primary);
    font-size: 14px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#v13-iframe-preview {
    flex: 1;
    border: none;
    background: white;
}

/* Chat area dentro do v1.3 */
#v13-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.v13-message-user {
    align-self: flex-end;
    background: var(--ds-primary);
    color: white;
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
    box-shadow: var(--ds-shadow-md);
}

.v13-message-ai {
    align-self: flex-start;
    background: var(--ds-bg-secondary);
    border: 1px solid var(--ds-border-color);
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
}

.v13-input-area {
    padding: 20px;
    border-top: 1px solid var(--ds-border-color);
    background: var(--ds-bg-primary);
}

.v13-input-wrapper {
    display: flex;
    gap: 12px;
    max-width: 100%;
}

#v13-messageInput {
    flex: 1;
    padding: 14px;
    border: 1px solid var(--ds-border-color);
    border-radius: var(--ds-border-radius-sm);
    background: var(--ds-bg-input);
    color: var(--ds-text-primary);
    font-size: 14px;
    resize: none;
    min-height: 46px;
    max-height: 120px;
}

#v13-messageInput:focus {
    outline: none;
    border-color: var(--ds-primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

#v13-create-btn {
    background: var(--ds-primary);
    color: white;
    border: none;
    padding: 0 24px;
    border-radius: var(--ds-border-radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

#v13-create-btn:hover {
    background: var(--ds-primary-hover);
    transform: translateY(-1px);
}

#v13-create-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Status indicator */
#v13-status {
    font-size: 12px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 12px;
    background: rgba(16, 185, 129, 0.1);
    color: var(--ds-success);
}

/* Cabeçalho do v1.3 */
.v13-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--ds-border-color);
    background: var(--ds-bg-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.v13-header-title {
    color: var(--ds-primary);
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.v13-clear-btn,
.v13-exit-btn {
    background: transparent;
    border: 1px solid var(--ds-border-color);
    color: var(--ds-text-secondary);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
}

.v13-clear-btn:hover {
    background: rgba(245, 34, 45, 0.1);
    border-color: var(--ds-error);
    color: var(--ds-error);
}

.v13-exit-btn:hover {
    background: rgba(0, 102, 204, 0.1);
    border-color: var(--ds-primary);
    color: var(--ds-primary);
}

/* Botão de lixeira na v1.3 */
/* Correção do Botão de Lixeira */
.v13-delete-btn {
    position: absolute !important;
    top: 5px !important;
    right: 5px !important;
    z-index: 999 !important; /* Fica acima de tudo */
    cursor: pointer !important;
    pointer-events: all !important; /* Garante que o clique funcione */
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid var(--ds-border-color) !important;
    padding: 4px 7px !important;
    border-radius: 4px !important;
    color: var(--ds-text-secondary) !important;
    opacity: 0;
    transition: opacity 0.2s;
}

/* Mostrar ao passar o mouse */
.v13-message-user:hover .v13-delete-btn,
.v13-message-ai:hover .v13-delete-btn {
    opacity: 1;
}

.v13-delete-btn:hover {
    color: #ef4444 !important; /* Vermelho */
    border-color: #ef4444 !important;
}

/* Correção da posição do texto do usuário (alinhado à esquerda) */
.v13-message-user {
    align-self: flex-start !important;
    margin-left: 0 !important;
    margin-right: auto !important;
    display: block !important;
    width: fit-content;
    max-width: 85%;
}

/* Ajuste para não cortar o botão */
#v13-chat-area {
    padding-right: 25px;
}

.footer-btn[onclick*="Excluir"]:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #ef4444;
}

.footer-btn[onclick*="Excluir"] i {
    color: #ef4444;
}

/* ===== TEMPLATES DO CONSTRUTOR v1.3 ===== */
.v13-templates {
    margin-bottom: 15px;
    padding: 12px;
    background: var(--ds-bg-secondary);
    border-radius: 10px;
    border: 1px solid var(--ds-border-color);
}

.v13-templates-header {
    margin-bottom: 10px;
    color: var(--ds-text-muted);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.v13-templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}

.v13-template-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: var(--ds-bg-tertiary);
    border: 1px solid var(--ds-border-color);
    border-radius: 8px;
    color: var(--ds-text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    text-align: left;
}

.v13-template-btn:hover {
    background: var(--ds-primary);
    color: white;
    border-color: var(--ds-primary);
    transform: translateY(-2px);
}

/* Controles do preview */
.v13-preview-controls {
    display: flex;
    gap: 5px;
}

.v13-preview-controls button {
    background: #e5e7eb;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    color: #4b5563;
}

.v13-preview-controls button:hover {
    background: #3b82f6;
    color: white;
}

/* Estilos para mensagens de erro v1.3 */
.v13-message-ai .v13-message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    color: #6b7280;
    padding-bottom: 6px;
    border-bottom: 1px solid #e5e7eb;
}

.v13-message-ai .v13-message-content {
    line-height: 1.5;
}

/* Botão de retry */
button[onclick*="retryV13Request"] {
    transition: all 0.2s ease;
}

button[onclick*="retryV13Request"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

button[onclick*="retryV13Request"]:active {
    transform: translateY(0);
}