/* SiteGuard 360 - application styles on top of Bootstrap 5.3 */

:root {
  --sg-sidebar: #0f1b2d;
  --sg-sidebar-2: #16263d;
  --sg-sidebar-text: #c3cede;
  --sg-accent: #2563eb;
  --sg-bg: #f4f6fa;
  --sg-line: #e3e8ef;
  --sg-ink: #172033;
  --sg-muted: #5b6678;
  /* Severity: reserved status colours, always shown with an icon and the word. */
  --sg-critical: #b42318;
  --sg-critical-bg: #fde8e7;
  --sg-high: #b54708;
  --sg-high-bg: #fef0e1;
  --sg-medium: #8a6100;
  --sg-medium-bg: #fdf6d8;
  --sg-low: #2f5fa8;
  --sg-low-bg: #e8f0fc;
  --sg-info: #5b6678;
  --sg-info-bg: #eef1f5;
  --sg-sidebar-w: 248px;
}

body.sg-app { background: var(--sg-bg); color: var(--sg-ink); }
.sg-skip { position: absolute; left: 12px; top: 12px; z-index: 2000; background: #fff; padding: 8px 12px; border-radius: 6px; }

/* ---- Sidebar ---------------------------------------------------------- */
.sg-sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sg-sidebar-w); z-index: 1030;
  background: var(--sg-sidebar); color: var(--sg-sidebar-text); padding: 20px 16px; overflow-y: auto;
  transition: transform .2s ease;
}
.sg-brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 1.1rem; text-decoration: none; margin: 0 4px 22px; }
.sg-brand:hover { color: #fff; }
.sg-brand-dark { color: var(--sg-ink); }
.sg-brand-dark:hover { color: var(--sg-ink); }
.sg-brand-mark { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--sg-accent); color: #fff; font-size: 1.05rem; }
.sg-btn-scan { background: var(--sg-accent); color: #fff; font-weight: 600; }
.sg-btn-scan:hover, .sg-btn-scan:focus-visible { background: #1d4ed8; color: #fff; }
.sg-nav { display: flex; flex-direction: column; gap: 2px; }
.sg-nav-heading { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #7d8ba1; margin: 18px 10px 6px; }
.sg-nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--sg-sidebar-text); text-decoration: none; font-size: .92rem; }
.sg-nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sg-nav-link:hover { background: var(--sg-sidebar-2); color: #fff; }
.sg-nav-link.active { background: rgba(37, 99, 235, .22); color: #fff; font-weight: 600; }
.sg-nav-link.disabled { opacity: .45; cursor: default; }
.sg-nav-link.disabled:hover { background: none; color: var(--sg-sidebar-text); }

/* ---- Main ------------------------------------------------------------- */
.sg-main { margin-left: var(--sg-sidebar-w); min-height: 100vh; }
.sg-topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 24px; background: #fff; border-bottom: 1px solid var(--sg-line); }
.sg-topbar-title { font-weight: 600; color: var(--sg-muted); font-size: .95rem; }
.sg-content { padding: 24px; max-width: 1480px; }

@media (max-width: 991.98px) {
  .sg-sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  .sg-sidebar.show { transform: none; }
  .sg-main { margin-left: 0; }
  .sg-topbar { padding: 0 12px; }
  .sg-content { padding: 16px; }
}

.card { border-color: var(--sg-line); border-radius: 12px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.card-header { background: #fff; border-bottom-color: var(--sg-line); padding: 12px 16px; border-radius: 12px 12px 0 0 !important; }
.table > :not(caption) > * > * { padding-top: .6rem; padding-bottom: .6rem; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--sg-muted); font-weight: 600; background: #fafbfd; white-space: nowrap; }
.sg-table-compact td { padding: .35rem .25rem !important; }
.breadcrumb { font-size: .85rem; margin-bottom: 12px; }
.sg-empty { text-align: center; padding: 40px 16px; color: var(--sg-muted); }
.sg-dl dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--sg-muted); font-weight: 600; margin-top: 10px; }
.sg-dl dt:first-child { margin-top: 0; }
.sg-dl dd { margin-bottom: 0; }
.sg-prewrap { white-space: pre-wrap; }
.sg-break { word-break: break-all; }
.sg-url { max-width: 460px; }
.sg-url a { word-break: break-all; }
.sg-clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-where { max-width: 340px; }

/* ---- Dashboard -------------------------------------------------------- */
.sg-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.sg-stat { display: flex; gap: 14px; align-items: center; padding: 18px; background: #fff; border: 1px solid var(--sg-line); border-radius: 12px; color: inherit; text-decoration: none; }
a.sg-stat:hover { border-color: #b9c6db; }
.sg-stat-icon { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; background: #eaf1fe; color: var(--sg-accent); font-size: 1.25rem; flex: none; }
.sg-stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.sg-stat-label { color: var(--sg-muted); font-size: .88rem; }
.sg-stat-sub { color: var(--sg-muted); font-size: .76rem; }
.sg-chart-box { position: relative; height: 180px; }
.sg-issue-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.sg-issue { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; padding: 12px; border: 1px solid var(--sg-line); border-radius: 10px; color: inherit; text-decoration: none; }
.sg-issue:hover { border-color: #b9c6db; background: #fafbfd; }
.sg-issue i { grid-row: span 2; font-size: 1.2rem; color: var(--sg-muted); align-self: center; }
.sg-issue-n { font-weight: 700; font-size: 1.15rem; line-height: 1.1; }
.sg-issue-label { font-size: .8rem; color: var(--sg-muted); }

/* ---- Severity, certainty, status ------------------------------------- */
.sg-sev { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.sg-sev-critical { color: var(--sg-critical); background: var(--sg-critical-bg); }
.sg-sev-high { color: var(--sg-high); background: var(--sg-high-bg); }
.sg-sev-medium { color: var(--sg-medium); background: var(--sg-medium-bg); }
.sg-sev-low { color: var(--sg-low); background: var(--sg-low-bg); }
.sg-sev-info { color: var(--sg-info); background: var(--sg-info-bg); }
.sg-count { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.sg-cert { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; white-space: nowrap; }
.sg-cert-verified { color: #146c43; }
.sg-cert-suspected { color: #8a6100; }
.sg-status { display: inline-block; font-size: .78rem; padding: 2px 8px; border-radius: 6px; background: #eef1f5; color: var(--sg-ink); white-space: nowrap; }
.sg-status-new { background: #e8f0fc; color: #1e4a8a; }
.sg-status-open { background: #fef0e1; color: #8a3b00; }
.sg-status-investigating { background: #f1e9fd; color: #5b2a9c; }
.sg-status-resolved { background: #e6f4ea; color: #146c43; }
.sg-status-false_positive, .sg-status-accepted_risk { background: #eef1f5; color: var(--sg-muted); }
.sg-http { font-family: var(--bs-font-monospace); font-size: .82rem; font-weight: 600; padding: 1px 6px; border-radius: 5px; }
.sg-http-success { color: #146c43; background: #e6f4ea; }
.sg-http-info { color: #1e4a8a; background: #e8f0fc; }
.sg-http-warning { color: #8a3b00; background: #fef0e1; }
.sg-http-danger { color: var(--sg-critical); background: var(--sg-critical-bg); }

/* ---- Scan summary ------------------------------------------------------ */
.sg-summary { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 991.98px) { .sg-summary { grid-template-columns: 1fr; } }
.sg-summary-sev { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.sg-sev-tile { display: flex; flex-direction: column; padding: 14px; border-radius: 12px; text-decoration: none; border: 1px solid transparent; }
.sg-sev-tile:hover { border-color: currentColor; }
.sg-sev-tile-n { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.sg-sev-tile-l { font-size: .8rem; font-weight: 600; }
.sg-summary-cov { background: #fff; border: 1px solid var(--sg-line); border-radius: 12px; padding: 14px 16px; font-size: .9rem; display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.sg-cov-n { font-weight: 700; }
@media (max-width: 575.98px) { .sg-summary-sev { grid-template-columns: repeat(3, 1fr); } }

/* ---- New scan ---------------------------------------------------------- */
.sg-hero-scan { background: #fff; border: 1px solid var(--sg-line); border-radius: 16px; padding: 32px; }
@media (max-width: 575.98px) { .sg-hero-scan { padding: 20px; } .sg-hero-scan .input-group-lg > .btn { padding-left: 12px !important; padding-right: 12px !important; } }
.sg-mode { border: 1px solid var(--sg-line); border-radius: 12px; padding: 14px; height: 100%; }
.sg-mode-active { border-color: var(--sg-accent); background: #f5f8ff; }
.sg-mode[aria-disabled="true"] { opacity: .7; }
.sg-advanced { border-top: 1px solid var(--sg-line); padding-top: 14px; }
.sg-advanced summary { cursor: pointer; font-weight: 600; color: var(--sg-accent); }

/* ---- Authorisation ------------------------------------------------------ */
.sg-auth-option { border: 1px solid var(--sg-line); border-radius: 10px; padding: 14px; margin-bottom: 12px; background: #fff; }
.sg-token { max-width: 640px; }

/* ---- Live progress ------------------------------------------------------ */
.sg-progress { height: 10px; }
.sg-live-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.sg-live-count { border: 1px solid var(--sg-line); border-radius: 10px; padding: 12px; }
.sg-live-n { font-size: 1.4rem; font-weight: 700; line-height: 1.1; }
.sg-live-label { font-size: .8rem; color: var(--sg-muted); }
.sg-log { max-height: 420px; overflow-y: auto; font-family: var(--bs-font-monospace); font-size: .8rem; padding: 10px 14px; background: #0f1b2d; color: #d5deea; border-radius: 0 0 12px 12px; }
.sg-log-static { max-height: 70vh; border-radius: 12px; }
.sg-log-line { padding: 1px 0; white-space: pre-wrap; word-break: break-word; }
.sg-log-time { color: #7d8ba1; margin-right: 10px; }
.sg-log-warning { color: #f6c760; }
.sg-log-error { color: #ff8a80; }

/* ---- Evidence ---------------------------------------------------------- */
.sg-evidence td { font-size: .82rem; vertical-align: top; }
.sg-code { background: #0f1b2d; color: #e6edf5; padding: 12px; border-radius: 8px; font-size: .8rem; white-space: pre-wrap; word-break: break-all; }

/* ---- Sign-in ------------------------------------------------------------ */
body.sg-guest { background: linear-gradient(160deg, #0f1b2d 0%, #1b3155 100%); min-height: 100vh; }
.sg-guest-main { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.sg-guest-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 32px; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); }

/* ---- Findings tables become stacked cards on phones ---------------------- */
@media (max-width: 767.98px) {
  .sg-findings thead { display: none; }
  .sg-findings, .sg-findings tbody, .sg-findings tr, .sg-findings td { display: block; width: 100%; }
  .sg-findings tr { padding: 12px 14px; border-bottom: 1px solid var(--sg-line); }
  .sg-findings td { border: 0 !important; padding: 2px 0 !important; max-width: none; }
  .sg-findings td:first-child, .sg-findings td:nth-last-child(-n+2) { display: inline-block; width: auto; margin-right: 8px; }
  .sg-findings .sg-where { max-width: 100%; }
}
.sg-num-inline { width: 64px; padding: 0 6px; height: 24px; }

/* Report branding: logo preview */
.sg-logo-preview { max-height: 80px; }

/* E-mail: preview frame, error line */
.sg-email-preview { width: 100%; height: 760px; border: 0; display: block; background: #f3f4f6; }
.sg-err { max-width: 520px; }
