@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg-deep: #0d2b3a;
    --bg-primary: #1a3a4a;
    --bg-surface: #1f4455;
    --bg-input: #153040;
    --accent: #c8e64a;
    --accent-hover: #b5d43a;
    --accent-muted: rgba(200,230,74,0.12);
    --purple: #a78bfa;
    --text-primary: #e8f0f2;
    --text-secondary: #8fb8c8;
    --text-muted: #5a8898;
    --border: #243f4f;
    --border-light: #2d5060;
    --msg-user: rgba(200,230,74,0.08);
    --danger: #e05252;
    --r: 6px; --r-lg: 10px; --r-xl: 16px;
}

body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg-deep); color: var(--text-primary); height: 100vh; overflow: hidden; font-size: 14px; line-height: 1.6; }

/* === LOGIN === */
.login-container { display: flex; justify-content: center; align-items: center; height: 100vh; background: linear-gradient(160deg, var(--bg-deep), var(--bg-primary) 60%, #1a4a3a); }
.login-card { background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 40px; width: 100%; max-width: 380px; }
.login-card h1 { text-align: center; font-size: 22px; font-weight: 700; margin-bottom: 2px; }
.login-card h1 span { color: var(--accent); }
.login-card .subtitle { text-align: center; color: var(--text-muted); margin-bottom: 28px; font-size: 13px; }
.login-card label { display: block; margin-bottom: 4px; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; }
.login-card input { width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--r); background: var(--bg-input); color: var(--text-primary); font-size: 14px; font-family: inherit; margin-bottom: 16px; transition: border 0.15s; }
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-muted); }
.login-card button { width: 100%; padding: 12px; background: var(--accent); color: var(--bg-deep); border: none; border-radius: var(--r); font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; }
.login-card button:hover { background: var(--accent-hover); }
.error-msg { background: rgba(224,82,82,0.12); color: var(--danger); padding: 10px 14px; border-radius: var(--r); margin-bottom: 16px; font-size: 13px; border-left: 3px solid var(--danger); }

/* === APP === */
.app { display: flex; height: 100vh; }

/* === SIDEBAR === */
.sidebar { width: 260px; background: var(--bg-primary); display: flex; flex-direction: column; border-right: 1px solid var(--border); flex-shrink: 0; }
.sidebar-header { padding: 18px 16px 14px; }
.sidebar-header h2 { font-size: 16px; font-weight: 700; }
.sidebar-header h2 span { color: var(--accent); }
.brand-center { text-align: center; }

.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--bg-deep); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.user-info { overflow: hidden; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-empresa { font-size: 11px; color: var(--text-muted); }

.sidebar-section { padding: 12px 10px 4px; }
.sidebar-section-grow { flex: 1; overflow-y: auto; }
.section-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 6px; padding: 0 6px; font-weight: 600; }

.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); }
.logout-btn { display: block; text-align: center; padding: 8px; border: 1px solid var(--border); border-radius: var(--r); color: var(--text-secondary); text-decoration: none; font-size: 13px; font-weight: 500; transition: all 0.15s; }
.logout-btn:hover { border-color: var(--danger); color: var(--danger); background: rgba(224,82,82,0.08); }

/* Agent buttons */
.agent-item { margin-bottom: 2px; }
.agent-btn { width: 100%; padding: 8px 10px; background: transparent; border: 1px solid transparent; border-radius: var(--r); color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; gap: 10px; text-align: left; font-family: inherit; transition: all 0.12s; }
.agent-btn:hover { background: var(--accent-muted); border-color: rgba(200,230,74,0.15); }
.agent-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.agent-btn-text { overflow: hidden; }
.agent-btn-name { display: block; font-size: 13px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-btn-model { display: block; font-size: 10px; color: var(--text-muted); }

/* Conversations */
.conversa-row { display: flex; align-items: center; margin-bottom: 2px; border-radius: var(--r); border-left: 2px solid transparent; }
.conversa-row:hover { background: rgba(255,255,255,0.04); }
.conversa-row:hover .delete-btn { opacity: 1; }
.conversa-row.active { background: var(--accent-muted); border-left-color: var(--accent); }
.conversa-item { display: block; flex: 1; padding: 8px 10px; color: var(--text-secondary); text-decoration: none; transition: color 0.12s; border: none; }
.conversa-item:hover { color: var(--text-primary); }
.conversa-item.active { color: var(--accent); }
.conversa-delete { flex-shrink: 0; }
.delete-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 6px 8px; font-size: 12px; opacity: 0; transition: all 0.15s; border-radius: var(--r); }
.delete-btn:hover { color: var(--danger); background: rgba(224,82,82,0.12); opacity: 1; }
.conversa-title { display: block; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; max-width: 180px; }
.conversa-meta { display: block; font-size: 10px; color: var(--text-muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.empty-msg { font-size: 12px; color: var(--text-muted); text-align: center; padding: 20px 8px; }

/* === CHAT === */
.chat-main { flex: 1; display: flex; flex-direction: column; background: var(--bg-deep); }

.chat-header { padding: 12px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; background: var(--bg-primary); }
.chat-header-agent { display: flex; align-items: center; gap: 10px; }
.agent-dot-lg { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.chat-header-name { font-size: 14px; font-weight: 600; }
.chat-header-model { font-size: 11px; color: var(--text-muted); }

/* Messages */
.chat-messages { flex: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 4px; }

.msg { max-width: 780px; width: 100%; margin: 0 auto; display: flex; gap: 10px; padding: 8px 0; }
.msg-user { justify-content: flex-end; }
.msg-avatar-user { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--bg-deep); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 11px; flex-shrink: 0; order: 2; }

.msg-bubble { max-width: 85%; }
.msg-user .msg-bubble { background: var(--msg-user); border: 1px solid rgba(200,230,74,0.15); padding: 12px 16px; border-radius: var(--r-xl) var(--r-xl) 4px var(--r-xl); font-size: 16px; }
.msg-assistant .msg-bubble { padding: 4px 0; }

.msg-agent-name { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; color: var(--accent); margin-bottom: 6px; background: var(--accent-muted); padding: 3px 10px; border-radius: 12px; }
.msg-body { font-size: 16px; line-height: 1.75; color: var(--text-primary); }

/* Markdown content */
.msg-body p { margin-bottom: 8px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body strong { color: #fff; }
.msg-body code { background: var(--bg-surface); padding: 2px 6px; border-radius: 4px; font-size: 12px; color: var(--accent); }
.msg-body pre { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; overflow-x: auto; margin: 8px 0; font-size: 12px; }
.msg-body pre code { background: none; padding: 0; color: var(--text-primary); }
.msg-body ul, .msg-body ol { padding-left: 20px; margin: 6px 0; }
.msg-body li { margin-bottom: 4px; }
.msg-body h1, .msg-body h2, .msg-body h3 { margin: 12px 0 6px; color: #fff; }
.msg-body h1 { font-size: 18px; } .msg-body h2 { font-size: 16px; } .msg-body h3 { font-size: 14px; }
.msg-body blockquote { border-left: 3px solid var(--accent); padding-left: 12px; color: var(--text-secondary); margin: 8px 0; }

/* Tables in chat */
.msg-body table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13px; }
.msg-body th { background: var(--bg-surface); padding: 8px 10px; text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); border-bottom: 2px solid var(--border-light); }
.msg-body td { padding: 7px 10px; border-bottom: 1px solid var(--border); }
.msg-body tr:hover td { background: rgba(255,255,255,0.03); }
.msg-body a { color: var(--accent); }

/* Thinking dots */
.thinking-dots { display: flex; gap: 4px; padding: 8px 0; }
.thinking-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); animation: blink 1.4s infinite both; }
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100% { opacity: 0.3; } 40% { opacity: 1; } }

/* Tool status bar */
.tool-status-bar { display: none; align-items: center; gap: 8px; padding: 8px 14px; background: var(--accent-muted); border-radius: var(--r); margin: 4px auto; max-width: 780px; width: 100%; font-size: 12px; color: var(--accent); border: 1px solid rgba(200,230,74,0.12); }
.tool-pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
.tool-check { color: var(--accent); font-size: 14px; }

/* Chat input */
.chat-input-area { padding: 12px 24px 16px; border-top: 1px solid var(--border); background: var(--bg-primary); }
.input-wrapper { max-width: 780px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
#message-input { flex: 1; padding: 13px 16px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--r-lg); color: var(--text-primary); font-size: 16px; resize: none; min-height: 44px; max-height: 180px; font-family: inherit; line-height: 1.5; transition: border 0.15s; }
#message-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-muted); }
#message-input::placeholder { color: var(--text-muted); }
#send-btn { padding: 11px 20px; background: var(--accent); color: var(--bg-deep); border: none; border-radius: var(--r-lg); cursor: pointer; font-size: 13px; font-weight: 600; font-family: inherit; min-width: 72px; transition: background 0.15s; }
#send-btn:hover { background: var(--accent-hover); }
#send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.input-hint { text-align: center; font-size: 11px; color: var(--text-muted); margin-top: 8px; max-width: 780px; margin-left: auto; margin-right: auto; }

/* Empty state */
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; }
.empty-brand { font-size: 32px; font-weight: 700; margin-bottom: 8px; letter-spacing: -1px; }
.empty-brand span { color: var(--accent); }
.chat-empty h2 { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.chat-empty p { color: var(--text-secondary); margin-bottom: 28px; font-size: 14px; max-width: 400px; text-align: center; }

.agent-cards { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.agent-card { background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px 16px; width: 170px; cursor: pointer; text-align: center; color: var(--text-primary); display: flex; flex-direction: column; align-items: center; gap: 6px; font-family: inherit; transition: all 0.15s; }
.agent-card:hover { border-color: var(--accent); background: var(--accent-muted); transform: translateY(-2px); }
.agent-card-dot { width: 10px; height: 10px; border-radius: 50%; margin-bottom: 4px; }
.agent-card-name { font-weight: 600; font-size: 14px; }
.agent-card-desc { font-size: 11px; color: var(--text-muted); line-height: 1.4; }
.agent-card-model { font-size: 10px; color: var(--text-muted); background: var(--bg-surface); padding: 2px 8px; border-radius: 10px; margin-top: 4px; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Sidebar toggle (mobile) */
.sidebar-toggle {
    display: none; position: fixed; top: 12px; left: 12px; z-index: 100;
    background: var(--bg-primary); border: 1px solid var(--border); color: var(--text-primary);
    width: 40px; height: 40px; border-radius: var(--r); cursor: pointer;
    font-size: 18px; align-items: center; justify-content: center;
}
.sidebar-close {
    display: none; background: none; border: none; color: var(--text-muted);
    font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: var(--r);
}
.sidebar-close:hover { color: var(--text-primary); }
.sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 49;
}
.sidebar-header { display: flex; align-items: center; justify-content: center; position: relative; }
.sidebar-close { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }

/* Responsive */
@media (max-width: 1024px) {
    .conversa-title, .conversa-meta { max-width: 160px; }
    .msg { max-width: 95%; }
    .input-wrapper { max-width: 95%; }
}

@media (max-width: 768px) {
    .sidebar-toggle { display: flex; }
    .sidebar-close { display: block; }
    .sidebar {
        position: fixed; left: -280px; top: 0; bottom: 0;
        width: 270px; z-index: 50; transition: left 0.25s ease;
        box-shadow: none;
    }
    .sidebar.open { left: 0; box-shadow: 4px 0 20px rgba(0,0,0,0.3); }
    .sidebar-overlay.open { display: block; }
    .chat-header { padding: 10px 16px 10px 56px; }
    .chat-messages { padding: 16px; }
    .chat-input-area { padding: 10px 16px 14px; }
    .msg-bubble { max-width: 92%; }
    .msg-body { font-size: 15px; }
    .agent-cards { gap: 8px; }
    .agent-card { width: 160px; padding: 16px 12px; }
    .conversa-title, .conversa-meta { max-width: 180px; }
    .empty-brand { font-size: 24px; }
    .chat-empty h2 { font-size: 16px; }
    .chat-empty { padding: 24px 16px; padding-top: 60px; }
}

@media (max-width: 480px) {
    .sidebar { width: 85vw; left: -85vw; }
    .msg-body { font-size: 14px; line-height: 1.6; }
    #message-input { font-size: 14px; padding: 10px 12px; min-height: 40px; }
    #send-btn { padding: 10px 14px; font-size: 12px; min-width: 56px; }
    .input-hint { font-size: 9px; }
    .agent-cards { flex-direction: column; align-items: center; }
    .agent-card { width: 100%; max-width: 280px; }
}
