/* M32 Mission Control — Dark Theme */

:root {
    --bg-deep: #0a0e1a;
    --bg-card: #111827;
    --bg-panel: #151d2e;
    --border: #1e293b;
    --border-hover: #334155;
    --blue: #3b82f6;
    --blue-hover: #2563eb;
    --blue-dim: #1e3a5f;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --success: #22c55e;
    --warning: #eab308;
    --error: #ef4444;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --radius: 8px;
    --radius-lg: 12px;
}

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

body {
    background: var(--bg-deep);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-hover); }

/* --- Navbar --- */
.navbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-logo { height: 28px; }

.navbar-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.navbar-sep {
    color: var(--text-muted);
    font-size: 20px;
    font-weight: 200;
}

.navbar-bot-name {
    font-size: 14px;
    color: var(--text-secondary);
}

.navbar-spacer { flex: 1; }

.navbar-link {
    color: var(--text-secondary);
    font-size: 13px;
    padding: 6px 12px;
    border-radius: var(--radius);
    transition: all 0.15s;
}
.navbar-link:hover {
    color: var(--text-primary);
    background: var(--bg-panel);
}

/* --- Page Layout --- */
.page-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
}

.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

/* --- Bot Grid (Index) --- */
.bot-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

@media (max-width: 768px) {
    .bot-grid { grid-template-columns: 1fr; }
}

/* --- Bot Card --- */
.bot-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all 0.2s;
    cursor: pointer;
    display: block;
    color: inherit;
}

.bot-card:hover {
    border-color: var(--blue);
    background: var(--bg-panel);
    transform: translateY(-2px);
    box-shadow: 0 4px 24px rgba(59, 130, 246, 0.1);
    color: inherit;
}

.bot-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.bot-emoji {
    font-size: 28px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-deep);
    border-radius: var(--radius);
}

.bot-card-info { flex: 1; }

.bot-card-name {
    font-size: 16px;
    font-weight: 600;
}

.bot-card-user {
    font-size: 12px;
    color: var(--text-secondary);
}

/* --- Status Dot --- */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.status-dot.running { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.stopped { background: var(--error); box-shadow: 0 0 6px var(--error); }
.status-dot.unknown { background: var(--text-muted); }

.status-text {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: capitalize;
}

/* --- Bot Card Stats --- */
.bot-card-stats {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--blue);
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bot-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

/* --- Bot Detail Layout --- */
.bot-detail {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    align-items: start;
}

@media (max-width: 900px) {
    .bot-detail { grid-template-columns: 1fr; }
}

/* --- Sidebar --- */
.sidebar-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
}

.sidebar-card h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.identity-name {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.identity-detail {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.session-meta {
    font-size: 13px;
    color: var(--text-secondary);
}

.session-meta dt {
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    margin-top: 8px;
}

.session-meta dd {
    margin: 2px 0 0 0;
}

/* --- Tabs --- */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab-btn {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    white-space: nowrap;
    font-family: inherit;
}

.tab-btn:hover {
    color: var(--text-secondary);
    background: var(--bg-panel);
}

.tab-btn.active {
    color: var(--blue);
    border-bottom-color: var(--blue);
}

.tab-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    min-height: 300px;
}

/* --- Memory List --- */
.memory-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.memory-item:last-child { border-bottom: none; }

.memory-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.memory-item-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--blue);
}

.memory-item-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.memory-item-preview {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    white-space: pre-wrap;
    overflow: hidden;
    max-height: 60px;
    line-height: 1.5;
}

/* --- Skills Table --- */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    vertical-align: top;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td { background: var(--bg-panel); }

/* --- Badges --- */
.badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 10px;
}

.badge-shared { background: var(--blue-dim); color: var(--blue); }
.badge-bundled { background: #1a2e1a; color: #4ade80; }
.badge-workspace { background: #2e2a1a; color: var(--warning); }
.badge-ok { background: #0a2e1a; color: var(--success); }
.badge-error { background: #2e0a0a; color: var(--error); }
.badge-enabled { background: #0a2e1a; color: var(--success); }
.badge-disabled { background: #1e1e1e; color: var(--text-muted); }

/* --- File Tree --- */
.file-tree { list-style: none; }

.file-tree li {
    padding: 0;
}

.tree-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: background 0.1s;
}

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

.tree-icon {
    font-size: 14px;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.tree-children {
    list-style: none;
    padding-left: 20px;
}

/* --- File Content --- */
.file-viewer {
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    overflow-x: auto;
}

.file-viewer-header {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.file-viewer pre {
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-secondary);
}

.file-viewer .md-content {
    font-size: 13px;
    line-height: 1.7;
}

.file-viewer .md-content h1 { font-size: 20px; margin: 16px 0 8px; color: var(--text-primary); }
.file-viewer .md-content h2 { font-size: 17px; margin: 14px 0 6px; color: var(--text-primary); }
.file-viewer .md-content h3 { font-size: 15px; margin: 12px 0 4px; color: var(--text-primary); }
.file-viewer .md-content p { margin: 8px 0; }
.file-viewer .md-content ul, .file-viewer .md-content ol { margin: 8px 0; padding-left: 24px; }
.file-viewer .md-content li { margin: 4px 0; }
.file-viewer .md-content code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--bg-card);
    padding: 2px 6px;
    border-radius: 4px;
}
.file-viewer .md-content pre code {
    display: block;
    padding: 12px;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow-x: auto;
}
.file-viewer .md-content table {
    border-collapse: collapse;
    margin: 8px 0;
}
.file-viewer .md-content th, .file-viewer .md-content td {
    border: 1px solid var(--border);
    padding: 6px 10px;
    font-size: 12px;
}
.file-viewer .md-content strong { color: var(--text-primary); }

/* --- Docker Logs --- */
.log-output {
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-secondary);
    max-height: 600px;
    overflow-y: auto;
}

/* --- Cron Table --- */
.cron-payload {
    font-size: 11px;
    color: var(--text-muted);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Sessions --- */
.session-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.session-item:last-child { border-bottom: none; }

.session-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.session-id {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--blue);
}

.session-detail {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.session-detail span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* --- Config View --- */
.config-json {
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    color: var(--text-secondary);
    overflow-x: auto;
}

/* --- Shared files panel --- */
.split-panel {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 16px;
}

.split-panel-tree {
    border-right: 1px solid var(--border);
    padding-right: 16px;
    max-height: 600px;
    overflow-y: auto;
}

.split-panel-content {
    min-height: 200px;
}

/* --- Loading Indicator --- */
.htmx-indicator {
    display: none;
    color: var(--text-muted);
    font-size: 13px;
    padding: 20px;
}
.htmx-request .htmx-indicator { display: block; }
.htmx-request.htmx-indicator { display: block; }

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* --- Utility --- */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.font-mono { font-family: var(--font-mono); }
