:root {
  --bg-color: #eef2f7;
  --text-color: #333;
  --input-bg: #fff;
  --input-border: #ccc;
  --btn-success-bg: #4caf50;
  --btn-secondary-bg: #ddd;
  --alert-success-bg: #e0f7e9;
  --alert-success-color: #2e7d32;
  --alert-error-bg: #fceceb;
  --alert-error-color: #c62828;
  --accent-color: #3a86ff;
}

body.dark-mode {
  --bg-color: #1e1e1e;
  --text-color: #f0f0f0;
  --input-bg: #2c2c2c;
  --input-border: #555;
  --btn-success-bg: #388e3c;
  --btn-secondary-bg: #555;
  --alert-success-bg: #2e7d32;
  --alert-success-color: #e0f7e9;
  --alert-error-bg: #c62828;
  --alert-error-color: #fdecea;
  --accent-color: #5d9cff;
}

body {
  font-family: "Inter", sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  padding: 10px;
  font-size: 14px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

.dialog {
  padding: 15px;
  border-radius: 12px;
  background: var(--input-bg);
  margin: 15px 0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

h2 {
  margin-top: 0;
  font-weight: 600;
  font-size: 1.4rem;
}

h3 {
  font-size: 1.2rem;
}

.d-flex {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

input,
select {
  flex: 1 1 100%;
  padding: 12px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 6px;
  font-size: 16px;
  color: var(--text-color);
  box-sizing: border-box;
}

input:focus,
select:focus {
  border-color: var(--accent-color);
  outline: none;
}

button {
  padding: 12px 16px;
  font-size: 15px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
  flex: 1;
  min-width: 120px;
}

button:hover {
  transform: translateY(-2px);
  opacity: 0.9;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.btn-success {
  background-color: var(--btn-success-bg);
  color: #fff;
}

.btn-secondary {
  background-color: #c62828;
  color: #fff;
  /* background-color: var(--btn-secondary-bg);
      color: var(--text-color); */
}

.btn-accent {
  background-color: var(--accent-color);
  color: white;
}

.info-row p {
  margin: 0;
  font-weight: 600;
  font-size: 18px;
}

.success {
  color: var(--btn-success-bg);
  font-weight: 600;
}

.error {
  color: red;
  font-weight: bold;
}

.button-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 15px;
}

@media (min-width: 768px) {
  input,
  select {
    flex: 1;
  }

  .button-group {
    flex-direction: row;
    justify-content: flex-end;
  }
}

.alert {
  padding: 10px 15px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-weight: 500;
  display: none;
  font-size: 14px;
}

.alert-success {
  background-color: var(--alert-success-bg);
  color: var(--alert-success-color);
}

.alert-error {
  background-color: var(--alert-error-bg);
  color: var(--alert-error-color);
}

.theme-toggle {
  position: fixed;
  top: 10px;
  right: 10px;
  background: var(--btn-secondary-bg);
  color: var(--text-color);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  z-index: 100;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
  background: var(--input-bg);
  font-size: 13px;
}

th,
td {
  border: 1px solid var(--input-border);
  padding: 8px;
  text-align: left;
}

th {
  background-color: var(--btn-secondary-bg);
  font-weight: 600;
  font-size: 13px;
}

.tabs {
  margin-top: 20px;
}

.tab-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 8px 12px;
  font-size: 13px;
  background-color: var(--btn-secondary-bg);
  color: var(--text-color);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  flex: 1;
  min-width: 120px;
}

.tab-btn.active {
  background-color: var(--accent-color);
  color: white;
  font-weight: bold;
}

.tab-content {
  display: none;
  overflow-x: auto;
}

.tab-content.visible {
  display: block;
}

.multi-product-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  padding: 10px;
  background: var(--btn-secondary-bg);
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
}

.multi-product-toggle input {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.multi-product-toggle label {
  font-weight: 600;
  cursor: pointer;
}

.multi-product-section {
  margin-top: 15px;
  display: none;
}

.multi-product-section.visible {
  display: block;
}

.multi-product-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}

.multi-product-table th {
  background-color: var(--accent-color);
  color: white;
  font-size: 13px;
}

.product-count {
  display: flex;
  align-items: center;
  gap: 5px;
}

.product-count button {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 4px;
  min-width: auto;
}

.header-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 15px;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-color);
  color: white;
}

.mode-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 20px;
  background: var(--alert-success-bg);
  color: var(--alert-success-color);
  font-size: 13px;
  margin-top: 5px;
}

.mode-indicator.multi {
  background: var(--accent-color);
  color: white;
}

.location-info {
  color: var(--accent-color);
}

/* Mobile specific styles */
@media (max-width: 767px) {
  body {
    padding: 8px;
  }

  .dialog {
    padding: 12px;
  }

  h2 {
    font-size: 1.3rem;
  }

  input,
  select {
    padding: 10px;
    font-size: 15px;
  }

  button {
    padding: 10px 14px;
    font-size: 14px;
    min-width: 100px;
  }

  .d-flex {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .theme-toggle {
    top: 5px;
    right: 5px;
    font-size: 12px;
    padding: 6px 10px;
  }

  .header-section h2 {
    font-size: 1.2rem;
  }

  .btn-group button {
    flex: 1 1 45%;
    min-width: auto;
    font-size: 13px;
  }

  .tab-btn {
    padding: 6px 10px;
    font-size: 12px;
    min-width: auto;
    flex: 1 1 45%;
  }

  th,
  td {
    padding: 6px;
    font-size: 12px;
  }

  .location-info {
    font-size: 15px;
  }
}

/* For very small screens */
@media (max-width: 480px) {
  button {
    min-width: auto;
    flex: 1;
  }

  .btn-group button {
    flex: 1 1 100%;
  }

  .tab-btn {
    flex: 1 1 100%;
  }
}

#snackbar {
  visibility: hidden;
  min-width: 250px;
  max-width: 90vw;
  margin-left: -125px;
  background-color: #333;
  color: #fff;
  text-align: center;
  border-radius: 8px;
  padding: 16px;
  position: fixed;
  z-index: 9999;
  left: 50%;
  bottom: 30px;
  font-size: 16px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  transition: visibility 0s, opacity 0.3s ease-in-out;
  opacity: 0;
}

#snackbar.show {
  visibility: visible;
  opacity: 1;
}

#snackbar.alert-success {
  background-color: #28a745;
}

#snackbar.alert-error {
  background-color: #dc3545;
}

.modal {
  display: none;
  position: fixed;
  z-index: 9998;
  background-color: rgba(0, 0, 0, 0.6);
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

.modal-content {
  background: white;
  padding: 20px;
  width: 300px;
  max-width: 90%;
  margin: 100px auto;
  border-radius: 8px;
}

.modal-content label {
  display: block;
  margin-top: 10px;
}

.modal-content input,
.modal-content select {
  width: 100%;
  padding: 6px;
  margin-top: 4px;
}

.modal-actions {
  margin-top: 15px;
  text-align: right;
}

.modal-actions button {
  margin-left: 10px;
}

#loadingOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.7);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
}

.loader {
  border: 8px solid #f3f3f3;
  border-top: 8px solid #3498db;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

  .pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 500px; /* หรือกว้างเท่าที่ต้องการ */
    margin: 10px auto; /* จัดให้อยู่กึ่งกลาง */
  }

  .pagination-container button {
    width: 33%;
    padding: 8px;
    font-size: 16px;
  }

  .pagination-container span {
    width: 33%;
    text-align: center;
    font-weight: bold;
    font-size: 16px;
  }