/* =========================================================
   ค้นหารูปของฉัน — ใช้ธีมเดียวกับเว็บโรงเรียน (ตัวแปร --primary, --sky ฯลฯ มาจาก style.css ของเว็บ)
   ทุก class ขึ้นต้นด้วย fp- เพื่อไม่ให้ชนกับ CSS ของเว็บโรงเรียน
   ========================================================= */

/* ค่าเริ่มต้น ใช้เมื่อเปิดหน้านี้นอกเว็บโรงเรียน (ไม่มี style.css ของเว็บ) */
.fp-standalone {
  --primary: #1e88e5; --primary-dark: #0d47a1; --accent: #e53935;
  --sky: #e3f2fd; --sky-2: #f4f9ff; --text: #1f2d3d; --muted: #64748b; --line: #e2e8f0;
  --radius: 16px; --shadow: 0 10px 30px rgba(13, 71, 161, .08); --ease: cubic-bezier(.22, .8, .36, 1);
  margin: 0; font-family: 'Sarabun', 'Prompt', sans-serif; font-size: 17px; line-height: 1.7; color: var(--text); background: #fff;
}
.fp-standalone *, .fp-standalone *::before, .fp-standalone *::after { box-sizing: border-box; }
.fp-standalone h1, .fp-standalone h2, .fp-standalone h3 { font-family: 'Prompt', sans-serif; line-height: 1.35; margin: 0 0 .6em; color: var(--primary-dark); }
.fp-standalone .container { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.fp-standalone .section { padding: 40px 0 70px; }
.fp-banner {
  padding: 46px 0 40px; color: #fff;
  background: radial-gradient(circle at 85% 10%, rgba(144,202,249,.6) 0, transparent 35%), linear-gradient(120deg, var(--primary-dark), var(--primary));
}
.fp-banner h1 { color: #fff; font-size: clamp(26px, 3.6vw, 40px); margin: 0; }

/* ---------- โครงหน้า ---------- */
.fp { --fp-gap: 22px; }
.section.fp { padding-top: 34px; }
.fp-wrap { max-width: 1040px; }
.fp-intro { text-align: center; color: var(--muted); max-width: 640px; margin: 0 auto 30px; }
.fp-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 26px; margin-bottom: var(--fp-gap);
}
.fp-step { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.fp-step-no {
  flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  font-family: 'Prompt', sans-serif; font-weight: 600; font-size: 19px; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}
.fp-step h2 { font-size: 20px; margin: 0; }
.fp-step p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.5; }
.fp-note { color: var(--muted); font-size: 14.5px; margin: 14px 0 0; display: flex; gap: 8px; align-items: flex-start; }
.fp-note i { color: var(--primary); margin-top: 2px; }
.fp-hidden { display: none !important; }

/* ---------- ปุ่ม (ใช้หน้าตาแบบ .btn ของเว็บโรงเรียน) ---------- */
.fp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 26px; border-radius: 40px;
  font-family: 'Prompt', sans-serif; font-weight: 500; font-size: 16px; border: 0; cursor: pointer;
  background: var(--primary); color: #fff; transition: all .3s var(--ease); box-shadow: 0 6px 18px rgba(30,136,229,.3);
}
.fp-btn:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-2px); }
.fp-btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.fp-btn-outline { background: #fff; color: var(--primary); border: 2px solid var(--primary); box-shadow: none; padding: 10px 22px; }
.fp-btn-outline:hover:not(:disabled) { background: var(--primary); color: #fff; }
.fp-btn-lg { padding: 14px 34px; font-size: 18px; }

/* ---------- 1. เซลฟี่ ---------- */
.fp-selfies { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.fp-drop {
  aspect-ratio: 1; border: 2px dashed #90caf9; border-radius: var(--radius); background: var(--sky-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: 6px; padding: 12px; cursor: pointer; color: var(--primary-dark); transition: all .25s var(--ease);
}
.fp-drop:hover, .fp-drop.over { border-color: var(--primary); background: var(--sky); transform: translateY(-2px); }
.fp-drop i { font-size: 34px; color: var(--primary); }
.fp-drop b { font-family: 'Prompt', sans-serif; font-weight: 500; font-size: 16px; }
.fp-drop small { color: var(--muted); font-size: 13px; line-height: 1.4; }
.fp-drop input { display: none; }
.fp-selfie { position: relative; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: var(--sky); }
.fp-selfie img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fp-selfie-rm {
  position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(15,23,42,.6); color: #fff; font-size: 16px; display: grid; place-items: center;
}
.fp-selfie-tag {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 10px; font-size: 13px; line-height: 1.35; color: #fff;
  background: rgba(22,163,74,.92);
}
.fp-selfie-tag.warn { background: rgba(217,119,6,.95); }
.fp-selfie-tag.busy { background: rgba(15,23,42,.6); }

/* ---------- ตัวเลือกแบบปุ่ม (ช่วงเวลา) ---------- */
.fp-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.fp-chip input { position: absolute; opacity: 0; pointer-events: none; }
.fp-chip span {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 20px; border-radius: 40px; cursor: pointer;
  border: 2px solid var(--line); background: #fff; font-family: 'Prompt', sans-serif; font-size: 15.5px; color: var(--text);
  transition: all .2s var(--ease); user-select: none;
}
.fp-chip span:hover { border-color: #90caf9; }
.fp-chip input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(30,136,229,.28); }
.fp-chip input:focus-visible + span { outline: 3px solid #90caf9; outline-offset: 2px; }
.fp-search-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 22px; }
.fp-status { color: var(--muted); font-size: 15px; }
.fp-status.err { color: #c2410c; }

/* ---------- 3. ผลลัพธ์ ---------- */
.fp-results-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.fp-results-head h2 { font-size: 22px; margin: 0; }
.fp-count { color: var(--muted); font-size: 15px; }

/* ระดับการจับคู่ใบหน้า: 3 ปุ่มใหญ่ กดง่ายบนมือถือ */
.fp-levels-label { font-family: 'Prompt', sans-serif; font-weight: 500; color: var(--primary-dark); margin: 0 0 4px; }
.fp-levels-help { color: var(--muted); font-size: 14.5px; margin: 0 0 12px; line-height: 1.5; }
.fp-levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 22px; }
.fp-level { position: relative; }
.fp-level input { position: absolute; opacity: 0; pointer-events: none; }
.fp-level-box {
  display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 14px 16px; border-radius: 14px; cursor: pointer;
  border: 2px solid var(--line); background: #fff; transition: all .2s var(--ease);
}
.fp-level-box:hover { border-color: #90caf9; }
.fp-level-title { display: flex; align-items: center; gap: 8px; font-family: 'Prompt', sans-serif; font-weight: 500; font-size: 16.5px; color: var(--text); }
.fp-level-title i { font-size: 20px; color: var(--primary); }
.fp-level-desc { color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.fp-level-n { margin-left: auto; font-size: 13px; font-weight: 500; color: var(--primary-dark); background: var(--sky); border-radius: 20px; padding: 1px 10px; white-space: nowrap; }
.fp-level input:checked + .fp-level-box { border-color: var(--primary); background: var(--sky-2); box-shadow: 0 6px 18px rgba(30,136,229,.18); }
.fp-level input:checked + .fp-level-box .fp-level-n { background: var(--primary); color: #fff; }
.fp-level input:focus-visible + .fp-level-box { outline: 3px solid #90caf9; outline-offset: 2px; }
.fp-badge-rec { font-size: 11.5px; background: var(--accent); color: #fff; border-radius: 10px; padding: 0 8px; font-weight: 400; }

/* ตารางรูป: หน้าตาเหมือน .gallery-item ของเว็บโรงเรียน */
.fp-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.fp-tile {
  position: relative; border-radius: 14px; overflow: hidden; aspect-ratio: 1; background: var(--sky);
  cursor: pointer; outline: 4px solid transparent; outline-offset: -4px; transition: outline-color .15s;
}
.fp-tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .6s var(--ease); }
.fp-tile:hover img { transform: scale(1.06); }
.fp-tile.sel { outline-color: var(--primary); }
.fp-tick {
  position: absolute; top: 10px; left: 10px; width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,.92); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2);
  display: grid; place-items: center; color: transparent; font-size: 16px; transition: all .15s;
}
.fp-tile.sel .fp-tick { background: var(--primary); color: #fff; }
.fp-open {
  position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 50%;
  background: rgba(15,23,42,.55); color: #fff; display: grid; place-items: center; font-size: 15px;
}
.fp-open:hover { background: var(--primary-dark); color: #fff; }
.fp-meta {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 12px 9px; color: #fff; font-size: 13.5px; line-height: 1.35;
  background: linear-gradient(transparent, rgba(13,71,161,.85));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fp-empty { text-align: center; padding: 34px 10px; color: var(--muted); }
.fp-empty i { font-size: 42px; color: #90caf9; display: block; margin-bottom: 6px; }

/* แถบดาวน์โหลด ลอยติดด้านล่างขณะเลื่อนดูผล */
.fp-actionbar {
  position: sticky; bottom: 14px; z-index: 50; margin-top: 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line); border-radius: 50px; padding: 8px 8px 8px 22px;
  box-shadow: 0 12px 34px rgba(13,71,161,.2);
}
/* ยกปุ่ม "กลับขึ้นด้านบน" ของเว็บโรงเรียนให้อยู่เหนือแถบดาวน์โหลด ไม่ทับกัน */
body:has(.fp-actionbar) .back-to-top { bottom: 96px; }
.fp-actionbar-text { font-family: 'Prompt', sans-serif; font-size: 15px; color: var(--primary-dark); }
.fp-actionbar-btns { display: flex; gap: 8px; }
.fp-tips { margin-top: 22px; background: var(--sky-2); border: 1px solid var(--sky); border-radius: var(--radius); padding: 16px 20px; font-size: 15px; color: var(--text); }
.fp-tips b { font-family: 'Prompt', sans-serif; font-weight: 500; color: var(--primary-dark); }
.fp-tips ul { margin: 6px 0 0; padding-left: 20px; color: var(--muted); }
.fp-privacy { text-align: center; color: var(--muted); font-size: 14px; margin-top: 30px; }

/* ---------- มือถือ ---------- */
@media (max-width: 900px) { .fp-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) {
  .section.fp { padding-top: 22px; }
  .fp-card { padding: 18px 16px; border-radius: 14px; }
  .fp-step-no { width: 36px; height: 36px; font-size: 17px; }
  .fp-step h2 { font-size: 18px; }
  .fp-selfies { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .fp-drop i { font-size: 26px; }
  .fp-drop b { font-size: 14px; }
  .fp-drop small { display: none; }
  .fp-selfie-tag { font-size: 11px; padding: 4px 6px; }
  .fp-chip span { padding: 9px 16px; font-size: 15px; }
  .fp-search-row .fp-btn { width: 100%; }
  .fp-levels { grid-template-columns: 1fr; gap: 8px; }
  .fp-level-box { padding: 12px 14px; }
  .fp-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .fp-meta { font-size: 12px; padding: 20px 8px 6px; }
  .fp-actionbar { border-radius: 18px; padding: 10px; bottom: 10px; gap: 6px; }
  .fp-actionbar-text { width: 100%; text-align: center; font-size: 14px; }
  .fp-actionbar-btns { width: 100%; }
  .fp-actionbar-btns .fp-btn { flex: 1; padding: 10px 8px; font-size: 15px; white-space: nowrap; gap: 6px; }
  body:has(.fp-actionbar) .back-to-top { bottom: 118px; right: 14px; width: 44px; height: 44px; }
}
