/* אמת Emet Command Center - Styles */

:root {
  /* Colors - Dark mode */
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-card: #21262d;
  --border: #30363d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --accent: #58a6ff;
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
  
  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-size-xs: 12px;
  --font-size-sm: 14px;
  --font-size-md: 16px;
  --font-size-lg: 20px;
  --font-size-xl: 24px;
  
  /* Spacing (4px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  
  /* Borders */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* ===== AUTH GATE ===== */
.auth-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-primary);
}

.auth-container {
  text-align: center;
  padding: var(--space-8);
}

.auth-container h1 {
  font-size: 64px;
  margin-bottom: var(--space-2);
  letter-spacing: 4px;
}

.auth-subtitle {
  color: var(--text-secondary);
  margin-bottom: var(--space-8);
  font-size: var(--font-size-sm);
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-width: 280px;
  margin: 0 auto;
}

#auth-form input {
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  text-align: center;
}

#auth-form input:focus {
  outline: none;
  border-color: var(--accent);
}

#auth-form button {
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-md);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--bg-primary);
  cursor: pointer;
  transition: opacity 0.2s;
}

#auth-form button:hover {
  opacity: 0.9;
}

.auth-error {
  color: var(--danger);
  font-size: var(--font-size-sm);
  margin-top: var(--space-4);
}

/* ===== DASHBOARD ===== */
.dashboard {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) var(--space-6);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: var(--font-size-xl);
  font-weight: 700;
  letter-spacing: 2px;
}

.logo-sub {
  font-size: var(--font-size-sm);
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: var(--space-2);
}

.header-right {
  display: flex;
  gap: var(--space-4);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

/* Main Content */
.main-content {
  flex: 1;
  padding: var(--space-6);
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Panels Grid */
.panels-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}

/* Panel */
.panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.panel-header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.panel-header h2 {
  font-size: var(--font-size-md);
  font-weight: 600;
}

.panel-content {
  padding: var(--space-4);
}

/* File List */
.file-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}

.file-item:hover {
  background: var(--border);
}

.file-name {
  font-size: var(--font-size-sm);
  font-family: 'SF Mono', 'Monaco', monospace;
}

.file-arrow {
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
}

/* Section Divider */
.section-divider {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: var(--space-3) 0;
  margin-top: var(--space-2);
  border-top: 1px solid var(--border);
}

/* Golem Stats */
.golem-stats {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-sm);
  padding: var(--space-1) 0;
}

.stat-label {
  color: var(--text-secondary);
}

.stat-value {
  font-weight: 500;
}

/* Agent Summary */
.agent-summary {
  display: flex;
  justify-content: space-between;
  padding: var(--space-3);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
}

.agent-stat {
  text-align: center;
}

.agent-stat-value {
  font-size: var(--font-size-lg);
  font-weight: 600;
}

.agent-stat-label {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

/* Agent List */
.agent-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.agent-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3);
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}

.agent-item:hover {
  background: var(--border);
}

.agent-label {
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.agent-meta {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 32px;
  margin-bottom: var(--space-2);
}

.empty-text {
  font-size: var(--font-size-sm);
}

/* Systems List */
.systems-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.system-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3);
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}

.system-card:hover {
  background: var(--border);
}

.system-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.system-name {
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.system-metric {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

.status-indicator {
  font-size: var(--font-size-md);
}

.status-ok { color: var(--success); }
.status-warning { color: var(--warning); }
.status-error { color: var(--danger); }

/* Alerts Section */
.alerts-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.alerts-list {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 200px;
  overflow-y: auto;
}

.alert-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
}

.alert-time {
  color: var(--text-secondary);
  white-space: nowrap;
}

.alert-source {
  color: var(--accent);
  white-space: nowrap;
}

.alert-message {
  flex: 1;
}

.alert-info { border-left: 3px solid var(--accent); }
.alert-warning { border-left: 3px solid var(--warning); }
.alert-error { border-left: 3px solid var(--danger); }

/* ===== MODAL ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  z-index: 200;
  overflow-y: auto;
}

.modal-content {
  max-width: 800px;
  margin: 0 auto;
  min-height: 100vh;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

.back-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: var(--font-size-sm);
  cursor: pointer;
}

.modal-header h2 {
  flex: 1;
  font-size: var(--font-size-md);
}

#modal-status {
  font-size: var(--font-size-sm);
}

.modal-body {
  padding: var(--space-6);
}

/* File Content */
.file-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
}

.file-content h1, .file-content h2, .file-content h3 {
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
}

.file-content h1:first-child, .file-content h2:first-child, .file-content h3:first-child {
  margin-top: 0;
}

.file-content p {
  margin-bottom: var(--space-4);
}

.file-content code {
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: 'SF Mono', 'Monaco', monospace;
  font-size: 0.9em;
}

.file-content pre {
  background: var(--bg-card);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: var(--space-4);
}

.file-content pre code {
  background: none;
  padding: 0;
}

.file-content ul, .file-content ol {
  margin-left: var(--space-6);
  margin-bottom: var(--space-4);
}

.file-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: var(--space-4);
  color: var(--text-secondary);
  font-style: italic;
}

/* System Detail */
.system-detail {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-4);
}

.metric-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-align: center;
}

.metric-value {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--accent);
}

.metric-label {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-top: var(--space-1);
}

.detail-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.detail-section h3 {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
  text-transform: uppercase;
  letter-spacing: 1px;
}

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

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

/* Agent Detail */
.agent-detail {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
}

.agent-task {
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

/* Bottom Nav (Mobile) */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: var(--space-2);
  justify-content: space-around;
  z-index: 100;
}

.nav-btn {
  background: none;
  border: none;
  font-size: 24px;
  padding: var(--space-3) var(--space-6);
  min-width: 48px;
  min-height: 48px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.nav-btn.active {
  opacity: 1;
}

/* Offline Banner */
.offline-banner {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--warning);
  color: var(--bg-primary);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  z-index: 150;
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--border) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s infinite;
  height: 40px;
  border-radius: var(--radius-sm);
}

@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Error State */
.error-state {
  text-align: center;
  padding: var(--space-6);
  color: var(--danger);
}

.error-icon {
  font-size: 32px;
  margin-bottom: var(--space-2);
}

.retry-btn {
  margin-top: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
}

.retry-btn:hover {
  background: var(--border);
}

/* ===== PHASE 2: Enhanced Detail Views ===== */

/* System description */
.system-description {
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

/* Components list */
.components-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.component-item {
  background: var(--bg-card);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  font-family: 'SF Mono', 'Monaco', monospace;
  font-size: var(--font-size-xs);
}

/* Output tables */
.output-table-container {
  overflow-x: auto;
  margin: var(--space-3) 0;
}

.output-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.output-table th,
.output-table td {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.output-table th {
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  font-size: var(--font-size-xs);
}

.output-table tbody tr:hover {
  background: var(--bg-card);
}

/* Output preview */
.output-preview {
  margin-top: var(--space-4);
}

.output-preview h4 {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.signal-text {
  background: var(--bg-card);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  font-family: 'SF Mono', 'Monaco', monospace;
  font-size: var(--font-size-xs);
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 300px;
  overflow-y: auto;
}

.output-json {
  background: var(--bg-card);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

.output-json pre {
  margin: 0;
  font-family: 'SF Mono', 'Monaco', monospace;
  font-size: var(--font-size-xs);
}

/* Categories grid */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.category-item {
  display: flex;
  justify-content: space-between;
  background: var(--bg-card);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
}

.category-name {
  text-transform: capitalize;
}

.category-count {
  color: var(--accent);
  font-weight: 600;
}

/* Positive/negative values */
.positive {
  color: var(--success);
}

.negative {
  color: var(--danger);
}

/* Notes */
.note {
  color: var(--text-secondary);
  font-style: italic;
  font-size: var(--font-size-sm);
}

/* Code in detail rows */
.detail-row code {
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: 'SF Mono', 'Monaco', monospace;
  font-size: var(--font-size-xs);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .panels-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  #systems-panel {
    grid-column: span 2;
  }
}

@media (max-width: 768px) {
  .panels-grid {
    grid-template-columns: 1fr;
  }
  
  #systems-panel {
    grid-column: span 1;
  }
  
  .main-content {
    padding: var(--space-4);
    padding-bottom: 80px;
  }
  
  .bottom-nav {
    display: flex;
  }
  
  .header-right {
    gap: var(--space-2);
  }
  
  .logo-sub {
    display: none;
  }
}

@media (max-width: 480px) {
  .header {
    padding: var(--space-3) var(--space-4);
  }
  
  .logo {
    font-size: var(--font-size-lg);
  }
  
  .panel-header h2 {
    font-size: var(--font-size-sm);
  }
  
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Small phones (320px) */
@media (max-width: 360px) {
  .header {
    padding: var(--space-2) var(--space-3);
  }
  
  .logo {
    font-size: var(--font-size-md);
  }
  
  .header-stats {
    font-size: var(--font-size-xs);
    gap: var(--space-2);
  }
  
  .panel {
    padding: var(--space-3);
  }
  
  .panel-header h2 {
    font-size: var(--font-size-xs);
  }
  
  .file-item, .system-item, .agent-item {
    padding: var(--space-2);
    font-size: var(--font-size-sm);
  }
  
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  
  .mobile-nav {
    padding: var(--space-2);
  }
  
  .nav-btn {
    font-size: 20px;
    padding: var(--space-2) var(--space-3);
  }
}

/* Agent Tabs */
.agent-tabs {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.agent-tab {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.agent-tab:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.agent-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-primary);
}

.agent-stats-row {
  display: flex;
  gap: var(--space-4);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.agent-info {
  flex: 1;
}

.agent-status {
  margin-right: var(--space-2);
}

.agent-status.completed { color: var(--success); }
.agent-status.active { color: var(--accent); }
.agent-status.failed { color: var(--danger); }

/* Persistent Agents */
.persistent-agents-section {
  margin-bottom: var(--space-4);
}

.section-label {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
  padding-left: var(--space-2);
}

.persistent-agent {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.1), rgba(255, 215, 0, 0.05));
  border: 1px solid rgba(212, 175, 55, 0.4) !important;
  border-radius: var(--radius-md);
}

.persistent-agent:hover {
  border-color: rgba(212, 175, 55, 0.7) !important;
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.15), rgba(255, 215, 0, 0.08));
}

.persistent-agent .agent-icon {
  margin-right: var(--space-2);
}

.proactive-badge {
  font-size: var(--font-size-xs);
  margin-left: var(--space-1);
  opacity: 0.8;
}

.spawned-agents-section {
  margin-top: var(--space-3);
}

/* Persistent Agent Modal */
.persistent-agent-detail .agent-purpose {
  color: var(--text-primary);
  line-height: 1.6;
}

.when-to-use {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.when-to-use code {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  font-size: var(--font-size-xs);
  color: var(--accent);
}

.memory-path {
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

/* Agent Detail Modal */
.detail-section {
  margin-bottom: var(--space-6);
}

.detail-section h3 {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-3);
}

.detail-grid {
  display: grid;
  gap: var(--space-2);
}

.agent-prompt-full {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: var(--font-size-sm);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow-y: auto;
  color: var(--text-primary);
}
