/* =====================================================
   สาขาวิชาเทคโนโลยีธุรกิจดิจิทัล วิทยาลัยเทคนิคจะนะ
   Global CSS
   ===================================================== */

:root {
  --navy:       #0a1f44;
  --navy-mid:   #12306a;
  --blue:       #1a56db;
  --blue-light: #3b82f6;
  --gold:       #f0a500;
  --gold-light: #fbbf24;
  --white:      #ffffff;
  --gray-soft:  #f4f6fb;
  --text-dark:  #0f172a;
  --text-mid:   #334155;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Noto Sans Thai', sans-serif;
  background: var(--white);
  color: var(--text-dark);
  overflow-x: hidden;
}

/* ===== NAVBAR ===== */
#navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: rgba(10, 31, 68, 0.97);
  backdrop-filter: blur(12px);
  border-bottom: 2px solid var(--gold);
  transition: box-shadow 0.3s;
}

.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.nav-logo {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  object-fit: cover;
  background: #fff;
}

.nav-title { display: flex; flex-direction: column; }
.nav-title span:first-child { font-size: 0.7rem; color: var(--gold-light); font-weight: 500; letter-spacing: 0.04em; }
.nav-title span:last-child  { font-size: 0.92rem; color: #fff; font-weight: 700; }

.nav-links { display: flex; align-items: center; gap: 2px; list-style: none; }
.nav-links a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.nav-links a:hover { background: rgba(240,165,0,0.15); color: var(--gold-light); }
.nav-links a.active { background: var(--gold); color: var(--navy); font-weight: 700; }

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
}
.hamburger span { display: block; width: 24px; height: 2px; background: #fff; border-radius: 2px; transition: all 0.3s; }

/* Mobile Menu */
@media (max-width: 900px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 68px; left: 0; right: 0;
    background: var(--navy);
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 1rem 0;
    border-top: 1px solid rgba(255,255,255,0.1);
  }
  .nav-links.open { display: flex; }
  .nav-links li { width: 100%; }
  .nav-links a { padding: 12px 1.5rem; border-radius: 0; width: 100%; }
  .hamburger { display: flex; }
}

/* ===== LAYOUT ===== */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 2rem;
}

section { padding: 5rem 0; }
section:first-of-type { padding-top: 0; }

/* ===== SECTION HEADER ===== */
.section-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
}
.section-label::before {
  content: '';
  display: block;
  width: 20px; height: 2px;
  background: var(--blue);
}

.section-title {
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  font-weight: 800;
  color: var(--navy);
  line-height: 1.3;
  margin-bottom: 0.75rem;
}

.section-desc {
  color: var(--text-mid);
  font-size: 1rem;
  line-height: 1.8;
  max-width: 560px;
}

/* ===== BUTTONS ===== */
.btn-primary {
  background: var(--gold);
  color: var(--navy);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 12px 28px;
  border-radius: 8px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary:hover { background: var(--gold-light); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(240,165,0,0.3); }

.btn-outline {
  background: transparent;
  color: var(--navy);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 10px 22px;
  border-radius: 8px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1.5px solid var(--navy);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-outline:hover { background: var(--navy); color: #fff; }

.btn-outline-white {
  background: transparent;
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 12px 28px;
  border-radius: 8px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1.5px solid rgba(255,255,255,0.5);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-outline-white:hover { border-color: #fff; background: rgba(255,255,255,0.1); }

.btn-dark {
  background: var(--navy);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 12px 28px;
  border-radius: 8px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-dark:hover { background: var(--navy-mid); transform: translateY(-2px); }

/* ===== FLASH MESSAGES ===== */
.flash-success {
  background: #d1fae5; color: #065f46;
  border: 1px solid #6ee7b7;
  padding: 12px 16px; border-radius: 8px;
  margin-bottom: 1rem;
  display: flex; align-items: center; gap: 8px;
}
.flash-error {
  background: #fee2e2; color: #991b1b;
  border: 1px solid #fca5a5;
  padding: 12px 16px; border-radius: 8px;
  margin-bottom: 1rem;
  display: flex; align-items: center; gap: 8px;
}

/* ===== PAGE HERO (secondary pages) ===== */
.page-hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
  padding: 7rem 0 4rem;
  margin-top: 0;
  position: relative;
  overflow: hidden;
}
.page-hero::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 50px 50px;
}
.page-hero-inner { position: relative; z-index: 1; }
.page-hero h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); font-weight: 800; color: #fff; margin-bottom: 0.5rem; }
.page-hero p { color: rgba(255,255,255,0.7); font-size: 1rem; }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; color: rgba(255,255,255,0.6); margin-bottom: 1rem; }
.breadcrumb a { color: var(--gold-light); text-decoration: none; }
.breadcrumb span { color: rgba(255,255,255,0.4); }

/* ===== FOOTER ===== */
footer {
  background: var(--navy);
  color: rgba(255,255,255,0.7);
  padding: 3.5rem 0 1.5rem;
  border-top: 2px solid var(--gold);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 3rem;
  margin-bottom: 2.5rem;
}

.footer-brand-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 1rem; }
.footer-logo { width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--gold); overflow: hidden; background: #fff; flex-shrink: 0; }
.footer-logo img { width: 100%; height: 100%; object-fit: cover; }
.footer-brand-name { font-size: 0.88rem; font-weight: 700; color: #fff; line-height: 1.4; }
.footer-desc { font-size: 0.82rem; line-height: 1.8; margin-bottom: 1.2rem; }
.footer-social { display: flex; gap: 8px; }
.footer-social a {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.footer-social a:hover { background: var(--gold); color: var(--navy); }

.footer-col h4 { color: #fff; font-weight: 700; font-size: 0.88rem; margin-bottom: 1rem; display: flex; align-items: center; gap: 8px; }
.footer-col h4 i { color: var(--gold); font-size: 0.78rem; }
.footer-col ul { list-style: none; }
.footer-col ul li { margin-bottom: 0.45rem; }
.footer-col ul li a { color: rgba(255,255,255,0.65); text-decoration: none; font-size: 0.82rem; display: flex; align-items: center; gap: 6px; transition: color 0.2s; }
.footer-col ul li a i { font-size: 0.65rem; color: var(--gold); }
.footer-col ul li a:hover { color: var(--gold-light); }
.footer-contact-item { display: flex; gap: 10px; margin-bottom: 0.7rem; font-size: 0.82rem; }
.footer-contact-item i { color: var(--gold); margin-top: 2px; flex-shrink: 0; }

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  font-size: 0.78rem;
}

.disclaimer {
  font-size: 0.75rem;
  background: rgba(240,165,0,0.12);
  border: 1px solid rgba(240,165,0,0.3);
  color: var(--gold-light);
  padding: 6px 14px;
  border-radius: 100px;
  display: flex; align-items: center; gap: 6px;
}

/* ===== SCROLL REVEAL ===== */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: all 0.6s ease;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ===== ANIMATIONS ===== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeLeft {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}
@keyframes pulse-ring {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50%       { opacity: 1;   transform: scale(1.03); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .container { padding: 0 1rem; }
  section { padding: 3.5rem 0; }
  .footer-grid { grid-template-columns: 1fr; gap: 2rem; }
  .footer-bottom { flex-direction: column; text-align: center; }
}

/* ===== BACK TO TOP ===== */
#backToTop {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
  z-index: 500;
  opacity: 0;
  transform: translateY(16px);
  transition: all 0.3s ease;
  box-shadow: 0 4px 16px rgba(10,31,68,0.25);
}
#backToTop.visible {
  opacity: 1;
  transform: translateY(0);
}
#backToTop:hover {
  background: var(--gold);
  color: var(--navy);
  transform: translateY(-3px);
}

/* ===== PAGE LOADER ===== */
#pageLoader {
  position: fixed;
  inset: 0;
  background: var(--navy);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
#pageLoader.hidden {
  opacity: 0;
  visibility: hidden;
}
.loader-logo {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  overflow: hidden;
  background: #fff;
  animation: pulse-ring 1.5s ease-in-out infinite;
}
.loader-logo img { width: 100%; height: 100%; object-fit: cover; }
.loader-bar {
  width: 180px;
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: 100px;
  overflow: hidden;
}
.loader-bar-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 100px;
  animation: loadBar 1.2s ease forwards;
}
.loader-text {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.05em;
}
@keyframes loadBar {
  from { width: 0%; }
  to   { width: 100%; }
}

/* ===== BREADCRUMB RESPONSIVE ===== */
@media (max-width: 480px) {
  .breadcrumb { font-size: 0.75rem; }
  .page-hero h1 { font-size: 1.5rem; }
}

/* ===== ABOUT PAGE RESPONSIVE ===== */
@media (max-width: 900px) {
  .info-grid { grid-template-columns: 1fr !important; }
  .info-img-badge { bottom: -1rem; right: 1rem; }
  .vision-grid { grid-template-columns: 1fr !important; }
}
@media (max-width: 640px) {
  .info-img-box { padding-bottom: 1.5rem; }
  .mission-list { gap: 0.6rem; }
}

/* ===== CONTACT RESPONSIVE ===== */
@media (max-width: 640px) {
  .contact-form-card { padding: 1.2rem; }
  .info-item { padding: 1rem; }
}

/* ===== TABLE RESPONSIVE ===== */
@media (max-width: 700px) {
  .subject-table { font-size: 0.78rem; }
  .subject-table th, .subject-table td { padding: 8px 10px; }
  .credit-summary { flex-direction: row; flex-wrap: wrap; }
  .credit-sum-num { font-size: 1.5rem; }
}

/* ===== GALLERY RESPONSIVE ===== */
@media (max-width: 480px) {
  .gallery-masonry { columns: 2; }
}

/* ===== NEWS DETAIL RESPONSIVE ===== */
@media (max-width: 640px) {
  .detail-body { padding: 1.2rem; }
  .detail-title { font-size: 1.2rem; }
}

/* ===== SMOOTH IMAGE LOAD ===== */
img {
  transition: opacity 0.3s ease;
}
img[loading="lazy"] {
  opacity: 0;
}
img[loading="lazy"].loaded {
  opacity: 1;
}

/* ===== SELECTION COLOR ===== */
::selection {
  background: var(--gold);
  color: var(--navy);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: var(--navy-mid); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: var(--navy); }

/* ===== PRINT ===== */
@media print {
  #navbar, footer, #backToTop, #pageLoader { display: none !important; }
  body { padding-top: 0; }
  section { padding: 1rem 0; }
}


/* ===== PHASE 4 BUGFIX ===== */

/* Fix: ข้อความล้นใน hero ทุกหน้า */
.about-hero p,
.teachers-hero p,
.news-hero p,
.gallery-hero p,
.curriculum-hero p,
.contact-hero p,
.news-detail-hero h1,
.search-hero p,
[class$="-hero"] p,
[class$="-hero"] h1 {
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
}

/* Fix: breadcrumb ล้นบนมือถือ */
.breadcrumb {
  flex-wrap: wrap;
  overflow-wrap: break-word;
  word-break: break-all;
}

/* Fix: ข้อความใน container ทุกที่ไม่ให้ล้น */
.container {
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Fix: hero subtitle บนมือถือ */
@media (max-width: 640px) {
  [class$="-hero"] h1 {
    font-size: 1.4rem !important;
    line-height: 1.4;
  }
  [class$="-hero"] p {
    font-size: 0.85rem !important;
    line-height: 1.6;
  }
  .page-hero h1 {
    font-size: 1.4rem !important;
  }
  .breadcrumb {
    font-size: 0.72rem;
  }
  /* navbar title ไม่ให้ล้น */
  .nav-title span:last-child {
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
  }
}

/* ===== BUGFIX: hero padding ไม่พอ ทำให้ h1 ถูก navbar บัง ===== */
.about-hero,
.teachers-hero,
.news-hero,
.news-detail-hero,
.gallery-hero,
.curriculum-hero,
.contact-hero,
.search-hero {
  padding-top: calc(68px + 5rem) !important;
}

/* Login button */
@media (max-width: 400px) {
  .nav-login-text { display: none; }
}

/* ===== LOGIN BUTTON ===== */
/* Desktop: แสดงในแถบ navbar */
.nav-login-desktop {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  border: 1.5px solid rgba(255,255,255,0.25);
  color: #fff;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
}
.nav-login-desktop:hover {
  background: rgba(240,165,0,0.2);
  border-color: var(--gold);
  color: var(--gold-light);
}

/* Mobile: ซ่อนปุ่ม desktop, แสดงใน hamburger แทน */
@media (max-width: 900px) {
  .nav-login-desktop { display: none !important; }
  .nav-login-mobile { display: block; }
  .nav-login-mobile a {
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: 4px;
    padding-top: 12px !important;
  }
}

/* Desktop: ซ่อน login ใน hamburger menu */
@media (min-width: 901px) {
  .nav-login-mobile { display: none !important; }
}

/* Desktop: แสดงปุ่ม login ใน navbar */
@media (min-width: 901px) {
  .nav-login-desktop {
    display: inline-flex !important;
  }
}
