/* ═══════════════════════════════════════════════════════════════════════════
   Kali Control Tower — Dark Cyberpunk Theme
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a28;
  --bg-card: #16161f;
  --bg-card-hover: #1e1e2d;
  --bg-input: #0e0e16;

  --text-primary: #e0e0e8;
  --text-secondary: #8888a0;
  --text-muted: #555568;

  --accent-cyan: #00e5ff;
  --accent-purple: #bb86fc;
  --accent-green: #00e676;
  --accent-red: #ff1744;
  --accent-orange: #ff9100;
  --accent-yellow: #ffea00;

  --border: #2a2a3a;
  --border-focus: var(--accent-cyan);

  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 20px rgba(0, 229, 255, 0.1);

  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

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

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-cyan); }

/* ── Header ────────────────────────────────────────────────────────────────── */
#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  height: 56px;
}

.header-left { display: flex; align-items: center; gap: 16px; }
.header-left h1 {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.subtitle {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.header-right { display: flex; align-items: center; gap: 16px; }
.system-info {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.ws-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transition: all 0.3s;
}
.ws-status.connected {
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}
.ws-status.disconnected {
  background: var(--accent-red);
  box-shadow: 0 0 8px var(--accent-red);
}

/* ── Main Layout ───────────────────────────────────────────────────────────── */
#main {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: calc(100vh - 56px);
  transition: grid-template-columns 0.3s;
}
#main.sessions-open {
  grid-template-columns: 240px 1fr 280px;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
#sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
}

.coverage-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--accent-cyan);
}

#category-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 2px;
}
.category-item:hover {
  background: var(--bg-tertiary);
}
.category-item.active {
  background: rgba(0, 229, 255, 0.08);
  border-left: 3px solid var(--accent-cyan);
}
.category-item .icon { font-size: 16px; }
.category-item .name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
}
.category-item .count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

/* ── Content ────────────────────────────────────────────────────────────────── */
#content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

#tool-grid-section,
#execution-panel,
#output-section {
  padding: 16px 24px;
}

#tool-grid-section {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

#execution-panel {
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

#output-section {
  border-top: 1px solid var(--border);
  background: var(--bg-primary);
  max-height: 50vh;
  min-height: 120px;
  display: flex;
  flex-direction: column;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.section-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.search-box input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  color: var(--text-primary);
  font-size: 13px;
  width: 200px;
  outline: none;
  transition: border-color 0.2s;
}
.search-box input:focus {
  border-color: var(--accent-cyan);
}

/* ── Tool Grid ──────────────────────────────────────────────────────────────── */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.tool-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-cyan);
  box-shadow: var(--shadow-glow);
}
.tool-card.installed {
  border-left: 3px solid var(--accent-green);
}
.tool-card:not(.installed) {
  opacity: 0.5;
}
.tool-card:not(.installed):hover {
  opacity: 0.7;
}
.tool-card.automatable::after {
  content: '⚡';
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 14px;
  title: 'Harness-wrapped';
}

.tool-card .tool-name {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}
.tool-card .tool-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.tool-card .tool-badges {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
}
.badge-installed {
  background: rgba(0, 230, 118, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(0, 230, 118, 0.3);
}
.badge-missing {
  background: rgba(255, 23, 68, 0.1);
  color: var(--accent-red);
  border: 1px solid rgba(255, 23, 68, 0.2);
}
.badge-harness {
  background: rgba(0, 229, 255, 0.1);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 229, 255, 0.2);
}

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 12px;
}
.form-group label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-group input,
.form-group select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-mono);
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent-cyan);
}
.form-group .hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.btn:hover {
  background: var(--bg-card-hover);
}
.btn-primary {
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.2), rgba(187, 134, 252, 0.2));
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}
.btn-primary:hover {
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.3), rgba(187, 134, 252, 0.3));
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.2);
}
.btn-secondary {
  border-color: var(--accent-purple);
  color: var(--accent-purple);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}
.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}
.btn-danger {
  border-color: var(--accent-red);
  color: var(--accent-red);
}

/* ── Terminal ───────────────────────────────────────────────────────────────── */
.terminal {
  flex: 1;
  background: #080810;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  min-height: 80px;
}

#terminal-output {
  white-space: pre-wrap;
  word-break: break-all;
}

.output-controls {
  display: flex;
  gap: 4px;
}

/* ── Terminal Colors ────────────────────────────────────────────────────────── */
.term-green { color: var(--accent-green); }
.term-red { color: var(--accent-red); }
.term-cyan { color: var(--accent-cyan); }
.term-yellow { color: var(--accent-yellow); }
.term-purple { color: var(--accent-purple); }
.term-muted { color: var(--text-muted); }
.term-bold { font-weight: 700; }

/* ── Sessions Panel ────────────────────────────────────────────────────────── */
#sessions-panel {
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sessions-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.session-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.session-item:hover {
  border-color: var(--accent-cyan);
}
.session-item .session-tool {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}
.session-item .session-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}
.session-item .session-status {
  font-size: 10px;
  margin-top: 4px;
}
.status-running { color: var(--accent-yellow); }
.status-completed { color: var(--accent-green); }
.status-error { color: var(--accent-red); }
.status-timeout { color: var(--accent-orange); }

/* ── Utilities ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.pulse { animation: pulse 1.5s infinite; }

@keyframes spin {
  to { transform: rotate(360deg); }
}
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Loading State ──────────────────────────────────────────────────────────── */
.loading-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-lg);
  height: 80px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  #main { grid-template-columns: 1fr; }
  #sidebar { display: none; }
}
