* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: #222;
  background: #f5f5f7;
}

a {
  color: inherit;
  text-decoration: none;
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.site-header {
  background: #111827;
  color: #f9fafb;
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header .container {
  max-width: 1100px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  gap: 12px;
  padding: 6px 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  flex-shrink: 0;
}

.logo img {
  height: 28px;
  border-radius: 6px;
}

.nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 4px;
  white-space: nowrap;
}

/* เดิมมีประมาณนี้อยู่แล้ว */
.nav a {
  margin-left: 0;
  font-size: 0.9rem;
  opacity: 0.9;
  text-decoration: none;

  cursor: pointer; /* เปลี่ยนเป็นรูปมือ */
  padding: 4px 8px; /* ให้มีพื้นที่คลิก */
  border-radius: 10px; /* มน ๆ แบบ pill */
  transition: background 0.2s, color 0.2s, opacity 0.2s; /* ทำให้เปลี่ยนนุ่ม ๆ */
}

/* ตอน hover หรือ focus (กด Tab) */
.nav a:hover,
.nav a:focus-visible {
  opacity: 1;
  background: rgba(248, 250, 252, 0.12); /* พื้นจาง ๆ */
  color: #ffffff; /* สีตัวอักษรขาวขึ้นชัด ๆ */
  text-decoration: none; /* ถ้าไม่อยากให้มีเส้นใต้ */
}

/* เผื่อใช้ keyboard: แสดงกรอบตอน focus */
.nav a:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.auth-actions {
  margin-left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.auth-actions[hidden] {
  display: none !important;
}

.auth-btn {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 999px;
  font-size: 0.86rem;
  color: #f8fafc;
  opacity: 1;
  background: rgba(248, 250, 252, 0.05);
}

.auth-btn:hover,
.auth-btn:focus-visible {
  background: rgba(248, 250, 252, 0.16);
  color: #ffffff;
}

.auth-btn.primary {
  background: #2563eb;
  border-color: #2563eb;
}

.auth-btn.primary:hover,
.auth-btn.primary:focus-visible {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.profile-menu {
  position: relative;
  margin-left: 8px;
  flex-shrink: 0;
}

.profile-menu[hidden] {
  display: none !important;
}

.profile-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(248, 250, 252, 0.08);
  color: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 999px;
  padding: 3px 8px 3px 12px;
  cursor: pointer;
  font: inherit;
  transition: background 0.2s, border-color 0.2s;
}

.profile-trigger:hover,
.profile-trigger:focus-visible {
  background: rgba(248, 250, 252, 0.16);
  border-color: rgba(148, 163, 184, 0.5);
}

.profile-trigger:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.profile-label {
  font-size: 0.85rem;
  max-width: 124px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #2dd4bf;
  color: #083344;
  font-size: 0.82rem;
  font-weight: 700;
}

.profile-caret {
  font-size: 0.75rem;
  opacity: 0.85;
}

.profile-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 230px;
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 12px 24px rgba(2, 6, 23, 0.2);
  padding: 8px;
  z-index: 35;
}

.profile-menu.open .profile-dropdown {
  display: block;
}

.profile-dropdown a {
  display: block;
  margin-left: 0;
  border-radius: 8px;
  padding: 8px 10px;
  color: #0f172a;
  font-size: 0.9rem;
  opacity: 1;
}

.profile-dropdown a[hidden] {
  display: none !important;
}

.profile-dropdown a:hover,
.profile-dropdown a:focus-visible {
  background: #eff6ff;
  color: #1d4ed8;
}

/* Hero */
.hero {
  padding: 40px 0 32px;
  background: linear-gradient(135deg, #0f172a, #1d283a);
  color: #e5e7eb;
}
.hero-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 2rem;
}

.hero-logo {
  height: 55px;
  border-radius: 8px;
}

.hero-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: stretch;
}

.hero h1 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 2rem;
}

.hero-sub {
  margin-top: 0;
  margin-bottom: 16px;
  max-width: 480px;
  color: #cbd5f5;
}

.hero-actions .btn {
  margin-right: 8px;
  margin-bottom: 8px;
}

.hero-card {
  background: rgba(15, 23, 42, 0.9);
  border-radius: 12px;
  padding: 16px 20px;
  min-width: 525px;
  max-width: 320px;
}

.btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
}

.btn.primary {
  background: #3b82f6;
  color: white;
}

.btn.primary:hover {
  filter: brightness(1.05);
}

.btn.outline {
  border: 1px solid #3b82f6;
  color: #3b82f6;
}

.btn.outline:hover {
  background: rgba(148, 163, 184, 0.1);
}

.btn.font {
  color: #2563eb;
}

.section {
  padding: 32px 0;
}

.section-alt {
  background: #e5e7eb;
}

.section-iot {
  background: linear-gradient(180deg, #f8fbff 0%, #eef4ff 100%);
}

.iot-card {
  background: #ffffff;
  border: 1px solid #dbe7ff;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.1);
}

.iot-card h2 {
  margin-top: 0;
  margin-bottom: 8px;
}

.iot-card p {
  margin-top: 0;
  margin-bottom: 14px;
  color: #334155;
}

.iot-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.iot-note {
  margin-top: 12px;
  margin-bottom: 0;
  font-size: 0.9rem;
  color: #475569;
}

.section h2 {
  margin-top: 0;
}

/* Keep spacing consistent for subsection titles inside the same section */
.section .grid-3 + h2 {
  margin-top: 32px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  align-items: stretch; /* สำคัญ: ให้การ์ดยืดสูงเท่ากัน */
}
/* เปลี่ยนการ์ดดาวน์โหลดเป็น flex column */
.card.download-card {
  display: flex;
  flex-direction: column;
}

/* ระยะหัวข้อ/คำบรรยายในการ์ดเอกสาร */
.card.download-card h3 {
  margin-top: 0;
  margin-bottom: 8px;
}

.card.download-card p {
  margin-top: 0;
  margin-bottom: 12px;
}

/* ดันปุ่มไปก้นการ์ด ให้ทุกใบอยู่ระดับเดียวกัน */
.card.download-card .btn {
  margin-top: auto; /* ตัวนี้แหละที่ดันลงล่าง */
  align-self: flex-start; /* ให้ปุ่มชิดซ้าย (จะใช้ center ก็ได้) */
}
.card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.site-footer {
  padding: 16px 0;
  font-size: 0.85rem;
  color: #6b7280;
  background: #f3f4f6;
}
.version-list {
  list-style: none;
  padding-left: 0;
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.version-list li .btn {
  width: 100%;
  text-align: center;
}

.download-card ul {
  padding-left: 18px;
  margin: 8px 0 0;
}

.download-card ul li {
  margin-bottom: 4px;
}

.hero.hero-download .hero-inner {
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: center;
  gap: 32px;
  min-height: 185px;
}

.hero.hero-download {
  padding: 40px 0 32px;
}

.hero-download-text {
  flex: 1 1 52%;
  min-width: 0;
}

.hero-download-visual {
  flex: 1 1 48%;
  display: flex;
  justify-content: flex-end;
  padding-top: 0;
  padding-right: 56px;
  margin-top: 0;
  min-width: 0;
}

.hero-download-visual img {
  width: min(100%, 360px);
  height: 190px;
  object-fit: cover;
  object-position: right 86%;
  display: block;
  border-radius: 0;
  box-shadow: none;
  filter: drop-shadow(0 2px 3px rgba(2, 6, 23, 0.78))
    drop-shadow(0 14px 22px rgba(2, 6, 23, 0.9));
}

.hero-download .hero-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 0;
  margin-bottom: 8px;
}

.hero-download .hero-logo {
  height: 55px;
  border-radius: 8px;
}
/* =========================
   Hero เฉพาะหน้า courses
========================= */
.hero-courses {
  /* ใช้พื้นเดียวกับ hero ปกติได้เลย ถ้าอยากให้เตี้ยลงก็ปรับ padding */
  padding: 40px 0 32px;
}

.hero-courses-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 32px;
}

.hero-courses-text {
  flex: 1 1 55%;
}

.hero-courses-illustration {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.hero-courses-illustration img {
  max-width: 260px;
  width: 100%;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  margin-top: 4px; /* ขยับรูปให้สูงระดับเดียวกับหัวข้อ */ 
}

/* =========================
   Cards & badges for courses
========================= */

.course-info-card p {
  margin-bottom: 0;
}

.course-card {
  position: relative;
  padding-top: 24px;        /* เผื่อที่ด้านบนอีกนิด */
}

/* ป้ายระดับคอร์ส */
.course-badge {
  position: absolute;
  top: 14px;
  right: 16px;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: #22c55e;
  color: #0f172a;
  font-weight: 700;
}

/* ถ้าอยากให้สีต่างกันตามระดับก็ใช้คลาสเดิมได้เหมือนเดิม */
.course-badge-mid {
  background: #f97316;
  color: #0f172a;
}

.course-badge-adv {
  background: #38bdf8;
  color: #0f172a;
}

/* ตรงนี้คือจุดสำคัญ: กันพื้นที่ด้านขวาให้ badge */
.course-card h3 {
  margin-top: 0;
  margin-bottom: 8px;
  margin-right: 90px;   /* ปรับตัวเลขได้ 70–100px ตามความกว้างป้าย */
  line-height: 1.3;
}


.course-desc {
  margin-top: 0;
  margin-bottom: 12px;
}

/* รายละเอียดคอร์สเป็น bullet สวย ๆ */
.course-meta {
  list-style: none;
  padding-left: 0;
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: #4b5563;
}

.course-meta li + li {
  margin-top: 4px;
}

/* ปุ่มใน card คอร์ส */
.course-card .btn {
  margin-top: auto;
}

/* =========================
   Responsive หน้า courses
========================= */
@media (max-width: 720px) {
  .hero-courses-inner {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .hero-courses-text {
    flex: 1 1 auto;
  }

  .hero-courses-illustration {
    margin-top: 16px;
  }
}

.download-links {
  list-style: none; /* ตัดจุด bullet ออก */
  padding-left: 0; /* เอาการเยื้องทางซ้ายของ ul ออก */
  margin: 8px 0 0;
}

.download-links li + li {
  margin-top: 5px; /* ระยะห่างระหว่างบรรทัด */
}

.download-links a {
  display: inline-block;
  color: #2563eb; /* น้ำเงิน */
  font-weight: 700; /* ตัวหนา */
  text-decoration: none;
}

.download-links a:hover {
  text-decoration: underline; /* ถ้าไม่ชอบเส้นใต้เอาบรรทัดนี้ออกได้ */
}

@media (max-width: 720px) {
  .hero-inner {
    flex-direction: column;
  }

  .hero.hero-download .hero-inner {
    min-height: 0;
  }

  .hero-download-visual {
    justify-content: center;
    padding-right: 0;
    margin-top: 0;
  }

  .hero-download-visual img {
    width: min(100%, 320px);
    height: auto;
    object-fit: contain;
    object-position: center top;
  }

  .nav {
    font-size: 0.85rem;
  }

  .profile-label {
    display: none;
  }

  .profile-menu,
  .auth-actions {
    margin-left: 10px;
  }

  .profile-trigger {
    padding-left: 6px;
  }
}

@media (max-width: 1250px) {
  .profile-label {
    display: none;
  }
}
