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

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  background: #1e1e1e;
  color: #cccccc;
  overflow: hidden;
  height: 100vh;
}

/* ── App shell ────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Top bar ──────────────────────────────────────────────────── */
#topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #252526;
  border-bottom: 1px solid #111;
  padding: 0 16px;
  height: 40px;
  flex-shrink: 0;
  user-select: none;
}

.logo {
  font-weight: 700;
  font-size: 14px;
  color: #ffffff;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.search-wrap {
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
  background: #3c3c3c;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 0 8px;
  gap: 6px;
  transition: border-color 0.15s;
}
.search-wrap:focus-within { border-color: #007acc; }
.search-icon { color: #aaa; font-size: 16px; }
#search-bar {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #cccccc;
  font-size: 13px;
  padding: 4px 0;
}
.search-hint {
  background: #555;
  color: #aaa;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: monospace;
}

/* TON-1889: PII masking badge inside the search box. Shows the masked form of
   the query when sensitive info (email/phone/account) is detected. */
.search-mask-note {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 220px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  background: #4a3a12;
  color: #ffd479;
  border: 1px solid #7a5e1d;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.search-mask-note[hidden] { display: none; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.btn-primary {
  background: #007acc;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-primary:hover { background: #005fa3; }
.btn-primary:active { background: #004a82; }

.scan-badge {
  font-size: 18px;
  color: #555;
  transition: color 0.3s;
}
.scan-badge.scanning { color: #f5a623; animation: pulse 0.8s infinite alternate; }
.scan-badge.clean    { color: #4caf50; }
.scan-badge.threat   { color: #f44336; }

@keyframes pulse { from { opacity: 1; } to { opacity: 0.4; } }

/* ── Workspace (three-panel) ─────────────────────────────────── */
#workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
#sidebar {
  width: 180px;
  flex-shrink: 0;
  background: #252526;
  border-right: 1px solid #111;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  color: #888;
  letter-spacing: 0.08em;
  padding: 0 12px 4px;
  text-transform: uppercase;
}

#nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.1s, border-color 0.1s;
}
.nav-item:hover   { background: #2a2d2e; }
.nav-item.active  { background: #37373d; border-left-color: #007acc; color: #fff; }
.nav-icon { font-size: 14px; }

/* Sidebar stats */
#sidebar-stats { padding: 4px 12px; }
.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 12px;
  color: #aaa;
}
.stat-row span:last-child { font-weight: 600; color: #ccc; }
.stat-row.threat span:last-child { color: #f44336; }

/* ── File explorer ───────────────────────────────────────────── */
#explorer {
  width: 240px;
  flex-shrink: 0;
  border-right: 1px solid #111;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #1e1e1e;
}

/* ── Panel header (shared) ───────────────────────────────────── */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: #252526;
  border-bottom: 1px solid #111;
  font-size: 11px;
  font-weight: 600;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.view-toggles { display: flex; gap: 4px; }
.view-btn {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 14px;
  padding: 1px 4px;
  border-radius: 3px;
  line-height: 1;
}
.view-btn:hover  { color: #ccc; background: #333; }
.view-btn.active { color: #007acc; }

/* ── TON-1891: File Vault integrated into the explorer ───────────── */
#vault-panel {
  flex-shrink: 0;
  border-top: 1px solid #111;
  background: #1b1b1b;
  display: flex;
  flex-direction: column;
  max-height: 45%;
  overflow: hidden;
}
.vault-header { cursor: pointer; }
#vault-body {
  padding: 8px;
  overflow-y: auto;
}
#vault-body.vault-collapsed { display: none; }
.vault-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}
.vault-btn {
  background: #0e639c;
  color: #fff;
  border: none;
  border-radius: 3px;
  padding: 5px 8px;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
}
.vault-btn:hover { background: #1177bb; }

/* File container */
.file-container {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

/* Grid view */
.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 6px;
  align-content: start;
}

/* List view */
.list-view {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px;
}

/* File card — grid */
.file-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px 7px;
  border-radius: 5px;
  cursor: pointer;
  background: #2d2d30;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
  user-select: none;
  text-align: center;
  position: relative;
  word-break: break-all;
}
.file-card:hover  { background: #37373d; border-color: #444; }
.file-card.active { background: #094771; border-color: #007acc; }
.file-card.threat { border-color: #f44336 !important; }
.file-card.clean  { border-color: #4caf50; }

.file-icon { font-size: 24px; line-height: 1; }
.file-name { font-size: 11px; color: #ccc; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
.threat-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #f44336;
  box-shadow: 0 0 4px #f44336aa;
  display: none;
}
.file-card.threat .threat-dot { display: block; }

/* File card — list */
.file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
  border-left: 2px solid transparent;
  transition: background 0.1s;
}
.file-row:hover  { background: #2a2d2e; }
.file-row.active { background: #094771; border-left-color: #007acc; }
.file-row.threat { border-left-color: #f44336; }
.file-row.clean  { border-left-color: #4caf50; }
.file-row .file-icon { font-size: 16px; }
.file-row .file-name { flex: 1; font-size: 12px; }
.file-row .sev-chip { font-size: 9px; font-weight: 700; border-radius: 3px; padding: 1px 4px; }

/* ── Right panel ─────────────────────────────────────────────── */
#right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Editor pane */
#editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-bottom: 1px solid #111;
}

#monaco-container {
  flex: 1;
  display: none; /* shown once Monaco loads a file */
}

#editor-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #555;
  gap: 10px;
}
.placeholder-icon { font-size: 40px; }

.btn-sm {
  background: #3c3c3c;
  border: 1px solid #555;
  color: #ccc;
  border-radius: 3px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.1s;
}
.btn-sm:hover:not([disabled]) { background: #4f4f4f; }
.btn-sm[disabled] { opacity: 0.4; cursor: default; }

#editor-filename {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}

/* Scan results pane */
#scan-pane {
  height: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #1e1e1e;
}

#scan-results {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  font-size: 12px;
}

.no-results { color: #555; text-align: center; margin-top: 20px; }

/* Finding row */
.finding-group { margin-bottom: 10px; }
.finding-filepath {
  font-size: 11px;
  color: #888;
  padding: 2px 0 4px;
  border-bottom: 1px solid #2a2a2a;
  margin-bottom: 4px;
}
.finding-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 4px;
  border-radius: 3px;
  transition: background 0.1s;
}
.finding-row:hover { background: #2a2d2e; }

.sev-badge {
  font-size: 9px;
  font-weight: 700;
  border-radius: 3px;
  padding: 1px 5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.sev-HIGH   { background: #f4433622; color: #f44336; border: 1px solid #f44336; }
.sev-MEDIUM { background: #f5a62322; color: #f5a623; border: 1px solid #f5a623; }
.sev-LOW    { background: #ffc10722; color: #ffc107; border: 1px solid #ffc107; }
.sev-INFO   { background: #2196f322; color: #2196f3; border: 1px solid #2196f3; }

.finding-label { flex: 1; color: #ccc; }
.finding-line  { color: #666; font-size: 11px; white-space: nowrap; }
.finding-snip  {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 11px;
  color: #888;
  padding: 2px 4px 2px 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.entropy-warning {
  font-size: 11px;
  color: #f5a623;
  padding: 2px 4px 2px 12px;
  font-style: italic;
}

/* ── Status bar ──────────────────────────────────────────────── */
#statusbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #007acc;
  color: #fff;
  padding: 0 12px;
  height: 22px;
  font-size: 11px;
  flex-shrink: 0;
}

/* ── Scrollbar style ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #424242; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ── Search highlight ────────────────────────────────────────── */
.file-card.hidden, .file-row.hidden { display: none; }
