/* ============================================================
   PrepBox — Shared Design Tokens & Base Styles
   frontend/assets/css/common.css
   Extracted from mockups: prepbox-login, prepbox-inventory-main,
   prepbox-item-edit, prepbox-location-edit
   ============================================================ */

/* ── Design Tokens ── */
:root {
  /* Surfaces */
  --bg:             #eef1f4;
  --app:            #f7f9fb;
  --pane:           #fff;
  --pane2:          #f2f5f8;
  --head:           #e4e9ef;

  /* Borders */
  --line:           #c7d0da;
  --line2:          #d9e0e8;

  /* Text */
  --text:           #202833;
  --muted:          #5f6b78;
  --faint:          #8893a0;

  /* Nav */
  --nav:            #dde4eb;
  --navActive:      #c7d7ea;
  --navStrong:      #2f4d69;

  /* Blue / primary */
  --blue:           #275f8e;
  --blueHov:        #204b70;
  --blueSoft:       #d9e7f3;

  /* Semantic colors */
  --green:          #2f6a3a;
  --greenSoft:      #deeadf;
  --amber:          #8a5d18;
  --amberSoft:      #efe2c8;
  --red:            #8c3e55;
  --redSoft:        #eedbe1;

  /* Buttons / states */
  --btn:            #edf2f6;
  --select:         #e9f2fb;
  --bulk:           #e7eff8;

  /* Shadows */
  --shadow:         0 1px 1px rgba(22,27,33,.05), 0 6px 18px rgba(22,27,33,.05);
  --shadowLg:       0 2px 4px rgba(22,27,33,.06), 0 16px 40px rgba(22,27,33,.11);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  line-height: 1.3;
}
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ── Chrome wrapper ── */
.chrome {
  margin: 10px;
  border: 1px solid var(--line);
  background: var(--app);
  box-shadow: var(--shadow);
  min-height: calc(100vh - 20px);
  display: flex;
  flex-direction: column;
}

/* ────────────────────────────────────────────
   TOP BAR
──────────────────────────────────────────── */
.topbar {
  display: grid;
  grid-template-columns: 220px 1fr;
  align-items: center;
  height: 42px;
  background: linear-gradient(180deg, var(--head), var(--pane2));
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.topbar.three-col {
  grid-template-columns: 220px 1fr auto;
}
.topbar.has-page-nav {
  grid-template-columns: minmax(220px, 260px) 1fr auto;
}
.topbar-primary {
  display: flex;
  align-items: center;
  height: 100%;
  min-width: 0;
  border-right: 1px solid var(--line);
}
.topbar-primary .brand {
  border-right: 0;
  flex: 0 0 auto;
  padding-left: 10px;
}
.page-nav {
  position: relative;
  flex: 0 0 auto;
  padding-left: 6px;
}
.nav-menu-button {
  width: 36px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--pane);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.nav-menu-button:hover { background: var(--blueSoft); border-color: #9eb6ca; }
.nav-menu-button:disabled { opacity: .5; cursor: not-allowed; }
.nav-menu-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; }
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  font-weight: 800;
  font-size: 14px;
  border-right: 1px solid var(--line);
  height: 100%;
  text-decoration: none;
  color: var(--text);
}
.brand:hover { background: color-mix(in srgb, var(--head) 60%, var(--navActive)); }
.brand .box {
  width: 20px; height: 20px;
  border: 1px solid var(--line);
  background: var(--pane);
  display: grid; place-items: center;
  font-size: 11px; color: var(--blue); font-weight: 800;
  flex-shrink: 0;
}
.topmeta { padding: 0 14px; color: var(--muted); font-size: 12px; }
.topbar-actions { padding: 0 14px; display: flex; gap: 6px; align-items: center; }

@media (max-width: 700px) {
  .topbar.has-page-nav {
    height: 44px;
    min-height: 44px;
    grid-template-columns: 1fr auto;
  }
  .topbar.has-page-nav .topbar-primary {
    min-width: 0;
  }
  .topbar.has-page-nav .topmeta { display: none; }
  .topbar.has-page-nav .topbar-actions { padding: 0 10px; }
}

/* Slide-out feature navigation */
.feature-nav-open { overflow: hidden; }
.feature-nav-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(24, 34, 45, .48);
  opacity: 0;
  transition: opacity 180ms ease;
}
.feature-nav-overlay.open { opacity: 1; }
.feature-nav-drawer {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1000;
  width: min(340px, calc(100vw - 40px));
  background: var(--pane);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadowLg);
  transform: translateX(-102%);
  transition: transform 180ms ease;
  display: flex;
  flex-direction: column;
}
.feature-nav-drawer[hidden] { display: none; }
.feature-nav-drawer.open { transform: translateX(0); }
.feature-nav-header {
  min-height: 58px;
  padding: 0 10px 0 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--head), var(--pane2));
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.feature-nav-header h2 { font-size: 16px; font-weight: 800; }
.feature-nav-close {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font: 400 30px/1 sans-serif;
  cursor: pointer;
}
.feature-nav-close:hover { color: var(--text); background: var(--nav); }
.feature-nav-drawer nav { padding: 12px; overflow-y: auto; }
.feature-nav-section + .feature-nav-section { margin-top: 14px; }
.feature-nav-section-title {
  margin: 0 0 6px;
  padding: 6px 8px;
  color: var(--navStrong);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.2;
}
.feature-nav-drawer ul { list-style: none; }
.feature-nav-drawer li + li { margin-top: 4px; }
.feature-nav-drawer a,
.feature-nav-placeholder {
  min-height: 48px;
  padding: 0 14px 0 24px;
  border-radius: 5px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  position: relative;
}
.feature-nav-placeholder {
  color: var(--faint);
  font-style: italic;
  cursor: default;
}
.feature-nav-drawer a:hover { background: var(--nav); }
.feature-nav-drawer a.active {
  background: var(--blueSoft);
  color: var(--navStrong);
  font-weight: 800;
}
.feature-nav-drawer a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 3px;
  background: var(--blue);
}

@media (max-width: 700px) {
  .feature-nav-drawer nav { padding: 10px; }
  .feature-nav-section + .feature-nav-section { margin-top: 10px; }
  .feature-nav-section-title {
    font-size: 14px;
    padding: 6px 6px;
  }
  .feature-nav-drawer a,
  .feature-nav-placeholder {
    min-height: 44px;
    padding-left: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .feature-nav-overlay,
  .feature-nav-drawer { transition: none; }
}

/* ────────────────────────────────────────────
   BREADCRUMB BAR
──────────────────────────────────────────── */
.breadcrumb-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: var(--pane2);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}
.breadcrumb-bar a { color: var(--blue); text-decoration: none; }
.breadcrumb-bar a:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--faint); }
.breadcrumb-current { color: var(--text); font-weight: 600; }
.breadcrumb-bar .breadcrumb-right { margin-left: auto; display: flex; gap: 6px; align-items: center; }

/* ────────────────────────────────────────────
   SECTION HEADER
──────────────────────────────────────────── */
.section-h {
  padding: 7px 10px;
  background: linear-gradient(180deg, var(--head), var(--pane2));
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ────────────────────────────────────────────
   BUTTONS
──────────────────────────────────────────── */
.btn {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--btn);
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  border-radius: 3px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 150ms;
}
.btn.primary  { background: var(--blue); border-color: var(--blueHov); color: #fff; font-weight: 700; }
.btn.danger   { background: var(--redSoft); border-color: color-mix(in srgb, var(--red) 35%, var(--line)); color: var(--red); }
.btn.ghost    { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small    { height: 24px; padding: 0 8px; font-size: 11px; }
.btn:hover             { background: color-mix(in srgb, var(--btn) 70%, var(--line)); }
.btn.primary:hover     { background: var(--blueHov); }
.btn.danger:hover      { background: color-mix(in srgb, var(--redSoft) 60%, #f5cdd6); }
.btn.ghost:hover       { background: var(--head); }
.btn:disabled          { opacity: .45; cursor: not-allowed; }

/* ────────────────────────────────────────────
   GLOBAL SEARCH BAR
──────────────────────────────────────────── */
.global-search-bar {
  padding: 10px 14px;
  background: var(--pane2);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}
.global-search-wrap { position: relative; width: 100%; max-width: 520px; }
.global-search-wrap input {
  width: 100%; height: 32px;
  border: 1px solid var(--line);
  background: var(--pane); color: var(--text);
  padding: 0 10px 0 32px;
  font-size: 13px; font-family: inherit;
  border-radius: 3px;
}
.global-search-wrap input:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.global-search-wrap svg {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--muted); pointer-events: none;
}

/* ────────────────────────────────────────────
   LEFT NAV TREE
──────────────────────────────────────────── */
.nav { background: var(--nav); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree .row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 6px;
  align-items: center;
  padding: 5px 8px 5px 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  cursor: pointer;
  font-size: 12px;
}
.tree .row:hover { background: color-mix(in srgb, var(--navActive) 50%, transparent); }
.tree .row.active { background: var(--navActive); color: var(--navStrong); font-weight: 700; }
.tree .count { font-size: 11px; color: var(--faint); }
.tree-label { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.tree-label-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.location-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: #000;
}
.tree-actions { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; }
.tree-edit {
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  padding: 2px 5px;
  border: 1px solid transparent;
  border-radius: 3px;
}
.tree-edit:hover { background: var(--blueSoft); border-color: color-mix(in srgb, var(--blue) 30%, var(--line)); }
.tree ul { margin-left: 14px; }
.location-tree-actions { padding: 8px 10px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--nav) 75%, var(--pane)); }
.nav-footer { padding: 10px; border-top: 1px solid var(--line); margin-top: auto; }
.btn-add-location {
  width: 100%; height: 30px;
  border: 1px dashed var(--blue);
  background: var(--blueSoft);
  color: var(--blue);
  font-size: 12px; font-weight: 700;
  border-radius: 3px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  font-family: inherit;
  transition: background 150ms;
}
.btn-add-location:hover { background: color-mix(in srgb, var(--blueSoft) 70%, var(--blue)); }

/* ────────────────────────────────────────────
   STATUS PILLS
──────────────────────────────────────────── */
.pill {
  display: inline-block; padding: 1px 5px; border-radius: 10px;
  font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .05em;
}
.pill.med    { background: var(--blueSoft);  color: var(--blue); }
.pill.food   { background: var(--pane2); color: var(--muted); border: 1px solid var(--line2); }
.pill.supply { background: var(--pane2); color: var(--muted); border: 1px solid var(--line2); }
.pill.warn   { background: var(--amberSoft); color: var(--amber); }
.pill.ok     { background: var(--greenSoft); color: var(--green); }
.pill.alert  { background: var(--redSoft);   color: var(--red); }

/* ────────────────────────────────────────────
   ALERT / CALLOUT BANNERS
──────────────────────────────────────────── */
.alert {
  display: none; align-items: flex-start; gap: 8px;
  padding: 8px 10px;
  font-size: 12px; line-height: 1.45;
  border: 1px solid color-mix(in srgb, var(--red) 35%, var(--line));
  background: var(--redSoft); color: var(--red);
}
.alert.show { display: flex; }
.alert.success {
  border-color: color-mix(in srgb, var(--green) 25%, var(--line));
  background: var(--greenSoft); color: var(--green);
}
.alert svg { flex-shrink: 0; margin-top: 1px; }

.callout {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 10px;
  background: var(--blueSoft);
  border: 1px solid color-mix(in srgb, var(--blue) 25%, var(--line));
  font-size: 11px; color: var(--navStrong); line-height: 1.5;
  margin-bottom: 14px;
}
.callout svg { flex-shrink: 0; margin-top: 1px; }

/* ────────────────────────────────────────────
   FORM SECTIONS
──────────────────────────────────────────── */
.form-section { border: 1px solid var(--line); margin-bottom: 14px; }
.form-section-h {
  padding: 7px 12px;
  background: linear-gradient(180deg, var(--head), var(--pane2));
  border-bottom: 1px solid var(--line);
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 800;
  display: flex; align-items: center; gap: 8px;
}
.form-section-h .required-note {
  margin-left: auto; font-size: 10px; text-transform: none;
  letter-spacing: 0; color: var(--faint); font-weight: 400;
}
.form-section-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; }

.danger-zone { border: 1px solid color-mix(in srgb, var(--red) 30%, var(--line)); background: var(--pane); margin-bottom: 14px; }
.danger-zone .form-section-h {
  background: linear-gradient(180deg, color-mix(in srgb, var(--redSoft) 60%, var(--head)), color-mix(in srgb, var(--redSoft) 40%, var(--pane2)));
  color: var(--red);
}

/* ────────────────────────────────────────────
   FORM FIELDS
──────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted);
}
.field label .req  { color: var(--red); margin-left: 2px; }
.field label .hint { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--faint); font-size: 10px; margin-left: 2px; }
.field input,
.field select,
.field textarea {
  height: 30px; border: 1px solid var(--line);
  background: var(--pane); color: var(--text);
  padding: 0 8px; font-size: 13px; font-family: inherit;
  border-radius: 2px;
}
.field textarea { height: 64px; padding: 6px 8px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.field input.error, .field select.error { border-color: var(--red); }
.field-error { font-size: 11px; color: var(--red); display: none; }
.field-error.show { display: block; }
.field-hint { font-size: 11px; color: var(--faint); }

.grid-2   { display: grid; grid-template-columns: 1fr 1fr;     gap: 14px; }
.grid-3   { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr;     gap: 14px; }

.char-count { font-size: 10px; color: var(--faint); text-align: right; margin-top: 2px; }
.char-count.warn { color: var(--amber); }
.char-count.over { color: var(--red); }

/* Tag input */
.tag-wrap {
  display: flex; flex-wrap: wrap; gap: 5px; align-items: center;
  padding: 5px; border: 1px solid var(--line); background: var(--pane);
  min-height: 32px; cursor: text;
}
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; background: var(--head);
  border: 1px solid var(--line); font-size: 11px; border-radius: 3px;
}
.tag button { background: none; border: none; color: var(--muted); cursor: pointer; line-height: 1; padding: 0; font-size: 13px; }
.tag button:hover { color: var(--red); }
.tag-input { height: 22px; border: none; outline: none; font: inherit; font-size: 12px; flex: 1; min-width: 80px; }

/* Category selector */
.cats { display: flex; gap: 8px; flex-wrap: wrap; }
.cat {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 7px 12px; border: 1px solid var(--line);
  background: var(--pane2); font-size: 11px; cursor: pointer;
  border-radius: 2px; transition: all 150ms;
  font-family: inherit;
}
.cat:hover { background: var(--head); }
.cat.active { background: var(--blueSoft); border-color: var(--blue); color: var(--blue); font-weight: 700; }
.cat svg { width: 16px; height: 16px; }

/* Photo upload drop zone */
.photo-upload {
  border: 2px dashed var(--line); background: var(--pane2);
  height: 110px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 7px;
  color: var(--muted); font-size: 11px; cursor: pointer;
  border-radius: 2px; transition: background 150ms;
}
.photo-upload:hover { background: var(--blueSoft); border-color: var(--blue); }
.photo-upload input[type=file] { display: none; }

/* ────────────────────────────────────────────
   STICKY FORM FOOTER
──────────────────────────────────────────── */
.form-footer {
  position: sticky; bottom: 0;
  padding: 10px 20px;
  background: linear-gradient(180deg, var(--pane2), var(--head));
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-shrink: 0;
}
.form-footer .status  { font-size: 11px; color: var(--muted); }
.form-footer .spacer  { flex: 1; }
.form-footer .actions { display: flex; gap: 8px; }

/* ────────────────────────────────────────────
   MODE BADGE
──────────────────────────────────────────── */
.mode-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px; border-radius: 10px;
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em;
}
.mode-badge.edit { background: var(--amberSoft); color: var(--amber); border: 1px solid color-mix(in srgb, var(--amber) 30%, var(--line)); }
.mode-badge.add  { background: var(--greenSoft);  color: var(--green); border: 1px solid color-mix(in srgb, var(--green) 25%, var(--line)); }

/* ────────────────────────────────────────────
   SPINNER / LOADING STATE
──────────────────────────────────────────── */
@keyframes prepbox-spin { to { transform: rotate(360deg); } }
.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
  border-radius: 50%;
  animation: prepbox-spin .7s linear infinite;
  display: none;
}
.btn.loading .spinner { display: inline-block; }
.btn.loading .btn-label { display: none; }
.btn-signin.loading .spinner { display: block; }
.btn-signin.loading .btn-label { display: none; }

/* ────────────────────────────────────────────
   VERSION BADGE
──────────────────────────────────────────── */
.version-badge {
  position: fixed; bottom: 12px; right: 14px;
  font-size: 10px; color: var(--faint);
  background: var(--pane); border: 1px solid var(--line2);
  padding: 3px 8px;
}
