/* 
  SwiftIOC Threat Intelligence Dashboard
  Complete stylesheet rewrite – dark, compact, dashboard-first
*/

:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  line-height: 1.6;

  --bg-color: #020617;
  --bg-gradient:
    radial-gradient(circle at 0% 0%, rgba(56, 189, 248, 0.18), transparent 55%),
    radial-gradient(circle at 100% 0%, rgba(168, 85, 247, 0.14), transparent 55%),
    linear-gradient(180deg, #020617, #020617 10%, #020617 50%, #020617 100%);

  --card-bg-soft: rgba(15, 23, 42, 0.90);
  --card-bg-strong: rgba(15, 23, 42, 0.98);

  --border-subtle: rgba(15, 23, 42, 1);
  --border-soft: rgba(148, 163, 184, 0.36);
  --border-strong: rgba(148, 163, 184, 0.85);

  --accent: #3b82f6;
  --accent-soft: #60a5fa;
  --accent-subtle: rgba(59, 130, 246, 0.18);

  --danger: #f97373;
  --danger-soft: #fb7185;
  --danger-subtle: rgba(248, 113, 113, 0.14);

  --warning: #fbbf24;
  --warning-soft: #facc15;
  --warning-subtle: rgba(250, 204, 21, 0.14);

  --success: #22c55e;
  --success-soft: #4ade80;
  --success-subtle: rgba(34, 197, 94, 0.16);

  --text-primary: #e5e7eb;
  --text-muted: #9ca3af;
  --text-soft: #94a3b8;
  --text-strong: #f9fafb;

  --shadow-soft: 0 18px 50px rgba(15, 23, 42, 0.96);
  --shadow-subtle: 0 18px 40px rgba(15, 23, 42, 0.9);

  --radius-card: 1rem;
  --radius-pill: 999px;

  --focus-ring: 0 0 0 1px rgba(15, 23, 42, 1), 0 0 0 2px rgba(129, 140, 248, 0.9);

  --transition-fast: 0.14s ease-out;
  --transition-med: 0.18s ease-out;
}

/* Base layout */

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--bg-gradient);
  color: var(--text-primary);
}

/* Typography */

body,
button,
input,
select {
  font-family: inherit;
}

h1,
h2,
h3,
h4 {
  color: var(--text-strong);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h1.section-title {
  font-size: clamp(1.6rem, 2.1vw, 1.9rem);
  font-weight: 650;
  margin: 0 0 0.15rem;
}

h2.panel-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
}

h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0;
}

p {
  margin-block: 0.1rem 0.45rem;
}

.page-header-subtitle,
.panel-subtitle {
  font-size: 0.82rem;
  color: var(--text-soft);
}

/* Layout wrappers */

.page-wrapper {
  max-width: 1240px;
  margin: 0 auto;
  padding: 1.5rem 1.75rem 2.5rem;
  position: relative;
}

.page-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

/* Top nav */

.top-nav {
  position: sticky;
  top: 0.75rem;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.75rem;
  margin-bottom: 1rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background:
    radial-gradient(circle at 0% 0%, rgba(37, 99, 235, 0.2), transparent 55%),
    radial-gradient(circle at 100% 0%, rgba(236, 72, 153, 0.16), transparent 55%),
    radial-gradient(circle at 0% 100%, rgba(34, 197, 94, 0.16), transparent 55%),
    rgba(15, 23, 42, 0.97);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.16rem 0.6rem 0.18rem;
  border-radius: 999px;
  border: 1px solid rgba(96, 165, 250, 0.6);
  background:
    radial-gradient(circle at 0 0, rgba(56, 189, 248, 0.35), transparent 55%),
    radial-gradient(circle at 100% 100%, rgba(59, 130, 246, 0.42), transparent 55%),
    rgba(15, 23, 42, 0.95);
  font-weight: 650;
  font-size: 0.86rem;
  color: #eff6ff;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.brand-tagline {
  font-size: 0.78rem;
  color: var(--text-soft);
}

.nav-links {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.8rem;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.14rem 0.55rem;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: background var(--transition-fast), border-color var(--transition-fast),
    color var(--transition-fast), transform 0.12s ease-out;
}

.nav-links a:hover {
  color: var(--text-strong);
  border-color: rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.8);
  transform: translateY(-0.5px);
}

.nav-links a:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Status banner */

.status-banner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  padding: 0.65rem 0.9rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(37, 99, 235, 0.55);
  background:
    radial-gradient(circle at 0% 0%, rgba(37, 99, 235, 0.25), transparent 65%),
    radial-gradient(circle at 90% 20%, rgba(56, 189, 248, 0.15), transparent 60%),
    rgba(15, 23, 42, 0.97);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.9);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.status-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.16);
}

.status-label {
  font-size: 0.82rem;
  font-weight: 500;
}

.status-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-soft);
}

.status-meta-label {
  color: var(--text-muted);
}

.status-meta-value {
  font-weight: 500;
  color: var(--text-primary);
}

/* Status visual variations based on data-state */

[data-site-status-root][data-state='live'] .status-dot {
  background: var(--success);
  box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.2);
}

[data-site-status-root][data-state='cache'] .status-dot {
  background: #f97316;
  box-shadow: 0 0 0 6px rgba(249, 115, 22, 0.22);
}

[data-site-status-root][data-state='cache-stale'] .status-dot {
  background: var(--warning);
  box-shadow: 0 0 0 6px rgba(250, 204, 21, 0.22);
}

[data-site-status-root][data-state='error'] .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 6px rgba(248, 113, 113, 0.28);
}

/* Metrics strip */

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.1rem;
}

.metric-card {
  border-radius: var(--radius-card);
  border: 1px solid var(--border-soft);
  background: radial-gradient(circle at 0 0, rgba(59, 130, 246, 0.12), transparent 55%),
    radial-gradient(circle at 100% 100%, rgba(37, 99, 235, 0.14), transparent 55%),
    var(--card-bg-soft);
  padding: 0.55rem 0.7rem 0.6rem;
  box-shadow: var(--shadow-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.metric-label {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.metric-value {
  font-size: 1.1rem;
  font-weight: 650;
  color: var(--text-strong);
}

.metric-caption {
  font-size: 0.72rem;
  color: var(--text-soft);
}

/* Panel */

.panel {
  border-radius: var(--radius-card);
  border: 1px solid var(--border-soft);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.99), rgba(15, 23, 42, 0.96));
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-header {
  padding: 0.7rem 0.9rem 0.55rem;
  border-bottom: 1px solid rgba(30, 64, 175, 0.65);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.panel-body {
  padding: 0.7rem 0.9rem 0.85rem;
}

/* Table card */

.table-card {
  border-radius: 0.8rem;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: radial-gradient(circle at 0 0, rgba(59, 130, 246, 0.14), transparent 55%),
    rgba(15, 23, 42, 0.98);
  box-shadow: var(--shadow-soft);
  padding: 0.55rem 0.65rem 0.6rem;
}

.table-card-header {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.35rem;
}

.table-card-header p {
  font-size: 0.74rem;
  color: var(--text-soft);
}

/* Tables */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

thead th {
  text-align: left;
  font-weight: 500;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0.35rem 0.45rem 0.32rem;
  border-bottom: 1px solid rgba(51, 65, 85, 0.9);
  background: radial-gradient(circle at 0 0, rgba(37, 99, 235, 0.18), transparent 55%),
    rgba(15, 23, 42, 1);
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody td {
  padding: 0.3rem 0.45rem;
  border-bottom: 1px dashed rgba(30, 64, 175, 0.42);
}

tbody tr:last-child td {
  border-bottom-color: transparent;
}

tbody tr:nth-child(2n) td {
  background: rgba(15, 23, 42, 0.85);
}

tbody tr:hover td {
  background: rgba(30, 64, 175, 0.5);
}

td.numeric {
  text-align: right;
}

td[data-title]::before {
  content: attr(data-title);
  display: none;
  font-weight: 500;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Buttons/links */

.button-link,
.panel-header-link {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: radial-gradient(circle at 0 0, rgba(59, 130, 246, 0.3), transparent 55%),
    rgba(15, 23, 42, 0.98);
  color: #eff6ff;
  text-decoration: none;
  font-size: 0.78rem;
  padding: 0.3rem 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 1);
  transition: transform 0.12s ease-out, box-shadow var(--transition-med),
    border-color var(--transition-fast), background var(--transition-fast);
}

.button-link:hover,
.panel-header-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 1);
  border-color: rgba(96, 165, 250, 0.9);
}

.button-link:focus-visible,
.panel-header-link:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.button-link[disabled],
.panel-header-link[disabled] {
  opacity: 0.65;
  cursor: default;
}

/* Form controls */

select,
input[type='search'],
input[type='text'] {
  font-size: 0.78rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.55);
  background: rgba(15, 23, 42, 0.98);
  color: var(--text-primary);
  padding: 0.2rem 0.6rem;
  min-height: 1.9rem;
  outline: none;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.9);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast),
    background var(--transition-fast);
}

select:focus-visible,
input[type='search']:focus-visible,
input[type='text']:focus-visible {
  border-color: rgba(96, 165, 250, 0.95);
  box-shadow: var(--focus-ring);
}

select:disabled,
input[type='search']:disabled,
input[type='text']:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Toolbar */

.toolbar-group {
  display: inline-flex;
  flex-direction: column;
  gap: 0.12rem;
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* Misc */

.panel-footnote {
  font-size: 0.72rem;
  color: var(--text-soft);
  margin-top: 0.45rem;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
}

/* Confidence badge colors */

.confidence-high {
  color: var(--success-soft);
}

.confidence-medium {
  color: var(--warning-soft);
}

.confidence-low {
  color: var(--text-soft);
}

/* Mobile layout adjustments */

@media (max-width: 960px) {
  .metrics-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .top-nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }

  .nav-links {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .page-wrapper {
    padding: 1.1rem 1.1rem 2.1rem;
  }

  .status-banner {
    padding-inline: 0.75rem;
  }

  thead {
    display: none;
  }

  tbody td {
    display: block;
    padding: 0.3rem 0.4rem;
  }

  tbody tr {
    border-radius: 0.6rem;
    border: 1px solid rgba(51, 65, 85, 0.9);
    overflow: hidden;
    margin-bottom: 0.4rem;
  }

  tbody td[data-title]::before {
    display: block;
    margin-bottom: 0.05rem;
  }

  td.numeric {
    text-align: left;
  }
}

@media (max-width: 540px) {
  .metrics-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel {
    border-radius: 0.9rem;
  }
}

/* Reduced motion */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
 *  SwiftIOC v2 – Micro-interactions & loading polish
 *  (Safe overrides added at the end of the stylesheet)
 * ========================================================== */

/* Softer movement + depth on the main cards */
.metric-card,
.table-card,
.action-card {
  transition:
    transform 0.16s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease;
}

.metric-card:hover,
.table-card:hover,
.action-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.9);
  border-color: rgba(148, 163, 184, 0.9);
}

/* Slight pop on primary links/buttons */
.button-link {
  transition:
    transform 0.12s ease,
    box-shadow 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease;
}

.button-link:hover {
  transform: translateY(-0.5px);
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.9);
}

/* Make the top nav feel more “app-like” */
.top-nav {
  backdrop-filter: blur(20px);
}

/* Tighter, more “dashboardy” preview header */
.preview-panel {
  gap: 0.45rem;
}

/* Keep the live preview table tidy on wide screens */
.preview-table {
  table-layout: auto;
}

.preview-table th:nth-child(2),
.preview-table th:nth-child(3),
.preview-table th:nth-child(4),
.preview-table th:nth-child(5),
.preview-table td:nth-child(2),
.preview-table td:nth-child(3),
.preview-table td:nth-child(4),
.preview-table td:nth-child(5) {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.preview-table td:nth-child(2),
.preview-table td:nth-child(3),
.preview-table th:nth-child(2),
.preview-table th:nth-child(3) {
  max-width: 10.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-indicator {
  justify-content: space-between;
  min-width: 0;
}

.preview-indicator-copy {
  flex-shrink: 0;
}

/* Scrollbar polish for the heavy IOC views */
.preview-table-wrapper,
.table-card {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.6) transparent;
}

.preview-table-wrapper::-webkit-scrollbar,
.table-card::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.preview-table-wrapper::-webkit-scrollbar-track,
.table-card::-webkit-scrollbar-track {
  background: transparent;
}

.preview-table-wrapper::-webkit-scrollbar-thumb,
.table-card::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.6);
  border-radius: 999px;
}

.preview-table-wrapper::-webkit-scrollbar-thumb:hover,
.table-card::-webkit-scrollbar-thumb:hover {
  background: rgba(248, 250, 252, 0.8);
}

/* ============================
 *  IOC preview loading state
 * ========================== */

/* When JS sets data-loading="true" on the preview container,
   we dim the table and overlay a subtle shimmer. */
[data-preview-container][data-loading='true'] .preview-table-wrapper {
  position: relative;
}

[data-preview-container][data-loading='true'] .preview-table-wrapper::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    linear-gradient(
      110deg,
      rgba(15, 23, 42, 0.92) 0%,
      rgba(37, 99, 235, 0.65) 35%,
      rgba(15, 23, 42, 0.92) 70%
    );
  background-size: 200% 100%;
  animation: preview-skeleton 1.2s ease-in-out infinite;
  opacity: 0.45;
}

@keyframes preview-skeleton {
  0% {
    background-position-x: -120%;
  }
  100% {
    background-position-x: 120%;
  }
}

[data-preview-container][data-loading='true'] .preview-table {
  opacity: 0.25;
  filter: blur(0.3px);
}

[data-preview-container][data-loading='true'] .preview-status {
  color: var(--text-soft);
  font-style: italic;
}

/* Make the status banner feel snappier across state changes */
.status-banner {
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.2s ease,
    transform 0.12s ease;
}

.status-banner:hover {
  transform: translateY(-0.5px);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.95);
}
