/* ============================================================
   NKWarehouse — Custom Stylesheet
   Stack: Bootstrap 5 + FontAwesome 6
   ============================================================ */

:root {
  --sidebar-w:        240px;
  --sidebar-bg:       #0f172a;
  --sidebar-hover:    #1e293b;
  --sidebar-active:   #1d4ed8;
  --sidebar-text:     #94a3b8;
  --topbar-h:         56px;
  --page-bg:          #f1f5f9;
  --card-radius:      8px;
  --card-shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
}

/* ---- Reset / Base ---- */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--page-bg);
  color: #1e293b;
  font-size: .9rem;
  margin: 0;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.layout-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .25s ease, width .25s ease;
  scrollbar-width: thin;
  scrollbar-color: #1e293b #0f172a;
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #f1f5f9;
  border-bottom: 1px solid #1e293b;
  flex-shrink: 0;
}
.sidebar-brand i { color: #60a5fa; font-size: 1.2rem; }

/* User block */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid #1e293b;
  flex-shrink: 0;
}
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #1d4ed8;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .9rem;
  flex-shrink: 0;
}
.user-info { overflow: hidden; }
.user-name {
  font-size: .8rem;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role { font-size: .7rem; color: #64748b; }

/* Nav */
.sidebar-nav { padding: 6px 0 20px; flex: 1; }

.nav-section {
  font-size: .63rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #475569;
  padding: 14px 18px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .82rem;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}
.nav-item i {
  width: 17px;
  text-align: center;
  font-size: .85rem;
  flex-shrink: 0;
}
.nav-item:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}
.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
  border-left-color: #60a5fa;
}
.nav-item-danger { color: #f87171 !important; }
.nav-item-danger:hover { background: #1a0505 !important; color: #fca5a5 !important; }

/* ============================================================
   MAIN WRAPPER
   ============================================================ */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin .25s ease;
}

/* Collapsed sidebar */
.sidebar.collapsed { width: 0; overflow: hidden; }
.main-wrapper.expanded { margin-left: 0; }

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  color: #64748b;
  line-height: 1;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: #f1f5f9; color: #0f172a; }

.topbar-title {
  font-size: .92rem;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
}

.breadcrumb { font-size: .78rem; }
.breadcrumb-item + .breadcrumb-item::before { color: #94a3b8; }
.breadcrumb-item a { color: #3b82f6; text-decoration: none; }
.breadcrumb-item.active { color: #64748b; }

/* ============================================================
   CONTENT AREA
   ============================================================ */
.content-area {
  padding: 22px 24px;
  flex: 1;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  border: 1px solid #e2e8f0;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  background: #fff;
}
.card-header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 13px 18px;
  font-weight: 600;
  font-size: .86rem;
  color: #374151;
  border-radius: var(--card-radius) var(--card-radius) 0 0 !important;
}
.card-body { padding: 18px; }
.card-footer {
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  padding: 10px 18px;
  font-size: .8rem;
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
  border-radius: var(--card-radius);
  padding: 18px 20px;
  color: #fff;
  position: relative;
  overflow: hidden;
  border: none;
  box-shadow: var(--card-shadow);
}
.stat-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2.4rem;
  opacity: .2;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
}
.stat-label {
  font-size: .78rem;
  opacity: .88;
  margin-top: 3px;
}
.stat-link {
  display: inline-block;
  margin-top: 10px;
  font-size: .75rem;
  color: rgba(255,255,255,.75);
  text-decoration: none;
}
.stat-link:hover { color: #fff; }
.stat-link i { font-size: .65rem; }

/* ============================================================
   TABLES
   ============================================================ */
.table thead th {
  font-size: .74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: #6b7280;
  background: #f8fafc;
  border-top: none;
  border-bottom: 2px solid #e2e8f0;
  padding: 10px 12px;
  white-space: nowrap;
}
.table tbody td {
  font-size: .84rem;
  vertical-align: middle;
  color: #374151;
  padding: 9px 12px;
  border-color: #f1f5f9;
}
.table-hover tbody tr:hover { background-color: #f0f9ff; }
.table tbody tr:last-child td { border-bottom: none; }

/* ============================================================
   BADGES
   ============================================================ */
.badge { font-size: .7rem; font-weight: 600; padding: .3em .6em; letter-spacing: .2px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-label {
  font-size: .8rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 5px;
}
.form-control, .form-select {
  font-size: .84rem;
  border-color: #d1d5db;
  border-radius: 6px;
  padding: .42rem .75rem;
  color: #1e293b;
}
.form-control:focus, .form-select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.form-text { font-size: .74rem; color: #6b7280; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn { font-size: .82rem; border-radius: 6px; font-weight: 500; }
.btn-sm { font-size: .76rem; padding: .3rem .65rem; }
.btn-xs { font-size: .72rem; padding: .18rem .5rem; }
.btn-primary   { background: #1d4ed8; border-color: #1d4ed8; }
.btn-primary:hover { background: #1e40af; border-color: #1e40af; }

/* ============================================================
   STOCK IN / OUT COLORS
   ============================================================ */
.text-stock-in  { color: #16a34a; font-weight: 600; }
.text-stock-out { color: #dc2626; font-weight: 600; }
.stock-zero     { color: #dc2626; font-weight: 700; }
.stock-low      { color: #d97706; font-weight: 600; }

/* ============================================================
   FLASH MESSAGES
   ============================================================ */
.flash-message {
  position: fixed;
  top: calc(var(--topbar-h) + 10px);
  right: 20px;
  z-index: 9999;
  min-width: 290px;
  max-width: 380px;
  font-size: .84rem;
  animation: slideInRight .3s ease;
}
@keyframes slideInRight {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(140deg, #0f172a 0%, #1e3a5f 60%, #0c4a6e 100%);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 12px;
  padding: 40px 36px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo i { font-size: 2.8rem; color: #1d4ed8; }
.login-logo h1 { font-size: 1.4rem; font-weight: 700; margin: 8px 0 2px; color: #0f172a; }
.login-logo p  { font-size: .78rem; color: #64748b; margin: 0; }

/* ============================================================
   PAGE SECTION TITLE
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 8px;
}
.page-header h5 {
  font-size: .95rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
}

/* ============================================================
   MISC UTILITIES
   ============================================================ */
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
code { background: #f1f5f9; padding: 2px 5px; border-radius: 4px; color: #be185d; font-size: .8rem; }

/* Small avatar circle used in tables */
.user-avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #1d4ed8;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .78rem;
  flex-shrink: 0;
}

/* ============================================================
   RESPONSIVE  (mobile)
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w);
  }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .content-area { padding: 14px; }
  .stat-value { font-size: 1.4rem; }
}
