/* OpenClaw Dashboard — Clean, minimal design */

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-hover: #222632;
    --border: #2a2e3a;
    --text: #e4e6eb;
    --text-muted: #8b8fa3;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --green: #22c55e;
    --red: #ef4444;
    --orange: #f59e0b;
    --radius: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

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

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

header h1 {
    font-size: 20px;
    font-weight: 600;
}

.nav-tabs {
    display: flex;
    gap: 4px;
}

.nav-tab {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.2s;
}

.nav-tab.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.nav-tab:hover:not(.active) {
    border-color: var(--accent);
    color: var(--text);
}

/* Alerts */
.alert-banner {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: alert-in 0.3s ease-out;
}

@keyframes alert-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-banner.critical {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--red);
}

.alert-banner.warning {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--orange);
}

.alert-icon { font-size: 15px; }

/* Status Bar (Health + KPI) */
.status-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.status-bar-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.status-divider {
    width: 1px;
    height: 32px;
    background: var(--border);
}

.status-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 80px;
}

.status-item.kpi {
    align-items: center;
    min-width: 60px;
}

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

.status-value {
    font-size: 13px;
    font-weight: 500;
}

.kpi-val {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
}

.h-ok { color: var(--green); }
.h-err { color: var(--red); }
.h-pct { font-size: 11px; margin-left: 3px; color: var(--text-muted); }
.h-pct.h-err { color: var(--red); }

/* Cards */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: border-color 0.2s;
}

.card:hover {
    border-color: var(--accent);
}

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

.card-emoji {
    font-size: 32px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-hover);
    border-radius: var(--radius-sm);
}

.card-title {
    font-size: 18px;
    font-weight: 600;
}

.card-role {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.card-gear {
    font-size: 18px;
    color: var(--text-muted);
    text-decoration: none;
    opacity: 0.4;
    transition: opacity 0.2s;
    padding: 4px;
}

.card:hover .card-gear { opacity: 0.7; }
.card-gear:hover { opacity: 1 !important; color: var(--accent); }

.card-metrics {
    display: flex;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.card-metric {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 50px;
}

.card-metric-val {
    font-weight: 600;
    font-size: 14px;
}

.card-metric-lbl {
    color: var(--text-muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Status indicator */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

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

/* Sections */
.section {
    margin-bottom: 32px;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 18px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
}

.date-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--surface-hover); }
.date-btn:disabled { opacity: 0.3; cursor: default; }

#date-label {
    font-size: 15px;
    font-weight: 600;
    min-width: 80px;
    text-align: center;
}

.feed-tabs {
    margin-left: auto;
    display: flex;
    gap: 4px;
}

.tab {
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.tab:hover:not(.active) {
    border-color: var(--accent);
    color: var(--text);
}

.day-summary {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text);
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(34, 197, 94, 0.06));
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.hour-bin {
    margin-bottom: 20px;
}

.hour-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.hour-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent);
    padding: 4px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.hour-count {
    font-size: 12px;
    color: var(--text-muted);
}

.hour-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 8px;
}

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

.hour-col {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.hour-col-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.hour-bullet {
    font-size: 13px;
    padding: 4px 0;
    line-height: 1.5;
    position: relative;
    padding-left: 14px;
}

.hour-bullet::before {
    content: '→';
    position: absolute;
    left: 0;
    font-weight: 600;
}

.hour-bullet.req::before {
    color: var(--accent);
}

.hour-bullet.resp::before {
    color: var(--green);
}

.bullet-time {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.bullet-user {
    font-weight: 600;
    color: var(--accent);
    font-size: 12px;
}

.hour-users {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.user-group {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.user-group-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.hour-summary {
    font-size: 13px;
    color: var(--text);
    line-height: 1.6;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.hour-narrative {
    font-size: 13px;
    color: var(--text);
    line-height: 1.7;
    padding: 4px 0;
}

.hour-details {
    margin-bottom: 4px;
}

.hour-toggle {
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 0;
    user-select: none;
}

.hour-toggle:hover {
    color: var(--accent);
}

.hour-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-left: 12px;
    border-left: 2px solid var(--border);
    margin-top: 6px;
}

.feed-time-inline {
    color: var(--text-muted);
    font-size: 12px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    margin-right: 6px;
}

.raw-msg.user {
    border-left: 2px solid var(--accent);
    padding-left: 10px;
}

.raw-msg.agent {
    border-left: 2px solid var(--green);
    padding-left: 10px;
}

.raw-text {
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
    margin-top: 2px;
    line-height: 1.5;
}

/* Feed */
.feed {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.feed-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 14px;
}

.feed-time {
    color: var(--text-muted);
    font-size: 13px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    min-width: 45px;
    flex-shrink: 0;
}

.feed-agent {
    font-weight: 600;
    min-width: 80px;
    flex-shrink: 0;
}

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

.feed-pair {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.feed-req {
    color: var(--text);
    font-size: 13px;
}

.feed-resp {
    color: var(--text-muted);
    font-size: 13px;
}

.feed-who {
    font-weight: 600;
    font-size: 12px;
    margin-right: 6px;
    display: inline-block;
}

.feed-who.user {
    color: var(--accent);
}

.feed-who.agent {
    color: var(--green);
}

/* Artifacts */
.artifacts {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.artifact {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.2s;
}

.artifact:hover {
    border-color: var(--accent);
}

.artifact-icon { font-size: 20px; }

.artifact-info { flex: 1; }

.artifact-name {
    font-weight: 500;
    font-size: 14px;
}

.artifact-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.artifact-download {
    color: var(--accent);
    font-size: 13px;
    font-weight: 500;
}

/* Admin-specific */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.metric {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.metric-value {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

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

/* Table */
.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    font-weight: 500;
}

td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-hover); }

/* Progress bar */
.progress {
    width: 100px;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

.progress-fill.low { background: var(--green); }
.progress-fill.mid { background: var(--orange); }
.progress-fill.high { background: var(--red); }

/* Logs */
.logs {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    max-height: 400px;
    overflow-y: auto;
    line-height: 1.8;
}

.log-line {
    color: var(--text-muted);
}

.log-line .ts { color: var(--text-muted); }
.log-line .level-error { color: var(--red); }
.log-line .level-warn { color: var(--orange); }
.log-line .msg { color: var(--text); }

/* Login */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    width: 360px;
}

.login-box h2 {
    margin-bottom: 24px;
    text-align: center;
}

.login-box input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    margin-bottom: 16px;
    outline: none;
}

.login-box input:focus {
    border-color: var(--accent);
}

.btn {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn:hover { background: var(--accent-hover); }

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

/* Config Page */
.config-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.config-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.config-name {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.config-id {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Fira Code', monospace;
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
}

.config-role {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.config-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

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

.config-value {
    font-size: 13px;
}

.config-value.mono {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    color: var(--text-muted);
}

.badge {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    margin-right: 4px;
}

.config-section {
    margin-top: 12px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
}

.config-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px 0;
    user-select: none;
}

.config-section-title:hover { color: var(--accent); }

.config-section-body {
    padding-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.config-skill-row, .config-file-row {
    display: flex;
    gap: 10px;
    font-size: 13px;
    padding: 6px 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    align-items: baseline;
    transition: background 0.15s;
}

.config-skill-row:hover, .config-file-row:hover {
    background: var(--surface-hover);
}

.config-skill-name {
    font-weight: 600;
    min-width: 120px;
    color: var(--accent);
    flex-shrink: 0;
}

.config-skill-preview {
    color: var(--text-muted);
    font-size: 12px;
}

.config-file-icon { font-size: 14px; }
.config-file-name { font-size: 13px; }

/* Modal */
#modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}

.modal-box {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: min(90vw, 700px);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

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

.modal-title {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.modal-close:hover { color: var(--text); }

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-text {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text);
}

.modal-code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text);
    margin: 0;
}

.config-cron {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    font-size: 13px;
    padding: 8px 10px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    align-items: center;
}

.config-cron-name { font-weight: 600; min-width: 160px; flex-shrink: 0; }
.config-cron-schedule { font-size: 12px; color: var(--text-muted); min-width: 140px; }
.config-cron-status { font-size: 12px; }
.config-cron-status.ok { color: var(--green); }
.config-cron-status.err { color: var(--red); font-weight: 600; }
.config-cron-dur { font-size: 11px; color: var(--text-muted); }
.config-cron-desc { font-size: 12px; color: var(--text-muted); margin-top: 4px; width: 100%; }
.config-cron-err { font-size: 11px; color: var(--red); margin-top: 2px; width: 100%; }

.config-file {
    margin-bottom: 4px;
}

.config-file-name {
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 0;
}

.config-file-name:hover { color: var(--accent); }

.config-file-content {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    line-height: 1.6;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Responsive */
@media (max-width: 768px) {
    .container { padding: 16px; }
    .cards { grid-template-columns: 1fr; }
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .card-metrics { flex-wrap: wrap; }
    .status-bar { flex-direction: column; gap: 12px; }
    .status-divider { width: 100%; height: 1px; }
    .hour-columns { grid-template-columns: 1fr; }
}
