/* OpenClaw operator portal — control-room design system.
   Direction: dark slate control room, phosphor status accents, mono data.
   Deliberate dark: this is an ops console read at a glance. */

:root {
  --bg: oklch(16% 0.012 260);
  --bg-raised: oklch(20% 0.014 260);
  --bg-overlay: oklch(24% 0.016 260);
  --line: oklch(30% 0.015 260);
  --line-soft: oklch(25% 0.012 260);
  --text: oklch(90% 0.01 260);
  --text-dim: oklch(66% 0.015 260);
  --text-faint: oklch(50% 0.015 260);

  --accent: oklch(78% 0.14 75);          /* amber — brand + interactive */
  --accent-ink: oklch(20% 0.05 75);
  --ok: oklch(75% 0.17 150);             /* phosphor green */
  --warn: oklch(80% 0.15 90);
  --bad: oklch(68% 0.19 25);
  --info: oklch(72% 0.12 230);

  --font-ui: system-ui, "Segoe UI", sans-serif;
  --font-data: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;

  --text-hero: clamp(1.7rem, 1.2rem + 1.6vw, 2.6rem);
  --space-1: 0.375rem; --space-2: 0.75rem; --space-3: 1.25rem;
  --space-4: 2rem; --space-5: 3.25rem;
  --radius: 6px;
  --dur: 160ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-ui); font-size: 15px; line-height: 1.5;
}
::selection { background: var(--accent); color: var(--accent-ink); }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line-soft);
  background:
    linear-gradient(180deg, oklch(19% 0.018 265), transparent 40%),
    var(--bg-raised);
  padding: var(--space-3) var(--space-2);
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 var(--space-2) var(--space-3); }
.brand-mark { font-size: 1.6rem; color: var(--accent); text-shadow: 0 0 18px oklch(78% 0.14 75 / 0.5); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; letter-spacing: 0.02em; }
.brand-sub { font-family: var(--font-data); font-size: 0.68rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.14em; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px var(--space-2); border-radius: var(--radius);
  color: var(--text-dim); text-decoration: none;
  border-left: 2px solid transparent;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.nav-item:hover { color: var(--text); background: var(--bg-overlay); }
.nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.nav-item.active {
  color: var(--accent); background: oklch(78% 0.14 75 / 0.08);
  border-left-color: var(--accent); border-radius: 0 var(--radius) var(--radius) 0;
}
.nav-icon { width: 1.1em; text-align: center; }

.sidebar-foot { border-top: 1px solid var(--line-soft); padding-top: var(--space-2); display: flex; flex-direction: column; gap: 6px; }
.user-chip {
  font-family: var(--font-data); font-size: 0.72rem; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ghost-btn {
  background: none; border: 1px solid var(--line); color: var(--text-dim);
  border-radius: var(--radius); padding: 4px 10px; font-size: 0.78rem; cursor: pointer;
  transition: border-color var(--dur), color var(--dur);
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }

.content { padding: var(--space-4) var(--space-5) var(--space-5); min-width: 0; }

/* ---------------------------------------------------------------- headers */
.page-head { margin-bottom: var(--space-4); }
.eyebrow {
  font-family: var(--font-data); font-size: 0.7rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--text-faint); margin: 0 0 4px;
}
.page-head h1 { font-size: var(--text-hero); font-weight: 750; letter-spacing: -0.02em; margin: 0; }
.section-label {
  font-family: var(--font-data); font-size: 0.72rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--text-dim);
  display: flex; align-items: center; gap: 10px;
  margin: var(--space-4) 0 var(--space-2);
}
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }

/* ---------------------------------------------------------------- home */
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-3); }
.app-card {
  display: flex; flex-direction: column; gap: 6px;
  padding: var(--space-3); text-decoration: none; color: var(--text);
  background: var(--bg-raised); border: 1px solid var(--line-soft); border-radius: var(--radius);
  transition: transform var(--dur) var(--ease), border-color var(--dur), box-shadow var(--dur);
}
.app-card:hover {
  transform: translateY(-2px); border-color: var(--accent);
  box-shadow: 0 8px 30px oklch(0% 0 0 / 0.35), 0 0 0 1px oklch(78% 0.14 75 / 0.2);
}
.app-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app-card-icon { font-size: 1.5rem; color: var(--accent); }
.app-card-title { font-weight: 650; font-size: 1.05rem; }
.app-card-desc { color: var(--text-dim); font-size: 0.86rem; flex: 1; }
.app-card-go { font-family: var(--font-data); font-size: 0.74rem; color: var(--text-faint); transition: color var(--dur); }
.app-card:hover .app-card-go { color: var(--accent); }

/* ---------------------------------------------------------------- login */
.login-body {
  display: grid; place-items: center; min-height: 100vh;
  background:
    radial-gradient(60vw 40vh at 70% 10%, oklch(24% 0.03 75 / 0.5), transparent 60%),
    radial-gradient(50vw 50vh at 10% 90%, oklch(22% 0.03 260 / 0.6), transparent 60%),
    var(--bg);
}
.login-card {
  width: min(380px, calc(100vw - 2rem));
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: 10px; padding: var(--space-4);
  box-shadow: 0 24px 80px oklch(0% 0 0 / 0.5);
}
.login-brand { padding: 0 0 var(--space-3); }
.login-card h1 { font-size: 1.3rem; margin: 0 0 var(--space-3); }
.login-card label {
  display: block; font-family: var(--font-data); font-size: 0.7rem;
  text-transform: uppercase; letter-spacing: 0.14em; color: var(--text-dim);
  margin: var(--space-2) 0 4px;
}
.login-card input {
  width: 100%; padding: 10px 12px; border-radius: var(--radius);
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
  font-size: 0.95rem; transition: border-color var(--dur), box-shadow var(--dur);
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px oklch(78% 0.14 75 / 0.18); }
.primary-btn {
  width: 100%; margin-top: var(--space-3); padding: 11px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
  border: none; border-radius: var(--radius); font-size: 0.95rem; cursor: pointer;
  transition: filter var(--dur), transform var(--dur) var(--ease);
}
.primary-btn:hover { filter: brightness(1.08); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.form-error {
  background: oklch(68% 0.19 25 / 0.12); border: 1px solid oklch(68% 0.19 25 / 0.4);
  color: var(--bad); border-radius: var(--radius); padding: 8px 12px; font-size: 0.86rem;
}
.login-foot { text-align: center; font-family: var(--font-data); font-size: 0.68rem; color: var(--text-faint); margin: var(--space-3) 0 0; }

/* ---------------------------------------------------------------- data tables */
.data-table { width: 100%; border-collapse: collapse; font-family: var(--font-data); font-size: 0.8rem; }
.data-table th {
  text-align: left; font-weight: 600; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.66rem;
  padding: 6px 10px; border-bottom: 1px solid var(--line);
}
.data-table td { padding: 7px 10px; border-bottom: 1px solid var(--line-soft); color: var(--text-dim); vertical-align: top; }
.data-table tr:hover td { background: oklch(24% 0.016 260 / 0.6); color: var(--text); }
.data-table .primary-cell { color: var(--text); font-weight: 600; }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.7rem; padding: 1px 8px; border-radius: 99px;
  border: 1px solid var(--line); white-space: nowrap;
}
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-ok   { color: var(--ok);   border-color: oklch(75% 0.17 150 / 0.4); }
.status-ok::before { box-shadow: 0 0 8px oklch(75% 0.17 150 / 0.8); }
.status-warn { color: var(--warn); border-color: oklch(80% 0.15 90 / 0.4); }
.status-bad  { color: var(--bad);  border-color: oklch(68% 0.19 25 / 0.4); }
.status-bad::before { box-shadow: 0 0 8px oklch(68% 0.19 25 / 0.8); }
.status-idle { color: var(--text-faint); }
.status-info { color: var(--info); border-color: oklch(72% 0.12 230 / 0.4); }

/* ---------------------------------------------------------------- monitor */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-2); margin-bottom: var(--space-2); }
.stat-card {
  background: var(--bg-raised); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
}
.stat-value { font-family: var(--font-data); font-size: 1.6rem; font-weight: 700; }
.stat-label { font-family: var(--font-data); font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-faint); }
.stat-value.ok { color: var(--ok); } .stat-value.bad { color: var(--bad); } .stat-value.warn { color: var(--warn); }

.refresh-note { font-family: var(--font-data); font-size: 0.7rem; color: var(--text-faint); }
.refresh-note .live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); margin-right: 5px;
  animation: pulse 2s var(--ease) infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
  * { transition-duration: 0.01ms !important; }
}

.log-pane {
  background: oklch(12% 0.01 260); border: 1px solid var(--line-soft); border-radius: var(--radius);
  font-family: var(--font-data); font-size: 0.72rem; line-height: 1.45;
  padding: var(--space-2) var(--space-3); overflow-x: auto; white-space: pre-wrap;
  max-height: 320px; overflow-y: auto; color: var(--text-dim);
}

/* ---------------------------------------------------------------- intake chat */
.chat-wrap { display: flex; flex-direction: column; gap: var(--space-2); max-width: 880px; }
.chat-history { display: flex; flex-direction: column; gap: var(--space-2); }
.msg { display: flex; flex-direction: column; gap: 2px; max-width: 85%; }
.msg-meta { font-family: var(--font-data); font-size: 0.64rem; color: var(--text-faint); letter-spacing: 0.06em; }
.msg-body {
  padding: 10px 14px; border-radius: 10px; font-size: 0.92rem;
  white-space: pre-wrap; word-break: break-word;
}
.msg.operator { align-self: flex-end; align-items: flex-end; }
.msg.operator .msg-body { background: oklch(78% 0.14 75 / 0.14); border: 1px solid oklch(78% 0.14 75 / 0.35); }
.msg.agent { align-self: flex-start; }
.msg.agent .msg-body { background: var(--bg-raised); border: 1px solid var(--line-soft); }
.msg.pending .msg-body { border-style: dashed; color: var(--text-faint); font-style: italic; }
.msg.error .msg-body { border-color: oklch(68% 0.19 25 / 0.5); color: var(--bad); }

.chat-form { display: flex; gap: var(--space-2); position: sticky; bottom: 0; padding: var(--space-2) 0; background: linear-gradient(transparent, var(--bg) 30%); }
.chat-form textarea {
  flex: 1; resize: vertical; min-height: 52px; max-height: 200px;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); padding: 10px 12px; font-family: var(--font-ui); font-size: 0.92rem;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.chat-form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px oklch(78% 0.14 75 / 0.18); }
.chat-form .primary-btn { width: auto; margin: 0; padding: 0 22px; }

.empty-note { color: var(--text-faint); font-size: 0.86rem; border: 1px dashed var(--line); border-radius: var(--radius); padding: var(--space-3); text-align: center; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar nav { flex-direction: row; }
  .sidebar-foot { border: none; padding: 0; margin-left: auto; flex-direction: row; }
  .content { padding: var(--space-3); }
}
