/* FRIP Mission Control — Dashboard Styles */
/* Dark theme, responsive grid, status indicators */

:root {
    --bg: #0a0a0a;
    --card-bg: rgba(255, 255, 255, 0.06);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-hover: rgba(255, 255, 255, 0.09);
    --text: #e0e0e0;
    --text-dim: #888;
    --text-bright: #fff;
    --green: #24e08a;
    --yellow: #ffd700;
    --red: #ff5c5c;
    --blue: #5c9eff;
    --orange: #ff9f43;
    --purple: #a78bfa;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --mono: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
}

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

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

/* ─── Header ──────────────────────────────────────── */

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

header h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-bright);
    letter-spacing: -0.3px;
}

.subtitle {
    color: var(--text-dim);
    font-size: 12px;
    margin-left: 12px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-dim);
}

.indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-dim);
    display: inline-block;
}

.indicator.live { background: var(--green); box-shadow: 0 0 6px var(--green); }
.indicator.stale { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.indicator.dead { background: var(--red); box-shadow: 0 0 6px var(--red); }

/* ─── Stale Banner ────────────────────────────────── */

.stale-banner {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    color: var(--yellow);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
    text-align: center;
}

.stale-banner.hidden { display: none; }

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

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 16px;
}

@media (max-width: 768px) {
    .grid {
        grid-template-columns: 1fr;
    }
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .subtitle { margin-left: 0; display: block; }
}

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

.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    overflow: hidden;
    transition: background 0.2s;
}

.card:hover {
    background: var(--card-hover);
}

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

.card-header h2 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-bright);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-body {
    padding: 12px 16px;
}

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

.badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge.ok {
    background: rgba(36, 224, 138, 0.15);
    color: var(--green);
}

.badge.warning {
    background: rgba(255, 215, 0, 0.15);
    color: var(--yellow);
}

.badge.error {
    background: rgba(255, 92, 92, 0.15);
    color: var(--red);
}

.badge.info {
    background: rgba(92, 158, 255, 0.15);
    color: var(--blue);
}

.badge.neutral {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-dim);
}

/* ─── Metric Rows ─────────────────────────────────── */

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

.metric-row + .metric-row {
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.label {
    color: var(--text-dim);
    font-size: 13px;
}

.value {
    color: var(--text-bright);
    font-size: 13px;
    font-weight: 500;
}

.value.mono {
    font-family: var(--mono);
    font-size: 12px;
}

/* ─── Status Dots ─────────────────────────────────── */

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.status-dot.ok { background: var(--green); }
.status-dot.warning { background: var(--yellow); }
.status-dot.error { background: var(--red); }

/* ─── Auth Profile Items ──────────────────────────── */

.auth-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
}

.auth-item + .auth-item {
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.auth-name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text);
}

.auth-detail {
    font-size: 11px;
    color: var(--text-dim);
}

/* ─── Session Items ───────────────────────────────── */

.session-item {
    padding: 8px 0;
}

.session-item + .session-item {
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.session-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.session-channel {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-bright);
    text-transform: capitalize;
}

.session-model {
    font-size: 11px;
    font-family: var(--mono);
    color: var(--purple);
}

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

/* ─── Cron Items ──────────────────────────────────── */

.cron-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
}

.cron-item + .cron-item {
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.cron-name {
    font-size: 13px;
    color: var(--text);
    font-weight: 500;
}

.cron-schedule {
    font-size: 11px;
    font-family: var(--mono);
    color: var(--text-dim);
}

/* ─── FRIP-KB Items ───────────────────────────────── */

.fripkb-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

.fripkb-item + .fripkb-item {
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.fripkb-name {
    font-size: 13px;
    color: var(--text);
}

.fripkb-count {
    font-size: 12px;
    font-family: var(--mono);
    color: var(--blue);
    font-weight: 500;
}

/* ─── Error Items ─────────────────────────────────── */

.error-item {
    padding: 6px 0;
    font-size: 12px;
}

.error-item + .error-item {
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.error-message {
    color: var(--red);
    font-family: var(--mono);
    font-size: 11px;
    word-break: break-all;
    line-height: 1.4;
}

.error-time {
    color: var(--text-dim);
    font-size: 10px;
    margin-top: 2px;
}

/* ─── Resource Sections ───────────────────────────── */

.resource-section h3 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.resource-section + .resource-section {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

/* ─── Empty State ─────────────────────────────────── */

.empty-state {
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
    padding: 12px 0;
    font-style: italic;
}

/* ─── Footer ──────────────────────────────────────── */

footer {
    display: flex;
    justify-content: space-between;
    padding: 16px 0;
    margin-top: 20px;
    border-top: 1px solid var(--card-border);
    font-size: 11px;
    color: var(--text-dim);
}

@media (max-width: 768px) {
    footer {
        flex-direction: column;
        gap: 4px;
    }
}

/* ─── Animations ──────────────────────────────────── */

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

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}


/* Active Tasks card — spans full width */
.card-wide {
    grid-column: 1 / -1;
}

.task-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

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

.task-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

.task-category {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.cat-research { background: #1a3a4a; color: #4fc3f7; }
.cat-coding { background: #1a3a1a; color: #81c784; }
.cat-analytics { background: #3a2a1a; color: #ffb74d; }
.cat-policy { background: #2a1a3a; color: #ce93d8; }
.cat-digest { background: #1a2a3a; color: #90caf9; }
.cat-system { background: #2a2a2a; color: #bdbdbd; }
.cat-unknown { background: #2a2a2a; color: #9e9e9e; }

.task-model {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-dim);
}

.task-duration {
    font-family: var(--mono);
    font-size: 12px;
}

.task-status-active {
    color: var(--green);
}

.task-status-idle {
    color: var(--text-dim);
}

/* ─── Tab Navigation ──────────────────────────────── */

.tab-nav {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--card-border);
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 20px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--text);
}

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

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ─── Session Inspector Layout ────────────────────── */

.si-layout {
    display: flex;
    gap: 16px;
    min-height: calc(100vh - 200px);
}

.si-sidebar {
    width: 360px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.si-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

@media (max-width: 900px) {
    .si-layout {
        flex-direction: column;
    }
    .si-sidebar {
        width: 100%;
    }
}

/* ─── Session Inspector Filters ───────────────────── */

.si-filters {
    display: flex;
    gap: 8px;
}

.si-select {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text);
    font-family: var(--font);
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 6px;
    flex: 1;
    cursor: pointer;
}

.si-select:focus {
    outline: none;
    border-color: var(--blue);
}

.si-btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text);
    font-family: var(--font);
    font-size: 12px;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.si-btn:hover {
    background: var(--card-hover);
    border-color: var(--blue);
}

/* ─── Session List ────────────────────────────────── */

.si-session-list {
    flex: 1;
    overflow-y: auto;
    max-height: calc(100vh - 260px);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
}

.si-session-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.15s;
}

.si-session-item:last-child {
    border-bottom: none;
}

.si-session-item:hover {
    background: var(--card-hover);
}

.si-session-item.active {
    background: rgba(92, 158, 255, 0.1);
    border-left: 3px solid var(--blue);
}

.si-session-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-bright);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.si-session-model {
    font-size: 11px;
    font-family: var(--mono);
    margin-bottom: 2px;
}

.si-session-info {
    font-size: 11px;
    color: var(--text-dim);
    display: flex;
    gap: 12px;
}

/* ─── Model Colors ────────────────────────────────── */

.model-claude { color: var(--purple); }
.model-gpt { color: var(--green); }
.model-qwen { color: var(--orange); }
.model-gemini { color: var(--blue); }
.model-unknown { color: var(--text-dim); }

.model-bg-claude { background: rgba(167, 139, 250, 0.08); border-left-color: var(--purple); }
.model-bg-gpt { background: rgba(36, 224, 138, 0.08); border-left-color: var(--green); }
.model-bg-qwen { background: rgba(255, 159, 67, 0.08); border-left-color: var(--orange); }
.model-bg-gemini { background: rgba(92, 158, 255, 0.08); border-left-color: var(--blue); }

/* ─── Transcript Header ──────────────────────────── */

.si-transcript-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px 10px 0 0;
    margin-bottom: 0;
}

.si-transcript-title {
    display: flex;
    flex-direction: column;
}

.si-transcript-title span:first-child {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-bright);
}

.si-transcript-meta {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 2px;
}

.si-transcript-filters {
    display: flex;
    gap: 8px;
}

/* ─── Transcript Messages ─────────────────────────── */

.si-transcript {
    flex: 1;
    overflow-y: auto;
    max-height: calc(100vh - 300px);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-top: none;
    border-radius: 0 0 10px 10px;
    padding: 8px;
}

.si-msg {
    padding: 10px 12px;
    margin-bottom: 6px;
    border-radius: 8px;
    border-left: 3px solid transparent;
    background: rgba(255, 255, 255, 0.02);
}

.si-msg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.si-msg-role {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.si-msg-role.role-human { color: var(--green); }
.si-msg-role.role-assistant { color: var(--purple); }
.si-msg-role.role-tool { color: var(--orange); }
.si-msg-role.role-toolResult { color: var(--yellow); }
.si-msg-role.role-system { color: var(--blue); }

.si-msg-time {
    font-size: 10px;
    color: var(--text-dim);
    font-family: var(--mono);
}

.si-msg-model {
    font-size: 10px;
    font-family: var(--mono);
    margin-bottom: 4px;
}

.si-msg-content {
    font-size: 12px;
    color: var(--text);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 120px;
    overflow: hidden;
    position: relative;
}

.si-msg-content.expanded {
    max-height: none;
}

.si-msg-content.truncated::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(transparent, rgba(10, 10, 10, 0.9));
    pointer-events: none;
}

.si-msg-expand {
    font-size: 11px;
    color: var(--blue);
    cursor: pointer;
    margin-top: 4px;
    display: inline-block;
}

.si-msg-expand:hover {
    text-decoration: underline;
}

/* ─── Special Message Types ───────────────────────── */

.si-msg.msg-model-change {
    background: rgba(92, 158, 255, 0.05);
    border-left-color: var(--blue);
    padding: 6px 12px;
}

.si-msg.msg-system {
    background: rgba(92, 158, 255, 0.05);
    border-left-color: var(--blue);
}

.si-msg.msg-human {
    border-left-color: var(--green);
}

.si-msg.msg-assistant {
    border-left-color: var(--purple);
}

.si-msg.msg-tool {
    border-left-color: var(--orange);
    background: rgba(255, 159, 67, 0.03);
}

.si-msg.msg-error {
    border-left-color: var(--red);
    background: rgba(255, 92, 92, 0.05);
}

.si-tool-name {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--orange);
    background: rgba(255, 159, 67, 0.1);
    padding: 1px 6px;
    border-radius: 3px;
    display: inline-block;
    margin-bottom: 4px;
}

.si-tool-input {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-dim);
    background: rgba(0, 0, 0, 0.3);
    padding: 6px 8px;
    border-radius: 4px;
    max-height: 80px;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-all;
}

.si-tool-input.expanded {
    max-height: none;
}

.si-usage-bar {
    display: flex;
    gap: 10px;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 4px;
}

.si-usage-bar span {
    opacity: 0.7;
}

/* ─── Loading / Empty ─────────────────────────────── */

.si-loading {
    text-align: center;
    color: var(--text-dim);
    padding: 40px 0;
    font-size: 13px;
}

.si-loading::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--text-dim);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
