@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --navy:       #0f1f3d;
  --navy2:      #162444;
  --navy3:      #1e2f52;
  --navy-light: #253660;
  --accent:     #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --border:     #e2e8f0;
  --border2:    #cbd5e1;
  --text:       #1e293b;
  --text2:      #64748b;
  --text3:      #94a3b8;
  --bg:         #f1f5f9;
  --bg2:        #ffffff;
  --bg3:        #f8fafc;
  --green:      #16a34a;
  --green-bg:   #f0fdf4;
  --yellow:     #d97706;
  --yellow-bg:  #fffbeb;
  --red:        #dc2626;
  --red-bg:     #fef2f2;
  --blue:       #2563eb;
  --blue-bg:    #eff6ff;
  --sidebar-w:  240px;
  --radius:     10px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--navy3);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand-icon {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-brand-text {
  font-weight: 700;
  font-size: .95rem;
  color: #fff;
  letter-spacing: -.2px;
}

.sidebar-brand-sub {
  font-size: .68rem;
  color: rgba(255,255,255,.4);
  font-weight: 400;
}

.sidebar-nav { padding: 12px 10px; flex: 1; }

.sidebar-section-title {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,.3);
  font-weight: 600;
  padding: 10px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-weight: 500;
  font-size: .85rem;
  margin-bottom: 2px;
  transition: all .15s;
  position: relative;
}

.nav-item:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.9); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item.active:hover { background: var(--accent-hover); }

.nav-item svg { flex-shrink: 0; opacity: .8; }
.nav-item.active svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  border-radius: 20px;
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 7px;
  min-width: 20px;
  text-align: center;
}

.nav-badge-yellow {
  background: var(--yellow);
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--navy3);
}

.sidebar-sync {
  font-size: .72rem;
  color: rgba(255,255,255,.35);
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-sync a {
  color: #60a5fa;
  text-decoration: none;
  font-weight: 500;
}

/* ===== TOPBAR ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-title {
  font-weight: 600;
  font-size: .95rem;
  color: var(--text);
}

/* ===== MAIN LAYOUT ===== */
.layout {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-content {
  padding: 24px;
  flex: 1;
}

/* ===== STAT CARDS ===== */
.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 46px; height: 46px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon-blue   { background: var(--blue-bg);   color: var(--blue); }
.stat-icon-green  { background: var(--green-bg);  color: var(--green); }
.stat-icon-yellow { background: var(--yellow-bg); color: var(--yellow); }
.stat-icon-red    { background: var(--red-bg);    color: var(--red); }

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  letter-spacing: -.5px;
}

.stat-label {
  font-size: .78rem;
  color: var(--text2);
  margin-top: 2px;
  font-weight: 500;
}

/* ===== CARDS ===== */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card-header-custom {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-weight: 600;
  font-size: .9rem;
  color: var(--text);
  margin: 0;
}

/* ===== BUTTONS ===== */
.btn-primary-custom {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-family: 'Inter', sans-serif;
  font-size: .83rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: background .15s;
  white-space: nowrap;
}
.btn-primary-custom:hover { background: var(--accent-hover); color: #fff; }

.btn-outline-custom {
  background: #fff;
  color: var(--text2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 7px 14px;
  font-family: 'Inter', sans-serif;
  font-size: .83rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: all .15s;
}
.btn-outline-custom:hover { border-color: var(--accent); color: var(--accent); }

/* ===== BADGES ===== */
.badge-green  { background: var(--green-bg);  color: var(--green);  border-radius: 6px; padding: 3px 10px; font-size: .72rem; font-weight: 600; }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); border-radius: 6px; padding: 3px 10px; font-size: .72rem; font-weight: 600; }
.badge-red    { background: var(--red-bg);    color: var(--red);    border-radius: 6px; padding: 3px 10px; font-size: .72rem; font-weight: 600; }
.badge-blue   { background: var(--blue-bg);   color: var(--blue);   border-radius: 6px; padding: 3px 10px; font-size: .72rem; font-weight: 600; }
.badge-gray   { background: #f1f5f9;          color: var(--text3);  border-radius: 6px; padding: 3px 10px; font-size: .72rem; font-weight: 600; }
.badge-orange { background: #fff7ed;          color: #ea580c;       border-radius: 6px; padding: 3px 10px; font-size: .72rem; font-weight: 600; }

/* ===== TABLE ===== */
.table-custom { width: 100%; border-collapse: collapse; }
.table-custom th {
  background: var(--bg3);
  color: var(--text2);
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table-custom td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: .85rem;
}
.table-custom tr:last-child td { border-bottom: none; }
.table-custom tr:hover td { background: var(--bg3); }

.product-thumb-sm {
  width: 40px; height: 40px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg3);
  border: 1px solid var(--border);
}

/* ===== ALERTS ===== */
.alert-custom {
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: .85rem;
  font-weight: 500;
  margin-bottom: 16px;
  border: 1px solid;
  display: none;
}
.alert-success-custom { background: var(--green-bg); border-color: #86efac; color: var(--green); }
.alert-error-custom   { background: var(--red-bg);   border-color: #fca5a5; color: var(--red); }

/* ===== SCAN PAGE ===== */
.scan-drop {
  border: 2px dashed var(--border2);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  color: var(--text3);
  cursor: pointer;
  transition: all .2s;
}
.scan-drop:hover, .scan-drop.active { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

.qty-ring {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: center;
  margin: 16px 0;
}
.qty-ring-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--border2);
  background: #fff;
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
  font-weight: 300;
}
.qty-ring-btn:hover { border-color: var(--accent); color: var(--accent); }
.qty-num { font-size: 2.2rem; font-weight: 700; color: var(--navy); min-width: 56px; text-align: center; }

/* ===== QR PAGE ===== */
.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.qr-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* ===== MOBILE ===== */
.mobile-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--navy);
  padding: 12px 16px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.mobile-brand { font-weight: 700; font-size: .9rem; color: #fff; display: flex; align-items: center; gap: 8px; }
.hamburger { background: none; border: none; color: rgba(255,255,255,.8); cursor: pointer; padding: 4px; }

.mobile-drawer {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 300;
}
.mobile-drawer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.5);
}
.mobile-drawer-panel {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 260px;
  background: var(--navy);
  overflow-y: auto;
}

/* ===== DATATABLES OVERRIDE ===== */
.dataTables_wrapper .dataTables_filter input {
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 6px 12px;
  font-family: 'Inter', sans-serif;
  font-size: .83rem;
  outline: none;
  transition: border-color .15s;
  margin-left: 6px;
}
.dataTables_wrapper .dataTables_filter input:focus { border-color: var(--accent); }
.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 5px 28px 5px 10px;
  font-family: 'Inter', sans-serif;
  font-size: .83rem;
  outline: none;
  margin: 0 6px;
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate { font-size: .8rem; color: var(--text2); padding: 12px 16px; }
.dataTables_wrapper .paginate_button {
  border-radius: 6px !important;
  border: 1px solid var(--border) !important;
  padding: 4px 10px !important;
  margin: 0 2px !important;
  font-size: .8rem !important;
  color: var(--text2) !important;
}
.dataTables_wrapper .paginate_button:hover { background: var(--accent-light) !important; color: var(--accent) !important; border-color: var(--accent) !important; }
.dataTables_wrapper .paginate_button.current { background: var(--accent) !important; color: #fff !important; border-color: var(--accent) !important; }
.dataTables_wrapper .paginate_button.disabled { opacity: .4; }
table.dataTable thead th { cursor: pointer; }
table.dataTable thead th.sorting:after,
table.dataTable thead th.sorting_asc:after,
table.dataTable thead th.sorting_desc:after { opacity: .5; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .mobile-header { display: flex; }
  .mobile-drawer { display: block; visibility: hidden; }
  .mobile-drawer.open { visibility: visible; }
  .layout { margin-left: 0; }
  .page-content { padding: 16px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.3rem; }
}

/* ===== PRINT ===== */
@media print {
  .sidebar, .mobile-header, .topbar, .no-print { display: none !important; }
  .layout { margin-left: 0; }
  body { background: #fff; }
  .qr-grid { grid-template-columns: repeat(4,1fr); }
  .qr-item { border: 1px solid #ddd; break-inside: avoid; }
  @page { margin: 1cm; }
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.08);
  padding: 14px 18px;
  min-width: 280px;
  max-width: 360px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  pointer-events: all;
  border-left: 4px solid;
  animation: toastIn .3s cubic-bezier(.34,1.56,.64,1);
}

.toast.toast-success { border-color: var(--green); }
.toast.toast-error   { border-color: var(--red); }
.toast.toast-info    { border-color: var(--blue); }
.toast.toast-loading { border-color: var(--yellow); }

.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-icon-success { color: var(--green); }
.toast-icon-error   { color: var(--red); }
.toast-icon-info    { color: var(--blue); }
.toast-icon-loading { color: var(--yellow); }

.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 600; font-size: .88rem; color: var(--text); margin-bottom: 2px; }
.toast-message { font-size: .8rem; color: var(--text2); line-height: 1.4; }

.toast-close {
  background: none; border: none; cursor: pointer;
  color: var(--text3); padding: 0; flex-shrink: 0;
  line-height: 1;
}
.toast-close:hover { color: var(--text); }

.toast.toast-hide {
  animation: toastOut .25s ease forwards;
}

@keyframes toastIn  { from { opacity:0; transform:translateX(40px); } to { opacity:1; transform:translateX(0); } }
@keyframes toastOut { from { opacity:1; transform:translateX(0); }    to { opacity:0; transform:translateX(40px); } }

.spin-anim { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
