/* ═══════════════════════════════════════════════════════
   GableOps WMS — app.css
   ═══════════════════════════════════════════════════════ */

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

:root {
  --navy:    #0d1f35;
  --navy2:   #1a3a5c;
  --teal:    #00c9a7;
  --teal2:   #00a589;
  --amber:   #f5a623;
  --coral:   #e85d42;
  --white:   #ffffff;
  --off:     #f0f4f8;
  --light:   #f8fafc;
  --gray:    #8a9ab5;
  --text:    #0d1f35;
  --textsm:  #6b82a0;
  --border:  rgba(13,31,53,0.1);
  --sans:    'DM Sans', system-ui, sans-serif;
  --display: 'Syne', sans-serif;
  --radius:  14px;
  --nav-h:   60px;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--navy);
  font-family: var(--sans);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ── Root Layout ─────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ── Header ──────────────────────────────────────────── */
#header {
  flex-shrink: 0;
  background: var(--navy);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: 16px;
  padding-right: 16px;
  padding-bottom: 12px;
  min-height: calc(56px + env(safe-area-inset-top, 0px));
}

.logo { display: flex; align-items: center; gap: 10px; }
.logo-mark { width: 36px; height: 36px; flex-shrink: 0; }
.logo-text {
  font-family: var(--display);
  font-size: 19px;
  font-weight: 800;
  color: var(--white);
  letter-spacing: -0.02em;
}
.logo-text span { color: var(--teal); }

.header-right { display: flex; align-items: center; gap: 10px; }

.sync-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}
.sync-dot.offline  { background: var(--gray); }
.sync-dot.syncing  { background: var(--amber); animation: pulse 1s infinite; }
.sync-dot.online   { background: var(--teal); box-shadow: 0 0 6px var(--teal); }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

.btn-connect {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  color: var(--white);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: background .15s;
}
.btn-connect:active { background: rgba(255,255,255,.18); }
.btn-connect.connected {
  background: rgba(0,201,167,.15);
  border-color: var(--teal);
  color: var(--teal);
}

/* ── Pages Container ─────────────────────────────────── */
#pages {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: var(--off);
}

/* ── Individual Pages ────────────────────────────────── */
.page {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px 20px;
  background: var(--off);
}
.page.active { display: flex; }

.form-page { display: flex; flex-direction: column; gap: 12px; }
.page-title {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  padding: 2px 0 4px;
}

/* ── Bottom Nav ──────────────────────────────────────── */
#nav {
  flex-shrink: 0;
  background: var(--navy);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid rgba(255,255,255,.07);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--gray);
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 500;
  transition: color .15s;
  padding: 8px 4px;
}
.nav-item svg { width: 22px; height: 22px; stroke: var(--gray); transition: stroke .15s; }
.nav-item:active { opacity: .6; }
.nav-item.active { color: var(--teal); }
.nav-item.active svg { stroke: var(--teal); }

/* ── Search Bar ──────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--white);
  border-radius: 12px;
  padding: 11px 14px;
  box-shadow: 0 1px 4px rgba(13,31,53,.06);
  flex-shrink: 0;
}
.search-bar svg { width: 18px; height: 18px; stroke: var(--gray); flex-shrink: 0; }
.search-bar input {
  flex: 1; border: none; outline: none;
  font-family: var(--sans); font-size: 15px; color: var(--text);
  background: transparent;
}
.search-bar input::placeholder { color: var(--gray); }

/* ── Filter Chips ────────────────────────────────────── */
.chip-row {
  display: flex; gap: 6px; flex-shrink: 0;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; padding-bottom: 2px;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--white);
  font-family: var(--sans);
  font-size: 12px; font-weight: 600;
  color: var(--textsm);
  cursor: pointer; white-space: nowrap;
  transition: all .15s;
}
.chip.active { background: var(--navy); color: var(--white); border-color: var(--navy); }
.chip span { opacity: .7; margin-left: 3px; }

/* ── List ────────────────────────────────────────────── */
.list-wrap {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(13,31,53,.06);
  flex: 1;
}

.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s;
}
.list-row:last-child { border-bottom: none; }
.list-row:active { background: var(--off); }

.list-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.list-body { flex: 1; min-width: 0; }
.list-title {
  font-weight: 600; font-size: 14px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-sub {
  font-size: 12px; color: var(--textsm); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }

/* ── Inventory Cards ─────────────────────────────────── */
.inv-card {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s;
}
.inv-card:last-child { border-bottom: none; }
.inv-card:active { background: var(--off); }

.inv-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.inv-sku { font-size: 11px; color: var(--textsm); font-weight: 600; letter-spacing: .04em; }
.inv-name {
  font-weight: 600; font-size: 14px; color: var(--text); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px;
}
.inv-cat { font-size: 11px; color: var(--textsm); margin-top: 1px; }

.bin-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.bin-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
  background: rgba(13,31,53,.06); color: var(--navy);
}
.bin-chip.zero { background: rgba(232,93,66,.1); color: var(--coral); }

/* ── Pills ───────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 20px;
  white-space: nowrap;
}
.pill-ok  { background: rgba(0,201,167,.12); color: #00776b; }
.pill-low { background: rgba(245,166,35,.15); color: #7a5000; }
.pill-out { background: rgba(232,93,66,.12); color: #922b21; }

/* ── Form Elements ───────────────────────────────────── */
.field-group { display: flex; flex-direction: column; gap: 5px; }
.field-group label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--textsm); }
.opt { font-weight: 400; text-transform: none; letter-spacing: 0; opacity: .7; }

.field-input {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  font-family: var(--sans); font-size: 15px; color: var(--text);
  outline: none; width: 100%;
  -webkit-appearance: none;
  transition: border-color .15s;
}
.field-input:focus { border-color: var(--teal); }
.field-input::placeholder { color: var(--gray); }
textarea.field-input { resize: none; line-height: 1.5; }

/* ── Stepper ─────────────────────────────────────────── */
.stepper {
  display: flex; align-items: center;
  background: var(--white); border: 1.5px solid var(--border);
  border-radius: 10px; overflow: hidden; height: 48px;
}
.step-btn {
  width: 56px; height: 100%;
  border: none; background: var(--off);
  font-size: 22px; color: var(--navy);
  cursor: pointer; flex-shrink: 0;
  transition: background .12s;
}
.step-btn:active { background: var(--border); }
.step-val {
  flex: 1; text-align: center;
  font-family: var(--display); font-size: 22px; font-weight: 800;
  color: var(--navy); border: none; outline: none;
  background: transparent; -moz-appearance: textfield;
}
.step-val::-webkit-inner-spin-button,
.step-val::-webkit-outer-spin-button { -webkit-appearance: none; }

/* ── SKU Lookup ──────────────────────────────────────── */
.sku-wrap { position: relative; }
.suggestions {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--white); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(13,31,53,.15);
  z-index: 50; max-height: 240px; overflow-y: auto;
  display: none;
}
.suggestions.open { display: block; }
.sug-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .12s;
}
.sug-row:last-child { border-bottom: none; }
.sug-row:active { background: var(--off); }
.sug-sku { font-size: 11px; color: var(--textsm); font-weight: 600; }
.sug-name { font-size: 14px; font-weight: 600; color: var(--text); }
.sug-stock { font-size: 12px; color: var(--textsm); flex-shrink: 0; margin-left: 8px; }

/* ── SKU Info Bar ────────────────────────────────────── */
.sku-info {
  background: rgba(0,201,167,.07);
  border: 1px solid rgba(0,201,167,.25);
  border-radius: 10px; padding: 10px 13px;
}
.sku-info-name { font-weight: 700; font-size: 13px; color: var(--text); }
.sku-info-bins { font-size: 12px; color: var(--textsm); margin-top: 3px; }

/* ── Bin Selector ────────────────────────────────────── */
.bin-list {
  background: var(--white); border-radius: 10px;
  overflow: hidden; box-shadow: 0 1px 4px rgba(13,31,53,.06);
}
.bin-list .bin-label {
  font-size: 10px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--textsm);
  padding: 8px 14px 4px;
}
.bin-option {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-top: 1px solid var(--border);
  cursor: pointer; transition: background .12s;
}
.bin-option:active { background: var(--off); }
.bin-option.selected { background: rgba(0,201,167,.07); }
.bin-loc { font-family: var(--display); font-size: 15px; font-weight: 800; color: var(--navy); }
.bin-avail { font-size: 12px; color: var(--textsm); margin-top: 2px; }
.bin-qty { font-family: var(--display); font-size: 20px; font-weight: 800; color: var(--teal); }



/* ── Buttons ─────────────────────────────────────────── */
.btn-primary, .btn-coral, .btn-ghost {
  width: 100%; padding: 14px;
  border-radius: 12px; border: none;
  font-family: var(--sans); font-size: 15px; font-weight: 700;
  cursor: pointer; transition: opacity .15s, transform .1s;
}
.btn-primary:active, .btn-coral:active, .btn-ghost:active {
  opacity: .8; transform: scale(.98);
}
.btn-primary:disabled, .btn-coral:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--teal);  color: var(--navy); }
.btn-coral   { background: var(--coral); color: var(--white); }
.btn-ghost   { background: var(--off); color: var(--textsm); border: 1.5px solid var(--border); }

/* ── Photo Grid ──────────────────────────────────────── */
.photo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.photo-thumb {
  background: var(--white); border-radius: 10px;
  overflow: hidden; aspect-ratio: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-size: 11px; color: var(--textsm); text-align: center;
  padding: 8px; box-shadow: 0 1px 4px rgba(13,31,53,.06);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }

.upload-zone {
  border: 2px dashed var(--border); border-radius: 12px;
  padding: 28px 20px; text-align: center;
  cursor: pointer; transition: border-color .15s, background .15s;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.upload-zone svg { width: 36px; height: 36px; stroke: var(--gray); }
.upload-zone:active { border-color: var(--teal); background: rgba(0,201,167,.04); }
.uz-title { font-weight: 700; font-size: 14px; color: var(--text); }
.uz-sub   { font-size: 12px; color: var(--textsm); }

/* ── Empty State ─────────────────────────────────────── */
.empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px; padding: 48px 24px;
  text-align: center; color: var(--textsm); font-size: 14px;
}
.empty-icon { font-size: 40px; }

/* ── Bottom Sheet ────────────────────────────────────── */
.sheet-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 100;
  display: none;
}
.sheet-bg.open { display: block; }
.sheet-box {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--white); border-radius: 20px 20px 0 0;
  z-index: 101; max-height: 85vh; display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform .25s ease;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sheet-box.open { transform: translateY(0); }
.sheet-handle { width: 36px; height: 4px; background: var(--border); border-radius: 2px; margin: 12px auto 6px; flex-shrink: 0; }
.sheet-body { flex: 1; overflow-y: auto; padding: 8px 16px 24px; }

/* ── Modal ───────────────────────────────────────────── */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6); z-index: 200;
  display: none; align-items: center; justify-content: center; padding: 24px;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--white); border-radius: 20px; width: 100%;
  max-width: 360px; padding: 24px; display: flex; flex-direction: column; gap: 12px;
  animation: modalIn .2s ease;
}
@keyframes modalIn { from{opacity:0;transform:scale(.95)} to{opacity:1;transform:scale(1)} }
.modal-title { font-family: var(--display); font-size: 17px; font-weight: 800; color: var(--navy); }

/* ── Toast ───────────────────────────────────────────── */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 12px);
  left: 50%; transform: translateX(-50%) translateY(10px);
  background: var(--navy); color: var(--white);
  font-size: 13px; font-weight: 600; padding: 10px 18px;
  border-radius: 20px; white-space: nowrap;
  opacity: 0; transition: opacity .2s, transform .2s;
  pointer-events: none; z-index: 999;
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok  { background: var(--teal); color: var(--navy); }
.toast.err { background: var(--coral); color: var(--white); }

/* ── Sheet detail rows ───────────────────────────────── */
.sheet-title { font-family: var(--display); font-size: 16px; font-weight: 800; color: var(--navy); margin-bottom: 12px; }
.detail-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.detail-row:last-child { border-bottom: none; }
.detail-key { color: var(--textsm); }
.detail-val { font-weight: 600; color: var(--text); }


/* ── Section Heading (sheet) ─────────────────────────── */
.section-heading {
  font-weight: 700; font-size: 13px; color: var(--text);
  margin: 16px 0 8px; padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ── SKU Photo Grid (in bottom sheet) ───────────────────*/
.sku-photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 4px;
}
.sku-photo-loading,
.sku-photo-empty {
  grid-column: 1 / -1;
  font-size: 12px; color: var(--textsm);
  text-align: center; padding: 16px 0;
  font-style: italic;
}
.sku-photo-thumb {
  border-radius: 8px; overflow: hidden;
  background: var(--off);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  aspect-ratio: 1; position: relative;
}
.sku-photo-thumb img {
  width: 100%; height: 100%; object-fit: cover;
}
.sku-photo-thumb.drive-link,
.sku-photo-thumb.pending {
  background: var(--off); text-align: center; padding: 6px;
}
.drive-icon {
  font-size: 22px; margin-bottom: 4px;
}
.sku-photo-note {
  font-size: 9px; color: var(--textsm);
  text-align: center; padding: 0 4px;
  overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; width: 100%;
}
.sku-photo-date {
  font-size: 9px; color: var(--gray);
  text-align: center; padding-bottom: 4px;
}

/* ── Utility ─────────────────────────────────────────── */
.hidden { display: none !important; }
