/* JOOJINA Mission Control — Warm Editorial Theme */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg: #faf8f4;
    --bg-card: #ffffff;
    --bg-hover: #f5f0e8;
    --bg-sidebar: #1a1a1a;
    --border: #e5ddd0;
    --border-light: #ede7dc;
    --text: #2c2c2c;
    --text-muted: #8a8070;
    --text-sidebar: #b8b0a0;
    --accent: #b8860b;
    --accent-light: #d4a94a;
    --olive: #5a7247;
    --olive-light: #e8f0e2;
    --terracotta: #c45a3c;
    --terracotta-light: #fbe8e3;
    --blue: #4a6fa5;
    --blue-light: #e4ecf5;
    --purple: #7a5bad;
    --purple-light: #efe7f7;
    --yellow: #c49a2a;
    --yellow-light: #fdf3d7;
    --radius: 6px;
    --sidebar-w: 200px;
    --serif: 'Instrument Serif', Georgia, serif;
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', 'SF Mono', monospace;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
}

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

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

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

/* ── Sidebar ──────────────────────────────────────────── */

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    padding: 1.5rem 0.75rem;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.logo { padding: 0 0.5rem; margin-bottom: 2rem; }
.logo h2 {
    font-family: var(--serif);
    color: var(--accent-light);
    font-size: 1.4rem;
    font-weight: 400;
    letter-spacing: 1px;
}
.logo .subtitle {
    color: var(--text-sidebar);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    display: block;
    margin-top: 2px;
}

.sidebar ul { list-style: none; }
.sidebar > ul { margin-bottom: 1.5rem; }
.sidebar > ul > li > a {
    display: block;
    padding: 0.45rem 0.75rem;
    border-radius: var(--radius);
    color: var(--text-sidebar);
    font-size: 0.82rem;
    font-weight: 500;
    margin-bottom: 1px;
    transition: all 0.15s;
}
.sidebar > ul > li > a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar > ul > li > a.active { background: rgba(255,255,255,0.1); color: var(--accent-light); }

.nav-section { margin-top: 1.25rem; }
.nav-section h4 {
    color: rgba(255,255,255,0.3);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 0.4rem;
    padding: 0 0.75rem;
}
.agent-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    color: var(--text-sidebar);
    font-size: 0.75rem;
    font-family: var(--mono);
    border-radius: var(--radius);
    transition: all 0.15s;
}
.agent-link:hover { color: #fff; background: rgba(255,255,255,0.06); }
.agent-link.active { color: var(--accent-light); background: rgba(255,255,255,0.1); }
.agent-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--text-sidebar);
    flex-shrink: 0;
}
.agent-dot.active { background: var(--olive); }
.agent-dot.blocked { background: var(--terracotta); }

/* ── Hamburger ────────────────────────────────────────── */

.menu-toggle {
    display: none;
    position: fixed;
    top: 0.75rem; left: 0.75rem;
    z-index: 1001;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.55rem;
    cursor: pointer;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow);
}
.menu-toggle span {
    display: block; width: 18px; height: 2px;
    background: var(--text);
    border-radius: 1px;
}
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
}

/* ── Content ──────────────────────────────────────────── */

.content {
    margin-left: var(--sidebar-w);
    padding: 2rem 2.5rem;
    flex: 1;
    max-width: 1200px;
    min-width: 0;
}

.page-header {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 0.25rem;
}
h1 {
    font-family: var(--serif);
    font-size: 1.75rem;
    font-weight: 400;
    color: var(--text);
}
.dateline {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.page-rule {
    border: none;
    border-top: 2px solid var(--text);
    margin: 0.5rem 0 1.5rem;
}
.page-rule.thin {
    border-top: 1px solid var(--border);
}

/* ── Cards ────────────────────────────────────────────── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}
.card h2 {
    font-family: var(--serif);
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--text);
}
.card h3 {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* ── Badges ───────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge.idle { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.badge.active, .badge.running { background: var(--olive-light); color: var(--olive); }
.badge.blocked { background: var(--terracotta-light); color: var(--terracotta); }
.badge.due { background: var(--blue-light); color: var(--blue); }
.badge.in_progress { background: var(--yellow-light); color: var(--yellow); }
.badge.completed { background: var(--olive-light); color: var(--olive); }
.badge.review, .badge.waiting_approval { background: var(--purple-light); color: var(--purple); }
.badge.backlog { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.badge.skipped { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.badge.urgent { background: var(--terracotta-light); color: var(--terracotta); }
.badge.high { background: var(--yellow-light); color: var(--yellow); }
.badge.normal { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.badge.low { background: var(--bg); color: var(--text-muted); }
.type-badge { background: var(--bg); border: 1px solid var(--border); color: var(--text-muted); }

/* ── Dashboard Grid ───────────────────────────────────── */

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
}
.dashboard-main { min-width: 0; }
.dashboard-aside { min-width: 0; }

/* ── Agent Cards ──────────────────────────────────────── */

.agent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 0.6rem;
}
.agent-card {
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 0.75rem;
    transition: all 0.2s;
    display: block;
    position: relative;
}
.agent-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
    color: var(--text);
}
.agent-card.status-active { border-left: 3px solid var(--olive); }
.agent-card.status-blocked { border-left: 3px solid var(--terracotta); }
.agent-name {
    font-family: var(--mono);
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}
.agent-role-short {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-top: 2px;
}
.agent-current {
    font-size: 0.7rem;
    color: var(--olive);
    margin-top: 0.4rem;
    font-style: italic;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.agent-idle-note {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
}

/* ── Kanban Board ─────────────────────────────────────── */

.kanban {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.kanban-col {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 0.5rem;
    min-height: 120px;
}
.kanban-col-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0.25rem 0.5rem;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 0.5rem;
}
.kanban-col-title {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    font-weight: 600;
}
.kanban-count {
    font-size: 0.6rem;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 1px 6px;
    border-radius: 10px;
    border: 1px solid var(--border-light);
}
.kanban-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 0.5rem;
    margin-bottom: 0.4rem;
    font-size: 0.75rem;
    transition: all 0.15s;
    display: block;
    color: var(--text);
}
.kanban-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
    color: var(--text);
}
.kanban-card-id {
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--text-muted);
}
.kanban-card-title {
    margin-top: 2px;
    line-height: 1.3;
}
.kanban-card-meta {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    margin-top: 0.35rem;
}
.kanban-agent {
    font-family: var(--mono);
    font-size: 0.6rem;
    color: var(--accent);
}

/* Blocked column */
.kanban-col.blocked { border-left: 2px solid var(--terracotta); }

/* ── Activity Feed ────────────────────────────────────── */

.activity-feed { max-height: 500px; overflow-y: auto; }
.activity-item {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.78rem;
    align-items: baseline;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--border);
    flex-shrink: 0;
    margin-top: 6px;
}
.activity-dot.alert { background: var(--terracotta); }
.activity-dot.task { background: var(--olive); }
.activity-dot.agent { background: var(--blue); }
.activity-body { flex: 1; min-width: 0; }
.activity-agent {
    font-family: var(--mono);
    font-weight: 600;
    color: var(--accent);
    font-size: 0.7rem;
}
.activity-msg {
    color: var(--text);
    overflow-wrap: break-word;
    line-height: 1.4;
}
.activity-time {
    color: var(--text-muted);
    font-size: 0.65rem;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Alerts ───────────────────────────────────────────── */

.alert-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}
.alert-item.priority-urgent { border-left: 3px solid var(--terracotta); background: var(--terracotta-light); }
.alert-item.priority-high { border-left: 3px solid var(--yellow); background: var(--yellow-light); }
.alert-item.dismissed { opacity: 0.5; }
.alert-header {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.4rem;
    flex-wrap: wrap;
}
.alert-header .from { color: var(--text-muted); font-size: 0.75rem; font-weight: 600; }
.alert-header .time { color: var(--text-muted); font-size: 0.65rem; margin-left: auto; }
.alert-item p { font-size: 0.8rem; line-height: 1.5; overflow-wrap: break-word; }

/* ── Needs Your Input ─────────────────────────────────── */

.input-needed {
    background: var(--yellow-light);
    border: 1px solid #e5d49a;
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}
.input-needed p { font-size: 0.8rem; line-height: 1.5; }

/* ── Tables ───────────────────────────────────────────── */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.task-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    min-width: 550px;
}
.task-table th {
    text-align: left;
    padding: 0.5rem;
    border-bottom: 2px solid var(--text);
    color: var(--text);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}
.task-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-light);
}
.task-table tr:hover { background: var(--bg-hover); }
.task-table.compact td { padding: 0.35rem 0.5rem; font-size: 0.78rem; }

.priority-1 { color: var(--terracotta); font-weight: 700; }
.priority-2 { color: var(--yellow); font-weight: 600; }
.priority-3 { color: var(--text-muted); }
.priority-4 { color: var(--text-muted); opacity: 0.6; }

/* ── Forms & Buttons ──────────────────────────────────── */

.filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    align-items: center;
    flex-wrap: wrap;
}
.filters select, .status-select {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius);
    font-size: 0.78rem;
    font-family: var(--sans);
}

.btn {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.78rem;
    font-family: var(--sans);
    white-space: nowrap;
    transition: all 0.15s;
}
.btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-light); }
.btn-muted { color: var(--text-muted); }
.btn-sm { padding: 2px 8px; font-size: 0.7rem; }
.btn-dismiss {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.65rem;
}
.btn-dismiss:hover { border-color: var(--terracotta); color: var(--terracotta); }

.task-input {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius);
    font-size: 0.82rem;
    font-family: var(--sans);
    width: 100%;
    max-width: 350px;
}
.actions-bar { margin-top: 1rem; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* ── Task Detail ──────────────────────────────────────── */

.task-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.75rem;
    margin: 1rem 0;
}
.meta-item label {
    display: block;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.agent-role-full { color: var(--text-muted); margin-bottom: 1rem; font-style: italic; }
.agent-actions { margin: 1rem 0; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* ── Messages / Thread ────────────────────────────────── */

.message {
    border-bottom: 1px solid var(--border-light);
    padding: 0.75rem 0;
}
.message:last-child { border-bottom: none; }
.message-header { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.25rem; flex-wrap: wrap; }
.message-header strong { font-family: var(--mono); color: var(--accent); font-size: 0.78rem; }
.message p { font-size: 0.82rem; line-height: 1.6; overflow-wrap: break-word; }

.working-memory {
    font-size: 0.78rem;
    line-height: 1.6;
    white-space: pre-wrap;
    color: var(--text-muted);
    overflow-wrap: break-word;
}

.brief-content pre {
    font-size: 0.82rem;
    line-height: 1.7;
    white-space: pre-wrap;
    font-family: var(--sans);
    overflow-wrap: break-word;
}

.muted { color: var(--text-muted); font-size: 0.82rem; }
.task-link { font-size: 0.75rem; }

/* ── Documents ────────────────────────────────────────── */

.doc-list { list-style: none; }
.doc-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.8rem;
}
.doc-item:last-child { border-bottom: none; }
.doc-type {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}
.doc-agent {
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--accent);
}
.doc-time { font-size: 0.65rem; color: var(--text-muted); }

/* ── Schedule Timeline ────────────────────────────────── */

.schedule-date-group {
    margin-bottom: 1.25rem;
}
.schedule-date-group:last-child {
    margin-bottom: 0;
}
.schedule-date {
    font-family: var(--serif);
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--text);
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 0.5rem;
}
.schedule-timeline {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.schedule-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.6rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    color: var(--text);
    transition: background 0.15s;
}
.schedule-item:hover {
    background: var(--bg-hover);
    color: var(--text);
}
.schedule-time {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 3.5rem;
}
.schedule-agent {
    min-width: 5rem;
    text-align: center;
    font-size: 0.6rem;
}
.schedule-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.schedule-freq {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Mobile Responsive ────────────────────────────────── */

@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .kanban {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .menu-toggle { display: flex; }
    .sidebar { transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-overlay { display: block; }

    .content {
        margin-left: 0;
        padding: 1rem;
        padding-top: 3.5rem;
    }

    h1 { font-size: 1.4rem; }
    .page-header { flex-direction: column; gap: 0.25rem; }

    .dashboard-grid { grid-template-columns: 1fr; }

    .kanban {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .agent-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .card { padding: 0.75rem; }

    .task-input { max-width: 100%; }

    .agent-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .activity-feed { max-height: 300px; }

    .task-meta-grid { grid-template-columns: repeat(2, 1fr); }

    .filters {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0.25rem;
    }

    .alert-header .time { margin-left: 0; }
}

@media (max-width: 400px) {
    .agent-grid { grid-template-columns: 1fr; }
    .kanban { grid-template-columns: 1fr; }
}
