/* ============================================================================
   NEXUS CEO v3.0 - STYLES.CSS
   Design completo com 6 temas funcionais
   ============================================================================ */

/* ============================================================================
   RESET E BASE
   ============================================================================ */

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

:root {
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, monospace;
    
    --transition-fast: 150ms ease;
    --transition-normal: 300ms ease;
    --transition-slow: 500ms ease;
    
    --border-radius-sm: 6px;
    --border-radius-md: 10px;
    --border-radius-lg: 16px;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.2);
}

/* ============================================================================
   TEMA: DARK (padrão)
   ============================================================================ */

body, .theme-dark {
    --bg-primary: #0a0e27;
    --bg-secondary: #0f172a;
    --bg-tertiary: #1e293b;
    --bg-hover: #334155;
    
    --text-primary: #e0e7ff;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    
    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-hover: #4f46e5;
    
    --border-color: #1e293b;
    --border-light: #334155;
    
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
}

/* ============================================================================
   TEMA: LIGHT
   ============================================================================ */

.theme-light {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-hover: #e2e8f0;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    
    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-hover: #4f46e5;
    
    --border-color: #e2e8f0;
    --border-light: #cbd5e1;
    
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
}

/* ============================================================================
   TEMA: CYBER
   ============================================================================ */

.theme-cyber {
    --bg-primary: #000000;
    --bg-secondary: #0d0d0d;
    --bg-tertiary: #1a1a1a;
    --bg-hover: #262626;
    
    --text-primary: #00ff88;
    --text-secondary: #00cc6f;
    --text-tertiary: #009955;
    
    --accent-primary: #ff00ff;
    --accent-secondary: #cc00cc;
    --accent-hover: #ff33ff;
    
    --border-color: #00ff88;
    --border-light: #00cc6f;
    
    --success: #00ff88;
    --warning: #ffcc00;
    --error: #ff0066;
    --info: #00ccff;
}

/* ============================================================================
   TEMA: NATURE
   ============================================================================ */

.theme-nature {
    --bg-primary: #f0f4f0;
    --bg-secondary: #e8f0e8;
    --bg-tertiary: #d8e8d8;
    --bg-hover: #c8e0c8;
    
    --text-primary: #1a3a1a;
    --text-secondary: #2d5a2d;
    --text-tertiary: #4a8a4a;
    
    --accent-primary: #2d8659;
    --accent-secondary: #3da672;
    --accent-hover: #247a4a;
    
    --border-color: #c8e0c8;
    --border-light: #d8e8d8;
    
    --success: #2d8659;
    --warning: #d4a056;
    --error: #c14a4a;
    --info: #4a7dc1;
}

/* ============================================================================
   TEMA: OCEAN
   ============================================================================ */

.theme-ocean {
    --bg-primary: #0a1628;
    --bg-secondary: #0f2240;
    --bg-tertiary: #1a3a5a;
    --bg-hover: #2a4a6a;
    
    --text-primary: #b8d4f0;
    --text-secondary: #8ab4d8;
    --text-tertiary: #6094c0;
    
    --accent-primary: #06b6d4;
    --accent-secondary: #22d3ee;
    --accent-hover: #0891b2;
    
    --border-color: #1a3a5a;
    --border-light: #2a4a6a;
    
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #06b6d4;
}

/* ============================================================================
   TEMA: SUNSET
   ============================================================================ */

.theme-sunset {
    --bg-primary: #1a0a0f;
    --bg-secondary: #2a1420;
    --bg-tertiary: #3a1e30;
    --bg-hover: #4a2840;
    
    --text-primary: #ffd4e8;
    --text-secondary: #f0b4d0;
    --text-tertiary: #d894b8;
    
    --accent-primary: #f97316;
    --accent-secondary: #fb923c;
    --accent-hover: #ea580c;
    
    --border-color: #3a1e30;
    --border-light: #4a2840;
    
    --success: #22c55e;
    --warning: #fbbf24;
    --error: #ef4444;
    --info: #ec4899;
}

/* ============================================================================
   LAYOUT PRINCIPAL
   ============================================================================ */

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    margin: 0;
    padding: 0;
}

.app-container {
    display: grid;
    grid-template-columns: 280px 1fr auto;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* ============================================================================
   SIDEBAR ESQUERDA
   ============================================================================ */

.sidebar {
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.version {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* Projetos */

.projects-section {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-tertiary);
    letter-spacing: 0.5px;
}

.btn-icon {
    background: var(--accent-primary);
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.btn-icon:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.projects-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.project-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

.project-item:hover {
    background: var(--bg-hover);
}

.project-item.active {
    background: var(--accent-primary);
    color: white;
}

.project-icon {
    font-size: 18px;
}

.project-name {
    font-size: 14px;
    font-weight: 500;
}

/* Setores */

.sectors-section {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
}

.sectors-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sector-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

.sector-item:hover {
    background: var(--bg-hover);
}

.sector-item.active {
    background: var(--accent-primary);
    color: white;
}

.sector-icon {
    font-size: 24px;
    width: 32px;
    text-align: center;
}

.sector-info {
    flex: 1;
}

.sector-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.sector-desc {
    font-size: 12px;
    opacity: 0.7;
}

/* Footer Sidebar */

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-footer {
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition-fast);
    text-align: left;
}

.btn-footer:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

/* ============================================================================
   ÁREA CENTRAL (CHAT)
   ============================================================================ */

.main-content {
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    height: 100vh;
    overflow: hidden;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 28px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.header-left h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.header-left span {
    font-size: 13px;
    color: var(--text-secondary);
}

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

.theme-selector {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
}

.btn-toggle {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition-fast);
}

.btn-toggle:hover {
    background: var(--bg-hover);
}

.btn-toggle.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

/* Chat Container */

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    /* Altura calculada: 100vh - header - input */
    max-height: calc(100vh - 80px - 200px);
}

.welcome-message {
    text-align: center;
    padding: 60px 20px;
    max-width: 600px;
    margin: 0 auto;
}

.welcome-message h2 {
    font-size: 28px;
    margin-bottom: 16px;
}

.welcome-message p {
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.6;
}

/* Mensagens */

.message {
    display: flex;
    gap: 12px;
    max-width: 800px;
}

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

.message-assistant {
    margin-right: auto;
}

.message-system {
    justify-content: center;
    opacity: 0.7;
    font-size: 13px;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.message-user .message-avatar {
    background: var(--bg-tertiary);
}

.message-content {
    flex: 1;
    background: var(--bg-secondary);
    padding: 14px 18px;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
}

.message-user .message-content {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.message-text {
    line-height: 1.6;
    word-wrap: break-word;
}

.message-text code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
}

.typing-indicator {
    display: inline-block;
    animation: blink 1.4s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 1; }
}

.cursor {
    display: inline-block;
    animation: cursor-blink 1s infinite;
}

@keyframes cursor-blink {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

/* Input Area */

.chat-input-container {
    flex-shrink: 0; /* CRÍTICO: nunca encolhe */
    padding: 20px 24px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.btn-input-action {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 16px;
    transition: var(--transition-fast);
}

.btn-input-action:hover {
    background: var(--bg-hover);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    cursor: pointer;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    resize: none;
    min-height: 44px;
    max-height: 150px;
    transition: var(--transition-fast);
}

.chat-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.btn-send, .btn-stop {
    width: 44px;
    height: 44px;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--border-radius-md);
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-send:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.btn-stop {
    background: var(--error);
}

.btn-stop:hover {
    background: #dc2626;
    transform: scale(1.05);
}

/* Processing Indicator */

.processing-indicator {
    margin-top: 12px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    gap: 12px;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-primary);
    transition: width 0.3s ease;
    width: 0%;
}

/* ============================================================================
   PAINEL DIREITA (PENSAMENTO)
   ============================================================================ */

.thinking-panel {
    width: 400px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.thinking-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.thinking-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    transition: var(--transition-fast);
}

.btn-close:hover {
    color: var(--text-primary);
}

.thinking-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.thinking-content pre {
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.thinking-placeholder {
    color: var(--text-tertiary);
    font-size: 13px;
    text-align: center;
    padding: 40px 20px;
}

/* ============================================================================
   MODAIS
   ============================================================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.modal-large {
    max-width: 800px;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.btn-close-modal {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    transition: var(--transition-fast);
}

.btn-close-modal:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Forms */

.form-label {
    display: block;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
}

.form-hint {
    display: block;
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
    font-weight: 400;
}

.form-input, .form-textarea, .form-select {
    width: 100%;
    padding: 10px 14px;
    margin-top: 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    transition: var(--transition-fast);
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.btn-primary {
    padding: 10px 20px;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--border-radius-sm);
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    padding: 10px 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition-fast);
    margin-right: 8px;
    margin-bottom: 8px;
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-danger {
    padding: 10px 20px;
    background: var(--error);
    border: none;
    border-radius: var(--border-radius-sm);
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition-fast);
    margin-bottom: 8px;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-cancel {
    padding: 10px 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-cancel:hover {
    background: var(--bg-hover);
}

/* Config Tabs */

.config-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
}

.config-tab {
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition-fast);
    margin-bottom: -2px;
}

.config-tab:hover {
    color: var(--text-primary);
}

.config-tab.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

.config-tab-content {
    display: none;
}

.config-tab-content.active {
    display: block;
}

/* Config Sections */

.config-section {
    margin-bottom: 24px;
}

.config-section h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

/* Help */

.help-list {
    list-style: none;
    padding-left: 0;
}

.help-list li {
    padding: 8px 0;
    line-height: 1.6;
}

.help-list strong {
    color: var(--accent-primary);
}

/* ============================================================================
   UTILIDADES
   ============================================================================ */

.hidden {
    display: none !important;
}

/* Scrollbar customizada */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-hover);
}

/* ============================================================================
   RESPONSIVO
   ============================================================================ */

@media (max-width: 1200px) {
    .thinking-panel {
        width: 350px;
    }
}

@media (max-width: 900px) {
    .app-container {
        grid-template-columns: 240px 1fr;
    }
    
    .thinking-panel {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        box-shadow: var(--shadow-lg);
    }
}

@media (max-width: 600px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 200;
        transition: left var(--transition-normal);
    }
    
    .sidebar.open {
        left: 0;
    }
}

/* ============================================================================
   ANIMAÇÕES E TRANSIÇÕES
   ============================================================================ */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.message {
    animation: slideUp 0.3s ease;
}

.modal {
    animation: fadeIn 0.2s ease;
}

.modal-content {
    animation: slideUp 0.3s ease;
}