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

:root {
  --qs-navbar-h: 56px;
  --qs-sidebar-w: 250px;
  --bs-body-font-family: 'Sarabun', sans-serif;
}

* {
  font-family: 'Sarabun', sans-serif;
}

html {
  width: 100%;
  font-size: 15px;
}

/* Slightly larger text on phones for readability */
@media (max-width: 767.98px) {
  html {
    font-size: 16px;
  }
}

body {
  font-family: 'Sarabun', sans-serif;
  background-color: #f8f9fa;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Top navigation ---------- */
nav.navbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  min-height: var(--qs-navbar-h);
}

.navbar-brand {
  font-weight: 600;
  letter-spacing: 0.5px;
  font-size: 1.1rem;
}

/* ---------- App shell ---------- */
/* Grows to fill the viewport so the footer stays at the bottom on short pages */
body > .container-fluid {
  flex: 1 0 auto;
  width: 100%;
}

main {
  min-width: 0;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background-color: #fff;
  border-right: 1px solid #dee2e6;
}

.sidebar .nav-link {
  color: #495057;
  border-radius: 0.375rem;
  margin: 0.125rem 0;
}

.sidebar .nav-link:hover {
  background-color: #f1f3f5;
}

.sidebar .nav-link.active {
  background-color: #0d6efd;
  color: #fff;
}

.sidebar .nav-link i {
  width: 1.25rem;
  text-align: center;
}

/* Desktop / notebook / large tablet: static sticky column */
@media (min-width: 992px) {
  /* Keep sidebar + main on one line; let the main column shrink instead of wrapping */
  body > .container-fluid > .row {
    flex-wrap: nowrap;
  }

  .sidebar {
    position: sticky;
    top: var(--qs-navbar-h);
    align-self: flex-start;
    flex: 0 0 var(--qs-sidebar-w);
    width: var(--qs-sidebar-w);
    max-width: var(--qs-sidebar-w);
    height: calc(100vh - var(--qs-navbar-h));
    max-height: calc(100vh - var(--qs-navbar-h));
    overflow-y: auto;
    overflow-x: hidden;
  }

  main.col-lg-10 {
    flex: 1 1 0%;
    width: auto;
    max-width: none;
    min-width: 0;
  }
}

/* Tablet portrait / mobile: off-canvas drawer */
@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
    top: var(--qs-navbar-h);
    bottom: 0;
    left: 0;
    width: var(--qs-sidebar-w);
    max-width: 82vw;
    z-index: 1045;
    overflow-y: auto;
    box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.18);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    top: var(--qs-navbar-h);
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
  }

  .sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  main.col-lg-10 {
    flex: 0 0 100%;
    width: 100%;
    max-width: 100%;
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
}

/* ---------- Cards & tables ---------- */
.card {
  border-radius: 0.6rem;
}

.table-responsive {
  -webkit-overflow-scrolling: touch;
}

.table > :not(caption) > * > * {
  vertical-align: middle;
}

.font-monospace {
  overflow-wrap: anywhere;
}

/* DataTables buttons wrap nicely on small screens */
.dt-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.dt-buttons .btn {
  margin: 0 !important;
}

.dataTables_wrapper .row {
  --bs-gutter-y: 0.5rem;
}

@media (max-width: 575.98px) {
  .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_length {
    text-align: left;
  }
}

/* Slightly smaller headings on phones */
@media (max-width: 575.98px) {
  h4 {
    font-size: 1.2rem;
  }

  .fs-4 {
    font-size: 1.35rem !important;
  }
}

.badge-count {
  font-size: 0.875rem;
}

#qr-reader {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  border-radius: 0.5rem;
  overflow: hidden;
}

.toast-container {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 1100;
}

.print-only {
  display: none;
}

@media print {
  .no-print {
    display: none !important;
  }

  .print-only {
    display: block !important;
  }

  body {
    background: #fff;
    font-size: 12px;
    display: block;
  }

  body > .container-fluid {
    display: block;
  }

  main.col-lg-10 {
    width: 100% !important;
    max-width: 100% !important;
  }

  .table {
    font-size: 11px;
  }
}
