/* Responsive overrides for smaller screens. */

.sidebar-header .logo img {
  height: 120px;
  width: auto;
}

.sidebar-wrapper .sidebar-header img {
  height: 120px;
  width: auto;
}

#auth #auth-left .auth-logo img {
  height: 3.6rem;
  width: auto;
}

.layout-horizontal .header-top .logo img {
  height: 36px;
  width: auto;
}

.barcode-box {
  width: min(92vw, 520px);
  margin: 8vh auto;
  box-sizing: border-box;
}

.barcode-preview,
.barcode-video {
  width: 100%;
  height: min(45vh, 360px);
  max-height: 360px;
  border-radius: 10px;
  background: #111;
  overflow: hidden;
}

.barcode-video {
  display: none;
  object-fit: cover;
}

.barcode-preview canvas,
.barcode-preview video,
.barcode-preview img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}

.barcode-help {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
  color: #6b7280;
}

.barcode-status {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: #1f2937;
  min-height: 1.1rem;
}

.barcode-status.is-error {
  color: #b91c1c;
}

.barcode-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.barcode-label {
  font-size: 0.9rem;
  color: #4b5563;
  margin: 0;
}

#barcode-zoom {
  flex: 1;
}

.barcode-manual {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.barcode-modal {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.barcode-image-preview {
  max-height: 90px;
  border-radius: 6px;
}

.scan-page .card-body {
  display: flex;
  justify-content: center;
}

.scan-page .scan-center {
  width: 100%;
  max-width: 760px;
}

.scan-page .scan-video-wrap {
  width: 100%;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

.scan-page .row {
  justify-content: center;
}

.scan-page .card {
  width: 100%;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

.scan-page .page-title {
  margin-bottom: 0.5rem;
}

@media (max-width: 1200px) {
  #main {
    margin-left: 0 !important;
    padding-left: 0 !important;
    padding-top: 4.5rem !important;
  }

  #sidebar .sidebar-wrapper {
    width: 80vw !important;
    max-width: 320px;
    position: fixed !important;
    z-index: 1050;
    left: -100% !important;
    top: 0;
    height: 100vh;
    transition: left 0.2s ease;
  }

  #sidebar.active .sidebar-wrapper {
    left: 0 !important;
  }

  #sidebar .sidebar-menu {
    overflow-y: auto;
    overflow-x: hidden;
  }

  .sidebar-toggler {
    display: block;
    position: relative;
    z-index: 1060;
  }

  .sidebar-hide {
    position: relative;
    z-index: 1061;
    pointer-events: auto;
  }

  .mobile-burger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 1040;
    padding: 0.5rem 0.6rem;
    border-radius: 0.6rem;
    background: #ffffff;
    color: #25396f;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
  }

  body.theme-dark .mobile-burger {
    background: #111827;
    color: #e5e7eb;
  }

  .card,
  .card .card,
  .card-content,
  .card-body {
    max-width: 100% !important;
  }

  .table-responsive,
  .table-responsive-lg,
  .table-ticket {
    overflow-x: auto;
  }

  .modal-dialog {
    max-width: 95vw;
    margin: 1rem auto;
  }
}

@media (display-mode: standalone) {
  #sidebar .sidebar-menu {
    overflow-y: auto;
    overflow-x: hidden;
  }
}

@media (max-width: 768px) {
  .form-control,
  .form-select,
  .input-group {
    width: 100% !important;
  }

  #video {
    height: 45vh !important;
    max-height: 320px !important;
  }

  .barcode-box {
    width: 94vw;
    margin: 5vh auto;
    padding: 0.75rem;
  }

  .barcode-preview,
  .barcode-video {
    height: 38vh;
    max-height: 260px;
  }

  #debugLog {
    max-height: 140px;
    font-size: 10px;
  }

  #productInfo .card .card-body .d-grid,
  #productInfo .card .card-body .d-md-flex {
    display: grid !important;
    gap: 0.5rem;
  }

  .sidebar-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
  }

  .sidebar-wrapper .sidebar-header {
    flex: 0 0 auto;
  }

  .sidebar-wrapper .sidebar-menu {
    flex: 1 1 auto;
    overflow: hidden;
  }

  .sidebar-wrapper .menu {
    padding-bottom: 2rem;
    height: calc(100vh - 220px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* Scrollbar styling for dark and light themes */
  .sidebar-wrapper .menu::-webkit-scrollbar {
    width: 8px;
  }

  .sidebar-wrapper .menu::-webkit-scrollbar-track {
    background: transparent;
  }

  .sidebar-wrapper .menu::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
  }

  .sidebar-wrapper .menu::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.5);
  }

  body.theme-dark .sidebar-wrapper .menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
  }

  body.theme-dark .sidebar-wrapper .menu::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
  }

  #auth .row.h-100 {
    flex-direction: column;
  }

  #auth-left {
    padding: 2rem 1.5rem;
  }

  #auth-right {
    display: none !important;
  }

  .header-top,
  .main-navbar {
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
  }

  .main-navbar ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
  }

}

@media (min-width: 769px) {
  .mouvements-accordion {
    display: none;
  }
}

@media (max-width: 576px) {
  .page-heading h3 {
    font-size: 1.25rem;
  }

  .btn,
  .btn-lg,
  .btn-block {
    width: 100%;
  }

  .card-title {
    font-size: 1rem;
  }

  #video {
    height: 40vh !important;
    max-height: 260px !important;
  }

  .scan-page .card {
    max-width: 100%;
  }

  #scanResult {
    font-size: 0.9rem;
  }

  #productDetails {
    font-size: 0.9rem;
  }

  .mouvements-table th,
  .mouvements-table td {
    font-size: 0.85rem;
  }

  .mouvements-table th:nth-child(6),
  .mouvements-table td:nth-child(6),
  .mouvements-table th:nth-child(7),
  .mouvements-table td:nth-child(7) {
    display: none;
  }
}

@media (max-width: 576px) and (orientation: portrait) {
  .mouvements-table th,
  .mouvements-table td {
    font-size: 0.78rem;
    padding: 0.35rem 0.4rem;
  }
}
