/* Lex Console 2.0 — Chat-First Dashboard */
/* Glassmorphism dark mode with Elevated Roofing branding */

/* iOS safe area handling (Capacitor) */
.console-app {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-glass: rgba(18, 18, 26, 0.7);
  --bg-glass-hover: rgba(25, 25, 38, 0.8);
  --border-glass: rgba(255, 255, 255, 0.06);
  --border-glass-hover: rgba(255, 255, 255, 0.12);
  --text-primary: #e8e8ec;
  --text-secondary: #9898a8;
  --text-muted: #5a5a6e;
  --accent: #4a9eff;
  --accent-glow: rgba(74, 158, 255, 0.15);
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 320px;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Top Strip ────────────────────────────────────────── */

.top-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-glass);
  border-bottom: 1px solid var(--border-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  height: 48px;
  flex-shrink: 0;
  z-index: 10;
}

.strip-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.strip-logo {
  height: 24px;
  width: auto;
  opacity: 0.8;
}

.strip-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.strip-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.strip-status {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.strip-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
}

.strip-status.degraded::before { background: var(--warning); }
.strip-status.offline::before { background: var(--danger); }

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

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

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.2s;
}

.sidebar-toggle:hover {
  background: rgba(255,255,255,0.05);
}

/* ── Main Area ────────────────────────────────────────── */

.main-area {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ── Chat Container ───────────────────────────────────── */

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
}

/* Welcome message */
.chat-welcome {
  text-align: center;
  padding: 60px 20px 40px;
  max-width: 500px;
  margin: auto;
}

.welcome-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto 20px;
  border: 2px solid var(--border-glass);
}

.welcome-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-welcome h2 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.chat-welcome p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Chat bubbles */
.chat-msg {
  max-width: 720px;
  animation: fadeIn 0.2s ease;
}

.chat-msg.user {
  align-self: flex-end;
}

.chat-msg.lex {
  align-self: flex-start;
}

.chat-msg .bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
}

.chat-msg.user .bubble {
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-msg.lex .bubble {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  backdrop-filter: blur(10px);
  border-bottom-left-radius: 4px;
}

.chat-msg .bubble strong { font-weight: 600; }
.chat-msg .bubble code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: rgba(255,255,255,0.05);
  padding: 2px 6px;
  border-radius: 4px;
}

.chat-msg .timestamp {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.chat-msg.user .timestamp { text-align: right; }

/* Reasoning trace (collapsible) */
.reasoning-trace {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  border-left: 2px solid var(--border-glass);
  padding-left: 10px;
  cursor: pointer;
}

.reasoning-trace summary {
  font-style: italic;
  opacity: 0.7;
}

.reasoning-trace .trace-content {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: pre-wrap;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  align-self: flex-start;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.4s infinite ease-in-out;
}

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

/* ── Chat Input ───────────────────────────────────────── */

.chat-input-area {
  padding: 12px 24px 20px;
  background: linear-gradient(transparent, var(--bg-primary) 20%);
}

.chat-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  padding: 8px 12px;
  backdrop-filter: blur(10px);
  transition: border-color 0.2s;
}

.chat-input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.chat-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.voice-btn, .send-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
}

.voice-btn:hover, .send-btn:hover {
  color: var(--accent);
  background: var(--accent-glow);
}

.send-btn { color: var(--accent); }

/* ── Sidebar ──────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-glass);
  border-left: 1px solid var(--border-glass);
  backdrop-filter: blur(20px);
  overflow-y: auto;
  flex-shrink: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.sidebar.collapsed {
  transform: translateX(100%);
  opacity: 0;
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
}

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

.sidebar-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.sidebar-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

.sidebar-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-glass);
}

.sidebar-section h4 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Agent cards */
.agent-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 4px;
}

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

.agent-health {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.agent-health.green { background: var(--success); }
.agent-health.yellow { background: var(--warning); }
.agent-health.red { background: var(--danger); }

.agent-info {
  flex: 1;
  min-width: 0;
}

.agent-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

/* Tier 2 approval inline */
.approval-card {
  background: rgba(251, 191, 36, 0.05);
  border: 1px solid rgba(251, 191, 36, 0.15);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 8px;
}

.approval-card .approval-summary {
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.approval-actions {
  display: flex;
  gap: 8px;
}

.approval-actions button {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  transition: opacity 0.2s;
}

.approval-actions .approve-btn {
  background: var(--success);
  color: #000;
}

.approval-actions .dismiss-btn {
  background: rgba(255,255,255,0.08);
  color: var(--text-secondary);
}

/* Tier 3 blocks */
.tier3-blocks {
  background: rgba(248, 113, 113, 0.03);
}

.block-card {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.2);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-primary);
}

/* Agent loading */
.agent-loading {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 20px;
}

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

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

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-8px); }
}

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

@media (max-width: 768px) {
  .sidebar {
    position: absolute;
    right: 0;
    top: 48px;
    bottom: 0;
    z-index: 20;
  }

  .sidebar.collapsed {
    display: none;
  }

  .strip-center { display: none; }
  .strip-meta { display: none; }
}
