/* ─── pyhall Desktop — Hall Monitor ─────────────────────────────────────────
   Theme: dark background, pyhall blue accent (#0050D4)
   ───────────────────────────────────────────────────────────────────────── */

:root {
  --bg-primary:     #1a1b1e;
  --bg-surface:     #25262b;
  --bg-raised:      #2c2e33;
  --bg-border:      #373a40;
  --accent-blue:    #0050D4;
  --accent-hover:   #0078D4;
  --accent-muted:   #1a3a7a;
  --success:        #40c057;
  --success-muted:  #1a4a28;
  --warning:        #fab005;
  --warning-muted:  #4a3800;
  --error:          #fa5252;
  --error-muted:    #4a1a1a;
  --info:           #74c0fc;
  --text-primary:   #c1c2c5;
  --text-bright:    #f8f9fa;
  --text-muted:     #6c757d;
  --text-dim:       #495057;
  --font:           -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  --font-mono:      'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --sidebar-width:  200px;
  --statusbar-h:    28px;
  --header-h:       48px;
  --radius:         6px;
  --radius-sm:      4px;
}

/* ─── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 13px;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  overflow: hidden;
}

/* ─── App Shell ──────────────────────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-rows: 1fr var(--statusbar-h);
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-areas:
    "sidebar content"
    "statusbar statusbar";
  height: 100vh;
  width: 100vw;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
#header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--bg-border);
}

#header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

#header-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: -0.01em;
}

#header-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

#header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.hall-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--bg-border);
  background: var(--bg-raised);
}

.hall-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.hall-indicator.online .dot  { background: var(--success); }
.hall-indicator.offline .dot { background: var(--error); }
.hall-indicator.connecting .dot {
  background: var(--warning);
  animation: pulse 1.2s ease-in-out infinite;
}

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

.hall-indicator.online  .label { color: var(--success); }
.hall-indicator.offline .label { color: var(--error); }
.hall-indicator.connecting .label { color: var(--warning); }

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
#sidebar {
  grid-area: sidebar;
  background: var(--bg-surface);
  border-right: 1px solid var(--bg-border);
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  border-radius: 0;
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s;
  border-left: 3px solid transparent;
  position: relative;
}

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

.nav-item.active {
  background: var(--accent-muted);
  color: var(--text-bright);
  border-left-color: var(--accent-blue);
}

.nav-item .nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item .nav-label {
  font-size: 12px;
  font-weight: 500;
}

.nav-badge {
  margin-left: auto;
  background: var(--error);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
}

.nav-spacer { flex: 1; }

.nav-divider {
  height: 1px;
  background: var(--bg-border);
  margin: 6px 0;
}

/* ─── Content ────────────────────────────────────────────────────────────── */
#content {
  grid-area: content;
  overflow-y: auto;
  padding: 20px 24px;
  background: var(--bg-primary);
}

.screen { display: none; }
.screen.active { display: block; }

/* ─── Status Bar ─────────────────────────────────────────────────────────── */
#statusbar {
  grid-area: statusbar;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 12px;
  background: var(--bg-surface);
  border-top: 1px solid var(--bg-border);
  font-size: 11px;
  color: var(--text-muted);
}

#statusbar .sep { color: var(--bg-border); }
#statusbar .status-online { color: var(--success); }
#statusbar .status-offline { color: var(--error); }
#statusbar #clock { margin-left: auto; font-family: var(--font-mono); }

/* ─── Section headers ────────────────────────────────────────────────────── */
.screen-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
}

.screen-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: -0.02em;
}

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

.section-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--bg-border);
}

/* ─── Stat Cards (Hall Status) ───────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 4px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius);
  padding: 16px;
}

.stat-card .stat-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-bright);
  font-family: var(--font-mono);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-card .stat-detail {
  font-size: 11px;
  color: var(--text-muted);
}

.stat-card .hall-status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.stat-card .hall-url {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  word-break: break-all;
}

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table th {
  text-align: left;
  padding: 6px 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--bg-border);
}

.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--bg-border);
  color: var(--text-primary);
  vertical-align: top;
}

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

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

/* Feed-specific row coloring */
.feed-table tr.dispatched {
  border-left: 3px solid var(--accent-blue);
}
.feed-table tr.dispatched td:first-child {
  padding-left: 7px;
}
.feed-table tr.refused {
  border-left: 3px solid var(--error);
}
.feed-table tr.refused td:first-child {
  padding-left: 7px;
}
.feed-table tr.held {
  border-left: 3px solid var(--warning);
}
.feed-table tr.held td:first-child {
  padding-left: 7px;
}

.outcome-dispatched { color: var(--accent-blue); font-weight: 600; }
.outcome-refused    { color: var(--error); font-weight: 600; }
.outcome-held       { color: var(--warning); font-weight: 600; }

/* ─── Worker Cards ───────────────────────────────────────────────────────── */
.worker-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.worker-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.12s;
}

.worker-card:hover { border-color: var(--accent-blue); }
.worker-card.critical-blast { border-color: var(--error); }

.worker-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.worker-species-id {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-bright);
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.status-badge.active     { background: var(--success-muted); color: var(--success); }
.status-badge.gated      { background: var(--warning-muted); color: var(--warning); }
.status-badge.idle       { background: var(--bg-raised); color: var(--text-muted); }
.status-badge.error      { background: var(--error-muted); color: var(--error); }
.status-badge.catalog    { background: var(--accent-muted); color: var(--info); }

.worker-card-meta {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 4px 0;
  font-size: 12px;
}

.worker-card-meta .meta-label {
  color: var(--text-muted);
}

.worker-card-meta .meta-value {
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11px;
}

.blast-tier {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}

.blast-low      { background: rgba(64, 192, 87, 0.15); color: #40c057; }
.blast-medium   { background: rgba(250, 176, 5, 0.15); color: #fab005; }
.blast-high     { background: rgba(250, 82, 82, 0.15); color: #fa5252; }
.blast-critical { background: var(--error-muted); color: var(--error); }

/* ─── Alert Cards ────────────────────────────────────────────────────────── */
.alert-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.alert-card {
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  border-left: 4px solid transparent;
}

.alert-card.severity-error   { border-left-color: var(--error); }
.alert-card.severity-warning { border-left-color: var(--warning); }
.alert-card.severity-info    { border-left-color: var(--text-dim); }

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

.alert-icon { font-size: 14px; }
.alert-title { font-weight: 600; color: var(--text-bright); font-size: 13px; }

.alert-body { font-size: 12px; color: var(--text-primary); line-height: 1.5; }

.alert-meta {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.alert-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.12s, border-color 0.12s;
}

.btn-primary {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-raised);
  color: var(--text-primary);
  border-color: var(--bg-border);
}
.btn-secondary:hover { background: var(--bg-border); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--bg-border);
}
.btn-ghost:hover { background: var(--bg-raised); color: var(--text-primary); }

.btn-sm {
  padding: 3px 8px;
  font-size: 11px;
}

/* ─── Inputs ─────────────────────────────────────────────────────────────── */
.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="url"],
.field select {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--font-mono);
  background: var(--bg-raised);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-sm);
  color: var(--text-bright);
  outline: none;
  transition: border-color 0.12s;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent-blue);
}

.field input[type="checkbox"] {
  accent-color: var(--accent-blue);
  margin-right: 6px;
}

.field .hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Radio group */
.radio-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--bg-border);
  background: var(--bg-raised);
  font-size: 12px;
  color: var(--text-muted);
  transition: all 0.12s;
}

.radio-option input[type="radio"] { display: none; }

.radio-option.selected {
  border-color: var(--accent-blue);
  background: var(--accent-muted);
  color: var(--text-bright);
}

/* ─── Enrollment drop zone ───────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--bg-border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  background: var(--bg-surface);
  margin-bottom: 16px;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent-blue);
  background: var(--accent-muted);
}

.drop-zone-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.5; }
.drop-zone-text { font-size: 14px; color: var(--text-muted); margin-bottom: 8px; }
.drop-zone-sub  { font-size: 12px; color: var(--text-dim); }

/* ─── Validation checklist ───────────────────────────────────────────────── */
.validation-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.validation-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--bg-border);
}

.validation-list li:last-child { border-bottom: none; }

.validation-list .check-ok      { color: var(--success); }
.validation-list .check-fail    { color: var(--error); }
.validation-list .check-warn    { color: var(--warning); }

/* ─── Preview card ───────────────────────────────────────────────────────── */
.preview-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 12px;
}

.preview-card .preview-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  padding: 4px 0;
  gap: 8px;
}

.preview-card .preview-label { color: var(--text-muted); }
.preview-card .preview-value { font-family: var(--font-mono); color: var(--text-primary); }

/* ─── Work ticket (evidence receipt) ────────────────────────────────────── */
.work-ticket {
  background: var(--bg-primary);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 6px;
  font-size: 11px;
  font-family: var(--font-mono);
}

.work-ticket .ticket-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  padding: 2px 0;
  gap: 8px;
}

.work-ticket .ticket-label { color: var(--text-muted); }
.work-ticket .ticket-value { color: var(--text-primary); word-break: break-all; }

/* ─── Filter chips ───────────────────────────────────────────────────────── */
.filter-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.chip {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--bg-border);
  background: var(--bg-raised);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.12s;
}

.chip:hover { border-color: var(--accent-blue); color: var(--text-primary); }
.chip.active {
  background: var(--accent-muted);
  border-color: var(--accent-blue);
  color: var(--text-bright);
}

/* ─── Pause / feed controls ──────────────────────────────────────────────── */
.feed-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.pause-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.paused-banner {
  background: var(--warning-muted);
  border: 1px solid var(--warning);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px;
  color: var(--warning);
  display: none;
}

.paused-banner.visible { display: block; }

/* ─── Search bar ─────────────────────────────────────────────────────────── */
.search-bar {
  position: relative;
  margin-bottom: 14px;
}

.search-bar input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  font-size: 13px;
  background: var(--bg-raised);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-sm);
  color: var(--text-bright);
  outline: none;
  font-family: var(--font);
}

.search-bar input:focus { border-color: var(--accent-blue); }

.search-bar .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
}

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state-icon { font-size: 36px; margin-bottom: 12px; opacity: 0.4; }
.empty-state-text { font-size: 14px; margin-bottom: 6px; }
.empty-state-sub  { font-size: 12px; }

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

.config-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--bg-border);
}

/* ─── Monospace code ─────────────────────────────────────────────────────── */
code, .mono {
  font-family: var(--font-mono);
  font-size: 11px;
}

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

/* ─── Refusal detail row ─────────────────────────────────────────────────── */
.refusal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--bg-border);
  font-size: 12px;
}

.refusal-row:last-child { border-bottom: none; }

.refusal-time { font-family: var(--font-mono); color: var(--text-muted); min-width: 100px; }
.refusal-cap  { font-family: var(--font-mono); color: var(--text-primary); flex: 1; padding: 0 12px; }
.refusal-reason { color: var(--warning); font-weight: 600; padding-right: 12px; }
.refusal-blast  { font-family: var(--font-mono); color: var(--error); }

/* ─── Hall info grid ─────────────────────────────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 0;
  font-size: 12px;
  padding: 10px 0;
}

.info-label { color: var(--text-muted); }
.info-value { font-family: var(--font-mono); color: var(--text-primary); }

/* ─── Connection test ────────────────────────────────────────────────────── */
.test-result {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

.test-result.success { background: var(--success-muted); color: var(--success); }
.test-result.failure { background: var(--error-muted); color: var(--error); }
