/* Proprietary — © Intelligent Automation, LLC. All rights reserved. */
/* IntelGRC — Design System v3 / Sovereign Dark — Apple Pro × JP Morgan Chase */

/* ── Design Tokens ─────────────────────────────────────────────── */
:root {
  --color-primary:      #2463EB;
  --color-primary-dark: #1D4ED8;
  --color-primary-light:#3B82F6;
  --color-accent:       #38BDF8;    /* cyan — GRC's signature highlight */
  --color-accent-glow:  rgba(56,189,248,.15);
  --color-surface:      #16161A;    /* neutral zinc */
  --color-surface-2:    #1C1C22;
  --color-surface-3:    #23232B;
  --color-navy:         #0C0C0E;    /* page background */
  --color-text:         #D4D4D8;
  --color-text-muted:   #52525B;
  --color-border:       rgba(255,255,255,.08);
  --color-glass:        rgba(255,255,255,.04);
  --color-glass-hover:  rgba(255,255,255,.07);
  --color-danger:       #EF4444;
  --color-danger-bg:    rgba(239,68,68,.12);
  --color-warning:      #F59E0B;
  --color-warning-bg:   rgba(245,158,11,.12);
  --color-success:      #10B981;
  --color-success-bg:   rgba(16,185,129,.12);
  --color-info:         #3B82F6;
  --color-silver:       #A1A1AA;

  /* Risk heat-map colors */
  --risk-critical: #DC2626;
  --risk-high:     #EA580C;
  --risk-medium:   #CA8A04;
  --risk-low:      #16A34A;
  --risk-minimal:  #0284C7;

  /* Shadows */
  --shadow-glass: 0 1px 0 rgba(255,255,255,.04) inset, 0 2px 8px rgba(0,0,0,.24);
  --shadow-glow:  none;
  --shadow-card:  0 2px 8px rgba(0,0,0,.24);

  /* Radii */
  --radius-sm:   4px;
  --radius-md:   6px;
  --radius-lg:   8px;
  --radius-xl:   10px;

  /* Transitions */
  --transition: 150ms cubic-bezier(.4,0,.2,1);
  --transition-slow: 300ms cubic-bezier(.4,0,.2,1);

  /* Z-index scale */
  --z-dropdown: 100;
  --z-sticky:   200;
  --z-modal:    300;
  --z-toast:    400;
}

/* ── Reset & Base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  background: var(--color-navy);
  color: var(--color-text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Mesh Gradient Background ───────────────────────────────────── */
/* Killed — Sovereign Dark uses a flat neutral background */
.bg-mesh { display: none; }

/* ── Typography ─────────────────────────────────────────────────── */
.font-display { font-family: 'Space Grotesk', 'Inter', sans-serif; }

h1, h2, h3, h4, h5, h6 {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-weight: 600;
  line-height: 1.25;
  color: var(--color-text);
  margin: 0;
}

h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.375rem, 3vw, 1.875rem); }
h3 { font-size: clamp(1.125rem, 2.5vw, 1.375rem); }
h4 { font-size: 1.125rem; }

p { margin: 0; line-height: 1.65; }
a { color: var(--color-accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: #7DD3FC; }

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.card:hover { box-shadow: var(--shadow-card); }

.card-body { padding: 1.5rem; }
.card-header {
  padding: .875rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.card-footer {
  padding: .875rem 1.5rem;
  border-top: 1px solid var(--color-border);
}

/* Stat tiles */
.stat-tile {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}
.stat-tile::before { display: none; }
.stat-tile:hover { box-shadow: none; }

.stat-value { font-size: 2rem; font-weight: 700; font-family: 'Space Grotesk', sans-serif; line-height: 1; }
.stat-label { color: var(--color-text-muted); font-size: .8125rem; margin-top: .25rem; }
.stat-trend { font-size: .75rem; font-weight: 600; }
.stat-trend.up   { color: var(--color-success); }
.stat-trend.down { color: var(--color-danger); }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.5;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  min-height: 40px;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--color-primary-light);
  color: #fff;
}

.btn-accent {
  background: var(--color-accent);
  color: var(--color-navy);
  font-weight: 700;
}
.btn-accent:hover { opacity: .9; color: var(--color-navy); }

.btn-ghost {
  background: var(--color-glass);
  border-color: var(--color-border);
  color: var(--color-text);
}
.btn-ghost:hover { background: var(--color-glass-hover); color: var(--color-text); }

.btn-danger {
  background: var(--color-danger-bg);
  border-color: rgba(239,68,68,.3);
  color: var(--color-danger);
}
.btn-danger:hover { background: var(--color-danger); color: #fff; }

.btn-sm { padding: .3125rem .875rem; font-size: .8125rem; min-height: 32px; }
.btn-lg { padding: .75rem 2rem; font-size: 1rem; min-height: 48px; }

.btn:disabled { opacity: .4; pointer-events: none; }

/* ── Forms ──────────────────────────────────────────────────────── */
.form-label {
  display: block;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: .375rem;
  letter-spacing: .025em;
  text-transform: uppercase;
}

.form-control {
  width: 100%;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  padding: .625rem .875rem;
  font-size: .9375rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  font-family: inherit;
}
.form-control::placeholder { color: var(--color-text-muted); }
.form-control:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(56,189,248,.1);
}
.form-control:invalid:not(:placeholder-shown) { border-color: var(--color-danger); }

select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2352525B' stroke-width='1.5' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2.25rem; }

textarea.form-control { resize: vertical; min-height: 100px; }

.form-group { margin-bottom: 1rem; }
.form-hint { font-size: .75rem; color: var(--color-text-muted); margin-top: .25rem; }
.form-error { font-size: .75rem; color: var(--color-danger); margin-top: .25rem; }

/* ── Badges & Pills ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .125rem .625rem;
  border-radius: var(--radius-sm);
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.badge-primary { background: rgba(36,99,235,.2);  color: #93C5FD; border: 1px solid rgba(147,197,253,.2); }
.badge-success { background: var(--color-success-bg); color: #34D399; border: 1px solid rgba(52,211,153,.2); }
.badge-warning { background: var(--color-warning-bg); color: #FCD34D; border: 1px solid rgba(252,211,77,.2); }
.badge-danger  { background: var(--color-danger-bg);  color: #FCA5A5; border: 1px solid rgba(252,165,165,.2); }
.badge-muted   { background: rgba(82,82,91,.15);       color: var(--color-text-muted); border: 1px solid rgba(82,82,91,.25); }
.badge-accent  { background: rgba(56,189,248,.12);     color: var(--color-accent); border: 1px solid rgba(56,189,248,.25); }

/* ── Tables ─────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--color-border); }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.table th {
  background: rgba(255,255,255,.02);
  padding: .75rem 1rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.table td {
  padding: .875rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.04);
  color: var(--color-text);
  vertical-align: middle;
}
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: rgba(255,255,255,.02); }
.table tbody tr:last-child td { border-bottom: 0; }

/* ── Progress / Completion Bars ─────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: rgba(255,255,255,.08);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar .fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 999px;
  transition: width .6s ease;
}

/* ── Navigation ─────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 260px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  z-index: var(--z-sticky);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform var(--transition-slow);
}

.sidebar-logo {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.sidebar-logo img { height: 32px; }
.sidebar-logo-text { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.125rem; }
.sidebar-logo-text span { color: var(--color-accent); }

.nav-section { padding: 1rem 0 .5rem; }
.nav-section-label {
  padding: 0 1.25rem .375rem;
  font-size: .6875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .625rem 1.25rem;
  margin: .125rem .75rem;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  text-decoration: none;
}
.nav-item:hover { background: var(--color-glass); color: var(--color-text); }
.nav-item.active {
  background: rgba(36,99,235,.12);
  color: var(--color-accent);
  border: 1px solid rgba(56,189,248,.2);
}
.nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item .badge { margin-left: auto; }

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: rgba(22,22,26,0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
}

.page-content {
  margin-left: 260px;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── Risk Heat Map ──────────────────────────────────────────────── */
.risk-matrix { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; }
.risk-cell {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  border: 2px solid transparent;
}
.risk-cell:hover { transform: scale(1.08); z-index: 5; }
.risk-cell.active { border-color: #fff; box-shadow: 0 0 15px rgba(255,255,255,.3); }

.risk-minimal  { background: rgba(2,132,199,.2);  color: #7DD3FC; }
.risk-low      { background: rgba(22,163,74,.2);  color: #86EFAC; }
.risk-medium   { background: rgba(202,138,4,.2);  color: #FDE047; }
.risk-high     { background: rgba(234,88,12,.25); color: #FD8C4A; }
.risk-critical { background: rgba(220,38,38,.3);  color: #FCA5A5; }

/* ── Alerts / Toasts ────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .875rem 1rem;
  border-radius: var(--radius-md);
  font-size: .875rem;
  border: 1px solid;
}
.alert-success { background: var(--color-success-bg); border-color: rgba(16,185,129,.25); color: #34D399; }
.alert-warning { background: var(--color-warning-bg); border-color: rgba(245,158,11,.25); color: #FCD34D; }
.alert-danger  { background: var(--color-danger-bg);  border-color: rgba(239,68,68,.25);  color: #FCA5A5; }
.alert-info    { background: rgba(59,130,246,.1);     border-color: rgba(59,130,246,.25); color: #93C5FD; }

/* ── Modal ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
}

/* ── AI Suggestion Chip ─────────────────────────────────────────── */
.ai-chip {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .25rem .75rem;
  background: rgba(56,189,248,.08);
  border: 1px solid rgba(56,189,248,.2);
  border-radius: var(--radius-md);
  font-size: .75rem;
  font-weight: 600;
  color: var(--color-accent);
  cursor: pointer;
  transition: all var(--transition);
}
.ai-chip:hover { background: rgba(56,189,248,.15); border-color: rgba(56,189,248,.4); }
.ai-chip .sparkle { width: 14px; height: 14px; }

/* ── Skeleton / Loading ─────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,.03) 25%, rgba(255,255,255,.06) 50%, rgba(255,255,255,.03) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Glow Divider ───────────────────────────────────────────────── */
.glow-divider {
  border: 0;
  height: 1px;
  background: var(--color-border);
  margin: 1.5rem 0;
}

/* ── Tooltips ───────────────────────────────────────────────────── */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.85);
  color: #fff;
  font-size: .75rem;
  padding: .3125rem .625rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 999;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ── Mobile ─────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
    z-index: 300;
  }
  .sidebar.open { transform: translateX(0); }
  .page-content { margin-left: 0; }
  .topbar { position: sticky; }

  /* Bottom tab nav on mobile */
  .mobile-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    display: flex;
    z-index: 250;
    padding: .375rem 0 max(.375rem, env(safe-area-inset-bottom));
  }
  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .25rem;
    padding: .5rem;
    font-size: .625rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color var(--transition);
    min-height: 44px;
    justify-content: center;
  }
  .mobile-nav-item.active { color: var(--color-accent); }
  .mobile-nav-item svg { width: 22px; height: 22px; }

  .card-body { padding: 1rem; }
  .page-content { padding-bottom: 80px; }
  .modal { max-height: 95vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; align-self: flex-end; }
}

/* ── Print ──────────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .mobile-nav, .btn, .ai-chip { display: none !important; }
  .page-content { margin-left: 0; }
  body { background: white; color: #000; }
  .card { border: 1px solid #ddd; box-shadow: none; }
}

/* ── HTMX Indicators ────────────────────────────────────────────── */
.htmx-indicator { opacity: 0; transition: opacity 200ms ease; }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator { opacity: 1; }
