/* ==========================================================================
   ภาพกิจกรรม (ปุ่มหมวดที่ 6) - includes/gallery-view.php, activity-edit.php, assets/gallery.js
   โหลดต่อจาก procurement.css (ใช้ตัวแปรสี --proc-* ของไฟล์นั้น)
   ========================================================================== */

.proc-staff-compact {
  padding: 14px 18px;
}

.proc-staff-compact .proc-staff-head {
  margin-bottom: 0;
}

.proc-staff-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.proc-back {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--proc-green-700);
  font-weight: 700;
  text-decoration: none;
}

.proc-back:hover {
  color: var(--proc-green-900);
  text-decoration: underline;
}

/* ---------- รายการกิจกรรม: ภาพปกซ้าย คำอธิบายขวา ---------- */
.proc-acts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.proc-act-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--proc-border);
  border-radius: var(--proc-radius);
  background: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.proc-act-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(27, 94, 32, 0.12);
}

.proc-act-link {
  display: flex;
  flex: 1;
  gap: 14px;
  padding: 12px;
  color: inherit;
  text-decoration: none;
}

.proc-act-link:hover {
  color: inherit;
}

.proc-act-link:focus-visible {
  outline: 3px solid rgba(46, 125, 50, 0.35);
  outline-offset: -3px;
}

.proc-act-thumb {
  position: relative;
  flex: none;
  width: 190px;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  background: var(--proc-green-100);
  overflow: hidden;
}

.proc-act-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.proc-act-count {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
}

.proc-act-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.proc-act-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  color: var(--proc-green-900);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.45;
}

.proc-act-date {
  color: var(--proc-muted);
  font-size: 0.84rem;
}

.proc-act-excerpt {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  color: var(--proc-text-soft);
  font-size: 0.9rem;
  line-height: 1.5;
}

.proc-act-more {
  margin-top: auto;
  padding-top: 2px;
  color: var(--proc-green-700);
  font-size: 0.86rem;
  font-weight: 700;
}

.proc-act-card-actions {
  justify-content: flex-end;
  padding: 0 12px 12px;
}

/* ---------- หน้ากิจกรรม ---------- */
.proc-act-head {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--proc-border);
}

.proc-act-heading {
  margin: 0 0 4px;
  color: var(--proc-green-900);
  font-size: 1.45rem;
  line-height: 1.45;
}

.proc-act-meta {
  margin: 0 0 8px;
  color: var(--proc-muted);
  font-size: 0.92rem;
}

.proc-act-story {
  margin-bottom: 20px;
  color: var(--proc-text-soft);
  font-size: 1rem;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.proc-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.proc-photo {
  display: block;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  background: var(--proc-green-100);
  overflow: hidden;
  cursor: zoom-in;
}

.proc-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s ease;
}

.proc-photo:hover img {
  transform: scale(1.04);
}

.proc-photo:focus-visible {
  outline: 3px solid rgba(46, 125, 50, 0.45);
  outline-offset: 2px;
}

/* ---------- ดูภาพใหญ่ (gallery.js สร้างต่อท้าย body) ---------- */
html.proc-lb-open,
html.proc-lb-open body {
  overflow: hidden;
}

.proc-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 14, 9, 0.96);
  touch-action: pan-y;
}

.proc-lightbox[hidden] {
  display: none;
}

.proc-lb-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 56px 72px 40px;
  box-sizing: border-box;
}

.proc-lb-figure img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.proc-lb-counter {
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.8);
  font-family: 'Sarabun', 'Prompt', Tahoma, sans-serif;
  font-size: 0.95rem;
}

.proc-lb-close,
.proc-lb-nav {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.proc-lb-close:hover,
.proc-lb-nav:hover {
  background: rgba(255, 255, 255, 0.28);
}

.proc-lb-close:focus-visible,
.proc-lb-nav:focus-visible {
  outline: 3px solid rgba(102, 187, 106, 0.8);
  outline-offset: 2px;
}

.proc-lb-close {
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  font-size: 1.9rem;
  line-height: 1;
}

.proc-lb-nav {
  top: 50%;
  width: 52px;
  height: 52px;
  margin-top: -26px;
  font-size: 2.4rem;
  line-height: 1;
}

.proc-lb-prev {
  left: 12px;
}

.proc-lb-next {
  right: 12px;
}

.proc-lightbox.is-single .proc-lb-nav {
  display: none;
}

/* ---------- หน้าลง/แก้ไขกิจกรรม ---------- */
.proc-act-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.proc-act-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px;
  align-items: start;
  gap: 14px;
}

/* ช่องชื่อกับช่องวันที่สูงเท่ากัน บรรทัดเดียวกัน (input date กับ text ต่างกันที่ความสูงตามค่าเริ่มต้นของเบราว์เซอร์) */
.proc-act-row input[type="text"],
.proc-act-row input[type="date"] {
  height: 46px;
  min-height: 46px;
  padding-top: 0;
  padding-bottom: 0;
  line-height: 44px;
}

.proc-act-row input[type="date"] {
  line-height: normal;
}

.proc-field input[type="date"],
.proc-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--proc-border-strong);
  border-radius: 10px;
  background: #fbfdfb;
  color: var(--proc-text);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.6;
  box-sizing: border-box;
}

.proc-field textarea {
  min-height: 140px;
  resize: vertical;
}

.proc-field textarea:focus {
  outline: none;
  border-color: var(--proc-green-700);
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.12);
}

.proc-act-set {
  margin: 0;
  padding: 14px 16px 16px;
  border: 1px solid var(--proc-border);
  border-radius: 12px;
  background: #fff;
}

.proc-act-set legend {
  padding: 0 6px;
  color: var(--proc-green-900);
  font-weight: 700;
}

/* กล่องลากไฟล์มาวาง */
.proc-dropzone {
  position: relative;
  align-items: center;
  gap: 4px;
  padding: 22px 16px;
  border: 2px dashed var(--proc-border-strong);
  border-radius: 12px;
  background: var(--proc-green-50);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.proc-dropzone:hover,
.proc-dropzone.is-dragover {
  border-color: var(--proc-green-700);
  background: var(--proc-green-100);
}

.proc-dropzone .proc-drop-title {
  color: var(--proc-green-900);
  font-size: 1.05rem;
  font-weight: 700;
}

.proc-dropzone .proc-drop-note {
  color: var(--proc-muted);
  font-size: 0.86rem;
  font-weight: 400;
  line-height: 1.6;
}

/* ช่องเลือกไฟล์จริงอยู่ในกล่อง (ใช้โฟกัสด้วยคีย์บอร์ดได้) แต่ซ่อนให้เห็นเฉพาะกล่อง */
.proc-dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.proc-dropzone:focus-within {
  outline: 3px solid rgba(46, 125, 50, 0.35);
  outline-offset: 2px;
}

.proc-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.proc-act-hint {
  margin: 10px 0 0;
  color: var(--proc-muted);
  font-size: 0.9rem;
}

.proc-act-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.proc-act-grid:empty {
  display: none;
}

.proc-act-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--proc-border);
  border-radius: 10px;
  background: var(--proc-green-50);
  transition: opacity 0.15s ease;
}

.proc-act-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  background: var(--proc-green-100);
  object-fit: cover;
}

.proc-act-tile label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.86rem;
  cursor: pointer;
}

/* ภาพที่เลือกเป็นปก มีกรอบเขียว */
.proc-act-tile:has(.proc-act-cover input:checked) {
  border-color: var(--proc-green-700);
  box-shadow: 0 0 0 2px var(--proc-green-400);
}

/* ปุ่ม × มุมขวาบนของแต่ละภาพ (ภาพที่เพิ่งเลือก = ปุ่ม, ภาพเดิม = ช่องติ๊กหน้าตาเป็นปุ่ม ใช้ได้แม้ไม่มี JavaScript) */
.proc-act-tile .proc-act-x {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(198, 40, 40, 0.92);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  color: #fff;
  font: inherit;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.12s ease;
}

.proc-act-tile .proc-act-x:hover {
  background: #a31f1f;
  transform: scale(1.08);
}

.proc-act-tile .proc-act-x:focus-visible,
.proc-act-tile .proc-act-x:has(input:focus-visible) {
  outline: 3px solid rgba(255, 255, 255, 0.95);
  outline-offset: 1px;
  box-shadow: 0 0 0 5px rgba(198, 40, 40, 0.6);
}

.proc-act-x input[type="checkbox"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.proc-act-removed-note {
  display: none;
  color: var(--proc-red);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}

/* ภาพเดิมที่ถูกกด × : จางลง มีข้อความ "จะถูกลบ" กด × อีกครั้งเพื่อยกเลิก */
.proc-act-tile.is-removed img,
.proc-act-tile.is-removed .proc-act-cover {
  opacity: 0.4;
}

.proc-act-tile.is-removed img {
  filter: grayscale(1);
}

.proc-act-tile.is-removed .proc-act-removed-note {
  display: block;
}

.proc-act-tile.is-removed .proc-act-x {
  background: #455a64;
}

.proc-act-tile.is-removed {
  border-color: var(--proc-red-border);
  box-shadow: none;
}

.proc-act-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

/* ---------- จอแคบ / มือถือ ---------- */
@media (max-width: 900px) {
  .proc-acts {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .proc-act-link {
    gap: 10px;
    padding: 10px;
  }

  .proc-act-thumb {
    width: 120px;
  }

  .proc-act-title {
    font-size: 0.95rem;
  }

  .proc-act-excerpt {
    display: none;
  }

  .proc-act-heading {
    font-size: 1.2rem;
  }

  .proc-photos {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .proc-lb-figure {
    padding: 56px 8px 72px;
  }

  /* ปุ่มก่อนหน้า/ถัดไปอยู่ด้านล่าง ไม่บังภาพ (ปัดนิ้วได้ด้วย) */
  .proc-lb-nav {
    top: auto;
    bottom: 14px;
    width: 44px;
    height: 44px;
    margin-top: 0;
  }

  .proc-act-row {
    grid-template-columns: 1fr;
  }

  .proc-act-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .proc-act-card,
  .proc-photo img {
    transition: none;
  }

  .proc-act-card:hover,
  .proc-photo:hover img {
    transform: none;
  }
}
