/* ClawHub Dashboard — Discord-like dark theme */

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

:root {
  --bg: #1a1a2e;
  --bg-dark: #151525;
  --bg-darker: #12121f;
  --surface: #1e1e35;
  --surface-2: #252542;
  --surface-3: #2a2a4a;
  --border: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.12);
  --text: #e8e8f0;
  --text-muted: #9898b0;
  --text-dim: #686888;
  --accent: #a78bfa;
  --accent-dim: #7c3aed;
  --accent-glow: rgba(167, 139, 250, 0.15);
  --green: #4ade80;
  --green-dim: rgba(74, 222, 128, 0.12);
  --orange: #fb923c;
  --orange-dim: rgba(251, 146, 60, 0.12);
  --red: #f87171;
  --red-dim: rgba(248, 113, 113, 0.12);
  --blue: #60a5fa;
  --blue-dim: rgba(96, 165, 250, 0.12);
  --pink: #f472b6;
  --cyan: #22d3ee;
  --yellow: #facc15;
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ─── Login screen ─────────────────────────────────────────────────────────── */

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: var(--bg-darker);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.login-logo {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 8px;
}

.login-logo span { color: var(--text); }

.login-subtitle {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 32px;
}

.login-card label {
  display: block;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.login-card input[type="email"] {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 16px;
  outline: none;
  background: var(--surface-2);
  color: var(--text);
  transition: border-color 0.2s;
}

.login-card input[type="email"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.login-card .btn-primary {
  width: 100%;
  margin-top: 16px;
}

.login-message {
  margin-top: 16px;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.login-message.success {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(74, 222, 128, 0.2);
}

.login-message.error {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.2);
}

/* ─── Buttons ──────────────────────────────────────────────────────────────── */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  background: var(--accent-dim);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}

.btn-primary:hover { background: #6d28d9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-secondary:hover { background: var(--surface-3); }

.btn-sm { padding: 5px 14px; font-size: 12px; }

.btn-green { background: #16a34a; }
.btn-green:hover { background: #15803d; }

.btn-red {
  background: var(--surface-2);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.2);
}
.btn-red:hover { background: var(--red-dim); }

/* ─── App layout ───────────────────────────────────────────────────────────── */

.app-layout {
  display: none;
  flex-direction: column;
  height: 100vh;
}

.app-layout.active {
  display: flex;
}

/* Top bar */
.topbar {
  background: var(--bg-darker);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }

.topbar-logo {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent);
}

.topbar-logo span { color: var(--text); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.topbar-plan {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
  background: var(--accent-glow);
  color: var(--accent);
  text-transform: capitalize;
}

.topbar-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.topbar-btn:hover {
  background: var(--surface);
  color: var(--text);
}

/* App body: 3-column */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ─── Left sidebar ─────────────────────────────────────────────────────────── */

.sidebar {
  width: 240px;
  background: var(--bg-dark);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  padding: 12px 0;
}

.sidebar-section { margin-bottom: 8px; }

.sidebar-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  padding: 8px 16px 4px;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.channel-item:hover { background: rgba(255, 255, 255, 0.03); }

.channel-item.active {
  background: var(--accent-glow);
  color: var(--text);
}

.channel-item-hash {
  color: var(--text-dim);
  font-weight: 500;
  flex-shrink: 0;
}

.channel-item-name { flex: 1; }

.channel-item-badge {
  font-size: 10px;
  font-weight: 700;
  background: var(--red);
  color: white;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
}

.agent-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.agent-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

.agent-dot.offline { background: var(--text-dim); }

.agent-item-name { font-weight: 500; }
.agent-item-role { color: var(--text-dim); font-size: 11px; }

/* ─── Main panel ───────────────────────────────────────────────────────────── */

.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.channel-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  background: var(--bg);
}

.channel-hash {
  color: var(--text-dim);
  font-size: 18px;
  font-weight: 500;
}

.channel-name {
  font-size: 15px;
  font-weight: 600;
}

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

/* Message feed */
.message-feed {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}

.empty-state p {
  font-size: 14px;
  max-width: 400px;
  margin: 0 auto;
}

/* Message bubbles */
.message {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  padding: 4px 0;
}

.message:hover { background: rgba(255, 255, 255, 0.01); border-radius: 8px; }

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  color: white;
}

.msg-avatar.user { background: var(--accent-dim); }
.msg-avatar.sam { background: var(--blue); }
.msg-avatar.maya { background: var(--pink); }
.msg-avatar.iris { background: var(--accent); }
.msg-avatar.felix { background: var(--green); }
.msg-avatar.nora { background: var(--orange); }
.msg-avatar.rex { background: var(--cyan); }
.msg-avatar.dash { background: var(--yellow); color: #333; }

.msg-body { flex: 1; min-width: 0; }

.msg-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.msg-name { font-size: 13px; font-weight: 600; }
.msg-role { font-size: 11px; color: var(--text-dim); }
.msg-time { font-size: 11px; color: var(--text-dim); margin-left: auto; }

/* Conversational messages */
.msg-text {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.7;
  word-break: break-word;
}

.msg-text strong { color: var(--text); font-weight: 600; }

.msg-text .msg-heading {
  display: block;
  font-weight: 700;
  color: var(--text);
  font-size: 14px;
  margin-top: 8px;
  margin-bottom: 2px;
}

.msg-text .msg-heading-lg { font-size: 15px; }

.msg-text .msg-list-item {
  display: block;
  padding-left: 16px;
  position: relative;
}

.msg-text .msg-list-bullet::before {
  content: '\2022';
  position: absolute;
  left: 4px;
  color: var(--accent);
}

.msg-text .msg-list-num { color: var(--accent); font-weight: 600; }

/* Draft messages */
.message-draft {
  background: rgba(167, 139, 250, 0.04);
  border-radius: 8px;
  padding: 4px 8px;
}

.msg-draft-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  margin-bottom: 6px;
}

.msg-draft {
  background: var(--accent-glow);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 12px 16px;
  margin-top: 4px;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  white-space: pre-wrap;
}

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

.msg-status {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 8px;
  display: inline-block;
}

.msg-status.approved { background: var(--green-dim); color: var(--green); }
.msg-status.rejected { background: var(--red-dim); color: var(--red); }
.msg-status.edited { background: var(--blue-dim); color: var(--blue); }

/* Approvals view */
.approvals-header {
  padding: 8px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.approvals-count {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.approval-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
}

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

.approval-agent { font-size: 13px; font-weight: 600; }

.approval-channel {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
}

.approval-prompt {
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 8px;
}

/* Message input */
.message-input-area {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}

.message-input-row {
  display: flex;
  gap: 8px;
}

#message-input {
  flex: 1;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  outline: none;
  font-family: inherit;
}

#message-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

#message-input::placeholder { color: var(--text-dim); }

.send-btn {
  background: var(--accent-dim);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.send-btn:hover { background: #6d28d9; }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── Right panel ──────────────────────────────────────────────────────────── */

.right-panel {
  width: 260px;
  background: var(--bg-dark);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  padding: 16px;
}

.panel-section { margin-bottom: 20px; }

.panel-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.panel-stat {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
}

.panel-stat-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.stat-label { font-size: 12px; color: var(--text-muted); }
.stat-value { font-size: 13px; font-weight: 700; color: var(--accent); }

/* Pending list in right panel */
.pending-item {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}

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

.pending-item-agent {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}

.pending-item-time {
  font-size: 10px;
  color: var(--text-dim);
}

.pending-item-text {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pending-item-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

/* ─── Modals ───────────────────────────────────────────────────────────────── */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  overflow-y: auto;
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
}

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

.modal-body { padding: 20px; }

.modal-hint {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* Form elements in modals */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.modal textarea {
  width: 100%;
  min-height: 200px;
  padding: 12px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.7;
  resize: vertical;
  outline: none;
  background: var(--surface-2);
  color: var(--text);
}

.modal textarea:focus {
  border-color: var(--accent);
}

.settings-saved {
  padding: 10px 14px;
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(74, 222, 128, 0.2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 12px;
}

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

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.loading-bar {
  height: 2px;
  background: var(--accent);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 300;
  animation: loading 1.5s ease-in-out infinite;
  display: none;
}

.loading-bar.active { display: block; }

@keyframes loading {
  0% { width: 0; }
  50% { width: 60%; }
  100% { width: 100%; opacity: 0; }
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-size: 12px;
  color: var(--text-dim);
}

.typing-dots {
  display: flex;
  gap: 3px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: typing 1.2s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

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

@media (max-width: 1024px) {
  .right-panel { display: none; }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .topbar-business { display: none; }
  .login-card { padding: 32px 24px; }
}
