/* Trails Inventory Portal — style.css */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --grey: #94a3b8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --header-bg: #1e293b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}

html { font-size: 16px; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

/* ─── Auth Screen ─── */
#auth-screen {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--header-bg);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 1rem;
  color: #fff;
}
#auth-screen.hidden { display: none; }
#auth-screen h1 { font-size: 1.5rem; }
#auth-screen input {
  padding: .75rem 1rem; border-radius: 8px; border: none;
  font-size: 1rem; width: 240px; text-align: center;
  background: rgba(255,255,255,.15); color: #fff;
}
#auth-screen input::placeholder { color: rgba(255,255,255,.5); }
#auth-screen .error { color: var(--red); font-size: .875rem; min-height: 1.25rem; }
#auth-screen button {
  padding: .75rem 2rem; border-radius: 8px; border: none;
  background: var(--green); color: #fff; font-size: 1rem; font-weight: 600;
  cursor: pointer;
}

/* ─── Header ─── */
header {
  background: var(--header-bg); color: #fff;
  padding: .875rem 1rem; position: sticky; top: 0; z-index: 100;
}
header h1 { font-size: 1.125rem; font-weight: 700; }
.header-row { display: flex; align-items: center; justify-content: space-between; }
.refresh-btn {
  background: rgba(255,255,255,.15); border: none; color: #fff;
  padding: .375rem .75rem; border-radius: 6px; font-size: .875rem; cursor: pointer;
}
.refresh-btn:active { opacity: .7; }
.refresh-btn.spinning { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Search ─── */
.search-bar {
  padding: .5rem 1rem; background: var(--header-bg); position: sticky; top: 52px; z-index: 99;
}
.search-bar input {
  width: 100%; padding: .625rem .875rem; border-radius: 8px; border: none;
  font-size: .9375rem; background: rgba(255,255,255,.12); color: #fff;
}
.search-bar input::placeholder { color: rgba(255,255,255,.45); }

/* ─── Summary Bar ─── */
.summary-bar {
  display: flex; gap: .5rem; padding: .75rem 1rem; overflow-x: auto;
}
.summary-chip {
  flex-shrink: 0; padding: .375rem .75rem; border-radius: 20px;
  font-size: .8125rem; font-weight: 600; color: #fff;
}
.chip-total { background: var(--text-muted); }
.chip-out { background: var(--red); }
.chip-reorder { background: var(--amber); }

/* ─── Sections ─── */
.section { margin: .5rem; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); cursor: pointer; user-select: none;
  min-height: 48px;
}
.section-header h2 { font-size: .9375rem; font-weight: 700; }
.section-header .chevron {
  transition: transform .2s; font-size: .75rem; color: var(--text-muted);
}
.section-header.open .chevron { transform: rotate(90deg); }
.section-items {
  display: none; margin-top: 2px; border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}
.section-items.open { display: block; }

/* ─── Item Row ─── */
.item-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem; background: var(--card); border-bottom: 1px solid #f1f5f9;
  min-height: 52px; cursor: pointer; gap: .5rem;
}
.item-row:active { background: #f8fafc; }
.item-left { flex: 1; min-width: 0; }
.item-name {
  font-size: .875rem; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item-meta { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.item-right { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.item-qty { font-size: 1rem; font-weight: 700; }
.item-unit { font-size: .75rem; color: var(--text-muted); }

/* ─── Status Badge ─── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: .6875rem; font-weight: 700; white-space: nowrap;
}
.badge-ok { background: #dcfce7; color: #16a34a; }
.badge-reorder { background: #fef3c7; color: #d97706; }
.badge-out { background: #fee2e2; color: #dc2626; }
.badge-other { background: #f1f5f9; color: #64748b; }

/* ─── Drawer (Bottom Sheet) ─── */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 200;
  display: none; opacity: 0; transition: opacity .2s;
}
.overlay.visible { display: block; opacity: 1; }

.drawer {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 201;
  background: var(--card); border-radius: 16px 16px 0 0;
  padding: 1.25rem 1rem 2rem; max-height: 85dvh; overflow-y: auto;
  transform: translateY(100%); transition: transform .25s ease-out;
}
.drawer.visible { transform: translateY(0); }
.drawer-handle {
  width: 36px; height: 4px; background: #cbd5e1; border-radius: 2px;
  margin: 0 auto .75rem;
}
.drawer h3 { font-size: 1.0625rem; font-weight: 700; margin-bottom: .25rem; }
.drawer .current-info { color: var(--text-muted); font-size: .875rem; margin-bottom: 1rem; }

/* ─── Update Tabs ─── */
.update-tabs {
  display: flex; gap: .5rem; margin-bottom: 1rem;
}
.tab-btn {
  flex: 1; padding: .625rem; border-radius: 8px; border: 2px solid #e2e8f0;
  background: #fff; font-size: .875rem; font-weight: 600; cursor: pointer;
  text-align: center;
}
.tab-btn.active { border-color: var(--header-bg); background: var(--header-bg); color: #fff; }

.update-input {
  width: 100%; padding: .75rem; border-radius: 8px; border: 2px solid #e2e8f0;
  font-size: 1.25rem; text-align: center; margin-bottom: 1rem;
  -moz-appearance: textfield;
}
.update-input::-webkit-inner-spin-button,
.update-input::-webkit-outer-spin-button { -webkit-appearance: none; }

.confirm-btn {
  width: 100%; padding: .875rem; border-radius: 10px; border: none;
  background: var(--header-bg); color: #fff; font-size: 1rem; font-weight: 700;
  cursor: pointer;
}
.confirm-btn:disabled { opacity: .4; }
.confirm-btn:active:not(:disabled) { opacity: .8; }

/* ─── Delivery Mode ─── */
.delivery-fab {
  position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 50;
  background: var(--header-bg); color: #fff; border: none;
  padding: .75rem 1.125rem; border-radius: 28px; font-size: .9375rem;
  font-weight: 600; box-shadow: 0 4px 12px rgba(0,0,0,.2); cursor: pointer;
}
.delivery-fab:active { transform: scale(.95); }

#delivery-screen {
  position: fixed; inset: 0; z-index: 300; background: var(--bg);
  display: none; flex-direction: column;
}
#delivery-screen.visible { display: flex; }
.delivery-header {
  background: var(--header-bg); color: #fff; padding: .875rem 1rem;
  display: flex; align-items: center; justify-content: space-between;
}
.delivery-header h2 { font-size: 1.0625rem; font-weight: 700; }
.delivery-close {
  background: rgba(255,255,255,.15); border: none; color: #fff;
  padding: .375rem .75rem; border-radius: 6px; font-size: .875rem; cursor: pointer;
}
.supplier-list { padding: .75rem; display: flex; flex-direction: column; gap: .5rem; }
.supplier-btn {
  padding: 1rem; background: var(--card); border: 2px solid #e2e8f0;
  border-radius: var(--radius); font-size: 1rem; font-weight: 600;
  text-align: left; cursor: pointer; min-height: 52px;
}
.supplier-btn:active { border-color: var(--header-bg); }

.delivery-items { flex: 1; overflow-y: auto; padding: .75rem; }
.delivery-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem; background: var(--card); border-radius: 10px;
  margin-bottom: .5rem; min-height: 52px;
}
.delivery-item-name { font-size: .875rem; font-weight: 500; flex: 1; }
.delivery-item-unit { font-size: .75rem; color: var(--text-muted); margin-left: .25rem; }
.delivery-qty-input {
  width: 72px; padding: .5rem; border: 2px solid #e2e8f0; border-radius: 8px;
  font-size: 1rem; text-align: center; -moz-appearance: textfield;
}
.delivery-qty-input::-webkit-inner-spin-button,
.delivery-qty-input::-webkit-outer-spin-button { -webkit-appearance: none; }

.delivery-footer {
  padding: 1rem; border-top: 1px solid #e2e8f0; background: var(--card);
}
.apply-delivery-btn {
  width: 100%; padding: .875rem; border-radius: 10px; border: none;
  background: var(--green); color: #fff; font-size: 1rem; font-weight: 700;
  cursor: pointer;
}
.apply-delivery-btn:disabled { opacity: .4; }

/* ─── Toast ─── */
.toast {
  position: fixed; bottom: 5rem; left: 50%; transform: translateX(-50%);
  background: var(--header-bg); color: #fff; padding: .625rem 1.25rem;
  border-radius: 10px; font-size: .875rem; font-weight: 500; z-index: 500;
  opacity: 0; transition: opacity .3s; pointer-events: none;
  max-width: 90vw; text-align: center;
}
.toast.visible { opacity: 1; }

/* ─── Loading ─── */
.loading-spinner {
  display: flex; align-items: center; justify-content: center;
  padding: 3rem; color: var(--text-muted); font-size: .875rem;
}

/* ─── Empty state ─── */
.empty-state {
  text-align: center; padding: 3rem 1rem; color: var(--text-muted);
  font-size: .875rem;
}

/* ─── Delivery summary ─── */
.delivery-summary {
  padding: 1rem; background: var(--card); border-radius: var(--radius);
  margin: .75rem;
}
.delivery-summary h3 { margin-bottom: .5rem; }
.delivery-summary li {
  list-style: none; padding: .25rem 0; font-size: .875rem;
}
