/* ==========================================================================
   MSOH - Stock Availability Portal
   Modern Responsive UI Stylesheet (Desktop & Mobile First)
   ========================================================================== */

:root {
  --bg-page: #f4f7fb;
  --bg-surface: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-hover: #f1f5f9;
  --bg-active: #eef2ff;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --primary-text: #1e40af;

  --accent-emerald: #059669;
  --accent-emerald-bg: #d1fae5;
  --accent-amber: #0284c7;
  --accent-amber-bg: #e0f2fe;
  --accent-danger: #334155;
  --accent-danger-bg: #f1f5f9;

  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 28px -4px rgba(15, 23, 42, 0.14);

  --sidebar-width: 260px;
  --topbar-height: 64px;
  --bottom-nav-height: 64px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   LOGIN PAGE
   ========================================================================== */
.login-page {
  min-block-size: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: radial-gradient(circle at 15% 20%, #dbeafe 0%, #f4f7fb 45%, #eef2ff 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  padding: 2.25rem 2rem;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-block-end: 1.5rem;
}

.login-brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
  flex-shrink: 0;
}

.login-brand-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.login-brand-subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.825rem;
  color: var(--text-muted);
}

/* ==========================================================================
   APP SHELL LAYOUT (Sidebar + Main + Mobile Bottom Nav)
   ========================================================================== */
.app-layout {
  display: flex;
  min-block-size: 100dvh;
}

.sidebar {
  width: var(--sidebar-width);
  background: #0f172a;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  z-index: 30;
  border-inline-end: 1px solid #1e293b;
}

.sidebar-header {
  padding: 1.25rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-block-end: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
  color: #ffffff;
}

.sidebar-subtitle {
  font-size: 0.75rem;
  color: #94a3b8;
  margin: 0;
}

.sidebar-nav {
  padding: 1.25rem 0.875rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.nav-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 0 0.75rem 0.35rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.875rem;
  border-radius: var(--radius-sm);
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.nav-item.active {
  background: var(--primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.nav-badge {
  margin-inline-start: auto;
  font-size: 0.68rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  font-weight: 600;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-block-start: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.6);
}

.user-profile-mini {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-block-end: 0.75rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #1e293b;
  border: 1px solid #334155;
  color: #60a5fa;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.user-meta {
  min-width: 0;
  flex: 1;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.user-sub {
  font-size: 0.72rem;
  color: #94a3b8;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.main-wrapper {
  flex: 1;
  margin-inline-start: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-block-end: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  inset-block-start: 0;
  z-index: 20;
}

.topbar-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-text);
}

.pill-badge.brand {
  background: #e0f2fe;
  color: #0369a1;
}

.main-content {
  padding: 1.5rem;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

.app-footer {
  padding-block: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.825rem;
  font-weight: 500;
  user-select: none;
}

.app-footer p {
  margin: 0;
}

/* ==========================================================================
   CARDS, FORMS & BUTTONS
   ========================================================================== */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-block-end: 1.25rem;
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem;
  border-block-end: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  background: var(--bg-subtle);
}

.card-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-body {
  padding: 1.25rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  align-items: end;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text-primary);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  min-height: 42px;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon svg {
  position: absolute;
  inset-inline-start: 0.85rem;
  color: var(--text-muted);
  pointer-events: none;
}

.input-with-icon .form-control {
  padding-inline-start: 2.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.125rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 42px;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-emerald {
  background: var(--accent-emerald);
  color: #ffffff;
}

.btn-emerald:hover:not(:disabled) {
  background: #047857;
}

.btn-outline {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

.btn-outline:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-copied {
  background: var(--accent-emerald-bg) !important;
  border-color: var(--accent-emerald) !important;
  color: var(--accent-emerald) !important;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-copied svg {
  animation: checkPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.btn-copied svg path,
.btn-copied svg polyline {
  stroke-dasharray: 28;
  stroke-dashoffset: 28;
  animation: checkDraw 0.3s ease-out 0.05s forwards;
}

@keyframes checkPop {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  70% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes checkDraw {
  to {
    stroke-dashoffset: 0;
  }
}

.btn-danger-ghost {
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.16);
  width: 100%;
  min-height: 36px;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

.btn-danger-ghost:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.btn-sm {
  min-height: 34px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

/* ==========================================================================
   STEP WORKFLOW & SELECTION QUEUE CHIPS
   ========================================================================== */
.selected-panel {
  background: #f8fafc;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.875rem 1rem;
  margin-block-start: 1rem;
}

.selected-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block-end: 0.65rem;
}

.counter-pill {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-text);
}

.counter-pill.limit-reached {
  background: var(--accent-danger-bg);
  color: var(--accent-danger);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  max-block-size: 130px;
  overflow-y: auto;
}

.item-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 0.2rem 0.5rem;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.item-chip button {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 2px;
  font-size: 0.95rem;
  line-height: 1;
}

.item-chip button:hover {
  color: var(--accent-danger);
}

/* ==========================================================================
   RESPONSIVE DATA TABLES (Modern Web Guidance Pattern)
   Uses sticky headers + @container queries for mobile stacked cards
   ========================================================================== */
.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: min(560px, 75vh);
  container-type: inline-size;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.table-wrapper:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}

.data-table caption {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.data-table thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
}

.data-table thead th {
  background: #f1f5f9;
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.75rem 1rem;
  text-align: left;
  border-block-end: 1px solid var(--border-strong);
  white-space: nowrap;
}

.data-table tbody tr {
  transition: background-color 0.1s ease;
}

.data-table tbody tr:hover {
  background-color: var(--bg-hover);
}

.data-table tbody tr.is-selected {
  background-color: var(--bg-active);
}

.data-table tbody th,
.data-table tbody td {
  padding: 0.75rem 1rem;
  border-block-end: 1px solid var(--border-color);
  vertical-align: middle;
}

/* Sticky row header on desktop */
.data-table tbody th {
  position: sticky;
  inset-inline-start: 0;
  background: var(--bg-surface);
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-primary);
  text-align: left;
  z-index: 1;
}

.data-table tbody tr:hover th {
  background: var(--bg-hover);
}

.data-table tbody tr.is-selected th {
  background: var(--bg-active);
}

.text-right {
  text-align: right !important;
}

.text-center {
  text-align: center !important;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.qty-badge {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.88rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
}

.qty-badge.in-stock {
  background: var(--primary-light);
  color: var(--primary-text);
}

.qty-badge.zero-stock {
  background: #fee2e2;
  color: #b91c1c;
}

.qty-badge.negative-stock {
  background: #fee2e2;
  color: #b91c1c;
}

.item-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--primary);
  font-weight: 600;
  font-family: var(--font-mono);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 0.85rem;
}

.item-link-btn:hover {
  color: var(--primary-hover);
}

/* Responsive Stacked Cards inside narrow container (< 640px) */
@container (width < 640px) {
  .data-table,
  .data-table thead,
  .data-table tbody,
  .data-table tr,
  .data-table th,
  .data-table td {
    display: block;
  }

  .data-table thead {
    display: none;
  }

  .data-table tbody tr {
    margin: 0.65rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
  }

  .data-table tbody th {
    position: sticky;
    inset-block-start: 0;
    z-index: 2;
    background: #f1f5f9;
    padding: 0.6rem 0.875rem;
    border-block-end: 1px solid var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .data-table tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.875rem;
    text-align: right !important;
  }

  .data-table tbody td:last-child {
    border-block-end: none;
  }

  .data-table tbody td::before {
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    text-align: left;
    flex-shrink: 0;
  }

  /* COMPACT SINGLE-TOUCH ROW FOR MASTER ITEMS SEARCH TABLE ON MOBILE */
  .search-table tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "itemId action"
      "itemDesc action";
    align-items: center;
    gap: 0.15rem 0.75rem;
    margin: 0;
    padding: 0.65rem 0.875rem;
    border: none;
    border-block-end: 1px solid var(--border-color);
    border-radius: 0;
    box-shadow: none;
  }

  .search-table tbody th {
    grid-area: itemId;
    position: static;
    background: transparent !important;
    border: none;
    padding: 0;
    justify-content: flex-start;
  }

  .search-table tbody td:nth-child(2) {
    grid-area: itemDesc;
    display: block;
    padding: 0 0 0 1.75rem;
    border: none;
    text-align: left !important;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.35;
  }

  .search-table tbody td:nth-child(2)::before {
    content: none !important;
  }

  .search-table tbody td:nth-child(3) {
    grid-area: action;
    padding: 0;
    border: none;
    justify-content: flex-end;
  }

  .search-table tbody td:nth-child(3)::before {
    content: none !important;
  }

  /* On mobile, hide the button text "Cek Semua Lokasi" so only the pin icon shows, giving maximum width to Item Description */
  .btn-loc-action .btn-loc-text {
    display: none;
  }

  .btn-loc-action {
    padding: 0.45rem !important;
    min-width: 36px;
    min-height: 36px;
  }

  /* Stock Results Table Labels (4 columns: ITEMID | DESCRIPTION | QTY | UNIT) */
  .stock-table {
    --label-2: "DESCRIPTION";
    --label-3: "QTY";
    --label-4: "UNIT";
  }
  .stock-table tbody td:nth-child(2)::before { content: var(--label-2) ": "; }
  .stock-table tbody td:nth-child(3)::before { content: var(--label-3) ": "; }
  .stock-table tbody td:nth-child(4)::before { content: var(--label-4) ": "; }

  /* Modal Location Breakdown Table Labels (3 columns: Location ID | Description | Qty + UOM) */
  .modal-stock-table {
    --label-2: "Description";
    --label-3: "Qty + UOM";
  }
  .modal-stock-table tbody td:nth-child(2)::before { content: var(--label-2) ": "; }
  .modal-stock-table tbody td:nth-child(3)::before { content: var(--label-3) ": "; }

  /* Master Users Table Labels */
  .users-table {
    --label-2: "Nama Lengkap";
    --label-3: "Role Akses";
    --label-4: "Warehouse ID";
    --label-5: "Allowed Brand";
    --label-6: "Akses Customer";
    --label-7: "Aksi";
  }
  .users-table tbody td:nth-child(2)::before { content: var(--label-2) ": "; }
  .users-table tbody td:nth-child(3)::before { content: var(--label-3) ": "; }
  .users-table tbody td:nth-child(4)::before { content: var(--label-4) ": "; }
  .users-table tbody td:nth-child(5)::before { content: var(--label-5) ": "; }
  .users-table tbody td:nth-child(6)::before { content: var(--label-6) ": "; }
  .users-table tbody td:nth-child(7)::before { content: var(--label-7) ": "; }

  /* Activity Logs Table Labels */
  .logs-table {
    --label-2: "User";
    --label-3: "Tipe Aksi";
    --label-4: "Lokasi";
    --label-5: "Jml Item";
    --label-6: "Daftar Item ID";
  }
  .logs-table tbody td:nth-child(2)::before { content: var(--label-2) ": "; }
  .logs-table tbody td:nth-child(3)::before { content: var(--label-3) ": "; }
  .logs-table tbody td:nth-child(4)::before { content: var(--label-4) ": "; }
  .logs-table tbody td:nth-child(5)::before { content: var(--label-5) ": "; }
  .logs-table tbody td:nth-child(6)::before { content: var(--label-6) ": "; }

  /* Pricelist Reguler Table Labels (4 columns: ITEM ID | DESCRIPTION | UNIT PRICE | UNIT) */
  .pricelist-table {
    --label-2: "DESCRIPTION";
    --label-3: "UNIT PRICE";
    --label-4: "UNIT";
  }
  .pricelist-table.is-bazaar {
    --label-2: "DESCRIPTION";
    --label-3: "UNIT PRICE";
    --label-4: "SELL PRICE";
    --label-5: "DISC";
  }
  .pricelist-table tbody td:nth-child(2)::before { content: var(--label-2) ": "; }
  .pricelist-table tbody td:nth-child(3)::before { content: var(--label-3) ": "; }
  .pricelist-table tbody td:nth-child(4)::before { content: var(--label-4) ": "; }
  .pricelist-table.is-bazaar tbody td:nth-child(5)::before { content: var(--label-5) ": "; }
}

/* ==========================================================================
   SEARCH TABS (Tab Search by ItemID & Tab Search by Item Description)
   ========================================================================== */
.search-tabs {
  display: inline-flex;
  background: #f1f5f9;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  gap: 0.25rem;
  margin-block-end: 1rem;
  flex-wrap: wrap;
}

.search-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.search-tab-btn:hover {
  color: var(--text-primary);
}

.search-tab-btn.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
}
.role-badge.role-0 { background: #ede9fe; color: #5b21b6; }
.role-badge.role-1 { background: #dbeafe; color: #1e40af; }
.role-badge.role-2 { background: #dcfce7; color: #166534; }
.role-badge.role-3 { background: #e0e7ff; color: #3730a3; }
.role-badge.role-4 { background: #e0f2fe; color: #0369a1; }


/* ==========================================================================
   MODAL DIALOG (<dialog closedby="any">)
   ========================================================================== */
dialog.stock-dialog {
  width: min(92vw, 860px);
  max-height: 88dvh;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0;
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

dialog.stock-dialog[open] {
  display: flex;
  flex-direction: column;
}

dialog.stock-dialog::backdrop {
  background-color: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
}

.dialog-header {
  padding: 1rem 1.25rem;
  background: var(--bg-subtle);
  border-block-end: 1px solid var(--border-color);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.dialog-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.dialog-subtitle {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.dialog-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.dialog-footer {
  padding: 0.875rem 1.25rem;
  background: var(--bg-subtle);
  border-block-start: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* ==========================================================================
   EMPTY STATES & TABLE FILTER BAR
   ========================================================================== */
.table-filter-bar {
  padding: 0.75rem 1.25rem;
  background: #f8fafc;
  border-block-end: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.table-filter-bar[hidden] {
  display: none !important;
}

.empty-state {
  text-align: center;
  padding: 2.75rem 1.25rem;
  color: var(--text-muted);
}

.empty-state-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-block-end: 0.75rem;
}

.empty-state h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  color: var(--text-primary);
}

.empty-state p {
  margin: 0 auto;
  max-width: 440px;
  font-size: 0.85rem;
}

/* Checkbox styling */
.checkbox-input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Mobile bottom navigation & Floating Action Bar */
.mobile-bottom-nav {
  display: none;
}

.mobile-floating-bar {
  display: none;
}

.stock-toolbar {
  padding: 0.75rem 1.25rem;
  background: #f8fafc;
  border-block-end: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.stock-toolbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Mobile user badge (hidden on desktop since sidebar shows full profile) */
.mobile-user-badge {
  display: none;
}

/* Pricelist Search Bar & Pagination */
.pricelist-search-bar {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.pricelist-search-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pagination-bar {
  padding: 0.85rem 1.25rem;
  background: var(--bg-subtle);
  border-block-start: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.pagination-info {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 0.6rem;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.page-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Barcode Scanner Modal Viewport */
.scanner-viewport {
  width: 100%;
  min-height: 260px;
  background: #0f172a;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scanner-viewport video {
  width: 100% !important;
  height: auto !important;
  border-radius: var(--radius-md);
  object-fit: cover;
}

.scanner-status-text {
  font-size: 0.83rem;
  color: var(--text-secondary);
  text-align: center;
  font-weight: 500;
}

.scanner-controls-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  .sidebar {
    display: none;
  }

  .main-wrapper {
    margin-inline-start: 0;
    padding-block-end: calc(var(--bottom-nav-height) + 5.5rem);
  }

  .topbar {
    padding: 0 0.875rem;
    gap: 0.5rem;
  }

  .topbar-title {
    font-size: 0.98rem;
    white-space: nowrap;
  }

  .topbar-actions {
    gap: 0.45rem;
  }

  .topbar-actions .pill-badge,
  .topbar-actions .role-badge {
    display: none;
  }

  .mobile-user-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.22rem 0.55rem 0.22rem 0.28rem;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    max-width: 165px;
  }

  .mobile-user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #1e293b;
    color: #60a5fa;
    font-size: 0.7rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .mobile-user-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .main-content {
    padding: 0.75rem;
  }

  /* Solution A: Natural Page Scroll on Mobile (No nested table scroll trap) */
  .main-content .table-wrapper {
    max-block-size: none;
    overflow-y: visible;
  }

  /* Solution B: Floating Action Bar right above bottom navigation */
  .mobile-floating-bar {
    display: flex;
    position: fixed;
    inset-block-end: calc(var(--bottom-nav-height) + 0.5rem);
    inset-inline: 0.75rem;
    background: #0f172a;
    color: #ffffff;
    border-radius: var(--radius-md);
    padding: 0.6rem 0.85rem;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.35);
    z-index: 39;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    border: 1px solid #334155;
  }

  .mobile-floating-bar[hidden] {
    display: none !important;
  }

  .mobile-floating-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .mobile-floating-count {
    font-size: 0.82rem;
    font-weight: 700;
    color: #60a5fa;
    white-space: nowrap;
  }

  .mobile-floating-loc {
    font-size: 0.7rem;
    color: #cbd5e1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-floating-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
  }

  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    inset-block-end: 0;
    inset-inline: 0;
    height: var(--bottom-nav-height);
    background: var(--bg-surface);
    border-block-start: 1px solid var(--border-color);
    box-shadow: 0 -4px 12px rgba(15, 23, 42, 0.06);
    z-index: 40;
    justify-content: space-around;
    align-items: center;
    padding: 0 0.25rem;
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius-sm);
    border: none;
    background: none;
    cursor: pointer;
  }

  .mobile-nav-item.active {
    color: var(--primary);
  }
}
