/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary  { background: var(--color-accent);   color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-accent-hover); }

.btn-danger   { background: var(--color-danger);   color: #fff; }
.btn-danger:hover:not(:disabled)  { background: #b91c1c; }

.btn-ghost    { background: transparent; color: var(--color-text); border: 1px solid var(--color-border); }
.btn-ghost:hover:not(:disabled)   { border-color: var(--color-accent); color: var(--color-accent); }

.btn-icon     { padding: .45rem; border-radius: var(--radius-sm); }
.btn-sm       { padding: .35rem .75rem; font-size: .82rem; }
.btn-block    { width: 100%; justify-content: center; }

/* ── Location groups (sidebar) ─────────────────────────── */
.location-group { border-bottom: 1px solid var(--color-border); }
.location-group:last-child { border-bottom: none; }

.location-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem 1rem;
  cursor: pointer;
  user-select: none;
  background: var(--color-surface);
  position: sticky;
  top: 0;
  z-index: 1;
}
.location-header:hover { background: var(--color-surface-2); }

.location-arrow { font-size: .65rem; color: var(--color-text-muted); width: .8rem; }
.location-name  { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); flex: 1; }
.location-count { font-size: .72rem; color: var(--color-text-muted); background: var(--color-surface-2); padding: .1rem .4rem; border-radius: 999px; }

/* ── Box card (sidebar list) ────────────────────────────── */
.box-card {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .1s, border-color .1s;
}
.box-card:hover  { background: var(--color-surface); }
.box-card.active { background: var(--color-surface); border-left-color: var(--color-accent); }

.box-card-thumb {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--color-surface-2);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: 1.2rem;
  overflow: hidden;
}
.box-card-thumb img { width: 100%; height: 100%; object-fit: cover; }

.box-card-info { flex: 1; min-width: 0; }
.box-card-code { font-size: .75rem; color: var(--color-text-muted); }
.box-card-title { font-size: .9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.box-card-matches { font-size: .75rem; color: var(--color-accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: .1rem; }

/* ── Box detail ─────────────────────────────────────────── */
.box-detail { padding: 1.5rem; max-width: 720px; }

.box-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.box-detail-meta { font-size: .82rem; color: var(--color-text-muted); margin-top: .2rem; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: .5rem;
  margin-bottom: 1.5rem;
}

.photo-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-surface-2);
  cursor: pointer;
  position: relative;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }

.photo-delete-btn {
  display: none;
  position: absolute;
  top: 4px; right: 4px;
  width: 1.6rem; height: 1.6rem;
  border-radius: 50%;
  border: none;
  background: rgba(220,38,38,.85);
  color: #fff;
  font-size: .75rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.photo-grid.editing .photo-delete-btn { display: flex; }

.photo-thumb.label-photo::after {
  content: '★';
  position: absolute;
  top: 4px; right: 6px;
  font-size: .8rem;
  color: #fbbf24;
}

.label-image {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  cursor: pointer;
}

.section-title {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-text-muted);
  margin-bottom: .75rem;
}

.items-list { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1.5rem; }

.item-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem .75rem;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  font-size: .9rem;
}
.item-qty {
  font-size: .8rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ── Mobile box cards ───────────────────────────────────── */
.mobile-card-list { padding: .5rem; display: flex; flex-direction: column; gap: .5rem; }

.mobile-box-card {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid var(--color-border);
}
.mobile-box-card:active { opacity: .8; }

.mobile-card-thumb {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--color-surface-2);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: 1.5rem;
  overflow: hidden;
}
.mobile-card-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ── Wizard ─────────────────────────────────────────────── */
.wizard-steps {
  display: flex;
  gap: .4rem;
  margin-bottom: 1.5rem;
}
.wizard-step-dot {
  height: 4px;
  flex: 1;
  border-radius: 2px;
  background: var(--color-border);
  transition: background .2s;
}
.wizard-step-dot.done  { background: var(--color-accent); }
.wizard-step-dot.active { background: var(--color-accent); opacity: .6; }

.wizard-nav {
  display: flex;
  gap: .75rem;
  margin-top: 1.5rem;
}

.camera-preview {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  margin-bottom: .75rem;
}

.photo-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: .4rem;
  margin-bottom: .75rem;
}
.photo-preview-grid img {
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

/* ── Toast ──────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-width: 320px;
}

.toast {
  padding: .75rem 1rem;
  border-radius: var(--radius-md);
  font-size: .88rem;
  color: #fff;
  box-shadow: var(--shadow-md);
  animation: toast-in .2s ease;
}
.toast.success { background: var(--color-success); }
.toast.error   { background: var(--color-danger); }
.toast.info    { background: var(--color-accent); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.badge.admin  { color: #fbbf24; border-color: #fbbf24; }
.badge.editor { color: var(--color-accent); border-color: var(--color-accent); }

/* ── Login page ─────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-box {
  width: 100%;
  max-width: 360px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
}
.login-box h1 { text-align: center; margin-bottom: 1.5rem; font-size: 1.4rem; }

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

.public-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1rem;
}
.public-logo { font-weight: 700; color: var(--color-accent); }

/* ── QR modal ───────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 320px;
  width: 90%;
  text-align: center;
}
.modal img { margin: 1rem auto; border-radius: var(--radius-sm); }
.modal-title { font-weight: 600; margin-bottom: .5rem; }
.modal-close { margin-top: .75rem; }

/* ── Lightbox ───────────────────────────────────────────── */
.lightbox-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.92);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-img-wrap {
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  user-select: none;
  -webkit-user-drag: none;
}

.lightbox-close {
  position: fixed;
  top: 1rem; right: 1rem;
  background: rgba(255,255,255,.12);
  border: none;
  color: #fff;
  font-size: 1.2rem;
  width: 2.2rem; height: 2.2rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 1;
}
.lightbox-close:hover { background: rgba(255,255,255,.22); }

.lightbox-prev,
.lightbox-next {
  position: fixed;
  top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,.12);
  border: none;
  color: #fff;
  font-size: 2rem;
  width: 2.5rem; height: 4rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.lightbox-prev { left: .5rem; }
.lightbox-next { right: .5rem; }
.lightbox-prev:hover, .lightbox-next:hover { background: rgba(255,255,255,.22); }

.lightbox-counter {
  position: fixed;
  bottom: 1rem; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,.6);
  font-size: .85rem;
}

/* ── Divider ────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--color-border);
  margin: 1rem 0;
}

/* ── Spinner ────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-center {
  display: flex;
  justify-content: center;
  padding: 3rem;
}
