/* ============================================================
   CTI Portal — Dark Red Threat Intelligence Theme
   ============================================================ */

:root {
  --bg:         #0a0a0a;
  --surface:    #111111;
  --surface2:   #161616;
  --surface3:   #1c1c1c;
  --border:     #222222;
  --border2:    #2a2a2a;
  --red:        #e63946;
  --red-dim:    #7c1a20;
  --red-glow:   rgba(230, 57, 70, 0.15);
  --red-subtle: rgba(230, 57, 70, 0.06);
  --text:       #d4d4d4;
  --text-dim:   #666;
  --text-mid:   #999;
  --green:      #2ecc71;
  --yellow:     #f39c12;
  --orange:     #e67e22;
  --blue:       #3498db;
  --mono:       'Share Tech Mono', monospace;
  --display:    'Orbitron', sans-serif;
  --body:       'Rajdhani', sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* SCANLINES */
.scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 9998;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.025) 2px, rgba(0,0,0,0.025) 4px);
}

/* CURSOR GLOW */
.cursor-glow {
  position: fixed;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(230,57,70,0.10) 0%, transparent 70%);
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: transform 0.08s ease-out;
  z-index: 0;
}

/* ============================================================
   NAVBAR
   ============================================================ */
/* ============================================================
   SIDEBAR NAVIGATION
   ============================================================ */
:root {
  --sidebar-w: 220px;
  --sidebar-w-collapsed: 56px;
}

.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: rgba(10,10,10,0.98);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: width 0.25s ease;
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-w-collapsed); }

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 72px;
}
.sidebar-brand-link {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; overflow: hidden;
}
.brand-skull { width: 34px; height: 34px; flex-shrink: 0; filter: drop-shadow(0 0 6px rgba(230,57,70,0.5)); }
.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.2; white-space: nowrap; }
.brand-name { font-family: var(--display); font-size: 13px; letter-spacing: 2px; color: #fff; }
.brand-name .accent { color: var(--red); }
.brand-sub { font-family: var(--mono); font-size: 8px; color: var(--text-dim); letter-spacing: 1.5px; }

/* Toggle button */
.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--text-dim); padding: 6px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.2s;
}
.sidebar-toggle:hover { color: var(--text); }

/* Nav */
.sidebar-nav {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 12px 0;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); }

.sidebar-section-label {
  font-family: var(--mono);
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 2px;
  padding: 10px 16px 4px;
  white-space: nowrap;
  overflow: hidden;
  opacity: 1;
  transition: opacity 0.2s;
}
.sidebar.collapsed .sidebar-section-label { opacity: 0; }

.sidebar-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 16px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  text-decoration: none;
  letter-spacing: 0.5px;
  border-left: 2px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.sidebar-link svg { flex-shrink: 0; }
.sidebar-link:hover { color: var(--text); background: var(--surface); border-left-color: var(--border); }
.sidebar-link.active { color: var(--red); background: var(--red-subtle); border-left-color: var(--red); }
.sidebar-link.phishing-inactive { color: #c49a16; }
.sidebar-link.phishing-inactive:hover { color: var(--yellow); background: rgba(243,156,18,0.06); border-left-color: var(--yellow); }
.sidebar-link.active.phishing { color: var(--green); background: rgba(46,204,113,0.06); border-left-color: var(--green); }
.sidebar-link.kb-inactive { color: #7d3f8c; }
.sidebar-link.kb-inactive:hover { color: #9b59b6; background: rgba(155,89,182,0.06); border-left-color: #9b59b6; }
.sidebar-link.active.kb { color: var(--green); background: rgba(46,204,113,0.06); border-left-color: var(--green); }

.sidebar-label { transition: opacity 0.2s; white-space: nowrap; overflow: hidden; }
.sidebar.collapsed .sidebar-label { opacity: 0; width: 0; }

/* Footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar-status { display: flex; align-items: center; gap: 8px; }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.status-label { font-family: var(--mono); font-size: 10px; color: var(--green); letter-spacing: 1px; white-space: nowrap; }

.btn-sync {
  display: flex; align-items: center; gap: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  padding: 5px 10px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  white-space: nowrap;
}
.btn-sync:hover { border-color: var(--red); color: var(--red); }
.btn-sync.syncing { border-color: var(--yellow); color: var(--yellow); pointer-events: none; }
.btn-sync.syncing svg { animation: spin 1s linear infinite; }

/* Page wrapper — sits next to sidebar */
.page-wrapper {
  margin-left: var(--sidebar-w);
  transition: margin-left 0.25s ease;
  min-height: 100vh;
}
.page-wrapper.sidebar-collapsed { margin-left: var(--sidebar-w-collapsed); }

/* Brand skull (keep existing filter) */
.brand-skull { filter: drop-shadow(0 0 6px rgba(230,57,70,0.5)); }

/* ============================================================
   LAYOUT
   ============================================================ */
.main-content { position: relative; z-index: 1; padding: 32px 32px; }

.page-header { margin-bottom: 32px; }
.page-title {
  font-family: var(--display);
  font-size: 22px;
  letter-spacing: 2px;
  color: #fff;
  margin-bottom: 6px;
}
.page-title .accent { color: var(--red); }
.page-subtitle { font-family: var(--mono); font-size: 11px; color: var(--text-dim); letter-spacing: 1px; }

.section-title {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--text-dim);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-transform: uppercase;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ============================================================
   STAT CARDS (with sliding highlight)
   ============================================================ */
.stat-highlight {
  position: fixed;
  pointer-events: none;
  background: linear-gradient(135deg, var(--red-dim) 0%, #1a0a0b 100%);
  border: 1px solid var(--red);
  box-shadow: 0 0 24px rgba(230,57,70,0.2), inset 0 0 30px rgba(0,0,0,0.3);
  transition: top 0.4s cubic-bezier(0.25,0.8,0.25,1),
              left 0.45s cubic-bezier(0.25,0.8,0.25,1),
              width 0.35s, height 0.35s, opacity 0.25s;
  opacity: 0;
  z-index: 2;
}
.stat-highlight::after {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, transparent, transparent 8px, rgba(0,0,0,0.12) 8px, rgba(0,0,0,0.12) 9px);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin-bottom: 40px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 28px 20px;
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; cursor: default;
  transition: border-color 0.2s;
  position: relative;
}
.stat-card:hover { border-color: transparent; }
.stat-card > * { position: relative; z-index: 3; }

.stat-icon { color: var(--red); }
.stat-count { font-family: var(--display); font-size: 28px; color: var(--red); font-weight: 700; }
.stat-label { font-family: var(--mono); font-size: 10px; color: var(--text-dim); letter-spacing: 1px; text-align: center; }

/* ============================================================
   PANEL / CARD
   ============================================================ */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 24px;
}
.panel-title {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--text-dim);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  display: flex; align-items: center; gap: 8px;
}
.panel-title svg { color: var(--red); }

/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 28px;
  margin-bottom: 32px;
}
.search-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 2px;
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
  text-transform: uppercase;
}
.search-label svg { color: var(--red); }

.search-row { display: flex; gap: 10px; }

.search-input-wrap { position: relative; flex: 1; }
.search-input-wrap .s-icon {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
}
.search-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 12px 14px 12px 40px;
  outline: none;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--red); }
.search-input::placeholder { color: var(--text-dim); }

.btn {
  padding: 12px 24px;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  letter-spacing: 1px;
  border: none;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  white-space: nowrap;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: #c0242f; }
.btn-outline { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--red); color: var(--red); }

/* ============================================================
   IOC RESULT
   ============================================================ */
.ioc-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  padding: 24px;
  margin-bottom: 24px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap;
}
.ioc-indicator { font-family: var(--mono); font-size: 20px; color: #fff; word-break: break-all; }
.ioc-meta { display: flex; gap: 12px; margin-top: 10px; flex-wrap: wrap; }

.badge {
  font-family: var(--mono);
  font-size: 10px;
  padding: 4px 10px;
  letter-spacing: 1px;
  border: 1px solid;
  text-transform: uppercase;
}
.badge-red    { color: var(--red);    border-color: var(--red-dim);   background: rgba(230,57,70,0.08); }
.badge-green  { color: var(--green);  border-color: rgba(46,204,113,0.3); background: rgba(46,204,113,0.05); }
.badge-yellow { color: var(--yellow); border-color: rgba(243,156,18,0.3);  background: rgba(243,156,18,0.05); }
.badge-blue   { color: var(--blue);   border-color: rgba(52,152,219,0.3);  background: rgba(52,152,219,0.05); }
.badge-gray   { color: var(--text-mid); border-color: var(--border2); background: var(--surface2); }

.risk-score {
  font-family: var(--display);
  font-size: 36px;
  color: var(--red);
  text-align: right;
  line-height: 1;
}
.risk-label { font-family: var(--mono); font-size: 9px; color: var(--text-dim); letter-spacing: 2px; }

/* ============================================================
   PULSE CARD
   ============================================================ */
.pulse-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 20px 24px;
  margin-bottom: 2px;
  display: flex; align-items: flex-start; gap: 20px;
  transition: border-color 0.2s, background 0.2s;
  text-decoration: none; color: inherit;
}
.pulse-card:hover { border-color: var(--red-dim); background: var(--surface2); }

.pulse-tlp {
  width: 4px; flex-shrink: 0; align-self: stretch; border-radius: 2px;
}
.tlp-white  { background: #fff; }
.tlp-green  { background: var(--green); }
.tlp-amber  { background: var(--yellow); }
.tlp-red    { background: var(--red); }

.pulse-body { flex: 1; min-width: 0; }
.pulse-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pulse-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tag {
  font-family: var(--mono); font-size: 9px; padding: 2px 8px;
  background: var(--surface3); border: 1px solid var(--border2);
  color: var(--text-dim); letter-spacing: 1px;
}

.pulse-meta { display: flex; gap: 20px; flex-wrap: wrap; }
.meta-item { font-family: var(--mono); font-size: 10px; color: var(--text-dim); display: flex; align-items: center; gap: 5px; }
.meta-item svg { color: var(--red); }

.pulse-ioc-count { font-family: var(--display); font-size: 22px; color: var(--red); text-align: right; white-space: nowrap; }
.pulse-ioc-label { font-family: var(--mono); font-size: 9px; color: var(--text-dim); }

/* ============================================================
   TABLE
   ============================================================ */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  font-family: var(--mono); font-size: 10px; letter-spacing: 2px;
  color: var(--text-dim); text-transform: uppercase;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  text-align: left; background: var(--surface2);
}
.data-table td {
  font-family: var(--mono); font-size: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  color: var(--text); vertical-align: middle;
}
.data-table tr:hover td { background: var(--surface2); }
.data-table .cell-mono { font-family: var(--mono); word-break: break-all; }

/* ============================================================
   EMPTY STATE / ERROR
   ============================================================ */
.empty-state {
  padding: 60px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  text-align: center;
}
.empty-icon { color: var(--text-dim); }
.empty-title { font-family: var(--mono); font-size: 14px; color: var(--text); letter-spacing: 1px; }
.empty-sub   { font-family: var(--mono); font-size: 11px; color: var(--text-dim); }

.alert-error {
  background: rgba(230,57,70,0.08);
  border: 1px solid var(--red-dim);
  border-left: 3px solid var(--red);
  padding: 14px 18px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--red);
  margin-bottom: 20px;
}

/* ============================================================
   GRID LAYOUTS
   ============================================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; }

/* ============================================================
   TAGS / TOP TAGS
   ============================================================ */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-pill {
  font-family: var(--mono); font-size: 10px;
  padding: 5px 12px; border: 1px solid var(--border2);
  color: var(--text-mid); background: var(--surface2);
  letter-spacing: 1px; transition: all 0.2s; cursor: default;
}
.tag-pill:hover { border-color: var(--red-dim); color: var(--red); }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination { display: flex; align-items: center; gap: 8px; margin-top: 24px; }
.page-btn {
  font-family: var(--mono); font-size: 11px;
  padding: 8px 16px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-dim);
  text-decoration: none; letter-spacing: 1px;
  transition: all 0.2s;
}
.page-btn:hover, .page-btn.active { border-color: var(--red); color: var(--red); background: var(--red-subtle); }
.page-info { font-family: var(--mono); font-size: 10px; color: var(--text-dim); margin: 0 8px; }

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  border-top: 1px solid var(--border);
  padding: 16px 32px;
  display: flex; justify-content: space-between; align-items: center;
  position: relative; z-index: 1;
}
.mono { font-family: var(--mono); }
.dim  { color: var(--text-dim); font-size: 10px; letter-spacing: 1px; }

/* ============================================================
   UTILS
   ============================================================ */
.text-red    { color: var(--red); }
.text-green  { color: var(--green); }
.text-yellow { color: var(--yellow); }
.text-dim    { color: var(--text-dim); }
.text-mid    { color: var(--text-mid); }
.mono        { font-family: var(--mono); }
.fw-bold     { font-weight: 700; }
.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; }
.flex  { display: flex; }
.items-center { align-items: center; }
.gap-8  { gap: 8px; }
.gap-16 { gap: 16px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .sidebar { width: var(--sidebar-w-collapsed); }
  .page-wrapper { margin-left: var(--sidebar-w-collapsed); }
  .main-content { padding: 20px 16px; }
}

/* ============================================================
   ENHANCEMENTS — Bulk Search, Watchlist, Tags, Cache Stats
   ============================================================ */

/* Pulse search keyword highlight */
.keyword-match { background: rgba(230,57,70,0.2); color: var(--red); padding: 0 2px; }

/* Tag pill active state */
.tag-pill.active { border-color: var(--red); color: var(--red); background: var(--red-subtle); }

/* Textarea search input */
textarea.search-input {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.6;
}
textarea.search-input:focus { border-color: var(--red); }

/* Select filter (used in watchlist) */
.select-filter {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 12px 14px;
  outline: none;
  cursor: pointer;
}

/* Bulk search summary cards */
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 20px;
  text-align: center;
  flex: 1;
  min-width: 120px;
}

/* Risk score colors */
.risk-high   { color: var(--red); }
.risk-medium { color: var(--yellow); }
.risk-low    { color: var(--green); }

/* Copy flash */
.copy-flash { color: var(--green) !important; transition: color 0.3s; }

/* Tag explorer overflow scroll */
.tag-scroll { max-height: 520px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.tag-scroll::-webkit-scrollbar { width: 4px; }
.tag-scroll::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* Watchlist star button */
.btn-watch {
  background: transparent;
  border: 1px solid rgba(243,156,18,0.4);
  color: var(--yellow);
  font-family: var(--mono);
  font-size: 10px;
  padding: 4px 12px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: background 0.2s, border-color 0.2s;
}
.btn-watch:hover { background: rgba(243,156,18,0.1); border-color: var(--yellow); }

/* MITRE ATT&CK badge */
.badge-mitre {
  background: rgba(83,74,183,0.12);
  border: 1px solid rgba(83,74,183,0.4);
  color: #9f98e8;
  font-family: var(--mono);
  font-size: 10px;
  padding: 4px 10px;
  letter-spacing: 1px;
  text-decoration: none;
  display: inline-block;
  transition: background 0.2s;
}
.badge-mitre:hover { background: rgba(83,74,183,0.25); }

/* IOC type filter buttons row */
.type-filter-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* Cached indicator badge */
.badge-cached {
  background: rgba(46,204,113,0.08);
  border: 1px solid rgba(46,204,113,0.3);
  color: var(--green);
  font-family: var(--mono);
  font-size: 9px;
  padding: 3px 8px;
  letter-spacing: 1px;
}
