/* =====================================================
   โรงเรียนชำนิพิทยาคม - Main Stylesheet
   Colors: Red #C0392B | Gold #E8A000 | White #FFFFFF
   ===================================================== */
:root {
  --primary:    #C0392B;
  --secondary:  #E8A000;
  --dark:       #1A1A2E;
  --light-red:  #FDECEA;
  --light-gold: #FEF9E7;
  --gray:       #6C757D;
  --font-th:    'Sarabun', sans-serif;
  --font-en:    'Poppins', sans-serif;
  --radius:     12px;
  --shadow:     0 4px 20px rgba(0,0,0,.08);
  --shadow-hover: 0 8px 30px rgba(0,0,0,.15);
}
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family: var(--font-th);
  color: #2C3E50;
  background: #fff;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--secondary); }
h1,h2,h3,h4,h5,h6 { font-weight: 600; }

/* ── Top Bar ─────────────────────────────────────────── */
.top-bar {
  background: var(--dark);
  padding: 6px 0;
  font-size: .82rem;
}

/* ── Navbar ──────────────────────────────────────────── */
.main-navbar {
  background: var(--primary);
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
  padding: 10px 0;
}
.main-navbar .navbar-brand { color: #fff !important; }
.main-navbar .navbar-brand img { border-radius: 50%; }
.school-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}
.school-slogan {
  font-size: .72rem;
  color: rgba(255,255,255,.8);
}
.logo-placeholder {
  width: 48px; height: 48px;
  background: var(--secondary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.3rem;
}
.main-navbar .nav-link {
  color: rgba(255,255,255,.9) !important;
  font-weight: 500;
  font-size: .9rem;
  padding: 6px 12px !important;
  border-radius: 6px;
  transition: all .2s;
}
.main-navbar .nav-link:hover,
.main-navbar .nav-link.active {
  background: rgba(255,255,255,.15);
  color: #fff !important;
}
.lang-btn {
  border-color: rgba(255,255,255,.5) !important;
  color: #fff !important;
  font-size: .8rem;
}
.navbar-toggler { border-color: rgba(255,255,255,.4); padding: 6px 10px; }
.navbar-toggler-icon { filter: invert(1); }
.navbar-toggler:focus { box-shadow: 0 0 0 3px rgba(255,255,255,.25); }
@media (max-width:991px) {
  #navMenu {
    background: var(--primary);
    padding: 8px 0 14px;
    border-top: 1px solid rgba(255,255,255,.15);
    margin-top: 8px;
  }
  #navMenu .nav-link { padding: 10px 16px !important; border-radius: 8px; margin: 1px 8px; }
  #navMenu .lang-btn { margin: 8px 8px 0; display: inline-flex; }
}

/* ── Hero Section ────────────────────────────────────── */
.hero-section {
  background: linear-gradient(135deg, var(--hero-start, var(--primary)) 0%, var(--hero-mid, #922B21) 50%, var(--hero-end, #1A1A2E) 100%);
  min-height: 85vh;
  display: flex; align-items: center;
  position: relative; overflow: hidden;
}
.hero-section::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.hero-badge {
  display: inline-flex; align-items: center;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  color: #fff; padding: 6px 16px;
  border-radius: 50px; font-size: .85rem; margin-bottom: 20px;
}
.hero-title {
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 700; color: #fff; line-height: 1.3;
}
.hero-slogan {
  font-size: 1.1rem; color: var(--secondary);
  font-weight: 500; margin: 12px 0;
}
.hero-desc { color: rgba(255,255,255,.8); }
.hero-btn {
  background: var(--secondary);
  border: none; color: #fff;
  padding: 12px 32px; border-radius: 50px;
  font-weight: 600; transition: all .3s;
  box-shadow: 0 4px 15px rgba(232,160,0,.4);
}
.hero-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(232,160,0,.5); color: #fff; }
.hero-img-wrap {
  position: relative; padding: 20px;
}
.hero-img-wrap::before {
  content: '';
  position: absolute;
  width: 100%; height: 100%;
  border: 3px solid var(--secondary);
  border-radius: 20px;
  top: 20px; left: 20px;
}
.hero-img-wrap img {
  border-radius: 15px;
  position: relative; z-index: 1;
  width: 100%; max-width: 480px;
}
.hero-stats {
  display: flex; gap: 30px; margin-top: 30px;
}
.hero-stat { text-align: center; }
.hero-stat-num {
  font-size: 1.8rem; font-weight: 700;
  color: var(--secondary); line-height: 1;
}
.hero-stat-label { color: rgba(255,255,255,.7); font-size: .8rem; }

/* ── Section Styles ──────────────────────────────────── */
.section-header { text-align: center; margin-bottom: 50px; }
.section-title {
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  font-weight: 700; color: var(--dark); position: relative;
  padding-bottom: 16px; display: inline-block;
}
.section-title::after {
  content: '';
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 60px; height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 2px;
}
.section-subtitle { color: var(--gray); margin-top: 10px; }

/* ── Cards ───────────────────────────────────────────── */
.card-modern {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: all .3s;
  overflow: hidden;
  height: 100%;
}
.card-modern:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

/* ── Admin Cards ─────────────────────────────────────── */
.admin-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  text-align: center;
  transition: all .3s;
  border-top: 4px solid var(--primary);
}
.admin-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.admin-avatar {
  width: 100px; height: 100px;
  border-radius: 50%; object-fit: cover;
  border: 4px solid var(--primary);
  margin: 0 auto 16px;
}
.admin-avatar-placeholder {
  width: 100px; height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px; font-size: 2rem; color: #fff;
}
.admin-name { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.admin-pos { color: var(--gray); font-size: .85rem; }

/* ── News & Announcement Cards ───────────────────────── */
.news-card {
  border: none; border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  transition: all .3s; height: 100%;
}
.news-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.news-card img {
  width: 100%; height: 200px; object-fit: cover;
}
.news-card .card-body { padding: 20px; }
.news-category {
  display: inline-block;
  background: var(--light-red); color: var(--primary);
  font-size: .75rem; padding: 2px 10px; border-radius: 50px;
  font-weight: 600; margin-bottom: 10px;
}
.news-date { color: var(--gray); font-size: .8rem; }

.ann-item {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 16px; border-radius: 10px;
  border-left: 4px solid var(--primary);
  background: #fff; box-shadow: var(--shadow);
  transition: all .2s; margin-bottom: 12px;
}
.ann-item:hover { transform: translateX(4px); box-shadow: var(--shadow-hover); }
.ann-icon {
  width: 40px; height: 40px; min-width: 40px;
  border-radius: 8px;
  background: var(--light-red); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}
.ann-title { font-weight: 600; font-size: .92rem; line-height: 1.4; margin-bottom: 4px; }
.ann-date { color: var(--gray); font-size: .78rem; }
.ann-pinned .ann-icon { background: var(--light-gold); color: var(--secondary); }

/* ── Enrollment Banner ───────────────────────────────── */
.enrollment-banner {
  background: linear-gradient(135deg, var(--secondary) 0%, #D4890A 100%);
  border-radius: var(--radius);
  padding: 50px 40px;
  color: #fff; text-align: center;
  position: relative; overflow: hidden;
}
.enrollment-banner::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 70% 50%, rgba(255,255,255,.1) 0%, transparent 60%);
}
.enrollment-banner h2 { font-size: 2rem; font-weight: 700; }
.enroll-btn {
  background: #fff; color: var(--secondary);
  border: none; padding: 14px 40px;
  border-radius: 50px; font-weight: 700; font-size: 1rem;
  transition: all .3s; display: inline-block;
}
.enroll-btn:hover { transform: scale(1.05); box-shadow: 0 8px 25px rgba(0,0,0,.2); color: var(--secondary); }

/* ── E-Service Grid ──────────────────────────────────── */
.eservice-card {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 28px 16px;
  border-radius: var(--radius); background: #fff;
  box-shadow: var(--shadow); transition: all .3s;
  text-align: center; cursor: pointer; text-decoration: none;
  color: inherit; height: 100%;
}
.eservice-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-hover);
  color: inherit;
}
.eservice-icon {
  width: 64px; height: 64px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; color: #fff; margin-bottom: 14px;
}
.eservice-title { font-weight: 600; font-size: .88rem; line-height: 1.3; }

/* ── Slideshow ───────────────────────────────────────── */
.slideshow-section { background: #f8f9fa; }
.slideshow-img {
  width: 100%; height: 420px; object-fit: cover;
  border-radius: var(--radius);
}
.carousel-control-prev, .carousel-control-next {
  width: 44px; height: 44px;
  background: var(--primary);
  border-radius: 50%; top: 50%; transform: translateY(-50%);
  opacity: 1;
}

/* ── Staff Grid ──────────────────────────────────────── */
.staff-card {
  border: none; border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  transition: all .3s; background: #fff;
}
.staff-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.staff-img {
  width: 90px; height: 90px; border-radius: 50%;
  object-fit: cover; border: 3px solid var(--primary);
}
.staff-avatar-ph {
  width: 90px; height: 90px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.6rem;
}
.website-btn { font-size: .78rem; }

/* ── OIT / PDF ───────────────────────────────────────── */
.oit-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-radius: 8px;
  background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.05);
  margin-bottom: 10px; transition: all .2s;
  border-left: 3px solid var(--primary);
}
.oit-item:hover { transform: translateX(4px); }
.pdf-modal-body { background: #1a1a1a; padding: 10px; border-radius: 8px; }

/* ── Buttons ─────────────────────────────────────────── */
.btn-primary {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
}
.btn-primary:hover { background: #a93226 !important; border-color: #a93226 !important; }
.btn-secondary-custom {
  background: var(--secondary) !important;
  border-color: var(--secondary) !important; color: #fff;
}
.btn-outline-primary {
  color: var(--primary) !important;
  border-color: var(--primary) !important;
}
.btn-outline-primary:hover {
  background: var(--primary) !important; color: #fff !important;
}

/* ── Chat Widget ─────────────────────────────────────── */
.chat-fab {
  position: fixed; bottom: 28px; right: 28px; z-index: 1050;
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--primary);
  border: none; box-shadow: 0 4px 20px rgba(192,57,43,.5);
  color: #fff; font-size: 1.4rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .3s;
}
.chat-fab:hover { transform: scale(1.1); box-shadow: 0 6px 25px rgba(192,57,43,.6); }
.chat-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--secondary); color: #fff;
  border-radius: 50%; font-size: .65rem;
  min-width: 20px; height: 20px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.chat-box {
  position: fixed; bottom: 100px; right: 28px; z-index: 1049;
  width: 340px; background: #fff;
  border-radius: 16px; box-shadow: 0 8px 40px rgba(0,0,0,.2);
  overflow: hidden;
}
.chat-header {
  background: var(--primary); color: #fff;
}
.chat-messages {
  height: 280px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
}
.msg-admin, .msg-visitor { display: flex; flex-direction: column; }
.msg-visitor { align-items: flex-end; }
.msg-bubble {
  max-width: 80%; padding: 8px 14px; border-radius: 14px;
  font-size: .88rem; line-height: 1.5;
}
.msg-admin .msg-bubble { background: #f0f0f0; color: #333; border-bottom-left-radius: 4px; }
.msg-visitor .msg-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg-time { font-size: .7rem; color: var(--gray); margin-top: 2px; padding: 0 4px; }

/* ── Footer ──────────────────────────────────────────── */
.site-footer {
  background: var(--dark);
  color: #fff; padding: 50px 0 20px;
}
.footer-title { color: #fff; margin-bottom: 16px; font-size: 1rem; }
.footer-links li { margin-bottom: 8px; }
.footer-links a { color: rgba(255,255,255,.6); font-size: .88rem; transition: color .2s; }
.footer-links a:hover { color: var(--secondary); }

/* ── Page Header ─────────────────────────────────────── */
.page-header {
  background: linear-gradient(135deg, var(--primary), #922B21);
  color: #fff; padding: 60px 0;
}
.page-header h1 { font-size: 2rem; font-weight: 700; }
.breadcrumb-item a { color: rgba(255,255,255,.8); }
.breadcrumb-item.active { color: var(--secondary); }
.breadcrumb-item + .breadcrumb-item::before { color: rgba(255,255,255,.5); }

/* ── Curriculum ──────────────────────────────────────── */
.subject-card {
  border: none; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px;
  text-align: center; transition: all .3s;
  border-top: 4px solid var(--primary);
  background: #fff;
}
.subject-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.subject-icon {
  width: 60px; height: 60px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; color: #fff; margin: 0 auto 16px;
}

/* ── Contact ─────────────────────────────────────────── */
.info-item { display: flex; gap: 16px; margin-bottom: 24px; align-items: flex-start; }
.info-icon {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--light-red); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; min-width: 48px;
}
.dev-card {
  border: none; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 30px;
  text-align: center; background: #fff;
  border-top: 4px solid var(--secondary);
}

/* ── Badges / Tags ───────────────────────────────────── */
.badge-primary { background: var(--primary); }
.badge-secondary-c { background: var(--secondary); }

/* ── Gallery Carousel ────────────────────────────────── */
.gallery-carousel-img { width: 100%; height: 400px; object-fit: cover; border-radius: var(--radius); }
.gallery-thumb {
  width: 80px; height: 60px; object-fit: cover;
  border-radius: 6px; cursor: pointer; opacity: .6; transition: opacity .2s;
  border: 2px solid transparent;
}
.gallery-thumb.active, .gallery-thumb:hover { opacity: 1; border-color: var(--primary); }

/* ── Animations ──────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-fadeup { animation: fadeInUp .6s ease forwards; }

/* ── Filter pills ────────────────────────────────────── */
.filter-pill {
  border: 2px solid #ddd; background: #fff; color: #555;
  padding: 6px 18px; border-radius: 50px; font-size: .85rem;
  cursor: pointer; transition: all .2s; font-weight: 500;
}
.filter-pill:hover, .filter-pill.active {
  background: var(--primary); border-color: var(--primary); color: #fff;
}

/* ── Article Content ─────────────────────────────────── */
.page-content { line-height: 1.9; font-size: 1rem; color: #2C3E50; }
.page-content h1,.page-content h2,.page-content h3 { margin-top: 1.5rem; color: var(--primary); }
.page-content img { max-width: 100%; border-radius: var(--radius); margin: 12px 0; }
.page-content p { margin-bottom: 1rem; }
.page-content ul,.page-content ol { padding-left: 1.5rem; margin-bottom: 1rem; }
.page-content table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.page-content table td,.page-content table th { border: 1px solid #dee2e6; padding: 8px 12px; }
.page-content table th { background: #f8f9fa; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  .hero-section { min-height: auto; padding: 60px 0; }
  .chat-box { width: calc(100vw - 30px); right: 15px; }
  .hero-stats { gap: 20px; }
}

/* ── Featured Admin Card (ผอ.) ───────────────────────── */
.admin-card-featured {
  background: linear-gradient(135deg, #fff 0%, #fff9f0 100%);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(192,57,43,.18);
  padding: 36px 28px 28px;
  text-align: center;
  transition: all .3s;
  border-top: 5px solid #c0392b;
  position: relative;
}
.admin-card-featured::before {
  content: '★ ผู้อำนวยการ';
  position: absolute; top: -1px; left: 50%; transform: translateX(-50%);
  background: #c0392b; color: #fff;
  font-size: .7rem; font-weight: 700; padding: 2px 14px;
  border-radius: 0 0 8px 8px; letter-spacing: .04em;
}
.admin-card-featured:hover { transform: translateY(-5px); box-shadow: 0 12px 40px rgba(192,57,43,.28); }
.admin-avatar-featured {
  width: 140px; height: 140px;
  border-radius: 50%; object-fit: cover;
  border: 5px solid #c0392b;
  margin: 16px auto 20px;
  box-shadow: 0 4px 16px rgba(192,57,43,.25);
}
.admin-avatar-featured-placeholder {
  width: 140px; height: 140px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  margin: 16px auto 20px; font-size: 3rem; color: #fff;
  box-shadow: 0 4px 16px rgba(192,57,43,.25);
}
.admin-name-featured { font-size: 1.2rem; font-weight: 800; margin-bottom: 6px; color: #2c3e50; }
.admin-pos-featured { color: var(--gray); font-size: .9rem; }

/* ── Chat Status Dot ─────────────────────────────────── */
.chat-status-dot {
  display: inline-block;
  width: 12px; height: 12px; border-radius: 50%;
  vertical-align: middle; margin-right: 5px;
  flex-shrink: 0;
}
.chat-status-dot.online  { background: #2ecc71; box-shadow: 0 0 0 3px rgba(46,204,113,.25); animation: pulse-green .8s infinite alternate; }
.chat-status-dot.offline { background: #aaa; }
@keyframes pulse-green { from { box-shadow: 0 0 0 2px rgba(46,204,113,.2); } to { box-shadow: 0 0 0 6px rgba(46,204,113,.05); } }
.chat-fab-dot {
  position: absolute; bottom: 3px; right: 3px;
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid #fff;
}
.chat-fab-dot.online  { background: #2ecc71; }
.chat-fab-dot.offline { background: #aaa; }
