/* Palette mirrors the desktop app's macOS-like theme (reference/desktop_app.py) for visual continuity. */
:root {
  --bg-app: #f5f5f7;
  --toolbar-bg: #ffffff;
  --toolbar-border: #d1d1d6;
  --card-bg: #ffffff;
  --border: #e5e5ea;
  --text-strong: #0b0b0f;
  --muted: #4b5563;
  --muted2: #6b7280;
  --primary: #0a84ff;
  --danger: #ff3b30;
  --warn: #ff9f0a;
  --ok: #34c759;
  --info: #8e8e93;
  --row-match-bg: #eaf4ff;
  --row-match-border: rgba(10, 132, 255, 0.35);
  --row-other-bg: #f3f4f6;
  --row-other-text: #6b7280;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-app);
  color: var(--text-strong);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.topbar {
  background: var(--toolbar-bg);
  border-bottom: 1px solid var(--toolbar-border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar form { display: flex; gap: 8px; flex: 1; min-width: 280px; }

input[type="text"], input[type="password"], input[type="number"] {
  border-radius: 14px;
  border: 1px solid var(--toolbar-border);
  padding: 10px 12px;
  font-size: 15px;
  background: #fff;
  color: var(--text-strong);
}

input[type="text"].search-input { flex: 1; min-height: 22px; }

/* --- Search button: turns solid green + pulses while the request is in flight,
       then snaps back to blue when the search is done and ready for the next. --- */
.search-btn { transition: background 0.15s ease, border-color 0.15s ease; }

.search-btn.is-searching,
.search-btn.is-searching:disabled {
  background: var(--ok) !important;
  border-color: var(--ok) !important;
  color: #fff !important;
  opacity: 1 !important;
  cursor: progress;
  animation: search-pulse 0.9s ease-in-out infinite;
}

@keyframes search-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(52,199,89,0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(52,199,89,0); }
  100% { box-shadow: 0 0 0 0 rgba(52,199,89,0); }
}

button:disabled { cursor: progress; }

button, .btn {
  border-radius: 12px;
  border: 1px solid var(--toolbar-border);
  background: #fff;
  padding: 9px 14px;
  font-weight: 700;
  color: var(--text-strong);
  cursor: pointer;
}
button:hover, .btn:hover { background: #f2f2f7; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #006fe6; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #e02820; }
.btn-secondary { background: #fff; }

.tabs { display: flex; gap: 6px; }
.tabs a {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--toolbar-border);
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
}
.tabs a.active { background: var(--text-strong); color: #fff; border-color: var(--text-strong); }

.user-chip { color: var(--muted); font-size: 13px; font-weight: 700; }

.content { padding: 18px; max-width: 980px; margin: 0 auto; }

.flash {
  background: #fff;
  border: 1px solid var(--toolbar-border);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-weight: 600;
  font-size: 14px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  margin-bottom: 16px;
  box-shadow: 0 8px 22px rgba(0,0,0,0.06);
}

.card-header { padding: 16px 18px 0 18px; display: flex; justify-content: space-between; gap: 12px; }
.card-title { font-size: 16px; font-weight: 900; margin: 0; display: flex; align-items: center; gap: 8px; }
.card-sub { font-family: Menlo, Monaco, monospace; font-size: 12px; color: var(--muted2); margin-top: 4px; }
.card-hint { color: var(--muted); font-size: 12px; font-weight: 700; margin-top: 4px; }
.card-deadline, .card-note { color: var(--muted2); font-size: 12px; font-weight: 700; margin-top: 4px; }

.copy-btn {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 8px;
  font-weight: 700;
}

.search-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 10px;
}

.badges { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.badge {
  padding: 5px 12px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 11px;
  color: #fff;
  white-space: nowrap;
}
.badge-primary { background: var(--primary); }
.badge-info { background: var(--info); }
.badge-danger { background: var(--danger); }
.badge-dark { background: #1c1c1e; }
.badge-warn { background: var(--warn); color: #111; }
.badge-ok { background: var(--ok); }
.badge-muted { background: var(--info); }

.products { padding: 12px 18px 0 18px; display: flex; flex-direction: column; gap: 10px; }

.product-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 14px;
}
.product-row.matched { background: var(--row-match-bg); border: 1px solid var(--row-match-border); }
.product-row.other { background: var(--row-other-bg); border: 1px solid var(--border); color: var(--row-other-text); }

.product-img {
  width: 46px;
  height: 46px;
  min-width: 46px;
  border-radius: 10px;
  border: 1px solid var(--border);
  object-fit: cover;
  background: #eef2f7;
}
.product-img-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: #7b8794;
}

.product-info { flex: 1; min-width: 0; }
.product-title { font-weight: 900; font-size: 14px; }
.product-meta { font-size: 12px; font-weight: 700; color: var(--muted2); }

.chip {
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 900;
}
.chip-pack { background: rgba(10,132,255,0.16); color: #1b4f9c; }
.chip-other { background: #e5e7eb; color: var(--row-other-text); }

/* Procurement order-preview: clickable code cells (EAN / ASIN / Allegro) */
.code-pick {
  font-family: Menlo, Monaco, monospace;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  color: var(--text-strong);
}
.code-pick:hover { background: #f2f2f7; border-color: var(--primary); }
.code-pick-asin { border-color: rgba(10,132,255,0.4); background: rgba(10,132,255,0.08); color: #1b4f9c; font-weight: 700; }
.code-pick-asin:hover { background: rgba(10,132,255,0.16); }

.qty-input { width: 70px; }

.pack-now-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}

.card-footer { padding: 12px 18px 16px 18px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.card-footer .spacer { flex: 1; }

.support-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.support-item { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.support-item:last-child { border-bottom: none; }
.status-open { color: var(--warn); font-weight: 800; }
.status-answered { color: var(--ok); font-weight: 800; }
.status-closed { color: var(--muted2); font-weight: 800; }

dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  max-width: 420px;
  width: 90%;
}
dialog::backdrop { background: rgba(0,0,0,0.35); }
.dialog-body { padding: 20px; }
.dialog-body textarea { width: 100%; border-radius: 12px; border: 1px solid var(--toolbar-border); padding: 10px; font-family: inherit; }

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px;
  width: 320px;
  box-shadow: 0 8px 22px rgba(0,0,0,0.08);
}
.login-card h1 { font-size: 18px; margin: 0 0 18px 0; }
.login-card input { width: 100%; margin-bottom: 10px; }
.login-error { color: var(--danger); font-size: 13px; margin-bottom: 10px; font-weight: 700; }

.empty-state { color: var(--muted2); text-align: center; padding: 40px 0; font-weight: 700; }

/* ============================================================
   Sidebar shell — global navigation moved off the top bar
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
  width: 236px;
  flex: 0 0 236px;
  background: var(--toolbar-bg);
  border-right: 1px solid var(--toolbar-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.side-brand {
  font-size: 16px; font-weight: 900; letter-spacing: .2px;
  padding: 18px 20px 14px; display: flex; align-items: center; gap: 8px;
}
.side-logo { font-size: 18px; }

.side-nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 12px; flex: 1; }

.side-group {
  font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted2); padding: 14px 10px 5px;
}

.side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 700; font-size: 13.5px;
  line-height: 1.25; transition: background .12s, color .12s;
}
.side-link .ico { font-size: 15px; width: 18px; text-align: center; flex: none; }
.side-link:hover { background: #f2f2f7; color: var(--text-strong); }
.side-link.active { background: var(--text-strong); color: #fff; }

.side-foot { border-top: 1px solid var(--border); padding: 12px; margin-top: auto; }
.side-user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.side-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: var(--primary); color: #fff; font-weight: 900; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.side-user-meta { display: flex; flex-direction: column; line-height: 1.2; overflow: hidden; }
.side-user-meta strong { font-size: 13px; }
.side-user-meta small { font-size: 11px; color: var(--muted2); font-weight: 700; }
.side-logout { width: 100%; font-size: 13px; }

.app-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.app-main .content { max-width: 1150px; width: 100%; }

/* Slim per-page header inside the main area (page title + page-specific tools) */
.page-head {
  background: var(--toolbar-bg);
  border-bottom: 1px solid var(--toolbar-border);
  padding: 12px 20px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.page-head .page-title { font-size: 15px; font-weight: 900; }
.page-head form { display: flex; gap: 8px; }

/* Mobile: sidebar collapses to a horizontal strip on top */
@media (max-width: 820px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%; flex-basis: auto; height: auto; position: static;
    border-right: none; border-bottom: 1px solid var(--toolbar-border);
  }
  .side-nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .side-group { display: none; }
  .side-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 0; }
  .side-foot form { flex: none; }
}

/* Top strip for pure-packing users (no sidebar) — just brand + user + logout */
.app-main--full { width: 100%; }
.topstrip {
  background: var(--toolbar-bg);
  border-bottom: 1px solid var(--toolbar-border);
  padding: 10px 20px;
  display: flex; align-items: center; gap: 12px;
}
.topstrip .side-brand { padding: 0; font-size: 15px; }
.topstrip .side-user { margin: 0; }

/* Partial tracking picklist (search input contains "*") */
.pick-head { font-size: 13px; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
.pick-list { display: flex; flex-direction: column; gap: 6px; }
.pick-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: #fff; cursor: pointer;
}
.pick-row:hover { background: var(--row-match-bg); border-color: var(--row-match-border); }
.pick-tn { font-size: 14px; font-weight: 700; letter-spacing: .3px; }
.pick-hint { color: var(--muted2); font-size: 12px; flex: 1; }
.pick-go { color: var(--primary); font-weight: 800; font-size: 12px; }
.src { padding: 2px 8px; border-radius: 6px; font-size: 10px; font-weight: 800; text-transform: uppercase; flex: none; }
.src-amazon { background: #fff3e0; color: #b26a00; }
.src-allegro { background: #e8f1ff; color: #1b4f9c; }
.src-manual { background: #ecfdf3; color: #1b7f4b; }
.muted-n { color: var(--muted2); font-weight: 600; font-size: 12px; }

/* Sidebar menu count badge */
.side-badge { display:inline-block; min-width:18px; padding:1px 6px; border-radius:999px; background:var(--danger); color:#fff; font-size:11px; font-weight:800; text-align:center; margin-left:4px; }
.side-link.active .side-badge { background:#fff; color:var(--text-strong); }
