/* =====================================================================
   Distribution ERP — global theme
   Keeps the existing class names + --brand-primary theming hooks, so every
   page picks this up without markup changes.
   ===================================================================== */
:root {
  --brand-primary: #1e5f4f;
  --brand-primary-dark: #143f34;
  --brand-accent: #2f9e6e;
  --sidebar-width: 262px;

  --ui-bg: #f3f6f5;
  --ui-surface: #ffffff;
  --ui-border: #e5ebe9;
  --ui-text: #1f2d2a;
  --ui-muted: #6b7c78;
  --ui-radius: 14px;
  --ui-shadow-sm: 0 1px 2px rgba(16, 42, 36, .05), 0 1px 3px rgba(16, 42, 36, .06);
  --ui-shadow: 0 6px 20px rgba(16, 42, 36, .08);
  --ui-shadow-lg: 0 18px 48px rgba(16, 42, 36, .16);

  --bs-body-font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  --bs-body-color: var(--ui-text);
  --bs-border-color: var(--ui-border);
  --bs-link-color: var(--brand-primary);
  --bs-link-hover-color: var(--brand-primary-dark);
  --bs-primary: var(--brand-primary);
  --bs-primary-rgb: 30, 95, 79;
}

html { scroll-behavior: smooth; }

body {
  background: var(--ui-bg);
  color: var(--ui-text);
  font-family: var(--bs-body-font-family);
  font-size: .93rem;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { letter-spacing: -.015em; font-weight: 700; }
h4 { font-size: 1.35rem; }
.text-muted { color: var(--ui-muted) !important; }

::selection { background: rgba(47, 158, 110, .25); }

/* thin, quiet scrollbars */
* { scrollbar-width: thin; scrollbar-color: #c3d0cc transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #c3d0cc; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #a9bbb6; }

/* ---------- Topbar ---------- */
.app-topbar {
  background: rgba(255, 255, 255, .85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--ui-border);
  padding: .55rem 1.1rem;
  position: sticky;
  top: 0;
  z-index: 1040;
  min-height: 58px;
}
.app-topbar .navbar-brand {
  color: var(--brand-primary-dark);
  font-weight: 800;
  letter-spacing: -.02em;
  display: flex;
  align-items: center;
  gap: .55rem;
}
.app-topbar .navbar-brand::before {
  content: "\f494"; /* fa-warehouse */
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: .85rem;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(30, 95, 79, .35);
}
.app-topbar .text-light { color: var(--ui-text) !important; }
.app-topbar .badge.text-bg-light {
  background: rgba(47, 158, 110, .12) !important;
  color: var(--brand-primary) !important;
  font-weight: 600;
  border-radius: 999px;
  padding: .35em .7em;
}
.app-topbar .btn-outline-light {
  color: var(--brand-primary);
  border-color: var(--ui-border);
  background: #fff;
  border-radius: 10px;
  font-weight: 500;
}
.app-topbar .btn-outline-light:hover {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
}

/* ---------- Layout ---------- */
.app-layout {
  display: flex;
  min-height: calc(100vh - 58px);
}

.app-sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--brand-primary-dark) 0%, #0d2a23 100%);
  flex-shrink: 0;
  transition: transform .25s ease;
  position: sticky;
  top: 58px;
  height: calc(100vh - 58px);
  overflow-y: auto;
  box-shadow: 4px 0 24px rgba(13, 42, 35, .10);
}
.app-sidebar .nav { padding: .85rem .7rem 2rem !important; }

.app-sidebar .nav-link {
  color: rgba(255, 255, 255, .72);
  border-radius: 10px;
  padding: .55rem .8rem;
  margin-bottom: 2px;
  font-size: .9rem;
  font-weight: 500;
  position: relative;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.app-sidebar .nav-link i.fa-fw { opacity: .8; width: 1.25em; }
.app-sidebar .nav-link:hover {
  background: rgba(255, 255, 255, .08);
  color: #fff;
}
.app-sidebar .nav-link.active {
  background: linear-gradient(135deg, var(--brand-accent), #25805a);
  color: #fff;
  box-shadow: 0 6px 14px rgba(0, 0, 0, .25);
}
.app-sidebar .nav-link.active i { opacity: 1; }
.app-sidebar .nav-group-toggle { color: rgba(255, 255, 255, .88); font-weight: 600; }
.app-sidebar .nav-group-toggle:not(.collapsed) { background: rgba(255, 255, 255, .06); color: #fff; }
.app-sidebar .nav-group .nav {
  border-left: 1px solid rgba(255, 255, 255, .12);
  margin: 2px 0 6px .95rem;
  padding: 0 0 0 .35rem !important;
}
.app-sidebar .nav-group .nav-link { font-weight: 400; font-size: .88rem; }

.app-content {
  flex: 1;
  padding: 1.75rem 2rem;
  min-width: 0;
  animation: pageIn .35s ease both;
}
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .app-content { animation: none; } html { scroll-behavior: auto; } }

/* ---------- Cards ---------- */
.card {
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  background: var(--ui-surface);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--ui-border);
  font-weight: 600;
  padding: .85rem 1.1rem;
}
.stat-card {
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  box-shadow: var(--ui-shadow-sm);
  transition: transform .2s ease, box-shadow .2s ease;
}
a .stat-card:hover, .stat-card.hoverable:hover {
  transform: translateY(-3px);
  box-shadow: var(--ui-shadow);
}
.stat-card .stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: #fff;
  box-shadow: 0 6px 14px rgba(0, 0, 0, .16);
}
.stat-card .fs-4, .stat-card .fs-5 { font-weight: 700; letter-spacing: -.02em; }

/* ---------- Tables ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .65rem .8rem; border-bottom-color: #edf1f0; }
.table thead th {
  background: #f6f9f8;
  color: var(--ui-muted);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
  border-bottom: 1px solid var(--ui-border);
  white-space: nowrap;
}
.table-hover > tbody > tr { transition: background .12s ease; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f1f8f5; }
.table tfoot td, .table tfoot th { background: #f6f9f8; font-weight: 700; }
.card-body.table-responsive { border-radius: var(--ui-radius); }

/* ---------- Buttons ---------- */
.btn {
  border-radius: 10px;
  font-weight: 500;
  transition: transform .12s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { box-shadow: 0 0 0 .22rem rgba(47, 158, 110, .3); }
.btn.text-white[style*="brand-primary"], .btn-primary {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent)) !important;
  border: 0;
  color: #fff;
  box-shadow: 0 4px 12px rgba(30, 95, 79, .28);
}
.btn.text-white[style*="brand-primary"]:hover, .btn-primary:hover {
  filter: brightness(1.06);
  box-shadow: 0 8px 18px rgba(30, 95, 79, .34);
  transform: translateY(-1px);
}
.btn-success { background: var(--brand-accent); border-color: var(--brand-accent); }
.btn-outline-secondary { color: #4a5b57; border-color: #d5dedb; background: #fff; }
.btn-outline-secondary:hover { background: #eef5f2; border-color: #bfd0ca; color: var(--brand-primary-dark); }
.btn-outline-danger { background: #fff; }
.btn-sm { border-radius: 8px; }

/* ---------- Forms ---------- */
.form-control, .form-select {
  border-radius: 10px;
  border-color: #d9e2df;
  background-color: #fff;
  padding: .5rem .8rem;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control-sm, .form-select-sm { border-radius: 8px; padding: .3rem .6rem; }
.form-control:focus, .form-select:focus {
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 .22rem rgba(47, 158, 110, .18);
}
.form-label { font-weight: 600; font-size: .82rem; color: #3a4b47; margin-bottom: .3rem; }
.form-check-input:checked { background-color: var(--brand-primary); border-color: var(--brand-primary); }
.input-group-text { border-radius: 10px; background: #f6f9f8; border-color: #d9e2df; }

/* ---------- Badges / alerts / misc ---------- */
.badge { border-radius: 999px; font-weight: 600; padding: .4em .75em; letter-spacing: .01em; }
.badge.text-bg-light { background: #eef3f1 !important; border: 1px solid #e0e8e5; }

.alert { border: 0; border-radius: 12px; box-shadow: var(--ui-shadow-sm); border-left: 4px solid currentColor; }
.alert-success { background: #e8f6ee; color: #14633f; }
.alert-danger  { background: #fdecec; color: #a12727; }
.alert-warning { background: #fff6e0; color: #8a5a00; }
.alert-info    { background: #e8f2fb; color: #1b5a8c; }

.modal-content { border: 0; border-radius: 18px; box-shadow: var(--ui-shadow-lg); }
.modal-header { border-bottom-color: var(--ui-border); }
.modal-footer { border-top-color: var(--ui-border); }
.dropdown-menu { border: 1px solid var(--ui-border); border-radius: 12px; box-shadow: var(--ui-shadow); padding: .4rem; }
.dropdown-item { border-radius: 8px; }
.pagination .page-link { border-radius: 8px; margin: 0 2px; color: var(--brand-primary); border-color: var(--ui-border); }
.pagination .active > .page-link { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }
.nav-tabs { border-bottom-color: var(--ui-border); }
.nav-tabs .nav-link { color: var(--ui-muted); border-radius: 10px 10px 0 0; font-weight: 500; }
.nav-tabs .nav-link.active { color: var(--brand-primary); font-weight: 600; border-color: var(--ui-border) var(--ui-border) #fff; }
.nav-pills .nav-link.active { background: var(--brand-primary); }
.progress { border-radius: 999px; background: #e8efed; }
.progress-bar { background: var(--brand-accent); }
hr { border-color: var(--ui-border); opacity: 1; }
h6.text-uppercase { letter-spacing: .08em; font-size: .72rem; color: var(--ui-muted) !important; }

/* ---------- Auth pages ---------- */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(900px 500px at 12% 8%, rgba(47, 158, 110, .55), transparent 60%),
    radial-gradient(800px 520px at 92% 92%, rgba(20, 63, 52, .9), transparent 60%),
    linear-gradient(135deg, #0d2a23, var(--brand-primary-dark) 45%, var(--brand-primary));
}
.auth-wrapper::before, .auth-wrapper::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, .06);
  pointer-events: none;
}
.auth-wrapper::before { width: 420px; height: 420px; top: -140px; right: -100px; }
.auth-wrapper::after  { width: 300px; height: 300px; bottom: -110px; left: -80px; }
.auth-card {
  width: 100%;
  max-width: 430px;
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 22px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 30px 70px rgba(0, 0, 0, .35);
  position: relative;
  z-index: 1;
  animation: pageIn .5s ease both;
}
.auth-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto .9rem;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
  box-shadow: 0 12px 26px rgba(30, 95, 79, .4);
}
.auth-card .form-control { padding: .65rem .9rem; }
.auth-card .btn-signin {
  padding: .7rem;
  font-weight: 600;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
  box-shadow: 0 10px 22px rgba(30, 95, 79, .35);
  border: 0;
}
.auth-card .btn-signin:hover { filter: brightness(1.07); transform: translateY(-1px); color: #fff; }

/* ---------- Print: keep documents clean ---------- */
@media print {
  .app-topbar, .app-sidebar, .no-print { display: none !important; }
  .app-content { padding: 0 !important; animation: none; }
  body { background: #fff; }
  .card, .stat-card { box-shadow: none !important; }
}

/* ---------- Responsive sidebar ---------- */
@media (max-width: 991.98px) {
  .app-sidebar {
    position: fixed;
    top: 58px;
    left: 0;
    bottom: 0;
    height: auto;
    z-index: 1030;
    transform: translateX(-100%);
    box-shadow: none;
  }
  .app-sidebar.show { transform: translateX(0); box-shadow: 10px 0 40px rgba(0, 0, 0, .35); }
  .app-content { padding: 1rem; }
  .app-topbar .btn-outline-light.d-lg-none { color: var(--brand-primary); }
}

/* Auth-card links follow the brand colour */
.auth-card a:not(.btn) { color: var(--brand-primary); text-decoration: none; font-weight: 500; }
.auth-card a:not(.btn):hover { text-decoration: underline; }
