/* Monochrome Black & White Apple-Level Design System */
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Status Colors: Green for Ready/Connected, Red for Disconnected/Not Ready */
  --status-green: #10B981;
  --status-red: #F43F5E;

  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Fira Code', monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

/* DARK MODE (PURE OBSIDIAN BLACK & CRISP WHITE) */
body.dark-theme {
  --bg-main: #0A0A0A;
  --bg-header: rgba(14, 14, 14, 0.96);
  --bg-card: rgba(20, 20, 20, 0.85);
  --bg-card-hover: rgba(28, 28, 28, 0.95);
  --bg-input: #121212;
  --bg-terminal: #050505;

  --border-subtle: rgba(255, 255, 255, 0.12);
  --accent-primary: #FFFFFF;
  --accent-secondary: #E5E5E5;
  --accent-glow: rgba(255, 255, 255, 0.15);

  --btn-primary-bg: #FFFFFF;
  --btn-primary-text: #000000;

  --text-main: #FFFFFF;
  --text-muted: #A3A3A3;
  --text-dim: #666666;
  --terminal-text: #E5E5E5;
}

/* LIGHT MODE (PURE SNOW WHITE & JET BLACK) */
body.light-theme {
  --bg-main: #F8F9FA;
  --bg-header: rgba(255, 255, 255, 0.96);
  --bg-card: #FFFFFF;
  --bg-card-hover: #F1F3F5;
  --bg-input: #F1F3F5;
  --bg-terminal: #0F172A;

  --border-subtle: rgba(0, 0, 0, 0.12);
  --accent-primary: #000000;
  --accent-secondary: #1A1A1A;
  --accent-glow: rgba(0, 0, 0, 0.12);

  --btn-primary-bg: #000000;
  --btn-primary-text: #FFFFFF;

  --text-main: #000000;
  --text-muted: #475569;
  --text-dim: #94A3B8;
  --terminal-text: #FDE68A;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

html, body {
  min-height: 100vh;
  width: 100vw;
  overflow-x: hidden;
  overflow-y: auto;
  font-family: var(--font-body);
  background: var(--bg-main);
  color: var(--text-main);
  transition: background-color 0.25s ease, color 0.25s ease;
}

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100vw;
}

/* Header Bar */
.app-header {
  height: 52px;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-header);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
  z-index: 50;
  transition: background-color 0.25s ease;
}

.app-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-primary), transparent);
}

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

.brand-text h1 {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: var(--text-main);
}

.version-tag {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* HEADER STATUS PILLS — EXACT 32px MATCHED HEIGHT */
.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-pill {
  height: 32px;
  line-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 0.74rem;
  font-weight: 700;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.2s ease;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

/* DISCONNECTED / NOT READY -> RED */
.status-pill.offline, .status-pill.not-ready, .status-pill.error {
  border-color: rgba(244, 63, 94, 0.4);
  color: var(--status-red);
  background: rgba(244, 63, 94, 0.08);
}
.status-pill.offline .status-dot, .status-pill.not-ready .status-dot, .status-pill.error .status-dot {
  background: var(--status-red);
  box-shadow: 0 0 8px var(--status-red);
}

/* CONNECTED / READY -> GREEN */
.status-pill.online, .status-pill.ready {
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--status-green);
  background: rgba(16, 185, 129, 0.08);
}
.status-pill.online .status-dot, .status-pill.ready .status-dot {
  background: var(--status-green);
  box-shadow: 0 0 10px var(--status-green);
  animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}

/* App Layout Body */
.app-body {
  display: flex;
  flex: 1;
  min-height: calc(100vh - 52px);
}

/* Sidebar Navigation */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--bg-header);
  border-right: 1px solid var(--border-subtle);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background-color 0.25s ease;
}

.nav-section-label {
  font-size: 0.64rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-dim);
  padding: 8px 12px 4px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: left;
}

.nav-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.nav-btn.active {
  background: var(--bg-card-hover);
  border-color: var(--border-subtle);
  color: var(--accent-primary);
  font-weight: 800;
}

/* Content Pane Area */
.content-area {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto !important;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
}

.tab-pane {
  display: none;
  width: 100%;
  flex-direction: column;
  gap: 12px;
}

.tab-pane.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

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

/* Page Headers */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.page-header h2 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
}

/* Glass Cards */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

/* UNIFORM MATCHED BUTTONS WITH FIXED HEIGHT */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 700;
  height: 32px;
  line-height: 32px;
  cursor: pointer;
  transition: all 0.18s ease;
  border: 1px solid transparent;
  font-family: var(--font-body);
}

.btn-primary, .btn-gold {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  font-weight: 800;
  box-shadow: 0 4px 18px var(--accent-glow);
}
.btn-primary:hover, .btn-gold:hover {
  filter: brightness(0.9);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-main);
  color: var(--text-main);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.btn-sm { padding: 0 12px; font-size: 0.74rem; height: 32px; line-height: 32px; }
.btn-block { width: 100%; }

/* Form Controls */
.form-control {
  width: 100%;
  height: 34px;
  padding: 6px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.8rem;
  font-family: var(--font-mono);
  outline: none;
  transition: all 0.2s ease;
}
.form-control:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 12px var(--accent-glow);
}

/* Terminal Console */
.console-card {
  padding: 12px;
  display: flex;
  flex-direction: column;
}

.console-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.console-header span, .console-header h3 {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
}

.terminal-log {
  background: var(--bg-terminal);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--terminal-text);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.45;
  padding: 12px 14px;
  overflow-y: auto !important;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 280px;
  max-height: 400px;
}

/* Badges */
.badge { padding: 3px 8px; border-radius: 6px; font-size: 0.72rem; font-weight: 700; }
.badge-gold, .badge-cyan { background: rgba(255, 255, 255, 0.1); color: var(--text-main); border: 1px solid var(--border-subtle); }
.badge-green { background: rgba(16, 185, 129, 0.15); color: var(--status-green); border: 1px solid var(--status-green); }
.badge-red { background: rgba(244, 63, 94, 0.15); color: var(--status-red); border: 1px solid var(--status-red); }

/* Drop Zone */
.drop-zone {
  border: 2px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.15);
  text-align: center;
  transition: all 0.2s ease;
}
.drop-zone.drag-over {
  border-color: var(--accent-primary);
  background: rgba(255, 255, 255, 0.05);
}

.hidden-file-input { display: none; }
.hidden { display: none !important; }
.flex-1 { flex: 1; }

/* Login Modal Overlay */
.login-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(4, 7, 13, 0.94);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.login-modal-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.login-card {
  width: 380px;
  max-width: 90vw;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.8), 0 20px 50px rgba(0, 0, 0, 0.9);
  border-radius: 18px;
}

.app-locked {
  filter: blur(16px);
  pointer-events: none;
  user-select: none;
}
