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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #16a34a;
    --warning: #d97706;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --bubble-user: #2563eb;
    --bubble-agent: #ffffff;
    --sidebar-width: 280px;
    --header-height: 56px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

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

header h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 999px;
}

/* Layout */
.container {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - var(--header-height));
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.section {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.section:last-child {
    border-bottom: none;
}

.section h3 {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* Radio group */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.15s;
}

.radio-option:hover {
    background: var(--bg);
}

.radio-option input[type="radio"] {
    cursor: pointer;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text);
}

/* Badges */
.badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-lead { background: #dbeafe; color: #1d4ed8; }
.badge-cliente { background: #dcfce7; color: #15803d; }
.badge-excliente { background: #fef9c3; color: #854d0e; }

/* Input */
.input-field {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--text);
    background: var(--bg);
    transition: border-color 0.15s;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    text-decoration: none;
    width: 100%;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

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

.btn-secondary {
    background: var(--bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
    font-size: 0.8rem;
}

.btn-outline:hover { background: #eff6ff; }

/* Tool calls */
.tool-calls-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
}

.tool-call-item {
    font-size: 0.75rem;
    padding: 4px 8px;
    background: var(--bg);
    border-radius: 4px;
    border-left: 2px solid var(--primary);
    color: var(--text);
    font-family: 'SF Mono', 'Fira Code', monospace;
    word-break: break-all;
}

.empty-state {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    padding: 8px;
}

/* Chat panel */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-idle { background: var(--secondary); }
.status-loading { background: var(--warning); animation: pulse 1s infinite; }
.status-success { background: var(--success); }

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

/* Chat messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
}

.welcome-message {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    padding: 40px 20px;
}

/* Message bubbles */
.message-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 75%;
}

.message-group.user {
    align-self: flex-end;
    align-items: flex-end;
}

.message-group.agent {
    align-self: flex-start;
    align-items: flex-start;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-group.user .message-bubble {
    background: var(--bubble-user);
    color: white;
    border-bottom-right-radius: 3px;
}

.message-group.agent .message-bubble {
    background: var(--bubble-agent);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 3px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.message-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0 4px;
}

/* Tool calls expand */
.tool-calls-toggle {
    font-size: 0.72rem;
    color: var(--primary);
    cursor: pointer;
    padding: 2px 8px;
    background: #eff6ff;
    border-radius: 4px;
    border: none;
    margin-top: 4px;
    transition: background 0.15s;
}

.tool-calls-toggle:hover { background: #dbeafe; }

.tool-calls-detail {
    font-size: 0.75rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
    margin-top: 4px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    max-width: 400px;
}

.tool-call-entry {
    color: var(--primary);
    margin: 2px 0;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 14px;
    background: var(--bubble-agent);
    border: 1px solid var(--border);
    border-radius: 12px;
    border-bottom-left-radius: 3px;
    width: fit-content;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 100% { transform: translateY(0); opacity: 0.4; }
    50% { transform: translateY(-4px); opacity: 1; }
}

/* Chat input */
.chat-input-area {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.message-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: none;
    line-height: 1.5;
    transition: border-color 0.15s;
    max-height: 120px;
}

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

.chat-input-area .btn-primary {
    width: auto;
    padding: 10px 20px;
    white-space: nowrap;
}

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