@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600&display=swap');

:root {
  --primary-color: #831b2d;
  --primary-hover: #6a1524;
  --secondary-color: #2b4b39;
  --secondary-hover: #1f3a2b;
  --text-dark: #333333;
  --text-light: #ffffff;
  --bg-light: #f5f5f5;
  --bg-gray: #e0e0e0;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Kanit', sans-serif;
}

body {
  background-color: #ffffff;
  color: var(--text-dark);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 50px;
  background-color: #ffffff;
}

.logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #0b457f;
  text-decoration: none;
}
.logo-icon {
  font-size: 40px;
  margin-bottom: 5px;
}
.logo-text {
  font-weight: 600;
  font-size: 18px;
  line-height: 1;
}
.logo-subtext {
  font-size: 10px;
  color: #666;
}

nav {
  display: flex;
  gap: 15px;
}

nav a {
  text-decoration: none;
  color: var(--text-light);
  background-color: var(--primary-color);
  padding: 8px 30px;
  border-radius: 25px;
  font-size: 16px;
  transition: background-color 0.3s;
}

nav a:hover, nav a.active {
  background-color: var(--primary-hover);
}

/* Hero Section */
.hero {
  position: relative;
  height: 550px;
  background-size: cover;
  background-position: center;
  display: flex;
  justify-content: center;
  align-items: center;
}

.search-box {
  background-color: rgba(255, 255, 255, 0.9);
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  text-align: center;
  width: 600px;
  max-width: 90%;
}

.search-title {
  background-color: var(--primary-color);
  color: white;
  display: inline-block;
  padding: 10px 40px;
  border-radius: 10px;
  font-size: 20px;
  margin-bottom: 25px;
  margin-top: -50px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.form-row {
  display: flex;
  gap: 15px;
}

.form-group {
  flex: 1;
  text-align: left;
}

.form-group input, .form-group select {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  background-color: #e9e9e9;
}

.btn-search {
  background-color: var(--secondary-color);
  color: white;
  border: none;
  padding: 12px 40px;
  border-radius: 25px;
  font-size: 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: center;
  margin-top: 10px;
  transition: background-color 0.3s;
}

.btn-search:hover {
  background-color: var(--secondary-hover);
}

/* Main Content area */
main {
  flex: 1;
  padding: 50px;
}

/* News Section */
.news-section {
  max-width: 1000px;
  margin: 0 auto;
}
.news-section h2 {
  color: var(--primary-color);
  margin-bottom: 20px;
  font-weight: 500;
}
.news-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}
.news-card {
  display: flex;
  gap: 15px;
  align-items: center;
}
.news-card img {
  width: 200px;
  height: 200px;
  object-fit: cover;
  border-radius: 10px;
}
.news-info h3 {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 5px;
}
.news-info p {
  font-size: 14px;
  color: #666;
}

/* Footer */
footer {
  background-color: var(--primary-color);
  color: white;
  padding: 40px 50px 20px;
}

.footer-content {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 30px;
  margin-bottom: 30px;
}

.footer-col h3 {
  font-size: 18px;
  margin-bottom: 15px;
  font-weight: 500;
}

.footer-col p {
  font-size: 14px;
  margin-bottom: 5px;
  line-height: 1.6;
}

.footer-links {
  list-style: none;
}
.footer-links li {
  margin-bottom: 8px;
}
.footer-links a {
  color: white;
  text-decoration: none;
  font-size: 14px;
}
.footer-links a:hover {
  text-decoration: underline;
}

.footer-bottom {
  text-align: center;
  font-size: 14px;
  border-top: 1px solid rgba(255,255,255,0.2);
  padding-top: 20px;
}

.call-center {
  font-size: 20px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 15px;
}

/* Schedule / Fare Tables */
.table-container {
  max-width: 1000px;
  margin: 0 auto;
}
.page-title {
  text-align: center;
  color: var(--primary-color);
  margin-bottom: 30px;
  font-weight: 500;
  font-size: 24px;
}
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 30px;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
th, td {
  padding: 15px;
  text-align: center;
  border-bottom: 1px solid #eee;
  font-size: 14px;
}
th {
  font-weight: 500;
  color: #333;
}
tr:nth-child(even) {
  background-color: #fafafa;
}

/* Contact Page */
.contact-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 50px;
  max-width: 1000px;
  margin: 0 auto;
}
.contact-box {
  background-color: #e0e0e0;
  padding: 20px;
  border-radius: 10px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 15px;
}
.contact-icon {
  width: 40px;
  height: 40px;
  background: #333;
  color: white;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 20px;
}
.contact-form {
  background-color: #e0e0e0;
  padding: 30px;
  border-radius: 10px;
}
.contact-form label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  font-size: 14px;
}
.contact-form input, .contact-form textarea {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 5px;
  margin-bottom: 15px;
  background-color: white;
}
.contact-form textarea {
  height: 120px;
  resize: vertical;
}
.btn-submit {
  background-color: #2b3a5c;
  color: white;
  border: none;
  padding: 10px 30px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  display: block;
  margin: 0 auto;
}

/* Station Page */
.station-date {
  background-color: #80d0f5;
  color: #333;
  text-align: center;
  padding: 15px;
  font-size: 18px;
  font-weight: 500;
  margin: 20px 0;
}
.train-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
  max-width: 1000px;
  margin: 0 auto;
}
.train-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #e0e0e0;
  padding: 15px 30px;
  border-radius: 10px;
}
.train-type {
  padding: 10px 20px;
  border-radius: 5px;
  color: white;
  font-weight: 500;
  width: 150px;
  text-align: center;
}
.type-normal { background-color: #4a7bd1; }
.type-local { background-color: #e6b325; }
.type-suburb { background-color: #d1a54a; }
.type-express { background-color: #9e3d64; }

.train-route, .train-status-col {
  flex: 1;
  text-align: center;
}
.train-route-name {
  font-size: 20px;
  font-weight: 500;
}
.train-status {
  font-size: 18px;
  font-weight: 500;
}
.status-ready { color: #2a7bd1; }
.status-none { color: #d12a2a; }

/* Map image */
.map-container {
  max-width: 1000px;
  margin: 40px auto 0;
  text-align: center;
}
.map-container img {
  width: 100%;
  border-radius: 10px;
}

/* Responsive */
@media (max-width: 768px) {
  header {
    flex-direction: column;
    gap: 20px;
    padding: 15px;
  }
  nav {
    flex-wrap: wrap;
    justify-content: center;
  }
  .form-row {
    flex-direction: column;
  }
  .news-grid, .footer-content, .contact-container {
    grid-template-columns: 1fr;
  }
  .train-card {
    flex-direction: column;
    gap: 15px;
    text-align: center;
  }
}

/* ============================================================
   Search Result — Badge ขนาดเล็กในตารางผลการค้นหา
   ============================================================ */

/* Badge เล็กในตาราง (index.html) */
.train-badge-sm {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 5px;
  color: white;
  font-size: 13px;
  font-weight: 500;
}

/* สีแต่ละประเภทรถ (ใช้ใน badge เล็กและ train-card) */
.train-badge-type-special  { background-color: #9e3d64; }  /* ด่วนพิเศษ */
.train-badge-type-express  { background-color: #7b5ea7; }  /* ด่วน */
.train-badge-type-rapid    { background-color: #4a7bd1; }  /* เร็ว */
.train-badge-type-normal   { background-color: #4a7bd1; }  /* ธรรมดา */
.train-badge-type-local    { background-color: #e6b325; }  /* ท้องถิ่น */
.train-badge-type-suburb   { background-color: #d1a54a; }  /* ชานเมือง */

/* ปุ่ม "ดูตาราง" ในผลการค้นหา */
.btn-detail {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background-color: #0b457f;
  color: white;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  transition: background-color 0.3s;
}
.btn-detail:hover {
  background-color: #083466;
}

/* ============================================================
   Train Type Classes — สำหรับ train-card ใน station.html
   ============================================================ */
.type-special { background-color: #9e3d64; }  /* ด่วนพิเศษ */
.type-express { background-color: #7b5ea7; }  /* ด่วน */
.type-rapid   { background-color: #4a7bd1; }  /* เร็ว */
/* .type-normal และ .type-local และ .type-suburb มีอยู่แล้ว */

/* ============================================================
   Train Badge — บน schedule.html (ป้ายบนสุดของตารางเวลา)
   ============================================================ */
.badge-type-special { background-color: #9e3d64; }
.badge-type-express { background-color: #7b5ea7; }
.badge-type-rapid   { background-color: #4a7bd1; }
.badge-type-normal  { background-color: #4a7bd1; }
.badge-type-local   { background-color: #e6b325; }
.badge-type-suburb  { background-color: #d1a54a; }

/* Schedule Detail */
.schedule-detail-container {
  max-width: 1000px;
  margin: 0 auto;
}
.train-badge {
  background-color: #4a7bd1;
  color: white;
  display: inline-block;
  padding: 10px 20px;
  border-radius: 5px;
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 15px;
}
.train-route-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 5px;
}
.train-date-subtitle {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 20px;
}

/* ============================================================
   HEADER STICKY — ติดด้านบน + เงาเมื่อ scroll
   ============================================================ */
header {
  transition: box-shadow 0.3s ease, padding 0.3s ease;
  position: sticky;
  top: 0;
  z-index: 100;
  background: white;
}
header.scrolled {
  box-shadow: 0 3px 20px rgba(0, 0, 0, 0.12);
}

/* ============================================================
   HAMBURGER BUTTON — ปุ่ม 3 ขีด (มือถือเท่านั้น)
   ============================================================ */
.hamburger-btn {
  display: none;            /* ซ่อนบน Desktop */
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  width: 44px;
  height: 44px;
  cursor: pointer;
  padding: 9px;
  background: transparent;
  border: 2px solid var(--primary-color);
  border-radius: 10px;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}
.hamburger-btn:hover {
  background-color: var(--primary-color);
}
/* 3 ขีดแนวนอน */
.hamburger-btn span {
  display: block;
  width: 100%;
  height: 2.5px;
  background: var(--primary-color);
  border-radius: 3px;
  transform-origin: center;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              opacity   0.25s ease,
              background-color 0.3s ease;
}
.hamburger-btn:hover span {
  background-color: white;
}

/* เมื่อ Active — 3 ขีด กลายเป็น × */
.hamburger-btn.active {
  background-color: var(--primary-color);
}
.hamburger-btn.active span       { background-color: white; }
.hamburger-btn.active span:nth-child(1) { transform: translateY(8.5px) rotate(45deg); }
.hamburger-btn.active span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger-btn.active span:nth-child(3) { transform: translateY(-8.5px) rotate(-45deg); }

/* ============================================================
   MOBILE NAV OVERLAY — พื้นหลังมืด + Panel เมนู
   ============================================================ */
.mobile-nav-overlay {
  display: none;              /* ซ่อนจาก DOM และ Flow ทั้งหมดเด็ดขาด */
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.55);
  z-index: 2000;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.mobile-nav-overlay.open {
  display: flex;              /* แสดงเฉพาะเมื่อสั่งเปิดในมือถือ */
  opacity: 1;
}

/* Panel ที่ slide มาจากขวา */
.mobile-nav-panel {
  position: absolute;
  top: 0; right: 0;
  width: min(300px, 82vw);
  height: 100%;
  background: white;
  display: flex;
  flex-direction: column;
  transform: translateX(110%);    /* เริ่มซ่อนออกนอกจอ */
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -5px 0 30px rgba(0, 0, 0, 0.2);
  overflow-y: auto;
}
.mobile-nav-overlay.open .mobile-nav-panel {
  transform: translateX(0);       /* Slide เข้ามา */
}

/* Header ภายใน Panel */
.mobile-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  background: var(--primary-color);
  color: white;
  flex-shrink: 0;
}
.mobile-nav-header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 600;
}
.mobile-nav-header-logo i { font-size: 22px; }

/* ปุ่มปิด × บน panel */
.mobile-nav-close-btn {
  width: 36px;
  height: 36px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: transparent;
  border-radius: 50%;
  color: white;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, border-color 0.2s;
  flex-shrink: 0;
  line-height: 1;
}
.mobile-nav-close-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: white;
}

/* รายการลิงก์เมนูใน Panel */
.mobile-nav-links {
  padding: 20px 15px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.mobile-nav-link {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: #333;
  font-size: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  font-weight: 500;
  transition: background-color 0.25s, color 0.25s, transform 0.25s;
}
.mobile-nav-link i {
  width: 22px;
  text-align: center;
  color: var(--primary-color);
  font-size: 16px;
  transition: color 0.25s;
}
.mobile-nav-link:hover {
  background-color: rgba(131, 27, 45, 0.08);
  transform: translateX(5px);
}
.mobile-nav-link.active {
  background-color: var(--primary-color);
  color: white;
}
.mobile-nav-link.active i { color: white; }

/* Footer เบอร์โทรใน Panel */
.mobile-nav-footer {
  padding: 20px;
  border-top: 1px solid #f0f0f0;
  color: #888;
  font-size: 13px;
  text-align: center;
  flex-shrink: 0;
}

/* แสดง hamburger และซ่อน desktop nav บน Mobile / Tablet ( <= 900px ) */
@media (max-width: 900px) {
  .hamburger-btn {
    display: flex !important;
  }
  header nav {
    display: none !important;
  }
  header {
    flex-direction: row !important;
    gap: 0 !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 12px 20px !important;
  }
}

/* บนจอ Desktop ใหญ่ ( > 900px ) ซ่อน Mobile Nav Overlay และ Hamburger */
@media (min-width: 901px) {
  .mobile-nav-overlay,
  .mobile-nav-overlay.open,
  .hamburger-btn {
    display: none !important;
  }
}



/* ============================================================
   SCROLL ANIMATIONS — fade-in + slide-up เมื่อ scroll
   ============================================================ */

/* State เริ่มต้น: ซ่อน */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
/* เมื่อเข้า viewport: แสดง */
.animate-on-scroll.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger delay — element ถัดไปช้าขึ้น 120ms */
.animate-on-scroll:nth-child(2) { transition-delay: 0.12s; }
.animate-on-scroll:nth-child(3) { transition-delay: 0.24s; }
.animate-on-scroll:nth-child(4) { transition-delay: 0.36s; }
.animate-on-scroll:nth-child(5) { transition-delay: 0.48s; }

/* ============================================================
   ENHANCED HOVER EFFECTS — micro-animations บน Card และปุ่ม
   ============================================================ */

/* News Card lift on hover */
.news-card {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  border-radius: 10px;
}
.news-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

/* Train Card lift on hover */
.train-card {
  transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s;
}
.train-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  background-color: #d5d5d5;
}

/* Contact Box slide on hover */
.contact-box {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.contact-box:hover {
  transform: translateX(6px);
  box-shadow: 4px 4px 16px rgba(0, 0, 0, 0.08);
}

/* ============================================================
   BUTTON ANIMATIONS
   ============================================================ */
.btn-search {
  transition: background-color 0.3s, transform 0.2s, box-shadow 0.3s;
}
.btn-search:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(43, 75, 57, 0.4);
}
.btn-search:active { transform: translateY(0); box-shadow: none; }

.btn-submit {
  transition: background-color 0.3s, transform 0.2s, box-shadow 0.3s;
}
.btn-submit:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(43, 58, 92, 0.4);
}

/* Table row highlight on hover */
tbody tr {
  transition: background-color 0.2s ease;
}
tbody tr:hover {
  background-color: #fff0f2 !important;
}

/* Search box entrance animation เมื่อหน้าโหลด */
@keyframes searchBoxEntrance {
  from { opacity: 0; transform: translateY(-20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}
.search-box {
  animation: searchBoxEntrance 0.6s ease forwards;
}
