/* Novatek Sales Intelligence — Dashboard CSS */
:root {
    --primary: #1E88E5;
    --primary-dim: #1565C0;
    --bg: #0D1B2A;
    --surface: #1B2838;
    --surface-2: #2C3E50;
    --surface-3: #34495E;
    --text: #ECEFF1;
    --text-dim: #B0BEC5;
    --success: #66BB6A;
    --warning: #FFA726;
    --danger: #EF5350;
    --profit: #66BB6A;
    --revenue: #42A5F5;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
}

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

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

/* Header */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--surface-2);
    flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-logo { width: 36px; height: 36px; }
.header-left h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
}
.subtitle { font-size: 0.75rem; color: var(--text-dim); }
.header-right { display: flex; align-items: center; gap: 12px; }

.btn-icon {
    background: none;
    border: 1px solid var(--surface-2);
    color: var(--text-dim);
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }

/* Status Badge */
.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}
.status-badge.online { background: rgba(102,187,106,0.15); color: var(--success); }
.status-badge.offline { background: rgba(239,83,80,0.15); color: var(--danger); }
.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: currentColor;
}

/* Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 16px 24px;
    flex-shrink: 0;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--surface-2);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: border-color 0.2s;
}
.stat-card:hover { border-color: var(--primary); }
.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-sm);
    background: rgba(30,136,229,0.12);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon.revenue { background: rgba(66,165,245,0.12); color: var(--revenue); }
.stat-icon.profit { background: rgba(102,187,106,0.12); color: var(--profit); }
.stat-icon.countries { background: rgba(255,167,38,0.12); color: var(--warning); }
.stat-data { display: flex; flex-direction: column; }
.stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
}
.stat-label { font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; }

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 8px;
    padding: 0 24px 12px;
    overflow-x: auto;
    flex-shrink: 0;
}
.action-pill {
    background: var(--surface);
    border: 1px solid var(--surface-2);
    color: var(--text-dim);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}
.action-pill:hover { background: var(--primary); color: white; border-color: var(--primary); }

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 24px 16px;
    overflow: hidden;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
    scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 3px; }

/* Messages */
.message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}
.message.user .message-content {
    background: var(--primary);
    color: white;
    border-radius: var(--radius) var(--radius) 4px var(--radius);
    align-self: flex-end;
    max-width: 70%;
}
.message.assistant .message-content {
    background: var(--surface);
    border: 1px solid var(--surface-2);
    border-radius: var(--radius) var(--radius) var(--radius) 4px;
    max-width: 85%;
}
.message-content {
    padding: 12px 16px;
    font-size: 0.9rem;
    line-height: 1.6;
}
.message-content p { margin-bottom: 8px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content strong { color: var(--primary); font-weight: 600; }
.message-content code {
    background: rgba(0,0,0,0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}
.message-content pre {
    background: rgba(0,0,0,0.3);
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 8px 0;
}
.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 0.85rem;
}
.message-content th, .message-content td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--surface-2);
}
.message-content th {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    color: var(--primary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Thinking dots */
.thinking-dots {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}
.thinking-dots span {
    width: 8px; height: 8px;
    background: var(--text-dim);
    border-radius: 50%;
    animation: thinking-pulse 1.4s infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes thinking-pulse {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* Tool Call Visualization (hunting-style) */
@keyframes tool-spin {
    to { transform: rotate(360deg); }
}

.tool-call {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    background: rgba(30, 136, 229, 0.06);
    border: 1px solid rgba(30, 136, 229, 0.15);
    border-left: 3px solid var(--primary);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    margin-bottom: 12px;
    max-width: 90%;
}

.tool-call .tool-icon {
    font-size: 1.1em;
    flex-shrink: 0;
}

.tool-call .tool-name {
    color: var(--primary);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 0.82rem;
}

.tool-call .tool-args {
    color: var(--text-dim);
    font-size: 0.75rem;
    margin-left: 4px;
    word-break: break-word;
}

.tool-call .tool-arg-key {
    color: #90CAF9;
}

.tool-spinner {
    display: inline-block;
    margin-left: auto;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(30, 136, 229, 0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: tool-spin 0.8s linear infinite;
    flex-shrink: 0;
}

.tool-badge {
    margin-left: auto;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    font-family: 'Space Grotesk', sans-serif;
    flex-shrink: 0;
}

.tool-badge.ok {
    background: rgba(102, 187, 106, 0.15);
    color: var(--success);
}

.tool-badge.err {
    background: rgba(239, 83, 80, 0.15);
    color: var(--danger);
}

/* Table wrapper for horizontal scroll */
.table-wrap {
    overflow-x: auto;
    margin: 8px 0;
}

/* Attachment Preview */
.attachment-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 24px 0;
    flex-shrink: 0;
}
.attachment-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--surface);
    border: 1px solid var(--surface-2);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: var(--text);
    animation: att-fade 0.2s ease;
}
@keyframes att-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.attachment-card .file-icon { font-size: 1rem; flex-shrink: 0; }
.attachment-card .file-name {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.attachment-card .file-size {
    color: var(--text-dim);
    font-size: 0.68rem;
    font-family: 'Space Grotesk', sans-serif;
}
.attachment-card .remove-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1rem;
    padding: 0 2px;
    line-height: 1;
}
.attachment-card .remove-btn:hover { color: var(--danger); }

/* Input Area */
.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--surface-2);
    border-radius: var(--radius);
    padding: 10px 14px;
    flex-shrink: 0;
}
.chat-input-area:focus-within { border-color: var(--primary); }

/* Attach button (paperclip) */
.btn-attach {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    background: transparent;
    border: 1px solid var(--surface-2);
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}
.btn-attach:hover { color: var(--text); border-color: var(--primary); }

/* Mic button */
.btn-mic {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    background: transparent;
    border: 1px solid var(--surface-2);
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}
.btn-mic:hover { color: var(--text); border-color: var(--primary); }
.btn-mic.recording {
    color: var(--danger);
    border-color: var(--danger);
    animation: mic-pulse 1.5s infinite;
}
.btn-mic.unsupported { opacity: 0.3; cursor: not-allowed; }
@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 83, 80, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(239, 83, 80, 0); }
}

#chat-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    resize: none;
    outline: none;
    max-height: 120px;
    line-height: 1.5;
}
#chat-input::placeholder { color: var(--text-dim); }
#btn-send {
    background: var(--primary);
    border: none;
    color: white;
    width: 38px; height: 38px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}
#btn-send:hover { background: var(--primary-dim); }
#btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* Auth Overlay */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(13,27,42,0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.auth-overlay.hidden { display: none; }
.auth-card {
    background: var(--surface);
    border: 1px solid var(--surface-2);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    width: 360px;
}
.auth-logo { width: 48px; height: 48px; margin-bottom: 16px; }
.auth-card h2 {
    font-family: 'Space Grotesk', sans-serif;
    color: var(--primary);
    margin-bottom: 8px;
}
.auth-card p { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 20px; }
.auth-card input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--surface-2);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.9rem;
    margin-bottom: 12px;
    outline: none;
}
.auth-card input:focus { border-color: var(--primary); }
.auth-card button {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
}
.auth-card button:hover { background: var(--primary-dim); }
.auth-error { color: var(--danger); font-size: 0.8rem; margin-top: 12px; }

/* Responsive */
@media (max-width: 768px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 12px 16px; }
    header { padding: 10px 16px; }
    .chat-container { padding: 0 16px 12px; }
    .quick-actions { padding: 0 16px 8px; }
    .message.user .message-content, .message.assistant .message-content { max-width: 95%; }
}
@media (max-width: 480px) {
    .stats-row { grid-template-columns: 1fr 1fr; }
    .stat-card { padding: 12px; }
    .stat-icon { width: 40px; height: 40px; }
    .stat-value { font-size: 1.1rem; }
}
