/* USB Catalog — mobile-first styles */

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

:root {
  --blue:      #3b82f6;
  --blue-dark: #2563eb;
  --bg:        #f8fafc;
  --surface:   #ffffff;
  --border:    #e2e8f0;
  --text:      #0f172a;
  --muted:     #64748b;
  --red:       #ef4444;
  --red-dark:  #b91c1c;
  --green:     #22c55e;
  --amber:     #f59e0b;
  --gray:      #94a3b8;
  --radius:    8px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font: inherit; }

/* ── Nav ──────────────────────────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: 52px;
  max-width: 900px;
  margin: 0 auto;
}
.nav-brand {
  font-weight: 700;
  font-size: 1rem;
  color: var(--blue);
}
.nav-links {
  display: flex;
  gap: .25rem;
}
.nav-links a {
  padding: .375rem .625rem;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: .875rem;
  font-weight: 500;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.nav-links a:hover, .nav-links a.active {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}

/* ── Page container ───────────────────────────────────────────────────────── */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
}

/* ── Search hero ──────────────────────────────────────────────────────────── */
.search-hero {
  padding: 1.25rem 0 .75rem;
}
.search-hero h1 {
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: 1rem;
}
.search-row {
  display: flex;
  gap: .5rem;
  margin-bottom: .75rem;
}
#search-input {
  flex: 1;
  padding: .625rem .875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  min-height: 44px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
}
#search-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

/* ── Filter row ───────────────────────────────────────────────────────────── */
.filter-row {
  display: flex;
  gap: .5rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: .25rem;
}
.filter-row::-webkit-scrollbar { height: 3px; }
.filter-row::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.filter-group {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  flex-shrink: 0;
}
.filter-group label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.filter-group select {
  padding: .375rem .625rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  min-height: 40px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .5rem center;
  padding-right: 1.75rem;
}
.filter-group select:focus {
  border-color: var(--blue);
}

/* ── Results meta ─────────────────────────────────────────────────────────── */
.results-meta {
  font-size: .8125rem;
  color: var(--muted);
  padding: .5rem 0;
}

/* ── Results grid ─────────────────────────────────────────────────────────── */
.results-grid {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

/* ── Tool card ────────────────────────────────────────────────────────────── */
.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .875rem 1rem;
  box-shadow: var(--shadow);
}
.tool-card-name {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: .2rem;
  word-break: break-word;
}
.tool-card-vendor {
  font-size: .8125rem;
  color: var(--muted);
  margin-bottom: .3rem;
}
.tool-card-desc {
  font-size: .875rem;
  color: var(--text);
  margin-bottom: .5rem;
  line-height: 1.45;
}
.tool-card-location {
  font-size: .75rem;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  color: var(--muted);
  margin-bottom: .5rem;
  word-break: break-all;
}
.tool-card-caps {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-bottom: .5rem;
}
.cap-chip {
  font-size: .7rem;
  font-weight: 600;
  padding: .15rem .45rem;
  border-radius: 99px;
  background: #eff6ff;
  color: var(--blue-dark);
  border: 1px solid #bfdbfe;
  white-space: nowrap;
}
.cap-chip.clickable {
  cursor: pointer;
}
.cap-chip.clickable:hover, .cap-chip.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.cap-chip .chip-count {
  opacity: .7;
  margin-left: .2rem;
}

/* ── Capability chip category colors ─────────────────────────────────────── */
/* Boot/Recovery — amber */
.cap-chip--boot { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.cap-chip--boot.clickable:hover, .cap-chip--boot.active { background: #f59e0b; color: #fff; border-color: #f59e0b; }

/* Disk & Storage — blue (same hue as default, kept explicit for clarity) */
.cap-chip--disk { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }
.cap-chip--disk.clickable:hover, .cap-chip--disk.active { background: #3b82f6; color: #fff; border-color: #3b82f6; }

/* Diagnostics/Hardware — violet/purple */
.cap-chip--diagnostics { background: #f5f3ff; color: #7c3aed; border-color: #ddd6fe; }
.cap-chip--diagnostics.clickable:hover, .cap-chip--diagnostics.active { background: #8b5cf6; color: #fff; border-color: #8b5cf6; }

/* Security — rose/red */
.cap-chip--security { background: #fff1f2; color: #be123c; border-color: #fecdd3; }
.cap-chip--security.clickable:hover, .cap-chip--security.active { background: #f43f5e; color: #fff; border-color: #f43f5e; }

/* Networking — teal */
.cap-chip--networking { background: #f0fdfa; color: #0f766e; border-color: #99f6e4; }
.cap-chip--networking.clickable:hover, .cap-chip--networking.active { background: #14b8a6; color: #fff; border-color: #14b8a6; }

/* System/OS — green */
.cap-chip--system { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.cap-chip--system.clickable:hover, .cap-chip--system.active { background: #22c55e; color: #fff; border-color: #22c55e; }
.tool-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem .75rem;
  font-size: .75rem;
  color: var(--muted);
  align-items: center;
}
.status-badge {
  font-size: .7rem;
  font-weight: 700;
  padding: .1rem .4rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.status-researched  { background: #dcfce7; color: #15803d; }
.status-partial     { background: #fef3c7; color: #b45309; }
.status-unknown     { background: #f1f5f9; color: #475569; }
.status-pending     { background: #eff6ff; color: var(--blue-dark); }

/* ── Empty / loading ──────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.empty-state h3 { font-size: 1rem; margin-bottom: .375rem; color: var(--text); }
.loading-spinner {
  display: flex;
  justify-content: center;
  padding: 3rem;
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: .375rem;
  padding: 1.25rem 0;
  flex-wrap: wrap;
}
.page-btn {
  min-width: 40px;
  min-height: 40px;
  padding: .25rem .5rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: .875rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.page-btn:hover:not(:disabled) {
  border-color: var(--blue);
  color: var(--blue);
}
.page-btn.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Browse caps ──────────────────────────────────────────────────────────── */
.cap-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: .75rem;
}
#browse-page h1 {
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: .875rem;
}
.browse-filters {
  margin-bottom: .5rem;
}

/* ── Upload page ──────────────────────────────────────────────────────────── */
#upload-page h1 {
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: .375rem;
}
.upload-hint {
  font-size: .875rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
}
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  margin-bottom: 1rem;
  position: relative;
}
.drop-zone.drag-over {
  border-color: var(--blue);
  background: #eff6ff;
}
.drop-zone-inner {
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
}
.drop-icon { color: var(--muted); }
.drop-label {
  font-size: .9375rem;
  color: var(--muted);
}
.drop-link {
  color: var(--blue);
  font-weight: 600;
  text-decoration: underline;
}
.file-name {
  font-size: .875rem;
  color: var(--text);
  font-weight: 600;
  word-break: break-all;
  margin-top: .25rem;
}
.file-hidden {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .625rem 1.5rem;
  min-height: 44px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  width: 100%;
  margin-bottom: 1rem;
  transition: background .15s;
}
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.upload-status {
  text-align: center;
  font-size: .9375rem;
  color: var(--muted);
  min-height: 1.5rem;
  margin-bottom: .75rem;
}

/* ── Upload results ───────────────────────────────────────────────────────── */
.deactivation-skipped-banner {
  background: var(--red);
  color: #fff;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.deactivation-skipped-banner h2 {
  font-size: 1.125rem;
  font-weight: 800;
  margin-bottom: .3rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.deactivation-skipped-banner p {
  font-size: .9rem;
  opacity: .92;
  line-height: 1.45;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .625rem;
  margin-bottom: 1rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  box-shadow: var(--shadow);
}
.stat-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin-bottom: .1rem;
}
.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
}

.error-section {
  margin-bottom: 1rem;
}
.error-toggle {
  background: none;
  border: none;
  color: var(--red);
  font-size: .9rem;
  font-weight: 600;
  padding: 0;
  display: flex;
  align-items: center;
  gap: .3rem;
  margin-bottom: .5rem;
  min-height: 44px;
}
.error-list {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: .75rem 1rem;
  font-size: .8125rem;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  color: var(--red-dark);
  max-height: 260px;
  overflow-y: auto;
}
.error-list li {
  margin-bottom: .3rem;
  word-break: break-word;
  list-style: none;
  padding-left: 1rem;
  position: relative;
}
.error-list li::before { content: "•"; position: absolute; left: 0; }

.upload-success-note {
  font-size: .875rem;
  color: #15803d;
  background: #dcfce7;
  border-radius: var(--radius);
  padding: .625rem .875rem;
  margin-bottom: 1rem;
  font-weight: 500;
}

/* ── Wider screens ────────────────────────────────────────────────────────── */
@media (min-width: 600px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .search-hero h1 { font-size: 1.625rem; }
  .btn-primary { width: auto; }
}
@media (min-width: 768px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  main { padding: 1.5rem 1rem; }
}
