/* ═══════════════════════════════════════════════════════
   AISACyberSecurity — Professional Dark UI
   ═══════════════════════════════════════════════════════ */

:root {
  --bg-primary:   #0a0e1a;
  --bg-secondary: #0f1423;
  --bg-card:      #141929;
  --bg-card2:     #1a2035;
  --border:       #1e2d4a;
  --accent:       #00d4aa;
  --accent2:      #0088ff;
  --accent3:      #7c3aed;
  --danger:       #ef4444;
  --warning:      #f59e0b;
  --success:      #10b981;
  --info:         #3b82f6;
  --text-primary: #e2e8f0;
  --text-secondary:#94a3b8;
  --text-muted:   #64748b;
  --font:         'Inter', 'Segoe UI', system-ui, sans-serif;
  --radius:       10px;
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
  --transition:   0.2s ease;
}

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

html { scroll-behavior: smooth; }

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

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

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: 240px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.5px;
}
.sidebar-logo .logo-sub {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}
.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
  font-size: 18px;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav-section { padding: 12px 16px 4px; }
.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-radius: 0;
  transition: var(--transition);
  position: relative;
}
.nav-item:hover {
  background: rgba(0,212,170,0.07);
  color: var(--text-primary);
}
.nav-item.active {
  background: rgba(0,212,170,0.12);
  color: var(--accent);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.nav-item .icon { width: 18px; text-align: center; font-size: 15px; }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Main content ── */
.main { margin-left: 240px; flex: 1; display: flex; flex-direction: column; }

/* ── Topbar ── */
.topbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0; z-index: 50;
}
.topbar-title { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.topbar-title span { color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 16px; }

.topbar-clock {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: var(--accent);
  background: rgba(0,212,170,0.08);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(0,212,170,0.2);
}

.btn-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }
.alert-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
}

/* ── Page content ── */
.page { padding: 24px; flex: 1; }

/* ── Page header ── */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 700; }
.page-header p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.card-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}
.card-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Stat cards grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: var(--transition);
}
.stat-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-icon.green  { background: rgba(16,185,129,0.15); color: var(--success); }
.stat-icon.blue   { background: rgba(59,130,246,0.15); color: var(--info); }
.stat-icon.red    { background: rgba(239,68,68,0.15);  color: var(--danger); }
.stat-icon.yellow { background: rgba(245,158,11,0.15); color: var(--warning); }
.stat-icon.purple { background: rgba(124,58,237,0.15); color: var(--accent3); }
.stat-icon.cyan   { background: rgba(0,212,170,0.15);  color: var(--accent); }

.stat-info { flex: 1; }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 26px; font-weight: 800; margin: 2px 0; line-height: 1; }
.stat-trend { font-size: 11px; }
.stat-trend.up   { color: var(--danger); }
.stat-trend.down { color: var(--success); }
.stat-trend.ok   { color: var(--success); }

/* ── Progress bar ── */
.progress-bar { background: var(--bg-primary); border-radius: 4px; height: 6px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }
.fill-green  { background: var(--success); }
.fill-blue   { background: var(--info); }
.fill-yellow { background: var(--warning); }
.fill-red    { background: var(--danger); }
.fill-cyan   { background: var(--accent); }
.fill-purple { background: var(--accent3); }

/* ── Grid layouts ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-12 { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; }
.grid-21 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(30,45,74,0.5);
  font-size: 13px;
  color: var(--text-secondary);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); color: var(--text-primary); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.badge-critical { background: rgba(239,68,68,0.15);  color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.badge-high     { background: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.3); }
.badge-medium   { background: rgba(59,130,246,0.15); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.badge-low      { background: rgba(16,185,129,0.15); color: #34d399; border: 1px solid rgba(16,185,129,0.3); }
.badge-open     { background: rgba(239,68,68,0.1);  color: #f87171; }
.badge-closed   { background: rgba(16,185,129,0.1); color: #34d399; }
.badge-info     { background: rgba(59,130,246,0.1); color: #60a5fa; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #0a0e1a;
}
.btn-primary:hover { background: #00bfa3; transform: translateY(-1px); }
.btn-secondary {
  background: var(--bg-card2);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger {
  background: rgba(239,68,68,0.15);
  color: #f87171;
  border: 1px solid rgba(239,68,68,0.3);
}
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
  transition: var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,212,170,0.1);
}
textarea { resize: vertical; min-height: 80px; }
select option { background: var(--bg-card2); }

/* ── Alert boxes ── */
.alert-box {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-box.critical { background: rgba(239,68,68,0.1);  border: 1px solid rgba(239,68,68,0.3);  color: #f87171; }
.alert-box.warning  { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3); color: #fbbf24; }
.alert-box.success  { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.3); color: #34d399; }
.alert-box.info     { background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.3); color: #60a5fa; }

/* ── Terminal / code box ── */
.terminal {
  background: #000;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--accent);
  overflow-y: auto;
  max-height: 400px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
}
.terminal .t-red    { color: #f87171; }
.terminal .t-yellow { color: #fbbf24; }
.terminal .t-green  { color: #34d399; }
.terminal .t-blue   { color: #60a5fa; }
.terminal .t-muted  { color: #64748b; }

/* ── AI response box ── */
.ai-box {
  background: linear-gradient(135deg, rgba(0,212,170,0.05), rgba(0,136,255,0.05));
  border: 1px solid rgba(0,212,170,0.2);
  border-radius: var(--radius);
  padding: 20px;
  font-size: 13px;
  line-height: 1.8;
  white-space: pre-wrap;
  color: var(--text-secondary);
}
.ai-box strong { color: var(--text-primary); }

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(0,212,170,0.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Chart canvas ── */
.chart-wrap { position: relative; height: 160px; }

/* ── Gauge ── */
.gauge-wrap { display: flex; flex-direction: column; align-items: center; }
.gauge-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── Network map ── */
#network-map {
  width: 100%;
  height: 420px;
  background: var(--bg-primary);
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* ── Chat ── */
.chat-messages {
  height: 400px;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-msg { max-width: 80%; }
.chat-msg.user { align-self: flex-end; }
.chat-msg.ai { align-self: flex-start; }
.chat-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
}
.chat-msg.user .chat-bubble {
  background: var(--accent);
  color: #0a0e1a;
  border-bottom-right-radius: 4px;
}
.chat-msg.ai .chat-bubble {
  background: var(--bg-card2);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
  white-space: pre-wrap;
}
.chat-meta { font-size: 10px; color: var(--text-muted); margin-top: 4px; text-align: right; }

/* ── Device card ── */
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.device-card {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: var(--transition);
  cursor: pointer;
}
.device-card:hover { border-color: var(--accent); }
.device-card.risk-critical { border-left: 3px solid var(--danger); }
.device-card.risk-high     { border-left: 3px solid var(--warning); }
.device-card.risk-low      { border-left: 3px solid var(--success); }
.device-ip { font-family: monospace; font-size: 14px; font-weight: 700; color: var(--text-primary); }
.device-hostname { font-size: 11px; color: var(--text-muted); }
.device-ports { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px; }
.port-tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-weight: 600;
}
.port-tag.risky  { background: rgba(239,68,68,0.15); color: #f87171; }
.port-tag.normal { background: rgba(100,116,139,0.15); color: #94a3b8; }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  margin-bottom: -1px;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Modals ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  max-width: 640px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.modal-close:hover { color: var(--danger); border-color: var(--danger); }

/* ── Severity indicator line ── */
.sev-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 13px;
}
.sev-line.critical { background: rgba(239,68,68,0.08); border-left: 3px solid var(--danger); }
.sev-line.high     { background: rgba(245,158,11,0.08); border-left: 3px solid var(--warning); }
.sev-line.medium   { background: rgba(59,130,246,0.08); border-left: 3px solid var(--info); }
.sev-line.low      { background: rgba(16,185,129,0.08); border-left: 3px solid var(--success); }

/* ── Loading overlay ── */
.loading {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,14,26,0.85);
  z-index: 300;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}
.loading.active { display: flex; }
.loading-spinner {
  width: 48px; height: 48px;
  border: 3px solid rgba(0,212,170,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading-text { color: var(--accent); font-size: 14px; }

/* ── Toasts ── */
#toast-container {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  min-width: 280px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  animation: slideIn 0.3s ease;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info    { border-left: 3px solid var(--info); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ── Utility ── */
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-accent  { color: var(--accent); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-success { color: var(--success); }
.text-muted   { color: var(--text-muted); }
.font-mono    { font-family: 'Courier New', monospace; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.fw-700 { font-weight: 700; }
.w-full { width: 100%; }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .grid-2, .grid-12, .grid-21 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-logo .logo-title,
  .sidebar-logo .logo-sub,
  .nav-item span,
  .nav-section { display: none; }
  .main { margin-left: 60px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
