/* =============================================
   AppSite Cybersecurity — Design System
   Appsations Inc.
   ============================================= */

:root {
  --background:          hsl(222, 22%, 4%);
  --foreground:          hsl(210, 20%, 92%);

  --card:                hsl(222, 20%, 7%);
  --card-foreground:     hsl(210, 20%, 92%);

  --primary:             hsl(155, 66%, 48%);
  --primary-foreground:  hsl(222, 26%, 10%);
  --primary-10:          hsla(155, 66%, 48%, 0.14);
  --primary-3:           hsla(155, 66%, 48%, 0.06);

  --secondary:           hsl(192, 85%, 55%);
  --secondary-foreground:hsl(222, 26%, 10%);

  --muted:               hsl(222, 18%, 11%);
  --muted-foreground:    hsl(218, 12%, 60%);

  --accent:              hsl(222, 16%, 13%);
  --accent-foreground:   hsl(210, 20%, 92%);

  --destructive:         hsl(0, 84%, 60%);
  --destructive-10:      hsla(0, 84%, 60%, 0.12);
  --warning:             hsl(42, 92%, 56%);
  --warning-10:          hsla(42, 92%, 56%, 0.12);
  --success:             hsl(155, 66%, 48%);
  --success-10:          hsla(155, 66%, 48%, 0.12);
  --info:                hsl(192, 85%, 55%);
  --info-10:             hsla(192, 85%, 55%, 0.12);

  --severity-critical:   hsl(0, 84%, 60%);
  --severity-high:       hsl(22, 92%, 58%);
  --severity-medium:     hsl(42, 92%, 56%);
  --severity-low:        hsl(192, 85%, 55%);
  --severity-info:       hsl(218, 12%, 60%);

  --border:              hsl(222, 14%, 18%);
  --border-50:           hsla(222, 14%, 20%, 0.55);
  --ring:                hsl(155, 66%, 48%);

  --radius:              10px;
  --surface:             hsl(222, 18%, 8%);

  --shadow-sm:
    0 0 0 1px hsla(210, 20%, 92%, 0.04),
    0 8px 20px hsla(222, 40%, 2%, 0.35);
  --shadow-md:
    0 0 0 1px hsla(210, 20%, 92%, 0.05),
    0 18px 44px hsla(222, 40%, 2%, 0.55);

  --sidebar-bg:          hsla(222, 20%, 7%, 0.92);
  --sidebar-foreground:  hsl(218, 12%, 68%);
  --sidebar-width:       240px;
  --header-height:       56px;

  font-size: 14px;
}

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

html, body { height: 100%; overflow: hidden; }

body {
  background:
    radial-gradient(1200px 600px at 0% -20%, hsla(155, 66%, 48%, 0.12), transparent 52%),
    radial-gradient(1100px 540px at 100% -10%, hsla(192, 85%, 55%, 0.08), transparent 50%),
    var(--background);
  color: var(--foreground);
  font-family: "Geist Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; background: none; border: none; outline: none; }

/* ---- Layout ---- */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100%;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
}

.sidebar-header {
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--foreground);
  letter-spacing: -0.01em;
}

.sidebar-logo .logo-icon {
  width: 28px;
  height: 28px;
  background: var(--primary-10);
  border: 1px solid var(--primary);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--primary);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.sidebar-nav a,
.nav-section-label {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--sidebar-foreground);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.nav-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  padding: 0.75rem 0.75rem 0.25rem;
  pointer-events: none;
}

.sidebar-nav a:hover { background: var(--accent); color: var(--foreground); }
.sidebar-nav a.active { background: var(--primary-10); color: var(--primary); }
.sidebar-nav a .nav-icon { font-size: 15px; opacity: 0.85; flex-shrink: 0; }

.sidebar-nav a .badge {
  margin-left: auto;
  padding: 1px 6px;
  border-radius: 100px;
  font-size: 0.6875rem;
  font-weight: 600;
  background: var(--destructive);
  color: #fff;
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}

/* ---- Main content ---- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.topbar {
  height: var(--header-height);
  min-height: var(--header-height);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  background: var(--surface);
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--foreground);
  flex: 1;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

/* ---- Cards ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border-50);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--foreground);
  flex: 1;
}

.card-body { padding: 1.25rem; }

/* ---- Stat cards ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.125rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.stat-card-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
}

.stat-card-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--foreground);
}

.stat-card-sub { font-size: 0.75rem; color: var(--muted-foreground); }

.stat-card.critical { border-left: 3px solid var(--severity-critical); }
.stat-card.high     { border-left: 3px solid var(--severity-high); }
.stat-card.medium   { border-left: 3px solid var(--severity-medium); }
.stat-card.low      { border-left: 3px solid var(--severity-low); }
.stat-card.ok       { border-left: 3px solid var(--success); }

/* ---- Severity badges ---- */
.badge-severity {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-severity.critical { background: var(--destructive-10);  color: var(--destructive); }
.badge-severity.high     { background: hsla(22,92%,58%,.12);    color: hsl(22,92%,58%);    }
.badge-severity.medium   { background: var(--warning-10);       color: var(--warning);     }
.badge-severity.low      { background: var(--info-10);          color: var(--info);        }
.badge-severity.info     { background: var(--muted);            color: var(--muted-foreground); }

/* ---- Status badges ---- */
.badge-status {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.6875rem;
  font-weight: 600;
}

.badge-status.open        { background: var(--destructive-10); color: var(--destructive); }
.badge-status.in-progress { background: var(--warning-10);     color: var(--warning);     }
.badge-status.patched     { background: var(--success-10);     color: var(--success);     }
.badge-status.wont-fix    { background: var(--muted);          color: var(--muted-foreground); }
.badge-status.pending     { background: var(--info-10);        color: var(--info);        }

/* ---- Table ---- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

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

thead th {
  padding: 0.625rem 1rem;
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

thead th:hover { color: var(--foreground); }

tbody tr {
  border-bottom: 1px solid var(--border-50);
  transition: background 0.1s;
  cursor: pointer;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--accent); }

tbody td {
  padding: 0.75rem 1rem;
  color: var(--foreground);
  vertical-align: middle;
}

td.muted { color: var(--muted-foreground); }
td.mono  { font-family: "Geist Mono", "Cascadia Code", monospace; font-size: 0.75rem; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.8125rem;
  font-weight: 600;
  transition: opacity 0.15s, background 0.15s;
}

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

.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { opacity: 0.88; }

.btn-destructive { background: var(--destructive); color: #fff; }
.btn-destructive:hover { opacity: 0.88; }

.btn-surface {
  background: var(--surface);
  color: var(--foreground);
  border: 1px solid var(--border);
}
.btn-surface:hover { background: var(--accent); }

.btn-ghost { color: var(--muted-foreground); }
.btn-ghost:hover { background: var(--accent); color: var(--foreground); }

.btn-sm { padding: 0.3rem 0.625rem; font-size: 0.75rem; }
.btn-icon { padding: 0.5rem; }

/* ---- Form controls ---- */
.form-group { display: flex; flex-direction: column; gap: 0.375rem; }
.form-label { font-size: 0.75rem; font-weight: 600; color: var(--muted-foreground); }

.input, .select, .textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--foreground);
  transition: border-color 0.15s;
  width: 100%;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px var(--primary-3);
}

.select { appearance: none; cursor: pointer; }

/* ---- Search bar ---- */
.search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.375rem 0.75rem;
  min-width: 220px;
}

.search-bar input {
  flex: 1;
  font-size: 0.8125rem;
  color: var(--foreground);
}

.search-bar input::placeholder { color: var(--muted-foreground); }

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 1rem;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-lg { max-width: 760px; }

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.modal-title { font-size: 1rem; font-weight: 600; flex: 1; }
.modal-body { padding: 1.25rem; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 1rem; }
.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ---- Toast ---- */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 999;
  pointer-events: none;
}

.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.875rem;
  box-shadow: var(--shadow-md);
  pointer-events: all;
  animation: toast-in 0.25s ease;
  max-width: 360px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--destructive); }
.toast.info    { border-left: 3px solid var(--info); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Misc utilities ---- */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 0.5rem; }
.gap-3  { gap: 0.75rem; }
.gap-4  { gap: 1rem; }
.mb-4   { margin-bottom: 1rem; }
.mb-6   { margin-bottom: 1.5rem; }
.mt-4   { margin-top: 1rem; }
.flex-1 { flex: 1; }
.text-sm   { font-size: 0.875rem; }
.text-xs   { font-size: 0.75rem; }
.text-muted { color: var(--muted-foreground); }
.font-semibold { font-weight: 600; }
.font-mono { font-family: "Geist Mono", monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-foreground); }

/* ---- Skeleton ---- */
.skeleton {
  background: var(--muted);
  border-radius: 4px;
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}

@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ---- Progress ring ---- */
.risk-ring-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.risk-score-label { font-size: 0.75rem; color: var(--muted-foreground); font-weight: 600; }

/* ---- Filter chips ---- */
.filter-chips { display: flex; gap: 0.375rem; flex-wrap: wrap; }

.chip {
  padding: 0.25rem 0.75rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--muted-foreground);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover { border-color: var(--ring); color: var(--foreground); }
.chip.active { background: var(--primary-10); border-color: var(--primary); color: var(--primary); }

/* ---- Tenant selector ---- */
.tenant-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s;
}

.tenant-pill:hover { border-color: var(--ring); }

.tenant-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

/* ---- Empty state ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  gap: 0.75rem;
}

.empty-state-icon { font-size: 3rem; opacity: 0.3; }
.empty-state-title { font-size: 1rem; font-weight: 600; color: var(--foreground); }
.empty-state-sub { font-size: 0.875rem; color: var(--muted-foreground); max-width: 320px; }

/* ---- Loading overlay ---- */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--background);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: opacity 0.3s;
}

#loading-overlay.hidden { opacity: 0; pointer-events: none; }

.spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  animation: spin 0.65s linear infinite;
}

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

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
