/* Merchant Stock Management System */
:root {
  --brand: #1a237e;
  --brand-light: #e8eaf6;
  --bottom-nav-h: 64px;
}

body {
  background-color: #f5f6fa;
  font-size: 0.9rem;
}

.navbar {
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.merchant-dashboard-logo {
  height: 36px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  border-radius: 4px;
  vertical-align: middle;
}

/* ═══════════════════════════════════════════════════════
   TWO-LAYER APP HEADER
   ═══════════════════════════════════════════════════════ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
}

/* Layer 1 — utility bar: brand, search, notifications, account/logout */
.app-header-top {
  background: linear-gradient(90deg, var(--brand) 0%, #283593 100%);
  padding: .5rem 0;
}

.app-brand {
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .4rem;
  white-space: nowrap;
}
.app-brand:hover { color: #fff; opacity: .9; }
.app-brand-logo {
  height: 28px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  border-radius: 3px;
}

.app-nav-toggler {
  border: none;
  margin-left: .6rem;
  padding: .3rem .5rem;
}
.app-nav-toggler:focus { box-shadow: none; }

.app-search {
  align-items: center;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 20px;
  padding: .32rem 1rem;
  margin-left: 1.5rem;
  gap: .55rem;
  transition: background .15s, border-color .15s;
}
.app-search:focus-within {
  background: rgba(255,255,255,.22);
  border-color: rgba(255,255,255,.55);
}
.app-search i { color: rgba(255,255,255,.8); font-size: .85rem; }
.app-search input {
  background: transparent;
  border: none;
  color: #fff;
  outline: none;
  width: 190px;
  font-size: .85rem;
}
.app-search input::placeholder { color: rgba(255,255,255,.7); }

.app-header-actions { gap: .3rem; }

.app-icon-btn {
  color: #fff;
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem;
  text-decoration: none;
  transition: background .15s;
  flex-shrink: 0;
}
.app-icon-btn:hover { background: rgba(255,255,255,.16); color: #fff; }

.app-badge-dot {
  position: absolute;
  top: 1px; right: 1px;
  background: #ff5252;
  color: #fff;
  font-size: .6rem;
  font-weight: 800;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
  border: 2px solid #1a237e;
}

.app-user-menu .dropdown-toggle::after { color: rgba(255,255,255,.7); margin-left: .5rem; vertical-align: middle; }
.app-user-toggle {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .28rem .7rem .28rem .3rem;
  border-radius: 24px;
  color: #fff;
  text-decoration: none;
  transition: background .15s;
}
.app-user-toggle:hover { background: rgba(255,255,255,.14); color: #fff; }
.app-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.4);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.app-user-info { flex-direction: column; line-height: 1.15; text-align: left; }
.app-user-name { font-size: .82rem; font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-user-role { font-size: .66rem; color: rgba(255,255,255,.72); text-transform: uppercase; letter-spacing: .04em; }

/* Layer 2 — module navigation */
.app-header-nav {
  background: #151c66;
  padding: 0;
}
.app-nav-pills {
  gap: .15rem;
  padding: .3rem .25rem;
}
.app-nav-pills .nav-link {
  color: rgba(255,255,255,.9) !important;
  font-size: .82rem;
  font-weight: 500;
  padding: .4rem .7rem !important;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: .35rem;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.app-nav-pills .nav-link:hover,
.app-nav-pills .nav-link:focus,
.app-nav-pills .show > .nav-link {
  background: rgba(255,255,255,.16);
  color: #fff !important;
}
.app-nav-pills .dropdown-menu {
  border: none;
  box-shadow: 0 10px 28px rgba(0,0,0,.2);
  border-radius: 10px;
  margin-top: .4rem;
}

@media (max-width: 991px) {
  .app-nav-pills { flex-direction: column; padding: .5rem .25rem; }
  .app-nav-pills .nav-link { padding: .6rem .7rem !important; }
}

/* Cards */
.card {
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  border-radius: 8px;
}
.card-header {
  background: #fff;
  border-bottom: 1px solid #eee;
  border-radius: 8px 8px 0 0 !important;
  padding: .6rem 1rem;
}

/* Tables */
.table th {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
  color: #666;
}

/* Form controls */
.form-control, .form-select {
  border-radius: 6px;
  font-size: .875rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 .2rem rgba(26,35,126,.15);
}

/* Signature canvas */
#signature-canvas {
  background: #fff;
  border: 2px dashed #adb5bd;
  border-radius: 8px;
  display: block;
  width: 100%;
  height: 150px;
}

/* PWA install prompt */
#pwaInstallBanner {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  min-width: 300px;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
}

/* Badge colors */
.badge.bg-warning { color: #000 !important; }

/* Status color helpers */
.status-paid { color: #198754; }
.status-pending { color: #6c757d; }
.status-rejected, .status-unpaid { color: #dc3545; }

/* ═══════════════════════════════════════════════════════
   MOBILE BOTTOM NAVIGATION BAR
   ═══════════════════════════════════════════════════════ */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 991px) {
  /* Show bottom nav on tablet + phone */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottom-nav-h);
    background: #fff;
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -2px 12px rgba(0,0,0,.12);
    z-index: 1040;
    align-items: stretch;
  }

  .mobile-bottom-nav .mbn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: #888;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .2px;
    padding: 6px 4px;
    border: none;
    background: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color .15s, background .15s;
    position: relative;
  }

  .mobile-bottom-nav .mbn-item i {
    font-size: 22px;
    line-height: 1;
  }

  .mobile-bottom-nav .mbn-item.active {
    color: var(--brand);
  }

  .mobile-bottom-nav .mbn-item.active::after {
    content: '';
    position: absolute;
    top: 0; left: 20%; right: 20%;
    height: 3px;
    background: var(--brand);
    border-radius: 0 0 3px 3px;
  }

  .mobile-bottom-nav .mbn-item:active {
    background: var(--brand-light);
  }

  .mobile-bottom-nav .mbn-badge {
    position: absolute;
    top: 6px; right: calc(50% - 18px);
    background: #dc3545;
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
  }

  /* Primary action button (centre FAB) */
  .mobile-bottom-nav .mbn-fab {
    flex: 0 0 56px;
    align-self: center;
    margin: 0 4px;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff !important;
    box-shadow: 0 4px 14px rgba(26,35,126,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    flex-direction: column;
    gap: 0;
  }

  .mobile-bottom-nav .mbn-fab i { font-size: 26px; }
  .mobile-bottom-nav .mbn-fab span { font-size: 9px; display: none; }

  /* Push page content above bottom nav */
  main.container-fluid {
    padding-bottom: calc(var(--bottom-nav-h) + 16px) !important;
  }

  /* Navbar: collapse menu taller and easier to tap */
  .navbar-nav .nav-link {
    padding: 10px 16px !important;
    font-size: 15px !important;
  }
  .dropdown-item {
    padding: 10px 20px !important;
    font-size: 14px !important;
  }

  /* General mobile layout */
  main.container-fluid {
    padding: .75rem .5rem;
  }
  .card-body { padding: .875rem; }
  h4 { font-size: 1.1rem; }

  /* Touch-friendly action buttons: minimum 44px tall */
  .btn {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
  }
  .btn-sm { min-height: 36px; }

  /* Make table action buttons bigger */
  .btn.btn-xs, .btn-xs { min-height: 32px; padding: 4px 10px !important; }
}

/* ═══════════════════════════════════════════════════════
   MOBILE CARD-LIST — replaces tables on small screens
   ═══════════════════════════════════════════════════════ */
.mobile-card-list { display: none; }

@media (max-width: 767px) {
  .mobile-card-list { display: block; }
  .desktop-table { display: none !important; }
}

.m-row {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  padding: 12px 14px;
  margin-bottom: 8px;
  position: relative;
}

.m-row .m-row-title {
  font-size: 15px;
  font-weight: 700;
  color: #1a237e;
  margin-bottom: 4px;
}

.m-row .m-row-sub {
  font-size: 12px;
  color: #666;
  margin-bottom: 6px;
}

.m-row .m-row-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}

.m-row .m-row-chip {
  font-size: 11px;
  background: #f0f0f0;
  border-radius: 12px;
  padding: 2px 8px;
  color: #444;
  white-space: nowrap;
}

.m-row .m-row-amount {
  font-size: 17px;
  font-weight: 800;
  color: #1a237e;
}

.m-row .m-row-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.m-row .m-row-actions .btn {
  flex: 1;
  min-width: 80px;
  font-size: 13px;
}

.m-row .m-row-time {
  position: absolute;
  top: 12px; right: 14px;
  font-size: 11px;
  color: #999;
  text-align: right;
}

/* Status dots */
.m-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
  vertical-align: middle;
  flex-shrink: 0;
}
.m-dot-pending  { background: #f59e0b; }
.m-dot-success  { background: #16a34a; }
.m-dot-danger   { background: #dc2626; }
.m-dot-info     { background: #0ea5e9; }

/* ═══════════════════════════════════════════════════════
   MOBILE KPI CARDS
   ═══════════════════════════════════════════════════════ */
@media (max-width: 575px) {
  .kpi-card .card-body {
    padding: .625rem .75rem;
  }
  .kpi-card .kpi-num {
    font-size: 1.6rem !important;
  }
  .kpi-card .kpi-icon {
    font-size: 1.4rem !important;
  }
}

/* ═══════════════════════════════════════════════════════
   MOBILE FILTER DRAWER
   ═══════════════════════════════════════════════════════ */
.filter-drawer-toggle {
  display: none;
}

@media (max-width: 767px) {
  .filter-drawer-toggle {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--brand);
    margin-bottom: 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .filter-drawer {
    display: none;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 8px;
  }
  .filter-drawer.open { display: block; }
  .filter-desktop { display: none !important; }
}

@media (min-width: 768px) {
  .filter-drawer-toggle { display: none !important; }
  .filter-drawer { display: block !important; }
}

/* ═══════════════════════════════════════════════════════
   PRODUCT CARDS
   ═══════════════════════════════════════════════════════ */
.product-card {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.10);
  background: #fff;
  transition: transform .18s, box-shadow .18s;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.product-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,.15);
}

/* Top border accent */
.product-card-instore  { border-top: 3px solid #16a34a; }
.product-card-outstore { border-top: 3px solid #0ea5e9; }

/* Image area */
.product-card-img {
  position: relative;
  width: 100%;
  height: 130px;
  overflow: hidden;
  background: #f3f4f6;
}
.product-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Placeholder when no image */
.product-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.product-card-placeholder i {
  font-size: 3.5rem;
  opacity: .55;
}
.placeholder-green {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  color: #065f46;
}
.placeholder-blue {
  background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
  color: #0369a1;
}

/* Category badge overlaid on image */
.product-card-badge {
  position: absolute;
  bottom: 7px;
  left: 7px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: .2px;
  backdrop-filter: blur(4px);
}
.badge-instore  { background: rgba(22,163,74,.88); color: #fff; }
.badge-outstore { background: rgba(14,165,233,.88); color: #fff; }

/* Low stock warning overlaid on image */
.product-card-low-stock {
  position: absolute;
  top: 7px;
  right: 7px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(220,38,38,.88);
  color: #fff;
  padding: 2px 7px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
}

/* Info section */
.product-card-body {
  padding: 10px 12px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.product-card-name {
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.product-card-price {
  font-size: 15px;
  font-weight: 800;
  color: #1a237e;
  letter-spacing: -.2px;
}
.product-card-stock {
  font-size: 11px;
  color: #64748b;
  margin-top: auto;
}
.product-card-stock.stock-low { color: #dc2626; font-weight: 600; }
.product-card-value {
  font-size: 11px;
  color: #16a34a;
  padding-top: 3px;
  margin-top: 3px;
  border-top: 1px dashed #e2e8f0;
}
.product-card-value strong { font-size: 12px; }

@media (max-width: 400px) {
  .product-card-img { height: 110px; }
  .product-card-placeholder i { font-size: 2.8rem; }
}

/* ═══════════════════════════════════════════════════════
   PULL-TO-REFRESH HINT
   ═══════════════════════════════════════════════════════ */
.ptr-hint {
  text-align: center;
  font-size: 12px;
  color: #aaa;
  padding: 4px 0 8px;
  display: none;
}
@media (max-width: 767px) {
  .ptr-hint { display: block; }
}
