/* ============================================================
   Goal Cotts Godwon – Custom Stylesheet
   Mobile-first, matching the app screenshots
   ============================================================ */

:root {
  --primary:    #4F46E5;
  --primary-dk: #3730A3;
  --bg:         #F2F2F7;
  --card-bg:    #FFFFFF;
  --border:     #E5E7EB;
  --text:       #111827;
  --muted:      #6B7280;
  --header-h:   56px;
  --nav-h:      55px;
  --radius:     6px;
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
}

/* ── Fixed Header ─────────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  z-index: 1000;
}

.header-brand {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  margin-left: 4px;
}
.header-brand span { font-weight: 700; font-size: 1.05rem; }
.header-brand small { font-size: .72rem; color: var(--muted); }

.btn-icon {
  background: none;
  border: none;
  padding: 8px;
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
}
.btn-icon:hover { background: var(--bg); }

/* ── Main Content ─────────────────────────────────────────── */
.app-content {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  bottom: var(--nav-h);
  overflow: hidden;
}

/* ── Pages ────────────────────────────────────────────────── */
.app-page {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  -ms-overflow-style: none;
  scrollbar-width: none;
  background: var(--bg);
  display: none;
}
.app-page::-webkit-scrollbar { display: none; }
.app-page.active { display: block; }

.overlay-page {
  z-index: 100;
  background: var(--bg);
}

.page-inner { min-height: 100%; }

/* ── Bottom Navigation ────────────────────────────────────── */
.app-bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 1000;
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* gap: 3px; */
  background: none;
  border: none;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 0;
  transition: color .2s;
}
.nav-tab i { font-size: 1.25rem; }
.nav-tab.active { color: var(--primary); font-weight: 700; }

/* ── Segmented Control ────────────────────────────────────── */
.seg-control {
  display: flex;
  background: #E5E7EB;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.seg-control-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-wrap: nowrap;
  scrollbar-width: none;
}
.seg-control-scroll::-webkit-scrollbar { display: none; }
.seg-control-scroll .seg-btn { flex-shrink: 0; }
.seg-btn {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 7px 0;
  font-size: .82rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: background .2s, color .2s;
  white-space: nowrap;
}
.seg-btn.active {
  background: #fff;
  color: var(--text);
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0,0,0,.12);
}

/* ── Search Bar ───────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  gap: 8px;
}
.search-bar i { color: var(--muted); font-size: 1rem; }
.search-bar input {
  border: none;
  outline: none;
  flex: 1;
  font-size: .9rem;
  background: transparent;
  color: var(--text);
}
.search-bar input::placeholder { color: var(--muted); }

/* ── Cards ────────────────────────────────────────────────── */
.dispatch-card .card-edit-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: var(--primary);
  font-size: 1.05rem;
  padding: 2px 4px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1;
}
.dispatch-card .card-edit-btn:hover { background: #EEF2FF; }

.dispatch-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  border: solid 1px #e1e1e1;
}
.dispatch-card .party-name { font-weight: 700; font-size: .95rem; margin-bottom: 2px; }
.dispatch-card .order-date { font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
.dispatch-card .item-row   { display: flex; gap: 12px; align-items: baseline; margin-bottom: 4px; border-bottom: 1px solid #e1e1e1; justify-content: space-between; }
.dispatch-card .item-name  { font-weight: 700; min-width: 60px; font-size: .85rem; }
.dispatch-card .item-sku   { color: var(--muted); font-size: .8rem; flex: 1; }
.dispatch-card .item-qty   { font-size: .8rem; white-space: nowrap; }

/* ── Stock Card ───────────────────────────────────────────── */
.stock-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 6px 8px;
  margin-bottom: 5px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: box-shadow .2s;
  border: solid 1px #e1e1e1;
}
.stock-card:active { box-shadow: 0 0 0 2px var(--primary); }
.stock-card img {
  width: 52px; height: 52px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg);
  flex-shrink: 0;
}
.stock-card .img-placeholder {
  width: 52px; height: 52px;
  border-radius: 8px;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stock-card .card-info { flex: 1; min-width: 0; }
.stock-card .fabric-name { font-weight: 700; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stock-card .group-name  { font-size: .75rem; color: var(--primary); }
.stock-card .qty-text    { font-weight: 700; font-size: .85rem; }
.stock-card .qty-unit    { font-size: .75rem; color: var(--muted); }
.stock-card .sku-code    { font-size: .75rem; color: var(--muted); text-align: right; white-space: nowrap; }

/* ── Master List ──────────────────────────────────────────── */
.master-item {
  background: #fff;
  border-radius: 10px;
  padding: 8px 11px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  border: solid 1px #e1e1e1;
}
.master-item .item-name { font-size: .9rem; font-weight: 600; }
.master-item .btn-del {
  background: none;
  border: none;
  color: #DC2626;
  font-size: 1rem;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 6px;
}

/* ── Entry Form – Item Row ────────────────────────────────── */
.entry-item-block {
  background: #fff;
  border-radius: var(--radius);
  padding: 6px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  position: relative;
}
.entry-item-block .item-fields {
  display: grid;
  grid-template-columns: 1fr 80px 70px 100px;
  gap: 6px;
  align-items: start;
}
.entry-item-block .item-fields > * {
  min-width: 0;
}
.entry-item-block .stock-hint {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: .9rem;
  color: var(--muted);
}
.entry-item-block .stock-total {
  font-weight: 700;
  color: var(--text);
}

/* ── Inventory Table ──────────────────────────────────────── */
.inv-table {
  min-width: 560px;
  font-size: .8rem;
}
.inv-table thead th {
  background: #F9FAFB;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: .65rem;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  white-space: nowrap;
}
.inv-table tbody td { padding: 9px 10px; border-bottom: 1px solid #F3F4F6; vertical-align: middle; }
.badge-in  { background: #D1FAE5; color: #065F46; font-size: .7rem; font-weight: 600; padding: 2px 7px; border-radius: 20px; }
.badge-out { background: #FEE2E2; color: #991B1B; font-size: .7rem; font-weight: 600; padding: 2px 7px; border-radius: 20px; }

/* ── SKU Detail – Godown Allocation ──────────────────────── */
.godown-alloc-row { margin-bottom: 12px; }
.godown-alloc-row .gd-name { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: 4px; }
.godown-alloc-row .gd-name span:last-child { font-weight: 700; }
.godown-alloc-row .progress { height: 6px; border-radius: 4px; background: #E5E7EB; }
.godown-alloc-row .progress-bar { background: var(--primary); border-radius: 4px; }

/* ── SKU Ledger Entry ─────────────────────────────────────── */
.ledger-entry {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.ledger-entry:last-child { border-bottom: none; }
.ledger-entry .le-party { font-weight: 700; font-size: .85rem; }
.ledger-entry .le-ref   { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.ledger-entry .le-qty   { font-weight: 700; font-size: .9rem; text-align: right; white-space: nowrap; }
.ledger-entry .le-qty.in  { color: #059669; }
.ledger-entry .le-qty.out { color: #DC2626; }
.ledger-entry .le-godown  { font-size: .7rem; color: var(--muted); }

/* ── Autocomplete ─────────────────────────────────────────── */
.autocomplete-list {
  position: absolute;
  z-index: 500;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  max-height: 200px;
  overflow-y: auto;
  width: 100%;
}
.autocomplete-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: .88rem;
  border-bottom: 1px solid #F3F4F6;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--bg); }

/* ── Login Page ───────────────────────────────────────────── */
.login-body {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.login-wrapper { width: 100%; max-width: 380px; padding: 20px; }
.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
}
.login-logo {
  width: 64px; height: 64px;
  background: var(--primary);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto;
  color: #fff;
  font-size: 1.8rem;
}

/* ── Utility ──────────────────────────────────────────────── */
.text-primary { color: var(--primary) !important; }
.btn-primary  { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dk); border-color: var(--primary-dk); }
.spinner-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000;
}

@media (max-width: 576px) {
  .entry-item-block .item-fields {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
  }
  .entry-item-block .item-fields > :first-child {
    grid-column: 1 / -1;
  }
  .entry-item-block {
    overflow-x: hidden;
  }
}
