/* ══════════════════════════════════════════
   BLCK-BRT Chat UI — style.css
   BLCKBX Security Agent
   ══════════════════════════════════════════ */

:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-tertiary: #1a1a1a;
    --bg-input: #161616;
    --bg-sidebar: #0e0e0e;
    --bg-hover: #1e1e1e;
    --bg-active: #252525;
    --border: #222222;
    --border-focus: #7c3aed;
    --text-primary: #e8e8e8;
    --text-secondary: #888888;
    --text-muted: #555555;
    --accent: #7c3aed;
    --accent-light: #a78bfa;
    --accent-dim: #7c3aed22;
    --accent-glow: #7c3aed44;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --msg-user: #1e1e2e;
    --msg-agent: transparent;
    --sidebar-width: 260px;
    --sidebar-collapsed: 56px;
}

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

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.25s ease;
    overflow: hidden;
    position: relative;
    z-index: 10;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
    min-height: 56px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-logo-mark {
    width: 32px;
    height: 32px;
    min-width: 32px;
    background: var(--accent);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: white;
}

.sidebar-logo-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.collapsed .sidebar-logo-text { display: none; }

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.collapsed .sidebar-toggle { margin: 0 auto; }

/* ── New Chat Button ── */
.new-chat-sidebar {
    margin: 12px;
    padding: 10px 14px;
    background: var(--accent);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'DM Sans', sans-serif;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
}

.new-chat-sidebar:hover { background: var(--accent-light); }

.new-chat-sidebar svg { min-width: 18px; width: 18px; height: 18px; }

.collapsed .new-chat-sidebar {
    margin: 12px 9px;
    padding: 10px;
    justify-content: center;
}

.collapsed .new-chat-sidebar span { display: none; }

/* ── Sidebar Nav ── */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.nav-section { margin-bottom: 16px; }

.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 8px 8px 6px;
    white-space: nowrap;
    overflow: hidden;
}

.collapsed .nav-section-label { font-size: 0; padding: 4px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text-secondary);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: 'DM Sans', sans-serif;
}

.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--bg-active); color: var(--accent-light); }

.nav-item svg { min-width: 18px; width: 18px; height: 18px; flex-shrink: 0; }

.nav-item .nav-label { overflow: hidden; text-overflow: ellipsis; }
.collapsed .nav-item .nav-label { display: none; }
.collapsed .nav-item { justify-content: center; padding: 9px; }

.nav-badge {
    margin-left: auto;
    font-size: 10px;
    background: var(--accent-dim);
    color: var(--accent-light);
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.collapsed .nav-badge { display: none; }

/* ── Chat History Items ── */
.chat-history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
}

.chat-history-item:hover { background: var(--bg-hover); color: var(--text-primary); }

.chat-history-dot {
    width: 6px;
    height: 6px;
    min-width: 6px;
    border-radius: 50%;
    background: var(--text-muted);
}

.collapsed .chat-history-item .nav-label { display: none; }

/* ── Sidebar Footer ── */
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }

.sidebar-footer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text-secondary);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-footer-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-footer-item svg { min-width: 18px; width: 18px; height: 18px; flex-shrink: 0; }
.collapsed .sidebar-footer-item span { display: none; }
.collapsed .sidebar-footer-item { justify-content: center; }

/* ── Main Content ── */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ── Header ── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
    flex-shrink: 0;
    min-height: 52px;
}

.header-left {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

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

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-secondary);
    padding: 5px 10px;
    border-radius: 16px;
    border: 1px solid var(--border);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.status-dot.offline { background: var(--error); box-shadow: 0 0 6px var(--error); }

.model-selector {
    display: none
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 5px 28px 5px 10px;
    cursor: pointer;
    outline: none;
    font-family: 'DM Sans', sans-serif;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.model-selector:focus { border-color: var(--border-focus); }

/* ── Chat Area ── */
.chat-container {
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.chat-container::-webkit-scrollbar { width: 4px; }
.chat-container::-webkit-scrollbar-track { background: transparent; }
.chat-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── Welcome ── */
.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px 24px;
    text-align: center;
}

.welcome-logo {
    width: 52px;
    height: 52px;
    background: var(--accent);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 20px;
    color: white;
    margin-bottom: 20px;
    box-shadow: 0 0 40px var(--accent-glow);
}

.welcome h1 {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.welcome p {
    font-size: 14px;
    color: var(--text-secondary);
    max-width: 460px;
    line-height: 1.6;
    margin-bottom: 28px;
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 560px;
}

.quick-action {
    padding: 9px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'DM Sans', sans-serif;
}

.quick-action:hover {
    border-color: var(--accent);
    color: var(--accent-light);
    background: var(--accent-dim);
}

/* ── Messages ── */
.message-wrapper { padding: 20px 0; border-bottom: 1px solid var(--border); }
.message-wrapper:last-child { border-bottom: none; }
.message-wrapper.user { background: var(--msg-user); }
.message-wrapper.agent { background: var(--msg-agent); }

.message-inner {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    gap: 14px;
}

.message-avatar {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
    margin-top: 2px;
}

.message-avatar.user-avatar {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.message-avatar.agent-avatar { background: var(--accent); color: white; }

.message-content { flex: 1; min-width: 0; }

.message-role { font-size: 12px; font-weight: 600; margin-bottom: 5px; color: var(--text-primary); }
.message-role.agent-role { color: var(--accent-light); }

.message-text {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message-text code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.message-text pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    margin: 10px 0;
    overflow-x: auto;
}

.message-text pre code {
    background: none;
    padding: 0;
    border: none;
    font-size: 12px;
    line-height: 1.5;
}

.message-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; }

.meta-tag {
    font-size: 10px;
    color: var(--text-muted);
    padding: 2px 7px;
    border-radius: 4px;
    background: var(--bg-tertiary);
    font-family: 'JetBrains Mono', monospace;
}

/* ── Typing ── */
.typing-indicator { display: flex; gap: 4px; padding: 4px 0; }

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--accent-light);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* ── Input ── */
.input-area {
    padding: 14px 24px 20px;
    background: var(--bg-primary);
    flex-shrink: 0;
}

.input-container {
    max-width: 720px;
    margin: 0 auto;
    position: relative;
}

.input-box {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 52px 14px 18px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: 'DM Sans', sans-serif;
    resize: none;
    outline: none;
    min-height: 48px;
    max-height: 180px;
    line-height: 1.5;
    transition: border-color 0.2s;
}

.input-box::placeholder { color: var(--text-muted); }

.input-box:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.send-btn {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--accent);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.send-btn:hover { background: var(--accent-light); }
.send-btn:disabled { background: var(--bg-tertiary); cursor: not-allowed; }
.send-btn svg { width: 15px; height: 15px; fill: white; }

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    padding: 0 4px;
}

.input-footer-left { font-size: 10px; color: var(--text-muted); }
.input-footer-right { font-size: 10px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }

/* ── Sidebar Panels ── */
.sidebar-panel {
    display: none;
    position: absolute;
    top: 0;
    left: var(--sidebar-width);
    width: 320px;
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    z-index: 20;
    flex-direction: column;
    animation: slideIn 0.2s ease;
}

.sidebar-panel.open { display: flex; }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

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

.panel-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }

.panel-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.panel-content { flex: 1; overflow-y: auto; padding: 12px; }
.panel-content::-webkit-scrollbar { width: 3px; }
.panel-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.capability-group { margin-bottom: 16px; }

.capability-group-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 8px;
    margin-bottom: 4px;
}

.capability-item {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 7px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.capability-item:hover { background: var(--bg-hover); color: var(--text-primary); }

.capability-num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--text-muted);
    min-width: 22px;
}

.panel-search {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 12px;
    font-family: 'DM Sans', sans-serif;
    outline: none;
    margin-bottom: 12px;
}

.panel-search::placeholder { color: var(--text-muted); }
.panel-search:focus { border-color: var(--accent); }

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 100;
        width: var(--sidebar-collapsed);
    }
    .sidebar.expanded-mobile { width: var(--sidebar-width); }
    .main { margin-left: var(--sidebar-collapsed); }
    .header { padding: 10px 16px; }
    .message-inner { padding: 0 16px; }
    .input-area { padding: 10px 16px 14px; }
    .sidebar-panel { left: var(--sidebar-collapsed); width: 280px; }
    .sidebar.expanded-mobile + .sidebar-panel { left: var(--sidebar-width); }
}
.powered-label {
    font-size: 11px;
    color: var(--accent-light);
    font-weight: 500;
    letter-spacing: 0.5px;
    padding: 5px 12px;
    border: 1px solid var(--accent-dim);
    border-radius: 16px;
    background: var(--accent-dim);
}