/* BL Office Promo Inventory — Styles */
/* Mobile-first */

:root {
  --blue:       #1a56db;
  --blue-dark:  #1e429f;
  --blue-light: #ebf5ff;
  --green:      #057a55;
  --green-light:#f3faf7;
  --red:        #c81e1e;
  --red-light:  #fdf2f2;
  --orange:     #b45309;
  --orange-light:#fffbeb;
  --gray-50:    #f9fafb;
  --gray-100:   #f3f4f6;
  --gray-200:   #e5e7eb;
  --gray-400:   #9ca3af;
  --gray-600:   #4b5563;
  --gray-700:   #374151;
  --gray-900:   #111827;
  --white:      #ffffff;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ─────────────────────────── */
.header {
  background: var(--blue);
  color: var(--white);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}
.header h1 { font-size: 1.1rem; font-weight: 600; flex: 1; }
.header a  { color: var(--white); text-decoration: none; font-size: .9rem; opacity: .85; }
.header a:hover { opacity: 1; }
.back-btn {
  background: rgba(255,255,255,.15);
  border: none;
  color: var(--white);
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.back-btn:hover { background: rgba(255,255,255,.25); }

/* ── Search & Filters ───────────────── */
.search-bar {
  padding: 12px 16px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 53px;
  z-index: 90;
}
.search-bar input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--gray-50);
  outline: none;
}
.search-bar input:focus { border-color: var(--blue); background: var(--white); }

.filter-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 16px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  scrollbar-width: none;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--gray-200);
  background: var(--white);
  font-size: .85rem;
  cursor: pointer;
  color: var(--gray-600);
  white-space: nowrap;
}
.filter-tab.active {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--white);
  font-weight: 600;
}

/* ── Item Grid ──────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  padding: 16px;
}
.item-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s;
}
.item-card:hover { box-shadow: var(--shadow-md); }
.item-card img {
  width: 100%;
  height: 130px;
  object-fit: cover;
  background: var(--gray-100);
}
.item-card .no-img {
  width: 100%;
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
  font-size: 2.5rem;
}
.item-card-body { padding: 10px; }
.item-card-name { font-size: .85rem; font-weight: 600; line-height: 1.3; margin-bottom: 2px; }
.item-card-brand { font-size: .75rem; color: var(--gray-400); margin-bottom: 6px; }
.item-card-qty {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--blue);
}
.item-card-qty.low { color: var(--red); }
.item-card-qty.warn { color: var(--orange); }

/* ── Item Detail Page ───────────────── */
.item-detail { max-width: 480px; margin: 0 auto; padding-bottom: 40px; }
.item-image {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  background: var(--gray-100);
}
.item-image-placeholder {
  width: 100%;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
  font-size: 5rem;
}
.item-info { padding: 20px 16px 0; }
.item-category { font-size: .8rem; font-weight: 600; color: var(--blue); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.item-name { font-size: 1.4rem; font-weight: 700; line-height: 1.2; margin-bottom: 4px; }
.item-brand { font-size: .9rem; color: var(--gray-600); margin-bottom: 16px; }
.stock-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.stock-label { font-size: .85rem; color: var(--gray-600); }
.stock-count { font-size: 2.5rem; font-weight: 800; color: var(--blue); }
.stock-count.low { color: var(--red); }
.stock-count.warn { color: var(--orange); }
.low-stock-badge {
  background: var(--red-light);
  color: var(--red);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: 16px;
}

/* ── Transaction Forms ──────────────── */
.action-forms { padding: 0 16px; display: flex; flex-direction: column; gap: 12px; }
.action-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.action-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 12px; }
.action-card h3.take { color: var(--red); }
.action-card h3.restock { color: var(--green); }
.qty-row { display: flex; gap: 8px; align-items: center; }
.qty-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 1.1rem;
  text-align: center;
  outline: none;
}
.qty-input:focus { border-color: var(--blue); }
.btn {
  padding: 10px 20px;
  border-radius: var(--radius);
  border: none;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.btn:hover { opacity: .88; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-take    { background: var(--red);   color: var(--white); }
.btn-restock { background: var(--green); color: var(--white); }
.btn-primary { background: var(--blue);  color: var(--white); }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-danger  { background: var(--red);   color: var(--white); }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-full { width: 100%; }

/* ── Feedback / Toast ───────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--gray-900);
  color: var(--white);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 500;
  z-index: 999;
  transition: transform .25s ease;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }

/* ── Section Headings ───────────────── */
.section-heading {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-400);
  padding: 20px 16px 8px;
}

/* ── Admin Layout ───────────────────── */
.admin-layout { display: flex; flex-direction: column; min-height: 100vh; }
.admin-nav {
  display: flex;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  overflow-x: auto;
  scrollbar-width: none;
}
.admin-nav::-webkit-scrollbar { display: none; }
.admin-tab {
  flex-shrink: 0;
  padding: 12px 20px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--gray-600);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  white-space: nowrap;
}
.admin-tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }
.admin-content { flex: 1; padding: 16px; }
.admin-section { display: none; }
.admin-section.active { display: block; }

/* ── Tables ─────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th {
  text-align: left;
  padding: 10px 12px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  font-size: .8rem;
  font-weight: 600;
  color: var(--gray-600);
  white-space: nowrap;
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }
.table-img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--gray-100);
}

/* ── Badges ─────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-blue   { background: var(--blue-light);   color: var(--blue-dark); }
.badge-green  { background: var(--green-light);  color: var(--green); }
.badge-red    { background: var(--red-light);     color: var(--red); }
.badge-orange { background: var(--orange-light);  color: var(--orange); }
.badge-gray   { background: var(--gray-100);      color: var(--gray-600); }

/* ── Modal ──────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px 20px;
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: 12px; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  background: var(--gray-100);
  border: none;
  border-radius: 999px;
  width: 30px;
  height: 30px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Forms ──────────────────────────── */
.form-group { margin-bottom: 14px; }
label { display: block; font-size: .85rem; font-weight: 600; color: var(--gray-700); margin-bottom: 5px; }
input[type=text], input[type=number], textarea, select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: .95rem;
  outline: none;
  background: var(--white);
  color: var(--gray-900);
}
input:focus, textarea:focus, select:focus { border-color: var(--blue); }
textarea { resize: vertical; min-height: 70px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-label { font-size: .9rem; color: var(--gray-700); }
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  background: var(--gray-200);
  border-radius: 999px;
  cursor: pointer;
  transition: .2s;
}
.slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--white);
  border-radius: 50%;
  transition: .2s;
}
.toggle input:checked + .slider { background: var(--blue); }
.toggle input:checked + .slider::before { transform: translateX(20px); }

/* ── Image upload preview ───────────── */
.img-upload-box {
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  background: var(--gray-50);
  transition: border-color .15s;
}
.img-upload-box:hover { border-color: var(--blue); }
.img-preview { max-width: 120px; max-height: 120px; object-fit: cover; border-radius: var(--radius); margin-bottom: 8px; }

/* ── QR Code ────────────────────────── */
.qr-container { text-align: center; padding: 20px; }
.qr-container canvas { border: 1px solid var(--gray-200); border-radius: var(--radius); }
.qr-label { font-weight: 700; margin-top: 12px; font-size: .95rem; }
.qr-sublabel { font-size: .8rem; color: var(--gray-400); margin-top: 4px; }

/* ── Empty states ───────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray-400);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state-text { font-size: 1rem; font-weight: 500; }

/* ── Toolbar ────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.toolbar-left  { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar-right { display: flex; gap: 8px; }
.toolbar input {
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: .9rem;
  outline: none;
  min-width: 180px;
}
.toolbar input:focus { border-color: var(--blue); }
.toolbar select {
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: .9rem;
  outline: none;
}

/* ── Stats cards ────────────────────── */
.stats-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.stat-card {
  flex: 1;
  min-width: 120px;
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  text-align: center;
}
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--blue); }
.stat-label { font-size: .8rem; color: var(--gray-600); margin-top: 2px; }
.stat-card.alert .stat-value { color: var(--red); }
.stat-card.warn  .stat-value { color: var(--orange); }

/* ── Transaction history (item page) ── */
.tx-list { padding: 0 16px; }
.tx-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
}
.tx-item:last-child { border-bottom: none; }
.tx-action { font-weight: 600; font-size: .9rem; }
.tx-action.take { color: var(--red); }
.tx-action.restock { color: var(--green); }
.tx-detail { font-size: .8rem; color: var(--gray-400); margin-top: 2px; }
.tx-qty { font-size: 1.1rem; font-weight: 700; }
.tx-qty.take { color: var(--red); }
.tx-qty.restock { color: var(--green); }

/* ── Responsive ─────────────────────── */
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .item-detail { padding: 0 0 40px; }
  .action-forms { flex-direction: row; }
  .action-card { flex: 1; }
}

@media (min-width: 1024px) {
  .admin-layout { flex-direction: row; }
  .admin-nav {
    flex-direction: column;
    width: 200px;
    border-bottom: none;
    border-right: 1px solid var(--gray-200);
    overflow-y: auto;
    overflow-x: visible;
    padding-top: 8px;
  }
  .admin-tab {
    border-bottom: none;
    border-left: 3px solid transparent;
    padding: 10px 20px;
  }
  .admin-tab.active { border-left-color: var(--blue); border-bottom: none; }
  .admin-content { padding: 24px; }
}

/* ── Print (QR labels) ──────────────── */
@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
}
