/* ── Reset & Variables ────────────────────────────────────── */

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

:root {
  --bg: #0f0f11;
  --surface: #18181c;
  --surface-hi: #1e1e24;
  --border: #2a2a30;
  --border-hi: #3e3e48;
  --text: #e8e8f0;
  --muted: #7a7a8c;
  --accent: #3b82f6;
  --accent-hi: #60a5fa;
  --smb: #22c55e;
  --smb-bg: rgba(34, 197, 94, 0.12);
  --enterprise: #a855f7;
  --enterprise-bg: rgba(168, 85, 247, 0.12);
  --indeterminate: #f59e0b;
  --indeterminate-bg: rgba(245, 158, 11, 0.12);
  --unknown: #6b7280;
  --unknown-bg: rgba(107, 114, 128, 0.12);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.12);
  --danger: #ef4444;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
  --radius: 8px;
  --radius-sm: 4px;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Layout ──────────────────────────────────────────────── */

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

header {
  margin-bottom: 2rem;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h1 .accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-hi));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--muted);
  margin-top: 0.25rem;
  font-size: 0.95rem;
}

footer {
  margin-top: 3rem;
  text-align: center;
  font-size: 0.85rem;
}

/* ── Buttons ─────────────────────────────────────────────── */

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn-primary:hover {
  background: var(--accent-hi);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

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

.btn-ghost-sm {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}

.btn-ghost-sm:hover {
  text-decoration: underline;
}

.full-width {
  width: 100%;
}

/* ── Tabs ────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.6rem 1rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel {
  animation: fadeIn 0.2s ease;
}

/* ── Form ────────────────────────────────────────────────── */

.input-row {
  display: flex;
  gap: 0.5rem;
}

#input-url {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

#input-url:focus {
  border-color: var(--accent);
}

#input-url::placeholder {
  color: var(--muted);
}

/* ── Result Card ─────────────────────────────────────────── */

.result-card {
  margin-top: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  animation: fadeIn 0.3s ease;
}

.result-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.bucket-icon {
  font-size: 1.75rem;
  line-height: 1;
}

.bucket-info {
  flex: 1;
}

.bucket-label {
  font-size: 1.1rem;
  font-weight: 600;
}

.bucket-desc {
  color: var(--muted);
  font-size: 0.85rem;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-mono);
}

.pill-smb {
  background: var(--smb-bg);
  color: var(--smb);
}

.pill-enterprise {
  background: var(--enterprise-bg);
  color: var(--enterprise);
}

.pill-indeterminate {
  background: var(--indeterminate-bg);
  color: var(--indeterminate);
}

.pill-unknown {
  background: var(--unknown-bg);
  color: var(--unknown);
}

.pill-error {
  background: var(--error-bg);
  color: var(--error);
}

.confidence-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.confidence-high {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.confidence-medium {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.confidence-low {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

.confidence-none {
  background: rgba(107, 114, 128, 0.15);
  color: #9ca3af;
}

/* ── Tech Stack ──────────────────────────────────────────── */

.tech-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.tech-tag {
  background: var(--surface-hi);
  border: 1px solid var(--border);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text);
}

/* ── Section Labels ──────────────────────────────────────── */

.section-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

/* ── Webappanalyzer Details ──────────────────────────────── */

.wap-section {
  margin-top: 0.75rem;
}

.wap-list {
  margin-top: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
}

.wap-item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.3rem 0;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.wap-item:last-child {
  border-bottom: none;
}

.wap-name {
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}

.wap-cats {
  flex: 1;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wap-via {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* ── About Page Section ──────────────────────────────────── */

.about-section {
  margin-top: 1rem;
}

.about-card {
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-top: 0.5rem;
}

.about-path {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.about-snippet {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
  max-height: 4.5em;
  overflow: hidden;
  text-overflow: ellipsis;
}

.about-signals {
  margin-top: 0.35rem;
  font-size: 0.8rem;
}

/* ── Signals ─────────────────────────────────────────────── */

.signals-section {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.signals-toggle {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.signals-toggle:hover {
  text-decoration: underline;
}

.signals-toggle .arrow {
  display: inline-block;
  transition: transform 0.2s;
  font-size: 0.75rem;
}

.signals-toggle.open .arrow {
  transform: rotate(90deg);
}

.signals-list {
  margin-top: 0.75rem;
}

.signal-group-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0.75rem 0 0.4rem;
}

.signal-group-title:first-child {
  margin-top: 0;
}

.signal-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.35rem 0;
  font-size: 0.85rem;
}

.signal-direction {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-sm);
}

.signal-direction.smb {
  background: var(--smb-bg);
  color: var(--smb);
}

.signal-direction.enterprise {
  background: var(--enterprise-bg);
  color: var(--enterprise);
}

.signal-name {
  font-weight: 500;
  color: var(--text);
}

.signal-desc {
  color: var(--muted);
  font-size: 0.8rem;
  grid-column: 3 / -1;
  padding-left: 0;
}

.signal-pts {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  text-align: right;
}

/* ── Upload Zone ─────────────────────────────────────────── */

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.04);
}

.upload-icon {
  font-size: 2rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.file-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.batch-options {
  margin-top: 0.75rem;
}

.batch-options label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.batch-options input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  outline: none;
  width: 140px;
}

.batch-options input:focus {
  border-color: var(--accent);
}

#btn-batch {
  margin-top: 0.75rem;
}

/* ── Progress ────────────────────────────────────────────── */

.progress-container {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--surface);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-label {
  font-size: 0.85rem;
  font-family: var(--font-mono);
  color: var(--muted);
  min-width: 60px;
  text-align: right;
}

/* ── Batch Results ───────────────────────────────────────── */

.batch-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  text-align: center;
}

.summary-count {
  font-size: 1.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.summary-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.batch-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.results-table-wrapper {
  overflow-x: auto;
  margin-top: 0.75rem;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.results-table th {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.results-table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.results-table tr:hover td {
  background: var(--surface-hi);
}

/* ── Dots ────────────────────────────────────────────────── */

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.3rem;
}

.dot.smb {
  background: var(--smb);
}

.dot.enterprise {
  background: var(--enterprise);
}

.dot.indeterminate {
  background: var(--indeterminate);
}

.dot.unknown {
  background: var(--unknown);
}

.dot.error {
  background: var(--error);
}

/* ── Modal ───────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.15s ease;
  padding: 1rem;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.5rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-header .btn-ghost {
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.2rem 0.5rem;
  border: none;
}

.modal-body h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.25rem 0 0.5rem;
  color: var(--accent);
}

.modal-body h3:first-child {
  margin-top: 0;
}

.modal-body h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 1rem 0 0.35rem;
}

.modal-body p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

/* ── Pipeline ────────────────────────────────────────────── */

.pipeline {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  overflow-x: auto;
  padding: 0.75rem 0;
  margin-bottom: 0.5rem;
}

.pipeline-step {
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.6rem;
  text-align: center;
  min-width: 80px;
  flex-shrink: 0;
}

.step-number {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.15rem;
}

.step-label {
  font-size: 0.75rem;
  font-weight: 600;
}

.step-desc {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.pipeline-arrow {
  color: var(--muted);
  font-size: 1rem;
  padding-top: 0.75rem;
  flex-shrink: 0;
}

/* ── Signal Details (modal <details> expandable sections) ── */

.signal-details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 0.75rem;
  overflow: hidden;
}

.signal-details > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  background: var(--surface-hi);
  user-select: none;
  gap: 0.5rem;
}

.signal-details > summary::-webkit-details-marker {
  display: none;
}

.signal-details > summary::before {
  content: "▶";
  font-size: 0.6rem;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform 0.15s;
}

.signal-details[open] > summary::before {
  transform: rotate(90deg);
}

.signal-details > summary:hover {
  background: var(--border);
}

.detail-count {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 0.1rem 0.5rem;
  margin-left: auto;
  white-space: nowrap;
}

.signal-details > p {
  padding: 0.5rem 0.75rem 0;
}

/* ── Signal Table (point-annotated rows) ─────────────────── */

.signal-details .info-table,
.signal-table {
  width: 100%;
  margin: 0;
}

.signal-details > table,
.signal-details > .info-table {
  border-top: 1px solid var(--border);
}

.pts {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  text-align: right;
}

.smb-pts {
  color: var(--smb);
}

.ent-pts {
  color: var(--enterprise);
}

/* ── Info Table ──────────────────────────────────────────── */

.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 0.5rem 0;
}

.info-table th {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
}

.info-table td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* ── Spinner ─────────────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 0.5rem;
}

/* ── Loading State ───────────────────────────────────────── */

.loading-card {
  margin-top: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
  animation: fadeIn 0.3s ease;
}

/* ── Error State ─────────────────────────────────────────── */

.error-card {
  margin-top: 1.5rem;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius);
  padding: 1rem;
  color: var(--danger);
  font-size: 0.9rem;
  animation: fadeIn 0.3s ease;
}

/* ── Utilities ───────────────────────────────────────────── */

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.muted {
  color: var(--muted);
}

.accent {
  color: var(--accent);
}

/* ── Animations ──────────────────────────────────────────── */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 520px) {
  h1 {
    font-size: 1.35rem;
  }

  .input-row {
    flex-direction: column;
  }

  .pipeline {
    flex-wrap: wrap;
    justify-content: center;
  }

  .pipeline-arrow {
    display: none;
  }
}
