/* PIA Dashboard Styles */

:root {
  --bg-primary: #0a0a15;
  --bg-secondary: #12121f;
  --bg-tertiary: #1a1a2e;
  --text-primary: #e0e0e0;
  --text-secondary: #8888aa;
  --text-muted: #555577;
  --accent-primary: #00ff88;
  --accent-secondary: #00aaff;
  --accent-warning: #ffaa00;
  --accent-error: #ff4444;
  --border-color: #2a2a4e;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.logo {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-primary);
  letter-spacing: 2px;
}

.subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.stats {
  display: flex;
  gap: 32px;
}

.stat {
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-alert .stat-value {
  color: var(--accent-warning);
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border-radius: 20px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-warning);
  animation: pulse 1s infinite;
}

.connection-status.connected .status-dot {
  background: var(--accent-primary);
  animation: none;
}

.connection-status.error .status-dot {
  background: var(--accent-error);
}

.status-text {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Navigation */
.nav {
  display: flex;
  gap: 8px;
  padding: 12px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.nav-item {
  padding: 10px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.nav-item.active {
  color: var(--accent-primary);
  background: var(--bg-tertiary);
}

/* Main Content */
.main {
  padding: 24px;
  min-height: calc(100vh - 140px);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.view-header h2 {
  font-size: 20px;
  font-weight: 600;
}

.view-controls {
  display: flex;
  gap: 12px;
}

/* Fleet Grid */
.fleet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

/* Agent Tile */
.agent-tile {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease;
  overflow: hidden;
}

.agent-tile:hover {
  transform: translateY(-2px);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow);
}

.agent-tile::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-secondary);
  opacity: 0.5;
}

.agent-tile[data-status="working"]::before {
  background: var(--accent-primary);
  animation: progress 2s infinite;
}

.agent-tile[data-status="waiting"]::before {
  background: var(--accent-warning);
  animation: pulse 1s infinite;
}

.agent-tile[data-status="error"]::before {
  background: var(--accent-error);
}

.agent-tile[data-status="idle"]::before {
  background: var(--text-muted);
  opacity: 0.3;
}

.agent-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.agent-name {
  font-weight: 600;
  font-size: 14px;
}

.agent-type {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  padding: 2px 8px;
  border-radius: 10px;
}

.agent-machine {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.agent-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  margin-bottom: 8px;
}

.status-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.agent-tile[data-status="working"] .status-indicator { background: var(--accent-primary); }
.agent-tile[data-status="waiting"] .status-indicator { background: var(--accent-warning); }
.agent-tile[data-status="error"] .status-indicator { background: var(--accent-error); }
.agent-tile[data-status="idle"] .status-indicator { background: var(--text-muted); }

.agent-mini-cli {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 10px;
  line-height: 1.4;
  background: var(--bg-primary);
  border-radius: 6px;
  padding: 8px;
  height: 50px;
  overflow: hidden;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.agent-progress {
  height: 4px;
  background: var(--bg-secondary);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent-primary);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* Terminal */
.tunnel-container {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  height: calc(100vh - 280px);
  min-height: 400px;
}

.terminal {
  height: 100%;
}

/* Alerts */
.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  border-left: 4px solid var(--accent-warning);
}

.alert-item[data-type="agent_error"],
.alert-item[data-type="task_failed"] {
  border-left-color: var(--accent-error);
}

.alert-item[data-type="agent_waiting"] {
  border-left-color: var(--accent-secondary);
}

.alert-icon {
  font-size: 20px;
}

.alert-content {
  flex: 1;
}

.alert-message {
  font-size: 14px;
  margin-bottom: 4px;
}

.alert-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.alert-actions {
  display: flex;
  gap: 8px;
}

/* Forms */
.select {
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
}

.select:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--accent-primary);
  color: var(--bg-primary);
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-secondary);
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state p:first-child {
  font-size: 16px;
  margin-bottom: 8px;
}

.text-muted {
  color: var(--text-muted);
}

/* Animations */
@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

@keyframes progress {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Responsive - Tablet */
@media (max-width: 1024px) {
  .fleet-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }

  .stats {
    gap: 20px;
  }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px;
  }

  .header-left {
    width: 100%;
    justify-content: center;
  }

  .header-center {
    width: 100%;
  }

  .stats {
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
  }

  .stat-value {
    font-size: 20px;
  }

  .stat-label {
    font-size: 10px;
  }

  .header-right {
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .nav {
    padding: 8px 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    padding: 8px 16px;
    font-size: 13px;
    white-space: nowrap;
  }

  .main {
    padding: 16px;
  }

  .fleet-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .agent-tile {
    padding: 14px;
  }

  .view-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .view-header h2 {
    font-size: 18px;
  }

  .view-controls {
    width: 100%;
    flex-wrap: wrap;
  }

  .select, .btn {
    flex: 1;
    min-width: 100px;
  }

  .tunnel-container {
    height: calc(100vh - 300px);
    padding: 12px;
  }

  .alert-item {
    padding: 12px;
    gap: 12px;
  }

  .alert-icon {
    font-size: 18px;
  }

  .alert-message {
    font-size: 13px;
  }
}

/* Responsive - Small Mobile */
@media (max-width: 480px) {
  .logo {
    font-size: 24px;
  }

  .subtitle {
    font-size: 12px;
  }

  .stats {
    gap: 12px;
  }

  .stat-value {
    font-size: 18px;
  }

  .main {
    padding: 12px;
  }

  .fleet-grid {
    gap: 10px;
  }

  .agent-tile {
    padding: 12px;
  }

  .agent-name {
    font-size: 13px;
  }

  .agent-mini-cli {
    height: 40px;
    font-size: 9px;
  }

  .view-controls {
    gap: 8px;
  }

  .btn {
    padding: 8px 16px;
    font-size: 13px;
  }
}

/* PWA Install Prompt */
.pwa-install-prompt {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  background: var(--bg-tertiary);
  border: 1px solid var(--accent-primary);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 8px 30px rgba(0, 255, 136, 0.2);
  z-index: 1000;
  animation: slideUp 0.3s ease;
}

.pwa-install-prompt.hidden {
  display: none;
}

.pwa-install-icon {
  font-size: 32px;
}

.pwa-install-content {
  flex: 1;
}

.pwa-install-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.pwa-install-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

.pwa-install-actions {
  display: flex;
  gap: 8px;
}

@keyframes slideUp {
  from {
    transform: translateY(100px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Safe area for notched phones */
@supports (padding: env(safe-area-inset-bottom)) {
  .main {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .pwa-install-prompt {
    bottom: calc(20px + env(safe-area-inset-bottom));
    left: calc(20px + env(safe-area-inset-left));
    right: calc(20px + env(safe-area-inset-right));
  }
}

/* Touch-friendly interactions */
@media (pointer: coarse) {
  .agent-tile {
    min-height: 120px;
  }

  .btn {
    min-height: 44px;
  }

  .nav-item {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .select {
    min-height: 44px;
  }
}

/* Dark mode scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* MCP Section */
.mcp-section {
  margin-bottom: 32px;
}

.mcp-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-secondary);
}

.mcp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.mcp-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  transition: all 0.2s ease;
}

.mcp-card:hover {
  border-color: var(--accent-secondary);
  box-shadow: var(--shadow);
}

.mcp-card.installed {
  border-color: var(--accent-primary);
}

.mcp-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.mcp-name {
  font-weight: 600;
  font-size: 15px;
}

.mcp-source {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 2px 8px;
  border-radius: 10px;
}

.mcp-category {
  font-size: 10px;
  color: var(--accent-secondary);
  background: rgba(0, 170, 255, 0.1);
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
}

.mcp-description {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.4;
}

.mcp-config {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11px;
  background: var(--bg-primary);
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  color: var(--text-secondary);
}

.mcp-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.mcp-categories {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.mcp-filter {
  padding: 6px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mcp-filter:hover {
  color: var(--text-primary);
  border-color: var(--accent-secondary);
}

.mcp-filter.active {
  background: var(--accent-primary);
  color: var(--bg-primary);
  border-color: var(--accent-primary);
}

.mcp-requires {
  font-size: 11px;
  color: var(--accent-warning);
  margin-bottom: 8px;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px;
  border-top: 1px solid var(--border-color);
}

/* Form */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
}

.input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.textarea {
  min-height: 80px;
  resize: vertical;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px;
}

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
}

.badge-success {
  background: rgba(0, 255, 136, 0.15);
  color: var(--accent-primary);
}

.badge-warning {
  background: rgba(255, 170, 0, 0.15);
  color: var(--accent-warning);
}

.badge-info {
  background: rgba(0, 170, 255, 0.15);
  color: var(--accent-secondary);
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Mobile MCP styles */
@media (max-width: 768px) {
  .mcp-grid {
    grid-template-columns: 1fr;
  }

  .mcp-categories {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 8px;
  }

  .mcp-filter {
    white-space: nowrap;
  }

  .modal-content {
    max-height: 80vh;
  }
}

/* ============ AI Section Styles ============ */

.stat-cost .stat-value {
  color: var(--accent-secondary);
  font-size: 18px;
}

/* AI Cost Summary Cards */
.ai-cost-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.cost-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
}

.cost-card.budget {
  border-color: var(--accent-primary);
  background: rgba(0, 255, 136, 0.05);
}

.cost-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cost-value {
  display: block;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
}

.cost-card.budget .cost-value {
  color: var(--accent-primary);
}

/* AI Sections */
.ai-section {
  margin-bottom: 32px;
}

.ai-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-secondary);
}

/* AI Provider Cards */
.ai-providers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.provider-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  transition: all 0.2s ease;
}

.provider-card:hover {
  border-color: var(--accent-secondary);
}

.provider-card[data-status="available"] {
  border-color: var(--accent-primary);
}

.provider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.provider-name {
  font-weight: 600;
  font-size: 14px;
}

.provider-tier {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.provider-tier.tier-0 {
  background: rgba(0, 255, 136, 0.2);
  color: var(--accent-primary);
}

.provider-tier.tier-1 {
  background: rgba(0, 170, 255, 0.2);
  color: var(--accent-secondary);
}

.provider-tier.tier-2 {
  background: rgba(255, 170, 0, 0.2);
  color: var(--accent-warning);
}

.provider-tier.tier-3 {
  background: rgba(255, 68, 68, 0.2);
  color: var(--accent-error);
}

.provider-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.provider-card .status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.provider-card[data-status="available"] .status-indicator {
  background: var(--accent-primary);
}

.provider-card[data-status="unavailable"] .status-indicator {
  background: var(--accent-error);
}

.provider-card .status-text {
  color: var(--text-secondary);
}

/* AI Usage Table */
.ai-usage-table {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
}

.ai-usage-table table {
  width: 100%;
  border-collapse: collapse;
}

.ai-usage-table th,
.ai-usage-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.ai-usage-table th {
  background: var(--bg-secondary);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ai-usage-table td {
  font-size: 13px;
}

.ai-usage-table tbody tr:hover {
  background: var(--bg-secondary);
}

.ai-usage-table tbody tr:last-child td {
  border-bottom: none;
}

.ai-usage-table .empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 32px;
}

/* Budget Form */
.budget-form {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
}

.form-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
}

.form-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

/* Mobile AI styles */
@media (max-width: 768px) {
  .ai-cost-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .ai-providers {
    grid-template-columns: 1fr;
  }

  .ai-usage-table {
    overflow-x: auto;
  }

  .ai-usage-table table {
    min-width: 600px;
  }

  .form-row {
    flex-direction: column;
  }

  .form-row .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .ai-cost-summary {
    grid-template-columns: 1fr;
  }

  .cost-value {
    font-size: 20px;
  }
}

/* Agent Modal Styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 18px;
  color: var(--accent-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
}

.modal-close:hover {
  color: var(--accent-error);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: 50vh;
}

.modal-footer {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-color);
}

.agent-detail-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-primary);
  border-radius: 6px;
}

.detail-label {
  color: var(--text-secondary);
  font-size: 13px;
}

.detail-value {
  color: var(--text-primary);
  font-weight: 500;
}

.detail-value.status-working {
  color: var(--accent-primary);
}

.detail-value.status-idle {
  color: var(--text-secondary);
}

.detail-value.status-waiting {
  color: var(--accent-warning);
}

.detail-value.status-error {
  color: var(--accent-error);
}

.agent-output-section h4 {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 8px;
}

.agent-output {
  background: var(--bg-primary);
  padding: 12px;
  border-radius: 6px;
  font-family: 'Fira Code', monospace;
  font-size: 12px;
  color: var(--text-primary);
  white-space: pre-wrap;
  max-height: 150px;
  overflow-y: auto;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent-primary);
  color: var(--bg-primary);
}

.btn-primary:hover {
  background: #00cc6a;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-color);
}

.btn-danger {
  background: var(--accent-error);
  color: white;
}

.btn-danger:hover {
  background: #cc3333;
}

/* Make agent tiles clickable */
.agent-tile {
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.agent-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(0, 255, 136, 0.15);
}

/* Command Center Styles */
.command-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  gap: 16px;
}

.chat-messages {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 12px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-message.system {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  align-self: center;
  max-width: 90%;
  font-size: 13px;
}

.chat-message.user {
  background: var(--accent-primary);
  color: var(--bg-primary);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-message.assistant {
  background: var(--bg-secondary);
  border: 1px solid var(--accent-secondary);
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-message .message-time {
  font-size: 10px;
  opacity: 0.7;
  margin-top: 6px;
  display: block;
}

.chat-message .message-content {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

.quick-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.quick-action {
  font-size: 13px;
  padding: 8px 16px;
}

.chat-input-container {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  resize: none;
  min-height: 48px;
  max-height: 120px;
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.chat-input::placeholder {
  color: var(--text-muted);
}

#btn-send-message {
  height: 48px;
  min-width: 100px;
}

/* Loading dots animation */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--accent-secondary);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-8px); opacity: 1; }
}

/* Responsive adjustments for Command Center */
@media (max-width: 768px) {
  .command-container {
    height: calc(100vh - 250px);
  }

  .quick-actions {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 8px;
  }

  .quick-action {
    white-space: nowrap;
  }

  .chat-message {
    max-width: 90%;
  }
}

/* ===== Hooks View ===== */
.hooks-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.hooks-stats .stat {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100px;
}

.hooks-stats .stat-value {
  font-size: 1.5em;
  font-weight: bold;
  color: var(--accent-primary);
}

.hooks-stats .stat-label {
  font-size: 0.75em;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.hooks-feed {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 70vh;
  overflow-y: auto;
}

.hook-event {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: hookSlideIn 0.3s ease;
}

@keyframes hookSlideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.hook-event.blocked {
  border-color: var(--accent-error);
  background: rgba(255, 68, 68, 0.05);
}

.hook-event.done {
  border-color: var(--accent-primary);
  background: rgba(0, 255, 136, 0.05);
}

.hook-event-badge {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.7em;
  font-weight: bold;
  text-transform: uppercase;
  white-space: nowrap;
  min-width: 90px;
  text-align: center;
}

.hook-event-badge.SessionStart { background: #1a3a5c; color: #66bbff; }
.hook-event-badge.PreToolUse { background: #3a3a1a; color: #ffcc44; }
.hook-event-badge.PostToolUse { background: #1a3a2a; color: #44ff88; }
.hook-event-badge.agent_done { background: #2a1a3a; color: #cc66ff; }
.hook-event-badge.blocked { background: #3a1a1a; color: #ff6666; }

.hook-event-body {
  flex: 1;
  min-width: 0;
}

.hook-event-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.hook-event-tool {
  font-weight: bold;
  color: var(--text-primary);
}

.hook-event-time {
  font-size: 0.75em;
  color: var(--text-muted);
}

.hook-event-session {
  font-size: 0.7em;
  color: var(--text-muted);
  font-family: monospace;
}

.hook-event-detail {
  font-size: 0.85em;
  color: var(--text-secondary);
  margin-top: 4px;
  word-break: break-all;
  max-height: 60px;
  overflow: hidden;
}

.hook-event-message {
  color: var(--accent-warning);
  font-size: 0.85em;
  margin-top: 4px;
}

/* ============ Task Queue ============ */

.engine-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  margin-bottom: 16px;
}

.engine-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.engine-status .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-error);
  display: inline-block;
}

.engine-status .status-dot.online {
  background: var(--accent-success);
  animation: pulse 2s infinite;
}

.engine-stats {
  display: flex;
  gap: 16px;
  flex: 1;
}

.stat-mini {
  font-size: 0.85em;
  color: var(--text-secondary);
}

.queue-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.task-item {
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  margin-bottom: 8px;
  border-left: 4px solid var(--border-color);
}

.task-item.task-pending { border-left-color: var(--accent-warning); }
.task-item.task-in_progress { border-left-color: var(--accent-info); }
.task-item.task-completed { border-left-color: var(--accent-success); }
.task-item.task-failed { border-left-color: var(--accent-error); }

.task-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.task-title { font-weight: 600; }

.task-meta {
  font-size: 0.85em;
  color: var(--text-secondary);
}

.task-output {
  margin-top: 8px;
  padding: 8px;
  background: var(--bg-primary);
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.8em;
  white-space: pre-wrap;
  max-height: 100px;
  overflow: hidden;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75em;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-pending { background: rgba(255, 193, 7, 0.2); color: #ffc107; }
.badge-in_progress { background: rgba(33, 150, 243, 0.2); color: #2196f3; }
.badge-completed { background: rgba(76, 175, 80, 0.2); color: #4caf50; }
.badge-failed { background: rgba(244, 67, 54, 0.2); color: #f44336; }
.badge-restart { background: rgba(33, 150, 243, 0.2); color: #2196f3; }
.badge-alert { background: rgba(255, 152, 0, 0.2); color: #ff9800; }
.badge-kill { background: rgba(244, 67, 54, 0.2); color: #f44336; }
.badge-free { background: rgba(76, 175, 80, 0.2); color: #4caf50; }
.badge-cheap { background: rgba(33, 150, 243, 0.2); color: #2196f3; }
.badge-medium { background: rgba(255, 152, 0, 0.2); color: #ff9800; }

/* ============ Agent Bus ============ */

.bus-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.bus-send {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.bus-send .input { flex: 1; min-width: 120px; }

.bus-feed {
  max-height: 500px;
  overflow-y: auto;
}

/* ============ Doctor ============ */

.doctor-report {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.doctor-section {
  margin-bottom: 16px;
}

.doctor-section h3 {
  margin-bottom: 12px;
  font-size: 1em;
  color: var(--text-secondary);
}

.doctor-stats {
  display: flex;
  gap: 16px;
}

.doctor-action {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 0.9em;
}

.doctor-action.success { border-left: 3px solid var(--accent-success); }
.doctor-action.failed { border-left: 3px solid var(--accent-error); }

.action-type { min-width: 60px; }
.action-target { font-weight: 600; min-width: 120px; }
.action-reason { flex: 1; color: var(--text-secondary); }
.action-time { color: var(--text-secondary); font-size: 0.85em; }
.action-result { font-weight: 600; }

/* ============ Delegation ============ */

.delegation-info {
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  margin-bottom: 16px;
  color: var(--text-secondary);
  font-size: 0.9em;
}

.delegation-rule {
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  margin-bottom: 8px;
}

.rule-header {
  margin-bottom: 4px;
  color: var(--accent-primary);
}

.rule-description {
  font-size: 0.9em;
  color: var(--text-secondary);
}

.delegation-tiers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.tier-card {
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.tier-card.available { border-color: var(--accent-success); }
.tier-card.unavailable { opacity: 0.5; }

.tier-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.tier-name { font-weight: 600; font-size: 0.9em; }
.tier-cost { color: var(--text-secondary); font-size: 0.85em; }
.tier-status { margin-top: 4px; font-size: 0.85em; }
