:root {
  --primary: #f15025;
  --on-primary: #ffffff;
  --bg: #ffffff;
  --bg-alt: #e6e8e6;
  --surface: #ced0ce;
  --text: #191919;
  --elevation: 0 2px 8px rgba(0, 0, 0, 0.15);
  --radius: 10px;
}

/* ปิดการไฮไลท์ข้อความทั้งหมด */
* {
  user-select: none !important;
  -webkit-user-select: none !important; /* Safari/Chrome */
  -moz-user-select: none !important; /* Firefox */
  -ms-user-select: none !important; /* IE10+ */
  -webkit-touch-callout: none !important; /* iOS Safari ปิด callout */
}

body {
  margin: 0;
  font-family: "Roboto", sans-serif;
  background: var(--bg);
  color: var(--text);
  text-align: center;
}

input,
textarea {
  user-select: text !important;
}

.appbar {
  background-color: var(--primary);
  color: var(--on-primary);
  padding: 1em;
  font-size: 1.2em;
  font-weight: 500;
  box-shadow: var(--elevation);
  position: sticky;
  top: 0;
  z-index: 10;
  text-align: left;        /* เปลี่ยนจาก center เป็น left */
  padding-left: 1.5em;     /* เพิ่มระยะห่างซ้าย */
}

#container {
  padding: 2em 1em;
  background: var(--bg);
  max-width: 1200px; /* กำหนดความกว้างสูงสุด */
  margin: 0 auto; /* กึ่งกลางแนวนอน */
  padding: 2em 1em; /* รักษาระยะขอบ (padding) เดิม */
  box-sizing: border-box; /* ให้ padding ไม่ทำให้เกินขนาด max-width */
  padding-bottom: 70px;
}

#qr {
  width: 300px !important; /* กำหนดความกว้างที่ต้องการ */
  height: 300px !important; /* กำหนดความสูงให้เท่ากับความกว้าง (สี่เหลี่ยมจัตุรัส) */
  margin: 10px auto;
  display: block; /* ให้ canvas อยู่กลาง */
}

#code {
  font-size: 2em;
  font-weight: bold;
  margin-top: 10px;
  letter-spacing: 3px;
}

button {
  background-color: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: var(--radius);
  padding: 0.6em 1.2em;
  font-size: 1em;
  font-weight: 500;
  box-shadow: var(--elevation);
  transition: background-color 0.3s, transform 0.2s;
  cursor: pointer;
}

button:hover {
  background-color: #d4421f;
  transform: scale(1.02);
}

a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

a:hover {
  text-decoration: underline;
}

#overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

#preview {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  background: black;
  border-radius: var(--radius);
}

.modal {
  position: fixed;
  z-index: 10;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: var(--surface);
  padding: 1.5em;
  border-radius: var(--radius);
  max-width: 400px;
  text-align: left;
  box-shadow: var(--elevation);
  position: relative;
  color: var(--text);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 1.5em;
  font-weight: bold;
  cursor: pointer;
}

.modal-images {
  display: flex;
  justify-content: space-between;
  margin-top: 1em;
}

.modal-images img {
  width: 30%;
  border-radius: var(--radius);
  box-shadow: var(--elevation);
}

#gallery {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 1em;
}

#gallery a {
  width: 150px; /* กำหนดขนาดความกว้าง */
  aspect-ratio: 1 / 1; /* กำหนดให้เป็นสี่เหลี่ยมจัตุรัส */
  overflow: hidden;
  border-radius: 6px;
  cursor: pointer;
  display: inline-block;
  position: relative;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}

#gallery a img {
  width: 100%;
  height: 100%;
  object-fit: cover; /* ครอปภาพให้เต็มกรอบโดยไม่บิดเบี้ยว */
  user-select: none;
  pointer-events: none;
  display: block;
  border-radius: inherit;
}

#gallery a.selected {
  outline: 4px solid var(--primary);
  border-radius: 8px;
}

#disconnect {
  margin-top: 1em;
  padding: 0.7em 1.5em;
  font-size: 1em;
  background-color: #e53935;
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  display: none;
}

#disconnect:hover {
  background-color: #c62828;
}

#codeSection {
  margin-top: 2em;
}

#codeInput {
  font-size: 2em;
  text-align: center;
  width: 120px;
  padding: 0.4em;
  border: 2px solid #ccc;
  border-radius: var(--radius);
}

#dropzone {
  margin-top: 1em;
  padding: 2em;
  border: 3px dashed var(--primary);
  border-radius: var(--radius);
  color: var(--primary);
  font-weight: bold;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.3s;
  display: none;
}

#dropzone.dragover {
  background-color: #ffe5dc;
}

#enterDeleteMode,
#deleteControls {
  margin-top: 1em;
}

#deleteControls {
  display: none;
}

#fileInput {
  display: none !important;
}

.sortable-ghost {
  opacity: 0.5;
  transform: scale(0.95);
  transition: all 0.2s ease;
}

#bottomNav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100vw;
  height: 56px;
  background-color: #f15025; /* โทนสีหลัก */
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  user-select: none;
}

#bottomNav .nav-link {
  color: white;
  text-decoration: none;
  font-weight: 600;
  font-size: 1.1em;
  flex-grow: 1;
  text-align: center;
  padding: 0.5em 0;
  transition: background-color 0.2s ease;
}

#bottomNav .nav-link:hover {
  background-color: #d03e1f;
}

#bottomNav .nav-link.active {
  background-color: #a63318;
}

#codeInputs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 1em;
}

.code-char {
  width: 40px;
  font-size: 2em;
  text-align: center;
}

.card {
  background-color: #ffffff; /* ขาวสะอาด */
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  padding: 1em;
  margin: 1em auto;
  box-sizing: border-box;
}

/* กรณีอยากให้ dropzone ดูโดดเด่นขึ้น */
#dropzone.card {
  border: none; /* เอาขอบ dashed ออกถ้าใส่ card */
  cursor: pointer;
  color: #f15025; /* ใช้โทนสีหลัก */
  font-weight: 600;
  font-size: 1.1em;
  text-align: center;
  padding: 3em 1em;
  user-select: none;
  transition: background-color 0.3s;
}

#dropzone.card.dragover {
  background-color: #ffe6e1; /* สีโทนอ่อนเมื่อ dragover */
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background-color: white;
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -1px 5px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #666;
  text-decoration: none;
  font-size: 12px;
  text-decoration: none;
}

.nav-item .material-icons {
  font-size: 24px;
  margin-bottom: 2px;
}

.nav-item.active {
  color: #f15025;
}

.nav-item:hover,
.nav-item:focus,
.nav-item:active {
  text-decoration: none;
  color: #f15025; /* หรือสีที่ต้องการเมื่อ hover */
}

@media (max-width: 768px) {
  #disconnect {
    width: 100%;
    box-sizing: border-box;
  }
}

#disconnect:hover {
  background-color: #c62828;
}

#qr-container {
  position: relative;
  margin: 0 auto;
}

#qr-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 4px solid #ccc;
  border-top-color: #f15025;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 10;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#loadingSpinner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1001;
  background: rgba(0, 0, 0, 0.6);
  padding: 1.5em;
  border-radius: 12px;
}

.spinner {
  border: 6px solid #eee;
  border-top: 6px solid #f15025;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  animation: spin 1s linear infinite;
}

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

@supports (padding: max(0px)) {
  html.ios-safe .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

#previewPlaceholder {
  text-align: center;
  font-style: italic;
  color: #444;
  margin-top: 50px;
  font-size: 1.1rem;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin: 30px 0;
}

.steps {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
}

.step img {
  width: 100%;
  max-width: 120px;
  height: auto;
  display: block;
  margin: 0 auto 12px;
}


.steps li {
  margin-bottom: 20px;
}

.steps li strong {
  display: block;
  font-size: 1.1rem;
  margin-bottom: 6px;
  color: var(--primary-color);
}

.steps li p {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: #555;
}

.steps li img {
  width: 100%;
  height: auto;
}

.step-image {
  width: 100%;
  min-height: 150px;
}

