/* ============================================================
   COMPONENT — Misc (sidebar, pagination, tabs, breadcrumb,
   post card, dashboard, cert, auth card, empty state, syllabus,
   stats)
   ============================================================ */

/* [2026-07-31] Select2: บีบ <select> ต้นฉบับที่ถูกซ่อนให้เหลือ 1px จริง ๆ
   (บางหน้ามีกฎ width:100% ทับ width:1px ของ select2 → element ที่ absolute+clip
   ยังกินความกว้างเต็ม ดัน scrollWidth เกินจอ ~9-24px ในช่วง search bar 1 คอลัมน์)
   กัน phantom horizontal overflow ทุกที่ที่ใช้ Select2 */
select.select2-hidden-accessible { width: 1px !important; }

/* === SIDEBAR FILTER === */
.sidebar {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  padding: 22px;
  /* [2026-07-31] เดิม position:sticky;top:88px (ธีมตั้งใจให้ตัวกรองติดตามจอ) แต่พังเงียบเพราะ overflow-x:hidden
     พอ fix overflow → clip มันเริ่มติดหนึบตอน scroll = ผู้ใช้งง → ปิดเป็น static (เลื่อนตามหน้า = พฤติกรรมเดิม)
     ↺ เปิด sticky คืน: `position: sticky; top: calc(var(--header-h) + 16px);` */
  position: static;
  align-self: start;
  box-shadow: 0 4px 16px rgba(0, 116, 75, 0.04);
}
.sidebar h4 {
  font-family: var(--font-heading);
  font-size: 13pt; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--primary-dark); margin-bottom: 12px;
}
.filter-list { list-style: none; padding: 0; margin: 0 0 24px; }
.filter-list li a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 13pt; color: var(--text-muted);
  transition: var(--trans-fast);
}
.filter-list li a:hover,
.filter-list li a.active { background: var(--primary-50); color: var(--primary); }
.filter-list .count { font-size: 12pt; opacity: .7; }

/* === PAGINATION === */
.pagination {
  display: flex; justify-content: center; gap: 8px; margin-top: 32px;
}
.pagination .page-btn {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 13pt; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
  transition: var(--trans-fast);
  cursor: pointer;
}
.pagination .page-btn { text-decoration: none; }
.pagination .page-btn:hover { border-color: var(--primary); color: var(--primary); }
.pagination .page-btn.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.pagination .page-btn.is-disabled {
  opacity: .4; pointer-events: none; cursor: not-allowed;
}
.pagination .page-btn.is-gap {
  border: 0; background: transparent; pointer-events: none; cursor: default;
  color: var(--text-muted);
}

/* === TABS === */
.tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}
.tabs .tab {
  padding: 12px 20px;
  font-family: var(--font-heading);
  font-weight: 600; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  font-size: 13pt; cursor: pointer;
  transition: var(--trans-fast);
}
.tabs .tab:hover { color: var(--primary); }
.tabs .tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* === BREADCRUMB === */
.breadcrumb {
  font-family: var(--font-heading);
  font-size: 13pt;
  line-height: 1.6;          /* normal Thai-friendly height */
  color: var(--text-muted);
  padding: 16px 0 20px;
  margin: 0;
}
.breadcrumb,
.breadcrumb * {
  vertical-align: middle;    /* baseline-safe for Thai */
}
.breadcrumb a,
.breadcrumb > span {
  display: inline;           /* keep them on same baseline as text */
  font-weight: 500;
  color: var(--text-muted);
  transition: color .2s;
}
.breadcrumb a { cursor: pointer; }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb > span:last-child { color: var(--text-strong); font-weight: 600; }
.breadcrumb .sep {
  color: var(--text-light);
  opacity: 0.6;
  margin: 0 10px;
  font-weight: 400;
  font-family: system-ui, sans-serif;  /* consistent ›  rendering */
}

/* === POST CARD (community) === */
.post-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px; margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0, 116, 75, 0.04);
}
.post-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.post-header .author-name { font-family: var(--font-heading); font-weight: 700; font-size: var(--fs-meta); color: var(--text-strong); }
.post-header .author-meta { font-size: var(--fs-meta); color: var(--text-muted); font-family: var(--font-heading); }
.post-body { font-size: var(--fs-body); line-height: 1.7; margin-bottom: 14px; color: #2d4239; }
.post-actions {
  display: flex; gap: 18px;
  font-family: var(--font-heading);
  font-size: var(--fs-meta); color: var(--text-muted);
}
.post-actions a { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.post-actions a:hover { color: var(--primary); }

/* === DASHBOARD CARD === */
.dash-card {
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: 0 4px 14px rgba(0, 116, 75, 0.05);
}
.dash-card h3 {
  font-family: var(--font-display);
  font-size: 14pt; margin-bottom: 16px;
  color: var(--text-strong);
}
.dash-grid {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: 20px;
}
.dash-span-4  { grid-column: span 4; }
.dash-span-6  { grid-column: span 6; }
.dash-span-8  { grid-column: span 8; }
.dash-span-12 { grid-column: span 12; }
@media (max-width: 1000px) {
  .dash-span-4, .dash-span-6, .dash-span-8 { grid-column: span 12; }
}

.progress-bar {
  height: 8px; background: var(--primary-50);
  border-radius: var(--radius-pill); overflow: hidden;
}
.progress-bar > span {
  display: block; height: 100%;
  background: var(--gradient-primary);
  border-radius: inherit;
}

/* === STATS === */
.stats-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px;
}
@media (max-width: 1000px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px)  { .stats-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 22px; text-align: center;
  box-shadow: 0 4px 12px rgba(0, 116, 75, 0.04);
  transition: var(--trans);
}
.stat-card:hover {
  box-shadow: 0 12px 28px rgba(0, 116, 75, 0.1);
  transform: translateY(-3px);
}
.stat-card .icon {
  width: 56px; height: 56px; margin: 0 auto 12px;
  border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18pt;
}
.stat-card .num {
  font-family: var(--font-display);
  font-size: 23pt; font-weight: 700;
  color: var(--primary);
}
.stat-card .lbl {
  font-family: var(--font-heading);
  font-size: var(--fs-meta); color: var(--text-muted); margin-top: 2px;
}

/* === AUTH CARD === */
.auth-card {
  max-width: 460px; margin: 48px auto;
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 44px;
  border: 1px solid var(--line);
  box-shadow: 0 14px 50px rgba(0, 116, 75, 0.1);
}
.auth-card h1 {
  font-family: var(--font-display);
  font-size: 23pt; margin-bottom: 6px;
}
.auth-card .lead {
  color: var(--text-muted); font-size: var(--fs-body-sm); margin-bottom: 28px;
}
.auth-card .btn { width: 100%; }
.auth-divider {
  text-align: center; color: var(--text-muted); font-size: var(--fs-micro);
  position: relative; margin: 24px 0;
  font-family: var(--font-heading);
}
.auth-divider::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%;
  border-top: 1px solid var(--line);
}
.auth-divider span { background: var(--surface); padding: 0 10px; position: relative; }

/* === CERTIFICATE === */
.cert-card {
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 116, 75, 0.06);
}
.cert-preview {
  aspect-ratio: 1.414 / 1;
  background: linear-gradient(135deg, #f7faf8, #eef4f0);
  position: relative;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px; text-align: center;
}
.cert-preview::before {
  content: ""; position: absolute; inset: 12px;
  border: 2px solid var(--primary-100); border-radius: 10px; pointer-events: none;
}
.cert-preview h4 {
  color: var(--primary-dark);
  font-family: var(--font-display);
  font-size: 17pt; margin-bottom: 8px;
}
.cert-preview .award {
  font-size: 36pt; margin-bottom: 12px; color: var(--primary);
}

/* === EMPTY STATE === */
.empty-state {
  text-align: center; padding: 72px 24px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--line-strong);
}
.empty-state .emoji { font-size: 48pt; margin-bottom: 12px; }
.empty-state h3 {
  font-family: var(--font-display);
  color: var(--primary-dark);
  margin-bottom: 6px;
}
.empty-state p { color: var(--text-muted); margin-bottom: 20px; }

/* === SYLLABUS === */
.syllabus { list-style: none; padding: 0; margin: 0; }
.syllabus li {
  padding: 14px 0; border-bottom: 1px solid var(--line);
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  font-family: var(--font-body);
  font-size: 18pt;
}
.syllabus li small { font-size: var(--fs-meta); }
.syllabus li:last-child { border: 0; }
.syllabus-items { list-style: none; }
.syllabus-items li {
  padding: 4px 0; border-bottom: 0;
  /* [2026-07-31] nowrap → wrap: ชื่อบทยาวบนมือถือ (คอลัมน์ ~280px) ตัดบรรทัดแทนล้น */
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  font-size: 16pt;
}
.syllabus-items li small { font-size: var(--fs-meta); }
.syllabus .num {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-50); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-heading);
  font-weight: 800; font-size: 15pt;
  flex-shrink: 0;
}

/* === SCHEDULE LIST (course detail — รุ่น/รอบเรียน) === */
.schedule-list { display: flex; flex-direction: column; gap: 12px; }
.schedule-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.schedule-row:hover { border-color: var(--primary); box-shadow: 0 4px 14px rgba(0, 116, 75, .08); }
.schedule-row.schedule-status-cancelled,
.schedule-row.schedule-status-completed,
.schedule-row.schedule-status-expired,
.schedule-row.schedule-status-closed_early { opacity: .65; background: #fafafa; }
.schedule-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px;
}
.schedule-round {
  font-family: var(--font-display);
  font-size: 18pt; font-weight: 700; color: var(--primary-dark);
}
.schedule-round small { color: var(--text-muted); font-weight: 400; font-size: 16pt; }
.schedule-row .course-status-badge { position: static; box-shadow: none; }
.schedule-body { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.schedule-dates { flex: 1 1 320px; font-size: 16pt; color: #40504a; line-height: 1.9; }
.schedule-dates i { color: var(--primary); margin-right: 6px; }
.schedule-capacity { flex: 1 1 200px; min-width: 0; }  /* [2026-07-31] min-width:200px → 0: หดได้บนจอเล็ก ≤355px ไม่ล้น */
.schedule-capacity .cap-text { font-size: 16pt; color: #40504a; margin-bottom: 6px; }
.schedule-capacity .cap-text i { color: var(--primary); margin-right: 6px; }
.schedule-capacity .cap-text small { color: var(--text-muted); margin-left: 4px; }
.schedule-capacity .cap-bar {
  height: 6px; border-radius: 3px;
  background: rgba(0, 0, 0, .06); overflow: hidden;
}
.schedule-capacity .cap-bar > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, #00a86b, #00744b);
  transition: width .3s ease;
}
.schedule-row.schedule-status-full .cap-bar > span { background: linear-gradient(90deg, #dc3545, #a02030); }

/* === LEARNING PATH CARDS (home) === */
.paths-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  max-width: 1160px;
  margin: 0 auto;
}
@media (max-width: 1000px) { .paths-grid { grid-template-columns: repeat(2, 1fr); max-width: 640px; } }
@media (max-width: 560px)  { .paths-grid { grid-template-columns: 1fr; max-width: 420px; } }
.path-card {
  background: var(--surface); border-radius: var(--radius-xl);
  padding: 36px; border: 1px solid var(--line);
  box-shadow: 0 4px 20px rgba(0, 116, 75, 0.05);
  transition: var(--trans);
  position: relative; overflow: hidden;
  cursor: pointer;
}
.path-card:hover {
  transform: translateY(-6px);
  border-color: var(--primary);
  box-shadow: 0 20px 50px rgba(0, 116, 75, 0.14);
}
.path-card::before {
  content: ""; position: absolute; top: 0; right: 0;
  width: 140px; height: 140px;
  background: radial-gradient(circle at top right, rgba(0, 168, 107, 0.15), transparent 65%);
  pointer-events: none;
}
.path-card .num {
  font-family: var(--font-display);
  font-size: 42pt; color: var(--primary);
  line-height: 1; margin-bottom: 18px;
  font-weight: 700; font-style: italic;
}
.path-card h3 {
  font-family: var(--font-display);
  font-size: 18pt; margin-bottom: 10px;
}
.path-card .tag-role {
  font-family: var(--font-heading);
  font-size: var(--fs-badge); letter-spacing: 0.12em; text-transform: uppercase;
  font-weight: 700; margin-bottom: 6px;
}
/* Force FA font on icon — protect against parent text-transform/letter-spacing */
.path-card .tag-role i.fa-solid,
.path-card .tag-role i.fa-regular,
.path-card .tag-role i.fa-brands {
  font-family: "Font Awesome 6 Free", "Font Awesome 6 Brands";
  letter-spacing: 0;
  margin-right: 6px;
  font-weight: 900;
}
.path-card p { color: #40504a; font-size: var(--fs-body-sm); margin-bottom: 20px; }
.path-card .stats {
  display: flex; gap: 20px; padding-top: 16px;
  border-top: 1px solid var(--line);
  font-family: var(--font-heading);
  font-size: var(--fs-meta); color: var(--text-muted);
}
.path-card .stats b { color: var(--text-strong); display: block; font-size: 13pt; margin-bottom: 2px; }

/* ============================================================
   Path Card v2 — ใช้เฉพาะข้อมูลจริงจาก API (group, count, hours)
   ไม่มี title/desc หลอก
   ============================================================ */
.path-card.path-card-v2 {
  display: flex;
  flex-direction: column;
  padding: 20px 22px 18px;
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius-lg, 14px);
  /* min-height ลบทิ้ง — ให้เนื้อหาเป็นตัวกำหนดความสูง */
}
.path-card.path-card-v2::before {
  width: 120px; height: 120px;
  background: radial-gradient(circle at top right, rgba(0, 116, 75, .18), transparent 70%); /* fallback */
  background: radial-gradient(circle at top right,
              color-mix(in srgb, var(--accent, var(--primary)) 18%, transparent),
              transparent 70%);
}

/* Head: icon + number */
.path-card-v2 .path-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.path-card-v2 .path-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(0, 116, 75, .12); /* fallback */
  background: color-mix(in srgb, var(--accent, var(--primary)) 14%, transparent);
  color: var(--accent, var(--primary));
  font-size: 14pt;
}
.path-card-v2 .path-num {
  font-family: var(--font-display);
  font-weight: 700; font-style: italic;
  font-size: 20pt;
  line-height: 1;
  color: rgba(0, 116, 75, .35); /* fallback */
  color: color-mix(in srgb, var(--accent, var(--primary)) 35%, transparent);
}

/* Body: role name */
.path-card-v2 .path-body { margin-bottom: 14px; }
.path-card-v2 .path-label {
  font-family: var(--font-heading);
  font-size: var(--fs-badge); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.path-card-v2 .path-role {
  font-family: var(--font-display);
  font-size: 17pt;
  line-height: 1.15;
  color: var(--text-strong);
  margin: 0;
}

/* Stats row */
.path-card-v2 .path-stats {
  display: flex; gap: 22px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.path-card-v2 .path-stat strong {
  display: block;
  font-family: var(--font-display);
  font-size: 15pt; font-weight: 700;
  color: var(--accent, var(--primary));
  line-height: 1; margin-bottom: 2px;
}
.path-card-v2 .path-stat span {
  font-family: var(--font-heading);
  font-size: var(--fs-meta);
  color: var(--text-muted);
}

/* CTA footer */
.path-card-v2 .path-cta {
  margin-top: auto;
  font-family: var(--font-heading);
  font-size: var(--fs-meta); font-weight: 600;
  color: var(--accent, var(--primary));
  display: inline-flex; align-items: center; gap: 6px;
  transition: gap .2s ease;
}
.path-card-v2:hover .path-cta { gap: 14px; }
.path-card-v2 .path-cta i { font-size: 12pt; }

/* Hover lifts + accent border */
.path-card.path-card-v2:hover {
  border-color: var(--accent, var(--primary));
}

/* ============================================================
   Organizations page — การ์ดหน่วยงานเครือข่าย
   ============================================================ */
.org-grid {
  display: grid;
  /* [2026-07-31] min(100%,280px): จอ < 328px คอลัมน์หดตามจอแทนบังคับ 280px แล้วล้น/โดน clip */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 20px;
}
.org-card {
  display: flex; align-items: center; gap: 18px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  box-shadow: 0 6px 20px rgba(0,116,75,.05);
  transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease;
}
.org-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: 0 18px 40px rgba(0,116,75,.14);
}
.org-card .org-logo {
  width: 72px; height: 72px;
  flex-shrink: 0;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.org-card .org-logo img {
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 6px;
}
.org-card .org-logo-placeholder {
  font-size: 21pt; color: var(--primary);
}
.org-card .org-info { min-width: 0; flex: 1; }
.org-card .org-info h4 {
  font-family: var(--font-display);
  font-size: 14pt;
  margin: 0 0 6px;
  line-height: 1.3;
  color: var(--text-strong);
}
.org-card .org-info small {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-heading);
  font-size: 12pt;
  color: var(--primary);
  transition: gap .2s ease;
}
.org-card:hover .org-info small { gap: 10px; }
.org-card .org-info small i { font-size: 11pt; }
