/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --primary: #2d6a4f;
  --primary-hover: #1b4332;
  --primary-light: #d8f3dc;
  --accent: #52b788;
  --sidebar-width: 260px;
  --topbar-height: 58px;
  --bg: #f8f9fa;
  --card-bg: #ffffff;
  --text: #212529;
  --text-muted: #6c757d;
  --border: #dee2e6;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,.08);
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', Arial, sans-serif; background: var(--bg); color: var(--text); }

/* ── Bootstrap overrides ───────────────────────────────────────────────────── */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }
.badge.bg-primary { background: var(--primary) !important; }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(82,183,136,.2); }

/* ── Auth page ─────────────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #1b4332 0%, #2d6a4f 50%, #52b788 100%);
  padding: 20px 16px;
}
.auth-container {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}
.auth-logo {
  text-align: center;
  margin-bottom: 20px;
}
.auth-logo-img {
  max-width: 200px;
  width: 65%;
  height: auto;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,.35));
}
.auth-card {
  background: #fff;
  border-radius: 16px;
  padding: 36px 32px 32px;
  box-shadow: 0 12px 48px rgba(0,0,0,.22);
}
.auth-title {
  text-align: center;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 24px;
  font-size: 1.25rem;
}
.otp-input {
  font-size: 2rem;
  letter-spacing: 14px;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
}

/* mobile auth */
@media (max-width: 480px) {
  .auth-card { padding: 28px 20px 24px; }
  .auth-logo-img { width: 55%; }
  .otp-input { font-size: 1.7rem; letter-spacing: 10px; }
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; right: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: #fff;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform .3s ease;
  overflow-y: auto;
}
.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo-area { display: flex; align-items: center; }
.sidebar-logo-img { max-height: 52px; max-width: 160px; width: auto; object-fit: contain; }
.sidebar-close { background: none; border: none; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: 12px 8px; }
.nav-section { margin-bottom: 8px; }
.nav-label {
  display: block;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: 8px 10px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: .9rem;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}
.nav-item i { width: 18px; text-align: center; color: var(--text-muted); }
.nav-item:hover { background: var(--primary-light); color: var(--primary); }
.nav-item:hover i { color: var(--primary); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-item.active i { color: var(--primary); }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-logout {
  display: block;
  width: 100%;
  padding: 8px;
  background: #fff3f3;
  color: #dc3545;
  border: 1px solid #f5c6cb;
  border-radius: 8px;
  text-align: center;
  text-decoration: none;
  font-size: .85rem;
  transition: background .2s;
}
.btn-logout:hover { background: #dc3545; color: #fff; }

/* ── Main wrapper ──────────────────────────────────────────────────────────── */
.main-wrapper {
  margin-right: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.sidebar-overlay { display: none; }

/* ── Topbar ────────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 6px rgba(0,0,0,.05);
}
.topbar-toggle { background: none; border: none; font-size: 1.2rem; padding: 4px 8px; }
.topbar-title { margin: 0; font-size: 1.05rem; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; gap: 8px; }

/* ── Flash messages ────────────────────────────────────────────────────────── */
.flash-container { padding: 12px 24px 0; }

/* ── Content area ──────────────────────────────────────────────────────────── */
.content-area { padding: 20px 24px 32px; flex: 1; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { background: #fff; border-bottom: 1px solid var(--border); padding: 12px 16px; border-radius: var(--radius) var(--radius) 0 0; }

/* ── Stat cards ────────────────────────────────────────────────────────────── */
.stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none;
  color: var(--text);
  transition: transform .15s, box-shadow .15s;
  box-shadow: var(--shadow);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.1); color: var(--text); }
.stat-icon { font-size: 1.6rem; width: 44px; height: 44px; border-radius: 10px;
             display: flex; align-items: center; justify-content: center; }
.stat-count { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }

.stat-card.card-primary .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-card.card-success .stat-icon { background: #d1e7dd; color: #0f5132; }
.stat-card.card-warning .stat-icon { background: #fff3cd; color: #664d03; }
.stat-card.card-info .stat-icon { background: #cff4fc; color: #055160; }
.stat-card.card-danger .stat-icon { background: #f8d7da; color: #842029; }
.stat-card.card-secondary .stat-icon { background: #e2e3e5; color: #41464b; }
.stat-card.card-dark .stat-icon { background: #d3d3d4; color: #141619; }

/* ── Tables ────────────────────────────────────────────────────────────────── */
.table thead th {
  background: #f8f9fa;
  font-size: .83rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.table td { vertical-align: middle; font-size: .9rem; }
.table-actions { white-space: nowrap; }
.table-actions .btn { margin-left: 2px; }

/* ── Product grid ──────────────────────────────────────────────────────────── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.product-card {
  background: #f8f9fa;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: box-shadow .15s;
}
.product-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.1); }
.product-img { height: 90px; background: #e9ecef; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.product-img img { width: 100%; height: 100%; object-fit: cover; }
.product-img-placeholder { font-size: 1.8rem; color: #adb5bd; }
.product-info { padding: 8px 10px 4px; }
.product-name { font-weight: 600; font-size: .87rem; }
.product-qty { font-size: .78rem; color: var(--text-muted); }
.product-actions { padding: 6px 10px 8px; display: flex; gap: 4px; }

/* ── Dual column selector ──────────────────────────────────────────────────── */
.dual-selector {
  display: grid;
  grid-template-columns: 1fr 40px 1fr;
  gap: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 420px;
}
.dual-col { display: flex; flex-direction: column; }
.dual-col:last-child { border-right: 1px solid var(--border); }
.dual-col-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: #f8f9fa;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dual-col-header h6 { margin: 0; font-size: .9rem; flex: 1; }
.dual-col-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  max-height: 450px;
}
.dual-arrows {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f9fa;
  border-right: 1px solid var(--border);
  border-left: 1px solid var(--border);
}
.dual-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s;
  margin-bottom: 3px;
  position: relative;
  flex-wrap: wrap;
}
.dual-item:not(.selected-item):hover { background: var(--primary-light); }
.dual-item.selected-item { background: #f0fdf4; border: 1px solid var(--accent); cursor: default; }
.dual-item.hidden-item { display: none !important; }
.dual-item-img {
  width: 36px; height: 36px;
  border-radius: 6px;
  background: #e9ecef;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.dual-item-img img { width: 100%; height: 100%; object-fit: cover; }
.dual-item-img i { font-size: .9rem; color: #adb5bd; }
.dual-item span { flex: 1; font-size: .87rem; font-weight: 500; }
.dual-item small { width: 100%; font-size: .75rem; padding-right: 44px; margin-top: -4px; }
.item-qty-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding-right: 44px;
  margin-top: 4px;
}
.qty-group { width: 80px; flex-shrink: 0; }
.qty-group .qty-input { min-width: 0; width: 32px; text-align: center; padding: 0 2px; }
.qty-group .qty-btn { padding: 0 5px; font-size: .9rem; line-height: 1; }
.remove-btn { margin-right: auto; }

/* ── Empty state ───────────────────────────────────────────────────────────── */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 12px; display: block; opacity: .4; }
.empty-state p { margin-bottom: 16px; }

/* ── Mobile responsive ─────────────────────────────────────────────────────── */
@media (max-width: 991px) {
  .sidebar {
    transform: translateX(100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: -4px 0 20px rgba(0,0,0,.15);
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 1035;
  }
  .sidebar-overlay.show { display: block; }
  .main-wrapper { margin-right: 0; }
  .topbar-toggle { display: inline-flex !important; }
  .dual-selector { grid-template-columns: 1fr; }
  .dual-col:last-child { border-right: none; border-top: 1px solid var(--border); }
  .dual-arrows { display: none; }
}

@media (max-width: 575px) {
  .content-area { padding: 12px 12px 24px; }
  .flash-container { padding: 8px 12px 0; }
  .topbar { padding: 0 12px; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .stat-card { padding: 12px; gap: 10px; }
  .stat-count { font-size: 1.3rem; }
}
