/* =====================================================================
   Inventory Management System - application styles
   Layered on Bootstrap 5.3; only what Bootstrap does not already give us.
   ===================================================================== */

:root {
  --app-sidebar-width: 250px;
  --app-topbar-height: 56px;
  --app-brand: #14532d;
  --app-brand-dark: #0f3d22;
}

body {
  background-color: #f5f6f8;
  font-size: 0.9375rem;
}

/* ---------- Topbar ---------- */
.app-topbar {
  background: linear-gradient(90deg, var(--app-brand), var(--app-brand-dark));
  min-height: var(--app-topbar-height);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}
.app-topbar .navbar-brand,
.app-topbar .navbar-brand:hover {
  color: #fff;
  font-weight: 600;
  letter-spacing: .2px;
}

/* Uploaded logo. Capped by height so a wide or tall logo both sit neatly in
   the bar, and by width so an extreme banner cannot push the user menu off
   a small screen. */
.app-brand-logo {
  height: 34px;
  max-width: 190px;
  width: auto;
  object-fit: contain;
}
@media (max-width: 575.98px) {
  .app-brand-logo { height: 28px; max-width: 130px; }
}

/* ---------- Shell ---------- */
.app-shell {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - var(--app-topbar-height));
}

.app-sidebar {
  width: var(--app-sidebar-width);
  flex: 0 0 var(--app-sidebar-width);
  background: #fff;
  border-right: 1px solid #e5e7eb;
  position: sticky;
  top: var(--app-topbar-height);
  height: calc(100vh - var(--app-topbar-height));
  overflow-y: auto;
}

.app-main {
  flex: 1 1 auto;
  min-width: 0;              /* lets wide tables scroll instead of stretching the page */
  padding: 1.25rem;
}

/* Below lg the sidebar becomes an offcanvas and must not reserve space. */
@media (max-width: 991.98px) {
  .app-sidebar {
    position: fixed;
    height: 100%;
    top: 0;
    flex-basis: auto;
  }
  .app-main { padding: 1rem; }
}

/* ---------- Sidebar nav ---------- */
.app-nav-group {
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #9ca3af;
  padding: 1rem 1rem .35rem;
}

.app-nav-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .5rem 1rem;
  color: #374151;
  border-left: 3px solid transparent;
}
.app-nav-link:hover { background: #f3f4f6; color: var(--app-brand); }
.app-nav-link.active {
  background: #ecfdf5;
  color: var(--app-brand);
  border-left-color: var(--app-brand);
  font-weight: 600;
}
.app-nav-link.disabled { color: #b6bcc5; pointer-events: none; }
.app-nav-link i { font-size: 1.05rem; width: 1.15rem; text-align: center; }

/* ---------- Footer ---------- */
.app-footer {
  border-top: 1px solid #e5e7eb;
  background: #fff;
  padding: .75rem 1.25rem;
  font-size: .8125rem;
  color: #6b7280;
}

/* ---------- Dashboard stat cards ---------- */
.stat-card {
  border: 0;
  border-left: 4px solid var(--bs-secondary);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
  height: 100%;
}
.stat-card .stat-label {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #6b7280;
}
.stat-card .stat-value { font-size: 1.65rem; font-weight: 700; line-height: 1.2; }
.stat-card .stat-icon  { font-size: 1.75rem; opacity: .28; }

.stat-card.tone-primary { border-left-color: var(--bs-primary); }
.stat-card.tone-success { border-left-color: var(--bs-success); }
.stat-card.tone-warning { border-left-color: var(--bs-warning); }
.stat-card.tone-danger  { border-left-color: var(--bs-danger); }
.stat-card.tone-info    { border-left-color: var(--bs-info); }

/* ---------- Tables ---------- */
.table-app {
  background: #fff;
  font-size: .875rem;
  margin-bottom: 0;
}
.table-app > thead th {
  background: #f9fafb;
  border-bottom: 2px solid #e5e7eb;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #4b5563;
  white-space: nowrap;
}
.table-app > tbody td { vertical-align: middle; }

/* Sortable column headers */
.th-sort { cursor: pointer; user-select: none; }
.th-sort .bi { opacity: .35; font-size: .75rem; }
.th-sort.sorted .bi { opacity: 1; }

/* Product thumbnail in list rows */
.thumb-sm {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: .375rem;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
}

/* ---------- Stock state pills ---------- */
.pill-stock { font-weight: 600; font-size: .75rem; }
.pill-stock.state-ok   { color: #166534; background: #dcfce7; }
.pill-stock.state-low  { color: #92400e; background: #fef3c7; }
.pill-stock.state-out  { color: #991b1b; background: #fee2e2; }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: .8125rem; color: #374151; }
.required-mark { color: var(--bs-danger); }

.image-drop {
  border: 2px dashed #d1d5db;
  border-radius: .5rem;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.image-drop:hover,
.image-drop.dragover { border-color: var(--app-brand); background: #f0fdf4; }
.image-drop img { max-height: 180px; max-width: 100%; border-radius: .375rem; }

/* ---------- Product picker ---------- */
[data-product-picker] { position: relative; }
[data-picker-menu] {
  position: absolute;
  z-index: 1055;
  top: 100%;
  left: 0;
  right: 0;
  display: none;
  max-height: 20rem;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: .375rem;
  box-shadow: 0 8px 20px rgba(16, 24, 40, .12);
  padding: .25rem 0;
}
[data-picker-menu].show { display: block; }

/* Balance readout beside the quantity field on the stock forms */
.balance-readout {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: .375rem;
  padding: .75rem 1rem;
}
.balance-readout .label {
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #6b7280;
}
.balance-readout .value { font-size: 1.35rem; font-weight: 700; line-height: 1.2; }

/* ---------- Audit diff rendering ---------- */
.diff-old {
  background: #fee2e2;
  text-decoration: line-through;
  padding: .05rem .3rem;
  border-radius: .2rem;
}
.diff-new { background: #dcfce7; padding: .05rem .3rem; border-radius: .2rem; }

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--app-brand), #065f46 60%, #0f766e);
  padding: 1rem;
}
.login-card {
  width: 100%;
  max-width: 25rem;
  border: 0;
  border-radius: .75rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .22);
}

/* ---------- Print ---------- */
.print-only { display: none; }

@media print {
  .app-topbar, .app-sidebar, .app-footer, .no-print { display: none !important; }
  .app-main { padding: 0; }
  body { background: #fff; }

  /* Reprint the branding the navigation bar would otherwise have carried. */
  .print-only { display: block; }
  .print-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 2px solid #333;
    padding-bottom: .5rem;
    margin-bottom: 1rem;
    font-size: .8125rem;
  }

  /* Keep table rows intact across page breaks. */
  table { page-break-inside: auto; }
  tr    { page-break-inside: avoid; page-break-after: auto; }
  thead { display: table-header-group; }
}
