/* Scan page — app header */
.scan-app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
  border-radius: 0.875rem;
  color: #fff;
  box-shadow: 0 4px 16px rgba(13, 110, 253, 0.28);
}

.scan-app-header__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.scan-app-header__icon {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 0.625rem;
  font-size: 1.15rem;
}

.scan-app-header__text {
  min-width: 0;
}

.scan-app-header__title {
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.3;
}

.scan-app-header__user {
  font-size: 0.78rem;
  opacity: 0.88;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 12rem;
}

.scan-app-header__logout {
  flex-shrink: 0;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.1);
  border-radius: 0.5rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
  line-height: 1.2;
}

.scan-app-header__logout:hover,
.scan-app-header__logout:focus {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.55);
  color: #fff;
}

@media (min-width: 576px) {
  .scan-app-header {
    padding: 1rem 1.25rem;
  }

  .scan-app-header__icon {
    width: 2.75rem;
    height: 2.75rem;
    font-size: 1.25rem;
  }

  .scan-app-header__title {
    font-size: 1.125rem;
  }

  .scan-app-header__user {
    font-size: 0.82rem;
    max-width: 16rem;
  }
}

.scan-last-result {
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  padding: 0.875rem 1rem;
  background: #f8f9fa;
}

.scan-last-result--success {
  border-color: #badbcc;
  background: #d1e7dd;
}

.scan-last-result--error {
  border-color: #f5c2c7;
  background: #f8d7da;
}

.scan-last-result__label {
  font-size: 0.75rem;
  color: #6c757d;
  margin-bottom: 0.25rem;
}

.scan-last-result__code {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  word-break: break-all;
}

.scan-last-result__msg {
  font-size: 0.9rem;
}

.scan-list-item--highlight {
  background: #fff3cd;
  transition: background 0.3s ease;
}

/* Scan page custom styles */
.scan-card {
  margin-top: 2.5rem;
  padding: 1.25rem;
  border-radius: 0.75rem;
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}
.barcode-input {
  font-size: 1.25rem;
  padding: .75rem .85rem;
}
.barcode-input:focus {
  border-color: #198754;
  box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.2);
}
.camera-btn { min-width: 3.6rem; }
.save-btn { min-width: 6rem; }

/* Camera modal — tự co giãn theo màn hình */
.scan-camera-dialog {
  max-width: min(420px, calc(100vw - 1.25rem));
  width: 100%;
  margin: clamp(0.5rem, 2vw, 1rem) auto;
}
.camera-modal-body {
  display: flex;
  flex-direction: column;
}
.camera-scanner-view {
  width: 100%;
  /* Chiều cao set thêm bằng JS theo viewport; CSS là fallback */
  min-height: clamp(200px, 34vh, 280px);
  max-height: min(42vh, 300px);
  background: #000;
  position: relative;
}
.camera-scanner-view video {
  display: block;
  width: 100% !important;
  height: auto !important;
  max-height: min(42vh, 300px);
  object-fit: cover;
}
.camera-scan-feedback {
  min-height: 48px;
  padding: 0.6rem 0.75rem;
  text-align: center;
  font-size: clamp(0.8rem, 2.8vw, 0.9rem);
  border-top: 1px solid #dee2e6;
}
@media (max-width: 380px) {
  .scan-camera-dialog {
    max-width: calc(100vw - 0.75rem);
    margin: 0.35rem auto;
  }
}
@media (min-height: 700px) and (max-width: 576px) {
  .camera-scanner-view {
    min-height: clamp(220px, 36vh, 300px);
  }
}

.list-small { max-height: 320px; overflow:auto; }
.list-item-text { font-family: monospace; font-size: .95rem; }
/* Ensure long codes wrap on small screens */
.list-item-text { word-break: break-all; }

/* Mobile tweaks */
.scan-mode-toggle .form-check-input {
  cursor: pointer;
}

.scan-mode-toggle .form-check-label {
  cursor: pointer;
}

@media (max-width: 576px) {
  .barcode-input { font-size: 1.05rem; padding: .6rem .7rem; }
  .camera-btn, .save-btn { min-width: 44px; height:44px; padding:0 .5rem; }
  .scan-card { padding: .75rem; }
  /* hide index column on xs (redundant with d-none but ensures layout) */
  th.d-none.d-sm-table-cell, td.d-none.d-sm-table-cell { display:none !important; }
  /* action button sizing on xs */
  td.text-end { text-align: right; }
  .list-small td .btn { padding:.35rem .5rem; }
  /* make video area larger and responsive */
  #video { width:100%; height:auto; border-radius:6px; }
}
