/* ============================================================
   style.css — ธีมทองราชสำนัก | วิทยาลัยเทคนิคจันทบุรี
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600&family=Noto+Serif+Thai:wght@400;500;600;700&display=swap');

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --gold1: #f5d94a;
  --gold2: #e8c020;
  --gold3: #c8a000;
  --gold4: #a07800;
  --purple1: #7b3fa0;
  --purple2: #6a2d8f;
  --purple3: #9b5fc0;
  --purple4: #4a1870;
  --text-light: #fff8e7;
  --text-gold: #f5d94a;
  --orange: #e87800;
  /* compat aliases */
  --brown1: #4a1870;
  --brown2: #6a2d8f;
  --brown3: #7b3fa0;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: 'Sarabun', sans-serif;
  font-size: 16px;
  color: var(--brown1);
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(200, 160, 255, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(160, 80, 220, 0.15) 0%, transparent 50%),
    /* linear-gradient(rgba(74, 24, 112, 0.65), rgba(74, 24, 112, 0.65)),  ← overlay ม่วง */
    url('./assecc/bg1.jpg') center center / cover no-repeat fixed;
}

/* TOPBAR */
.topbar {
  background: rgba(74, 24, 112, 0.95);
  border-bottom: 2px solid var(--gold2);
  padding: 8px 1.5rem;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 12px rgba(100, 30, 160, 0.3);
}

.topbar-logo {
  height: 52px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-right: auto;
}

.topbar-logo img {
  height: 125px;
  width: auto;
  max-width: 280px;
  object-fit: contain;
  display: block;
}

.topbar-name {
  flex: 1;
}

.topbar-name h1 {
  font-family: 'Noto Serif Thai', serif;
  color: var(--text-gold);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}

.topbar-name p {
  font-size: 11px;
  color: rgba(245, 217, 74, 0.7);
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-gold);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 14px;
  border: 1px solid rgba(200, 160, 255, 0.5);
  border-radius: 20px;
  background: rgba(180, 120, 255, 0.15);
  transition: all 0.2s;
  white-space: nowrap;
  font-weight: 500;
  margin-left: auto;
  flex-shrink: 0;
}

.back-btn:hover {
  background: rgba(180, 120, 255, 0.3);
  color: #fff;
}

/* WRAPPER */
.wrapper {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem 4rem;
}

/* HERO */
.hero {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
}

.hero-emblem {
  font-size: 46px;
  display: block;
  margin-bottom: 0.4rem;
  color: var(--brown1);
  animation: embGlow 3s ease-in-out infinite;
}

@keyframes embGlow {

  0%,
  100% {
    text-shadow: 0 2px 8px rgba(150, 90, 0, 0.3);
  }

  50% {
    text-shadow: 0 2px 20px rgba(180, 120, 0, 0.6);
  }
}

/* HERO IMAGE */
.hero-img-wrap {
  margin: 0 auto 1.5rem;
  width: 100%;
  max-width: 800px; /* กำหนดขนาดความกว้างสูงสุดเพื่อไม่ให้รูปใหญ่เกินไปบนหน้าจอคอม */
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 28px rgba(80, 20, 140, 0.3), 0 0 0 3px rgba(150, 80, 220, 0.3);
}

.hero-img {
  width: 100%;
  height: auto;       /* ให้ความสูงปรับอัตโนมัติตามสัดส่วน */
  max-height: 400px;  /* ล็อกความสูงสูงสุดไว้ไม่ให้กินพื้นที่หน้าจอแนวตั้งมากไป */
  display: block;
  object-fit: cover;  /* ให้รูปครอปพอดีกับกรอบ (ถ้าไม่อยากให้ครอป เปลี่ยนเป็น contain) */
  object-position: center top; /* จัดให้อยู่กึ่งกลาง และเน้นส่วนบนของภาพ */
}

.hero-h1 {
  font-family: 'Noto Serif Thai', serif;
  color: #fff8ff;
  font-size: clamp(26px, 5vw, 38px);
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 0.4rem;
  text-shadow: 0 2px 8px rgba(80, 0, 140, 0.4);
}

.hero-royal {
  font-family: 'Noto Serif Thai', serif;
  color: rgba(255, 220, 255, 0.95);
  font-size: clamp(15px, 2.8vw, 18px);
  font-weight: 500;
  line-height: 1.65;
  margin-bottom: 0.3rem;
}

.hero-tagline {
  font-family: 'Noto Serif Thai', serif;
  color: var(--gold1);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 0.3rem;
  text-shadow: 0 1px 6px rgba(200, 150, 0, 0.5);
}

.hero-school {
  color: rgba(230, 190, 255, 0.8);
  font-size: 15px;
  margin-bottom: 1.8rem;
  opacity: 0.85;
}

/* STAT BAR */
.stat-bar {
  display: flex;
  justify-content: center;
  gap: 3rem;
  margin-bottom: 1.5rem;
}

.stat-box {
  text-align: center;
}

.stat-num {
  font-family: 'Noto Serif Thai', serif;
  color: #fff;
  font-size: 36px;
  font-weight: 700;
  display: block;
  line-height: 1;
  background: rgba(120, 50, 180, 0.45);
  border: 1px solid rgba(200, 150, 255, 0.4);
  border-radius: 10px;
  padding: 8px 24px;
  min-width: 80px;
  box-shadow: 0 2px 8px rgba(80, 0, 160, 0.2);
}

.stat-label {
  font-size: 14px;
  color: rgba(230, 190, 255, 0.9);
  margin-top: 6px;
  font-weight: 500;
}

/* DIVIDER */
.div-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 1rem auto;
  max-width: 320px;
}

.div-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(245, 217, 74, 0.5), transparent);
}

.div-gem {
  color: var(--gold2);
  font-size: 14px;
}

/* MAIN COLS */
.main-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 640px) {
  .main-cols {
    grid-template-columns: 1fr;
  }
}

/* CARD */
.card {
  background: rgba(255, 250, 255, 0.9);
  border: 1px solid rgba(150, 80, 200, 0.2);
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(80, 20, 140, 0.12);
}

.card-title {
  font-family: 'Noto Serif Thai', serif;
  color: var(--purple2);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(150, 80, 200, 0.2);
  padding-bottom: 10px;
}

/* FORM */
.form-group {
  margin-bottom: 13px;
}

.form-label {
  display: block;
  color: var(--purple2);
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 5px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: #fdf8ff;
  border: 1px solid rgba(130, 60, 190, 0.3);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--purple4);
  font-family: 'Sarabun', sans-serif;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: rgba(100, 50, 150, 0.3);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: rgba(130, 60, 190, 0.6);
  box-shadow: 0 0 0 3px rgba(150, 80, 220, 0.12);
}

.form-select {
  cursor: pointer;
  background-color: #fdf8ff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%237b3fa0'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-select option {
  background: #f8eeff;
  color: var(--purple4);
}

.form-textarea {
  resize: none;
  height: 80px;
  line-height: 1.6;
}

.char-row {
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
}

.char-hint {
  font-size: 11px;
  color: rgba(120, 80, 0, 0.4);
}

/* SUBMIT BTN */
.submit-btn {
  width: 100%;
  background: linear-gradient(135deg, #7b3fa0 0%, #9b5fc0 40%, #6a2d8f 100%);
  color: #fff;
  border: none;
  padding: 13px;
  border-radius: 30px;
  font-family: 'Noto Serif Thai', serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
  letter-spacing: 0.04em;
  transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 14px rgba(100, 40, 160, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(100, 40, 160, 0.55);
}

.submit-btn:active {
  transform: scale(0.98);
}

.submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ALERT */
.alert {
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.6;
  display: none;
}

.alert.show {
  display: block;
  animation: fadeIn 0.4s ease;
}

.alert-success {
  background: rgba(150, 80, 200, 0.1);
  border: 1px solid rgba(130, 60, 190, 0.3);
  color: var(--text-light);
}

.alert-error {
  background: rgba(200, 60, 0, 0.08);
  border: 1px solid rgba(200, 60, 0, 0.3);
  color: #8b2000;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* LIST */
.list-header {
  display: flex;
  align-items: center;
  /* justify-content: space-between; */
  margin-bottom: 1rem;
}

.list-count {
  font-size: 12px;
  color: var(--purple3);
  font-weight: 500;
}

.search-input {
  width: 100%;
  background: #fdf8ff;
  border: 1px solid rgba(130, 60, 190, 0.25);
  border-radius: 6px;
  padding: 7px 12px 7px 30px;
  color: var(--purple4);
  font-family: 'Sarabun', sans-serif;
  font-size: 13px;
  outline: none;
  margin-bottom: 12px;
  transition: border-color 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='%237b3fa0' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 9px center;
}

.search-input::placeholder {
  color: rgba(100, 50, 150, 0.35);
}

.search-input:focus {
  border-color: rgba(130, 60, 190, 0.45);
}

.sig-wrap {
  max-height: 500px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(130, 60, 190, 0.2) transparent;
}

.sig-wrap::-webkit-scrollbar {
  width: 4px;
}

.sig-wrap::-webkit-scrollbar-thumb {
  background: rgba(130, 60, 190, 0.2);
  border-radius: 4px;
}

.sig-card {
  background: rgba(255, 248, 200, 0.65);
  border: 1px solid rgba(160, 120, 0, 0.15);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 8px;
  transition: border-color 0.2s, background 0.2s;
  animation: slideIn 0.35s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-6px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.sig-card:hover {
  border-color: rgba(160, 120, 0, 0.3);
  background: rgba(255, 248, 200, 0.9);
}

.sig-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.sig-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple3), var(--purple1));
  border: 1px solid var(--purple2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Noto Serif Thai', serif;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.sig-info {
  flex: 1;
  min-width: 0;
}

.sig-name {
  font-family: 'Noto Serif Thai', serif;
  color: var(--purple4);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sig-meta {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 3px;
}

.sig-badge {
  font-size: 10px;
  background: rgba(150, 80, 200, 0.12);
  color: var(--purple2);
  padding: 2px 7px;
  border-radius: 20px;
  border: 1px solid rgba(130, 60, 190, 0.2);
}

.sig-msg {
  color: var(--purple3);
  font-size: 13px;
  margin-top: 6px;
  line-height: 1.55;
  font-style: italic;
  border-left: 2px solid rgba(130, 60, 190, 0.3);
  padding-left: 8px;
}

.sig-date {
  color: rgba(100, 50, 150, 0.4);
  font-size: 11px;
  margin-top: 5px;
  text-align: right;
}

.sig-num-badge {
  font-size: 11px;
  color: rgba(100, 50, 150, 0.5);
  font-weight: 600;
  padding-top: 2px;
  min-width: 22px;
  text-align: right;
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: rgba(100, 50, 150, 0.45);
  font-size: 14px;
  line-height: 1.7;
}

.empty-icon {
  font-size: 30px;
  display: block;
  margin-bottom: 8px;
  opacity: 0.35;
}

/* SPINNER */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

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

/* PAGINATION */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.page-btn {
  background: rgba(150, 80, 200, 0.1);
  border: 1px solid rgba(130, 60, 190, 0.25);
  color: var(--purple2);
  padding: 5px 12px;
  border-radius: 20px;
  font-family: 'Sarabun', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.page-btn:hover,
.page-btn.active {
  background: var(--purple1);
  color: #fff;
  border-color: var(--purple1);
}

/* FOOTER */
.page-footer {
  text-align: center;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.4);
  color: #ffffff;
  font-size: 15px;
  line-height: 2;
}

.page-footer strong {
  color: #ffffff;
  font-weight: 700;
  font-size: 16px;
}

/* ============================================================
   NEW LAYOUT — รายชื่อบน / ฟอร์มล่าง
   ============================================================ */

/* รายชื่อ full width */
.list-card-full {
  margin-bottom: 0;
}

/* ตารางรายชื่อ */
.sig-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Sarabun', sans-serif;
  table-layout: fixed;
}

/* ห่อตารางด้วย div เพื่อให้ border-radius ทำงาน */
.sig-list-wrap {
  max-height: 460px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(130, 60, 190, 0.2) transparent;
  border-radius: 8px;
  border: 1px solid rgba(130, 60, 190, 0.2);
  box-shadow: 0 2px 12px rgba(80, 20, 140, 0.1);
}

.sig-list-wrap::-webkit-scrollbar {
  width: 5px;
}

.sig-list-wrap::-webkit-scrollbar-thumb {
  background: rgba(130, 60, 190, 0.25);
  border-radius: 4px;
}

/* หัวตาราง — ใช้ background-color แทน gradient เพื่อความเสถียร */
.sig-th {
  background-color: #6a2d8f !important;
  color: #fff !important;
  font-family: 'Noto Serif Thai', serif;
  font-size: 15px;
  font-weight: 700;
  padding: 12px 16px;
  text-align: left;
  letter-spacing: 0.03em;
  border: none !important;
  position: sticky;
  top: 0;
  z-index: 2;
  -webkit-appearance: none;
  appearance: none;
}

.sig-th-num {
  width: 52px;
  text-align: center;
  background-color: #5a1f80 !important;
}

.sig-th-prefix {
  width: 180px;
  background-color: #6a2d8f !important;
}

.sig-th-name {
  background-color: #6a2d8f !important;
}

.sig-tr {
  transition: background 0.15s;
}

.sig-tr-even {
  background-color: rgba(248, 235, 255, 0.95);
}

.sig-tr-odd {
  background-color: rgba(240, 220, 255, 0.6);
}

.sig-tr:hover td {
  background-color: rgba(220, 180, 255, 0.8) !important;
}

.sig-td {
  padding: 11px 16px;
  font-size: 15px;
  color: var(--purple4);
  border-bottom: 1px solid rgba(130, 60, 190, 0.1);
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sig-td-num {
  text-align: center;
  font-size: 14px;
  color: rgba(100, 50, 150, 0.4);
  font-weight: 700;
  width: 52px;
}

.sig-td-prefix {
  width: 180px;
  color: var(--purple2);
  font-size: 15px;
}

.sig-td-name {
  font-family: 'Noto Serif Thai', serif;
  font-weight: 600;
  font-size: 16px;
}

.sig-td-empty {
  color: rgba(130, 60, 190, 0.25);
  font-size: 14px;
}

.sig-td-loading,
.sig-td-empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: rgba(100, 50, 150, 0.5);
  font-size: 15px;
  font-family: 'Sarabun', sans-serif;
  white-space: normal;
}

.spinner-gold {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(130, 60, 190, 0.2);
  border-top-color: var(--purple3);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

/* ฟอร์ม centered */
.form-card-center {
  max-width: 600px;
  margin: 0 auto;
}

.form-inline-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

@media (max-width: 500px) {
  .form-inline-row {
    flex-direction: column;
  }

  .form-inline-row .form-group {
    flex: unset !important;
    width: 100%;
  }
}