/* -------------------------------------------------------------------------
   Ghidra Web UI -- design tokens
   A disassembler workbench, not a marketing page: three panes, hex
   addresses as the real navigational structure, phosphor-amber accent
   borrowed from old diagnostic-terminal displays.
   ---------------------------------------------------------------------- */

:root {
  --bg:          #15181c;
  --surface:     #1c2026;
  --surface-2:   #21262d;
  --border:      #2a2f37;
  --text:        #d8dee6;
  --text-muted:  #7c8592;
  --accent:      #e8a33d;   /* phosphor amber -- addresses, active state */
  --accent-dim:  #8a6b34;
  --teal:        #5fb3a3;   /* secondary -- signatures, secondary labels */
  --ok:          #7fae6f;
  --error:       #d9776f;

  --font-ui:   'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
}

* { box-sizing: border-box; }

/* A class with an explicit `display` (e.g. .auth-gate { display:flex })
   otherwise beats the UA rule for [hidden], leaving "hidden" panes visible. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input {
  font-family: inherit;
  font-size: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* --------------------------------- Auth gate -------------------------- */

.auth-gate {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 30%, rgba(232, 163, 61, 0.06), transparent 60%),
    var(--bg);
}

.auth-card {
  width: 340px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.auth-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 12px;
}

.auth-card h1 {
  font-size: 20px;
  margin: 0 0 8px;
  font-weight: 600;
}

.auth-card p {
  color: var(--text-muted);
  margin: 0 0 20px;
  line-height: 1.5;
}

#auth-form { display: flex; flex-direction: column; gap: 10px; }

.auth-card input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

.auth-card button {
  background: var(--accent);
  color: #1a1305;
  border: none;
  padding: 10px 12px;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
}

.auth-card button:hover { filter: brightness(1.08); }

.auth-error {
  margin-top: 12px;
  color: var(--error);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* --------------------------------- App shell --------------------------- */

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-right: 8px;
}

.brand-mark {
  font-family: var(--font-mono);
  color: var(--accent);
  font-weight: 600;
}

.brand-name {
  font-weight: 600;
  letter-spacing: 0.01em;
}

.upload-control {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.processor-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  width: 260px;
  max-width: 40vw;
}

.processor-input::placeholder { color: var(--text-muted); }

#upload-btn, .ghost-btn {
  background: var(--accent);
  color: #1a1305;
  border: none;
  padding: 8px 14px;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

#upload-btn:hover { filter: brightness(1.08); }

.ghost-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-weight: 500;
}

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

/* --------------------------------- Workbench ---------------------------- */

.workbench {
  flex: 1;
  display: grid;
  grid-template-columns: 240px 300px 1fr;
  min-height: 0;
}

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
}

.code-pane { border-right: none; }

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  width: 110px;
  text-transform: none;
  letter-spacing: normal;
}

.list {
  overflow-y: auto;
  flex: 1;
}

.empty-state {
  padding: 20px 16px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

.empty-state::before {
  content: '> ';
  color: var(--accent);
  font-family: var(--font-mono);
}

/* --------------------------------- Binaries list ------------------------ */

.binary-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.binary-item:hover { background: var(--surface); }
.binary-item.selected { background: var(--surface); box-shadow: inset 2px 0 0 var(--accent); }

.binary-item-name {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
}

.binary-item-status {
  font-family: var(--font-mono);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-ready .status-dot { background: var(--ok); }
.status-analyzing .status-dot, .status-queued .status-dot { background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.status-error .status-dot { background: var(--error); }

.status-ready { color: var(--ok); }
.status-analyzing, .status-queued { color: var(--accent); }
.status-error { color: var(--error); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.binary-item-error {
  margin-top: 6px;
  font-size: 11px;
  color: var(--error);
  font-family: var(--font-mono);
  white-space: pre-wrap;
  word-break: break-word;
}

.binary-item-delete {
  margin-top: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.binary-item-delete:hover { color: var(--error); }

/* --------------------------------- Functions list ------------------------ */

.function-item {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-family: var(--font-mono);
}

.function-item:hover { background: var(--surface); }
.function-item.selected { background: var(--surface); box-shadow: inset 2px 0 0 var(--accent); }

.function-item-addr {
  color: var(--accent);
  font-size: 12px;
}

.function-item-name {
  font-size: 12.5px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --------------------------------- Code pane ------------------------------ */

.code-pane-header { justify-content: flex-start; gap: 20px; }

.code-tabs { display: flex; gap: 4px; }

.code-tab {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

.code-tab.active {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
}

.function-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-view {
  flex: 1;
  overflow: auto;
  font-family: var(--font-mono);
}

.code-view pre {
  margin: 0;
  padding: 16px 20px;
  line-height: 1.6;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

.disasm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.disasm-table tr:hover { background: var(--surface); }

.disasm-addr {
  color: var(--accent);
  padding: 3px 14px 3px 20px;
  white-space: nowrap;
  border-right: 1px solid var(--border);
  user-select: none;
  width: 1%;
}

.disasm-bytes {
  color: var(--text-muted);
  padding: 3px 14px;
  white-space: nowrap;
  border-right: 1px solid var(--border);
  user-select: none;
  width: 1%;
}

.disasm-text {
  padding: 3px 16px;
  white-space: pre;
}

.loading-state {
  padding: 20px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 13px;
}

.loading-state::after {
  content: '';
  display: inline-block;
  width: 8px;
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  0%, 50% { content: '_'; }
  51%, 100% { content: ''; }
}

.error-state {
  padding: 20px;
  color: var(--error);
  font-family: var(--font-mono);
  font-size: 13px;
  white-space: pre-wrap;
}

/* --------------------------------- Responsive ------------------------------ */

@media (max-width: 900px) {
  .workbench {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    overflow-y: auto;
  }
  .pane {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 240px;
  }
  .code-pane { max-height: none; }
  .processor-input { display: none; }
}
