/* b2box — main stylesheet */

:root {
  --cream: #faf9f7;
  --paper: #f4f2ee;
  --ink: #1a1917;
  --ink-2: #4a4845;
  --ink-3: #8a8784;
  --rule: #e2e0db;
  --accent: #2c5f8a;
  --accent-light: #e8f0f7;
  --danger: #8b2e2e;
  --danger-light: #f7e8e8;
  --radius: 4px;
  --max: 760px;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, sans-serif;
  --mono: 'SF Mono', 'Fira Code', monospace;
}

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

html { font-size: 16px; }

body {
  font-family: var(--sans);
  background: var(--cream);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Nav */
nav {
  border-bottom: 1px solid var(--rule);
  padding: 0 2rem;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--cream);
}

.wordmark {
  font-family: var(--serif);
  font-size: 1.25rem;
  letter-spacing: 0.05em;
  color: var(--ink);
  text-decoration: none;
  font-style: italic;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-user {
  font-size: 0.8rem;
  color: var(--ink-3);
}

.nav-link-btn {
  background: none;
  border: none;
  font-size: 0.8rem;
  color: var(--ink-3);
  cursor: pointer;
  padding: 0;
  font-family: var(--sans);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.nav-link-btn:hover { color: var(--ink); }

/* Main */
main {
  flex: 1;
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

/* Footer */
footer {
  border-top: 1px solid var(--rule);
  padding: 1.25rem 2rem;
  font-size: 0.75rem;
  color: var(--ink-3);
  font-family: var(--serif);
  font-style: italic;
  text-align: center;
}

/* Typography */
h1 {
  font-family: var(--serif);
  font-size: 1.75rem;
  font-weight: normal;
  letter-spacing: -0.01em;
  color: var(--ink);
}

h2 {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: normal;
}

.subtitle {
  font-size: 0.875rem;
  color: var(--ink-2);
  margin-top: 0.2rem;
}

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

code {
  font-family: var(--mono);
  font-size: 0.8rem;
  background: var(--paper);
  padding: 0.1em 0.4em;
  border-radius: 2px;
}

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-shrink: 0;
}

/* Buttons */
.btn-primary, button.btn-primary {
  display: inline-block;
  background: var(--ink);
  color: var(--cream);
  border: 1px solid var(--ink);
  padding: 0.5rem 1.1rem;
  font-size: 0.85rem;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  font-family: var(--sans);
  letter-spacing: 0.01em;
  transition: opacity 0.15s;
}

.btn-primary:hover { opacity: 0.8; }

.btn-ghost, button.btn-ghost {
  display: inline-block;
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--rule);
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  font-family: var(--sans);
  transition: border-color 0.15s, color 0.15s;
}

.btn-ghost:hover { border-color: var(--ink-3); color: var(--ink); }

.btn-small {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink-2);
  background: transparent;
}

.btn-small:hover { border-color: var(--ink-3); }

.btn-danger, button.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--rule);
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--sans);
}

.btn-danger:hover { background: var(--danger-light); border-color: var(--danger); }

.btn-delete {
  background: none;
  border: none;
  color: var(--ink-3);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}

.btn-delete:hover { color: var(--danger); }

/* Forms */
label {
  display: block;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 0.35rem;
  margin-top: 1.1rem;
}

label:first-child { margin-top: 0; }

input[type="text"],
input[type="url"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"] {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: white;
  font-size: 0.95rem;
  font-family: var(--sans);
  color: var(--ink);
  transition: border-color 0.15s;
}

input:focus {
  outline: none;
  border-color: var(--accent);
}

.req { color: var(--ink-3); }

.form-card {
  background: white;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.75rem;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.form-card button { margin-top: 1.5rem; }

/* Auth */
.auth-wrap {
  max-width: 380px;
  margin: 3rem auto;
}

.auth-wrap h1 {
  margin-bottom: 1.75rem;
}

.auth-wrap form {
  background: white;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
}

.auth-wrap form button { margin-top: 1.5rem; width: 100%; }

.auth-alt {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--ink-3);
  text-align: center;
}

.auth-alt a { color: var(--ink-2); }

.error {
  background: var(--danger-light);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

/* Box list */
.box-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  background: white;
}

.box-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--rule);
}

.box-card:last-child { border-bottom: none; }
.box-card:hover { background: var(--paper); }

.box-card-link {
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
}

.box-name {
  font-size: 0.95rem;
  color: var(--ink);
  font-weight: 500;
}

.box-location {
  font-size: 0.8rem;
  color: var(--ink-3);
}

.box-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.item-count {
  font-size: 0.78rem;
  color: var(--ink-3);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--ink-3);
}

.empty-state p { margin-bottom: 1.25rem; font-size: 0.95rem; }

/* Add item form */
.add-item-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.add-item-form input { margin-bottom: 0; }
.add-item-form input[name="name"] { flex: 2; min-width: 160px; }
.add-item-form input[name="qty"] { width: 70px; flex-shrink: 0; }
.add-item-form input[name="category"] { flex: 1; min-width: 100px; }
.add-item-form input[name="notes"] { flex: 2; min-width: 140px; }

/* Search */
.search-bar {
  margin-bottom: 1.25rem;
}

.search-bar form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.search-bar input[type="search"] { max-width: 300px; }

/* Item table */
.item-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.item-table th {
  text-align: left;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--rule);
  font-weight: normal;
}

.item-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

.item-table tr:last-child td { border-bottom: none; }
.item-table tbody tr:hover { background: var(--paper); }

.tag {
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  background: var(--paper);
  color: var(--ink-2);
  padding: 0.15rem 0.5rem;
  border-radius: 2px;
  white-space: nowrap;
}

/* Danger zone */
.danger-zone {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

/* QR page */
.qr-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 0;
}

.qr-card {
  background: white;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.qr-label {
  font-family: var(--serif);
  font-size: 1.1rem;
  color: var(--ink);
}

.qr-sub {
  font-size: 0.8rem;
  color: var(--ink-3);
}

.qr-actions {
  display: flex;
  gap: 0.75rem;
}

/* Public box view */
.public-box {
  max-width: 600px;
  margin: 0 auto;
}

.public-box h1 { margin-bottom: 0.25rem; }
.public-box .item-table { margin-top: 1.5rem; }

/* Print styles */
@media print {
  nav, footer, .qr-actions, .page-header a { display: none; }
  body { background: white; }
  .qr-card { border: none; box-shadow: none; }
}

/* Mobile */
@media (max-width: 600px) {
  main { padding: 1.5rem 1rem; }
  nav { padding: 0 1rem; }
  .page-header { flex-direction: column; gap: 1rem; }
  .add-item-form input[name="notes"] { display: none; }
  .item-table th:nth-child(3),
  .item-table td:nth-child(3),
  .item-table th:nth-child(4),
  .item-table td:nth-child(4) { display: none; }
}

/* Inline item edit */
.edit-row td { padding: 0.5rem 0.75rem; background: var(--paper); }
.inline-edit-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.inline-edit-form input { margin-bottom: 0; }
.inline-edit-form input[name="name"] { flex: 2; min-width: 140px; }
.inline-edit-form input[name="qty"] { width: 70px; flex-shrink: 0; }
.inline-edit-form input[name="category"] { flex: 1; min-width: 100px; }
.inline-edit-form input[name="notes"] { flex: 2; min-width: 120px; }
.item-actions { white-space: nowrap; }

/* QR label */
.qr-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 2rem;
  background: white;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 1.5rem;
  max-width: 520px;
}
.qr-label-block { display: flex; flex-direction: column; gap: 0.35rem; }
.qr-label { font-family: var(--serif); font-size: 1.3rem; color: var(--ink); }
.qr-sub { font-size: 0.85rem; color: var(--ink-2); }
.qr-url { font-family: var(--mono); font-size: 0.7rem; color: var(--ink-3); margin-top: 0.5rem; word-break: break-all; }

/* Print */
@media print {
  nav, footer, .qr-actions, .page-header, p.muted { display: none; }
  body { background: white; }
  .qr-card { border: 1.5px solid #000; border-radius: 6px; max-width: 100%; }
  main { padding: 0; }
}
