/* =====================================================
   THREATS DASHBOARD — STYLESHEET
   College of Engineering Technology | Cybersecurity Dept.
   ===================================================== */

/* ── HERO ──────────────────────────────────────────── */
.threats-hero {
  position: relative;
  overflow: hidden;
  padding: 72px 20px 56px;
  background: linear-gradient(180deg, var(--bg2) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
}

.threats-hero-bg {
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
}

.th-shape {
  position: absolute; border-radius: 50%; opacity: .06;
}
.th-shape.s1 {
  width: 560px; height: 560px;
  background: radial-gradient(circle, var(--accent2), transparent 70%);
  top: -180px; left: -120px;
}
.th-shape.s2 {
  width: 420px; height: 420px;
  background: radial-gradient(circle, var(--accent), transparent 70%);
  bottom: -140px; right: -80px;
}
.th-shape.s3 {
  width: 280px; height: 280px;
  background: radial-gradient(circle, var(--danger), transparent 70%);
  top: 60px; right: 30%;
  opacity: .04;
}

.threats-hero-content {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 28px;
  flex-wrap: wrap;
}

.threats-hero-icon {
  width: 88px; height: 88px; flex-shrink: 0;
  background: linear-gradient(135deg, rgba(124,58,237,.3), rgba(0,212,170,.2));
  border: 2px solid rgba(0,212,170,.3);
  border-radius: 24px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  box-shadow: 0 0 40px rgba(0,212,170,.15);
}

.threats-hero-text { flex: 1; min-width: 240px; }

.threats-hero-title {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 800;
  background: linear-gradient(135deg, var(--text) 40%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
  line-height: 1.3;
}

.threats-hero-desc {
  color: var(--muted);
  font-size: .97rem;
  margin-bottom: 18px;
  max-width: 600px;
}

/* ── LIVE BADGE ────────────────────────────────────── */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.35);
  border-radius: 100px;
  font-size: .82rem;
  font-weight: 700;
  color: #fc8181;
  letter-spacing: .05em;
}

.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 0 rgba(239,68,68,.5);
  animation: livePulse 1.6s ease-in-out infinite;
}

@keyframes livePulse {
  0%   { box-shadow: 0 0 0 0 rgba(239,68,68,.5); }
  70%  { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}

/* ── MAIN AREA ─────────────────────────────────────── */
.threats-main {
  padding: 40px 0 80px;
}

/* ── STATS GRID ────────────────────────────────────── */
.threats-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 40px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0; left: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px rgba(0,0,0,.4);
}

.stat-card-1::before { background: linear-gradient(90deg, var(--accent), #00b38f); }
.stat-card-2::before { background: linear-gradient(90deg, var(--accent2), #9f67ff); }
.stat-card-3::before { background: linear-gradient(90deg, var(--accent3), #fbbf24); }
.stat-card-4::before { background: linear-gradient(90deg, var(--danger), #f97316); }

.stat-card-1 .stat-icon { color: var(--accent); background: rgba(0,212,170,.12); }
.stat-card-2 .stat-icon { color: var(--accent2); background: rgba(124,58,237,.12); }
.stat-card-3 .stat-icon { color: var(--accent3); background: rgba(245,158,11,.12); }
.stat-card-4 .stat-icon { color: var(--danger); background: rgba(239,68,68,.12); }

.stat-icon {
  width: 52px; height: 52px; flex-shrink: 0;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
}

.stat-body { flex: 1; min-width: 0; }

.stat-num {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-label {
  font-size: .8rem;
  color: var(--muted);
  font-weight: 500;
}

/* ── THREAT SECTION ────────────────────────────────── */
.threat-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 28px;
  overflow: hidden;
}

.threat-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.02);
}

.threat-section-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
}

.threat-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.threat-section-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.section-badge {
  font-size: .75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 100px;
  letter-spacing: .03em;
}

.badge-accent2 { background: rgba(124,58,237,.18); color: #a78bfa; border: 1px solid rgba(124,58,237,.3); }
.badge-danger  { background: rgba(239,68,68,.15); color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }
.badge-accent3 { background: rgba(245,158,11,.15); color: #fcd34d; border: 1px solid rgba(245,158,11,.3); }
.badge-ok      { background: rgba(34,197,94,.15); color: #86efac; border: 1px solid rgba(34,197,94,.3); }

.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(0,212,170,.1);
  border: 1px solid rgba(0,212,170,.3);
  border-radius: 8px;
  color: var(--accent);
  font-family: var(--font);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .2s;
}

.refresh-btn:hover {
  background: rgba(0,212,170,.2);
  transform: translateY(-1px);
}

.refresh-btn.spinning svg {
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── CVE CARDS ─────────────────────────────────────── */
.cve-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding: 20px 24px;
}

.cve-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform .2s, border-color .2s;
}

.cve-card:hover {
  transform: translateY(-3px);
  border-color: rgba(0,212,170,.3);
}

.cve-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cve-id {
  font-size: .8rem;
  font-weight: 700;
  color: var(--accent);
  font-family: 'Courier New', monospace;
  background: rgba(0,212,170,.08);
  padding: 3px 8px;
  border-radius: 6px;
  direction: ltr;
}

.cve-title {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cve-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: .75rem;
  color: var(--muted);
}

.cve-package {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
}

.cve-package::before {
  content: '📦';
  font-size: .7rem;
}

.cve-date {
  margin-right: auto;
  direction: ltr;
}

/* Severity Badges */
.severity-badge {
  font-size: .7rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: .05em;
  flex-shrink: 0;
}

.severity-critical {
  background: rgba(239,68,68,.2);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,.4);
}

.severity-high {
  background: rgba(249,115,22,.2);
  color: #fdba74;
  border: 1px solid rgba(249,115,22,.4);
}

.severity-medium {
  background: rgba(245,158,11,.2);
  color: #fcd34d;
  border: 1px solid rgba(245,158,11,.4);
}

.severity-low {
  background: rgba(34,197,94,.2);
  color: #86efac;
  border: 1px solid rgba(34,197,94,.4);
}

.severity-unknown {
  background: rgba(100,116,139,.2);
  color: #94a3b8;
  border: 1px solid rgba(100,116,139,.4);
}

/* ── BIG BREACH CARDS ──────────────────────────────── */
.breach-big-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  padding: 20px 24px;
}

.breach-big-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform .2s, border-color .2s;
  position: relative;
  overflow: hidden;
}

.breach-big-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--danger), transparent);
  opacity: 0;
  transition: opacity .2s;
}

.breach-big-card:hover {
  transform: translateY(-4px);
  border-color: rgba(239,68,68,.3);
}

.breach-big-card:hover::after { opacity: 1; }

.breach-big-logo {
  width: 52px; height: 52px;
  border-radius: 12px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}

.breach-big-logo img {
  width: 100%; height: 100%; object-fit: contain;
}

.breach-big-logo-placeholder {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--danger);
}

.breach-big-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.breach-big-count {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--danger);
}

.breach-big-count-label {
  font-size: .75rem;
  color: var(--muted);
  margin-top: 2px;
}

.breach-big-date {
  font-size: .75rem;
  color: var(--muted);
  direction: ltr;
  text-align: right;
}

/* ── KEV LIST ──────────────────────────────────────── */
.kev-list {
  padding: 12px 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kev-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px 16px;
  align-items: start;
  transition: border-color .2s, transform .2s;
}

.kev-item:hover {
  border-color: rgba(245,158,11,.3);
  transform: translateX(-3px);
}

.kev-cve-id {
  font-size: .8rem;
  font-weight: 700;
  color: var(--accent3);
  font-family: 'Courier New', monospace;
  background: rgba(245,158,11,.08);
  padding: 3px 8px;
  border-radius: 6px;
  direction: ltr;
  white-space: nowrap;
  align-self: center;
}

.kev-body { min-width: 0; }

.kev-product-line {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.kev-vendor {
  color: var(--muted);
  font-weight: 500;
}

.kev-vendor::before { content: '·'; margin-left: 4px; }

.kev-desc {
  font-size: .78rem;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kev-date {
  font-size: .72rem;
  color: var(--muted);
  direction: ltr;
  white-space: nowrap;
  align-self: center;
}

.kev-new-badge {
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 7px;
  background: rgba(239,68,68,.18);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,.35);
  border-radius: 100px;
}

/* ── BAR CHART ─────────────────────────────────────── */
.bar-chart-wrap {
  padding: 24px 28px 20px;
}

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 52px 1fr 72px;
  align-items: center;
  gap: 12px;
}

.bar-year-label {
  font-size: .82rem;
  font-weight: 700;
  color: var(--muted);
  text-align: left;
  direction: ltr;
}

.bar-track {
  background: rgba(255,255,255,.04);
  border-radius: 100px;
  height: 26px;
  overflow: hidden;
  position: relative;
}

.bar {
  height: 100%;
  border-radius: 100px;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  width: 0;
  transition: width 1.1s cubic-bezier(.4,0,.2,1);
  position: relative;
  min-width: 3px;
}

.bar.bar-animated {
  /* triggered by JS */
}

.bar-track:hover .bar {
  opacity: .85;
}

.bar-value {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text);
  text-align: right;
  direction: ltr;
  white-space: nowrap;
}

.chart-loading {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── SKELETON LOADING ──────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position: 600px 0; }
}

.skeleton-base {
  background: linear-gradient(
    90deg,
    rgba(255,255,255,.04) 25%,
    rgba(255,255,255,.08) 50%,
    rgba(255,255,255,.04) 75%
  );
  background-size: 600px 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: 10px;
}

.skeleton-cve {
  height: 130px;
  background: linear-gradient(
    90deg,
    rgba(255,255,255,.04) 25%,
    rgba(255,255,255,.08) 50%,
    rgba(255,255,255,.04) 75%
  );
  background-size: 600px 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: 12px;
}

.skeleton-breach-big {
  height: 160px;
  background: linear-gradient(
    90deg,
    rgba(255,255,255,.04) 25%,
    rgba(255,255,255,.08) 50%,
    rgba(255,255,255,.04) 75%
  );
  background-size: 600px 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: 12px;
}

.skeleton-kev {
  height: 72px;
  background: linear-gradient(
    90deg,
    rgba(255,255,255,.04) 25%,
    rgba(255,255,255,.08) 50%,
    rgba(255,255,255,.04) 75%
  );
  background-size: 600px 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: 10px;
}

.skeleton-bar {
  height: 26px;
  background: linear-gradient(
    90deg,
    rgba(255,255,255,.04) 25%,
    rgba(255,255,255,.08) 50%,
    rgba(255,255,255,.04) 75%
  );
  background-size: 600px 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: 100px;
}

/* ── ERROR STATE ───────────────────────────────────── */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

.error-state svg {
  color: var(--danger);
  opacity: .6;
}

.error-state p {
  font-size: .9rem;
  max-width: 320px;
  line-height: 1.6;
}

.error-state .retry-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: 8px;
  color: #fca5a5;
  font-family: var(--font);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}

.error-state .retry-btn:hover {
  background: rgba(239,68,68,.22);
}

/* ── RESPONSIVE ────────────────────────────────────── */
@media (max-width: 900px) {
  .threats-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .threats-stats {
    grid-template-columns: 1fr;
  }

  .threats-hero-content {
    flex-direction: column;
    text-align: center;
  }

  .threat-section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .cve-grid,
  .breach-big-grid {
    grid-template-columns: 1fr;
  }

  .kev-item {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
  }

  .kev-cve-id {
    grid-column: 1;
  }

  .kev-date {
    grid-column: 2;
    grid-row: 1;
  }

  .kev-body {
    grid-column: 1 / -1;
  }

  .bar-row {
    grid-template-columns: 44px 1fr 60px;
    gap: 8px;
  }
}

/* ── NAV TOGGLE (mobile) ───────────────────────────── */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 38px; height: 38px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  padding: 8px;
}

.nav-toggle span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: .25s;
}

@media (max-width: 768px) {
  .nav-toggle { display: flex; }

  .header-nav {
    display: none;
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 12px 0;
    z-index: 99;
  }

  .header-nav.open {
    display: flex;
  }

  .header-nav a {
    padding: 10px 24px;
    border-radius: 0;
  }
}
