/* ================================================================
   QR Kub Tools — สไตล์เฉพาะหน้าเครื่องมือ
   โหลดต่อจาก ../style.css ซึ่งเป็นระบบดีไซน์กลาง
   ไฟล์นี้เก็บเฉพาะสิ่งที่มีแต่ในหน้าเครื่องมือเท่านั้น
   ================================================================ */

/* หน้าเครื่องมือทั่วไป */
.tool-page {
  max-width: 860px;
  margin-inline: auto;
  padding: 32px 20px 64px;
}
.tool-page-wide { max-width: var(--page-max); }

.tool-head { margin-bottom: 24px; }
.tool-head h1 { margin-bottom: 8px; }
.tool-lead { color: var(--text-muted); font-size: .96rem; line-height: 1.75; max-width: 620px; }

/* การ์ดในหน้าเครื่องมือวางเรียงลงมา จึงต้องมีระยะห่างระหว่างกัน */
.tool-box { margin-bottom: 20px; }
.tool-box:last-of-type { margin-bottom: 0; }
.tool-box .card-title { margin-bottom: 16px; }

/* แถบบอกว่าไฟล์ไม่ถูกอัปโหลด */
.privacy-note {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 22px;
  border: 1px solid var(--success-border);
  border-radius: var(--radius);
  background: var(--success-subtle);
  color: var(--text-muted);
  font-size: .85rem;
  line-height: 1.6;
}
.privacy-note strong { color: var(--success); }

/* พื้นที่ลากไฟล์ */
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 180px;
  padding: 26px 20px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--ease), background var(--ease);
}
.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--accent);
  background: var(--accent-subtle);
  outline: none;
}
.dropzone.is-over { border-color: var(--accent); background: var(--accent-subtle); }
.dropzone-icon { color: var(--text-faint); }
.dropzone-icon svg { width: 30px; height: 30px; }
.dropzone-title { font-weight: 600; font-size: .93rem; color: var(--text); }
.dropzone-sub { font-size: .8rem; color: var(--text-muted); line-height: 1.55; }

/* กรอบแสดงผลลัพธ์ที่ต้องมีพื้นขาวเสมอ เช่น บาร์โค้ดและรูป */
.preview-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 190px;
  padding: 20px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}
.preview-frame img,
.preview-frame svg,
.preview-frame canvas,
.preview-frame video { max-width: 100%; height: auto; display: block; }

/* กล่องข้อความผลลัพธ์ */
.result-panel {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-inset);
}
.result-value {
  font-family: var(--mono);
  font-size: .88rem;
  line-height: 1.7;
  color: var(--text);
  word-break: break-all;
  white-space: pre-wrap;
}
.result-empty { color: var(--text-faint); font-family: var(--font); }

/* ── กริดภาพย่อของหน้า PDF ─────────────────────────────────── */
.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 14px;
}

.page-thumb {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
  transition: border-color var(--ease), opacity var(--ease);
}
.page-thumb canvas,
.page-thumb img {
  width: 100%;
  height: auto;
  display: block;
  background: #ffffff;
}
.page-thumb.is-selected { border-color: var(--accent); }
.page-thumb.is-removed { opacity: .35; border-style: dashed; }
.page-thumb.is-removed .page-thumb-media { filter: grayscale(1); }

.page-thumb-media {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  background: #ffffff;
}
.page-thumb-media .skeleton { width: 100%; aspect-ratio: 1 / 1.414; }

.page-thumb-no {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(22, 24, 29, .78);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
}

.page-thumb-actions {
  display: flex;
  gap: 4px;
  padding: 6px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}
.page-thumb-actions button {
  flex: 1;
  min-height: 34px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: var(--ease);
}
.page-thumb-actions button:hover { background: var(--bg-hover); color: var(--text); }
.page-thumb-actions button svg { width: 15px; height: 15px; margin: 0 auto; }
.page-thumb-actions .is-danger:hover { background: var(--danger-subtle); color: var(--danger); }

@media (pointer: coarse) {
  .page-thumb-actions button { min-height: 44px; }
}

/* แถบความคืบหน้า */
.progress-track {
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-inset);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: var(--radius-pill);
  background: var(--accent);
  transition: width .2s ease;
}

/* หน้ารวมเครื่องมือ */
.hub-toolbar { display: flex; flex-direction: column; gap: 12px; margin-bottom: 28px; }
.hub-cat-title { font-size: 1.05rem; font-weight: 700; margin: 32px 0 14px; }
.hub-cat-title:first-of-type { margin-top: 0; }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}
.tool-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: inherit;
  text-decoration: none;
  transition: var(--ease);
}
a.tool-card:hover {
  border-color: var(--accent-border);
  background: var(--accent-subtle);
  text-decoration: none;
}
.tool-card .tool-icon { margin-bottom: 3px; }
.tool-card-name { font-size: .96rem; font-weight: 700; color: var(--text); }
.tool-card-desc { font-size: .83rem; color: var(--text-muted); line-height: 1.6; }
.tool-card-soon { opacity: .55; cursor: not-allowed; }
.hub-empty { padding: 44px 20px; text-align: center; color: var(--text-muted); }

/* เครื่องมือที่เกี่ยวข้องท้ายหน้า */
.related-tools { margin-top: 36px; }
.related-tools h2 { font-size: 1.05rem; margin-bottom: 14px; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.related-link {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: .88rem;
  font-weight: 500;
  text-decoration: none;
  transition: var(--ease);
}
.related-link:hover { border-color: var(--cat-fg, var(--accent-border)); background: var(--cat-bg, var(--accent-subtle)); text-decoration: none; }

/* ไอคอนขนาดเล็กในลิงก์เครื่องมือที่เกี่ยวข้อง */
.tool-icon-sm { width: 32px; height: 32px; border-radius: 9px; }
.tool-icon-sm svg { width: 17px; height: 17px; }

@media (max-width: 560px) {
  .tool-page { padding: 24px 16px 48px; }
}
