/* ==========================================================================
   M03 ข้อมูลพื้นฐานการเรียน (prefix .m03-) — MST-01 หมวดหมู่, MST-02…05 ผู้สอน, MST-06 ระดับ/ทักษะ/แท็ก
   Tokens only (tokens.css); layout primitives come from base/components.
   ========================================================================== */

/* ---------- shared ---------- */
.m03-chips { display: inline-flex; flex-wrap: wrap; gap: var(--rv-space-1); min-width: 0; }
.m03-pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.m03-inline-field { flex: 0 1 300px; }
.m03-section { display: flex; flex-direction: column; gap: var(--rv-space-3); padding-bottom: var(--rv-space-4); border-bottom: 1px solid var(--rv-divider); }
.m03-section:last-child { border-bottom: 0; padding-bottom: 0; }
.m03-section__title { margin: 0; font-size: var(--rv-fs-body); line-height: var(--rv-lh-body); font-weight: 600; color: var(--rv-text-primary); }
.m03-form { display: flex; flex-direction: column; gap: var(--rv-space-4); min-width: 0; }
.m03-effect { padding: var(--rv-space-3); border: 1px solid var(--rv-divider); border-radius: var(--rv-radius-card); background: var(--rv-surface-subtle); }
.m03-effect:last-child { padding-bottom: var(--rv-space-3); }
.m03-impact { margin: 0; padding-left: var(--rv-space-5); display: flex; flex-direction: column; gap: var(--rv-space-1); }
.m03-rules { margin: var(--rv-space-1) 0 0; }
.m03-courselist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--rv-space-2); }
.m03-courselist > li { display: flex; align-items: center; flex-wrap: wrap; gap: var(--rv-space-2); padding: var(--rv-space-2); border: 1px solid var(--rv-divider); border-radius: var(--rv-radius-control); }
.m03-courselist > li > .rv-cell { flex: 1 1 240px; min-width: 0; }
.m03-mini-courses { margin: 0; padding-left: var(--rv-space-4); font-size: var(--rv-fs-small); line-height: var(--rv-lh-small); }
.m03-danger-icon { color: var(--rv-danger); }
.m03-danger-icon:hover { color: var(--rv-danger); background: var(--rv-danger-bg); }

/* ---------- MST-01 categories ---------- */
.m03-catname { display: flex; align-items: center; gap: var(--rv-space-2); min-width: 0; }
.m03-tree__toggle { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 28px; height: 28px; margin: 0; padding: 0; border: 0; border-radius: var(--rv-radius-control); background: transparent; color: var(--rv-text-secondary); cursor: pointer; }
.m03-tree__toggle:hover { background: var(--rv-neutral-100); color: var(--rv-primary-700); }
.m03-tree__toggle:focus-visible { outline: 2px solid var(--rv-focus); outline-offset: 2px; }
.m03-caticon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 36px; height: 36px; border-radius: var(--rv-radius-control); background: var(--rv-primary-50); color: var(--rv-primary-700); overflow: hidden; }
.m03-caticon.has-image { background: var(--rv-neutral-100); }
.m03-caticon img { width: 100%; height: 100%; object-fit: cover; }
.m03-catname__text { display: flex; flex-direction: column; min-width: 0; }
.m03-catname__en { font-weight: 500; }
.m03-catname__th { font-size: var(--rv-fs-small); line-height: var(--rv-lh-small); color: var(--rv-text-muted); }
.m03-sub { position: relative; margin: var(--rv-space-2) 0 0 14px; padding: var(--rv-space-1) 0 var(--rv-space-1) var(--rv-space-5); border-left: 1px dashed var(--rv-neutral-300); }
.m03-sub__empty { position: relative; margin: 0; font-size: var(--rv-fs-small); line-height: var(--rv-lh-small); color: var(--rv-text-muted); }
.m03-sub__empty::before { content: ""; position: absolute; left: calc(var(--rv-space-5) * -1); top: 10px; width: 14px; border-top: 1px dashed var(--rv-neutral-300); }
.m03-sub__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--rv-space-2); }
.m03-sub__item { display: flex; align-items: center; flex-wrap: wrap; gap: var(--rv-space-2); }
.m03-sub__name { flex: 1 1 160px; min-width: 0; }
.m03-switch { white-space: nowrap; }
.m03-count { font-variant-numeric: tabular-nums; white-space: nowrap; }
.m03-order { display: inline-flex; align-items: center; gap: 2px; }
.m03-order__n { min-width: 24px; text-align: right; font-variant-numeric: tabular-nums; }
.m03-iconpick { gap: var(--rv-space-2); }
.m03-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: var(--rv-space-1); max-width: 520px; }
.m03-icon-opt { position: relative; display: block; cursor: pointer; }
.m03-icon-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.m03-icon-opt__box { display: flex; align-items: center; justify-content: center; height: 44px; border: 1px solid var(--rv-border); border-radius: var(--rv-radius-control); background: var(--rv-surface); color: var(--rv-text-secondary); }
.m03-icon-opt:hover .m03-icon-opt__box { border-color: var(--rv-neutral-700); color: var(--rv-primary-700); }
.m03-icon-opt input:checked + .m03-icon-opt__box { border-color: var(--rv-primary-700); background: var(--rv-primary-50); color: var(--rv-primary-800); box-shadow: inset 0 0 0 1px var(--rv-primary-700); }
.m03-icon-opt input:focus-visible + .m03-icon-opt__box { outline: 2px solid var(--rv-focus); outline-offset: 2px; }

/* ---------- MST-06 taxonomies ---------- */
.m03-taxname { font-weight: 500; }

/* ---------- MST-02 instructors list ---------- */
.m03-insname { display: flex; align-items: center; gap: var(--rv-space-2); min-width: 0; }
.m03-insname > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.m03-insname a { font-weight: 500; }
.m03-insname__prefix { display: block; }

/* ---------- MST-04 detail ---------- */
.m03-ihead .rv-dhead__body { gap: var(--rv-space-3); }
.m03-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--rv-space-3) var(--rv-space-4); margin: 0; }
.m03-facts > div { min-width: 0; }
.m03-facts dt { font-size: var(--rv-fs-small); line-height: var(--rv-lh-small); color: var(--rv-text-secondary); }
.m03-facts dd { margin: 2px 0 0; min-width: 0; font-size: var(--rv-fs-body); line-height: var(--rv-lh-body); overflow-wrap: anywhere; }
.m03-timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--rv-space-3); }
.m03-timeline > li { position: relative; padding-left: var(--rv-space-4); }
.m03-timeline > li::before { content: ""; position: absolute; left: 0; top: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--rv-primary-500); }
.m03-internal { border-color: var(--rv-warning-border); background: var(--rv-warning-bg); }

/* public profile preview */
.m03-profile { display: flex; flex-direction: column; gap: var(--rv-space-4); }
.m03-profile__head { display: flex; align-items: flex-start; gap: var(--rv-space-4); }
.m03-profile__head > div { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: var(--rv-space-1); }
.m03-profile__name { margin: 0; font-size: var(--rv-fs-section); line-height: var(--rv-lh-section); font-weight: 500; }
.m03-profile__pos { margin: 0; color: var(--rv-text-secondary); }
.m03-profile h4 { margin: 0 0 var(--rv-space-1); font-size: var(--rv-fs-body); line-height: var(--rv-lh-body); font-weight: 600; }
.m03-profile ul { margin: 0; }

/* ---------- MST-03 / MST-05 form ---------- */
.m03-avatars { display: flex; flex-wrap: wrap; align-items: center; gap: var(--rv-space-2); }
.m03-avatar-opt { position: relative; display: block; cursor: pointer; }
.m03-avatar-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.m03-avatar-opt__box { display: flex; padding: 3px; border: 2px solid transparent; border-radius: 50%; }
.m03-avatar-opt:hover .m03-avatar-opt__box { border-color: var(--rv-neutral-300); }
.m03-avatar-opt input:checked + .m03-avatar-opt__box { border-color: var(--rv-primary-700); box-shadow: 0 0 0 2px var(--rv-primary-100); }
.m03-avatar-opt input:focus-visible + .m03-avatar-opt__box { outline: 2px solid var(--rv-focus); outline-offset: 2px; }
.m03-avatarpick.is-busy .m03-avatars { opacity: .6; pointer-events: none; }
.m03-avatar-upload { margin-left: var(--rv-space-1); }
.m03-chipsinput .m03-chips { min-height: 24px; }
.m03-chipsinput__row { display: flex; gap: var(--rv-space-2); max-width: 520px; }
.m03-chipsinput__row .rv-input { flex: 1 1 auto; min-width: 0; }
.m03-repeat { gap: var(--rv-space-2); }
.m03-repeat__head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--rv-space-2); }
.m03-repeat__list { display: flex; flex-direction: column; gap: var(--rv-space-2); }
.m03-repeat__empty { margin: 0; padding: var(--rv-space-3); border: 1px dashed var(--rv-neutral-400); border-radius: var(--rv-radius-card); background: var(--rv-surface-subtle); font-size: var(--rv-fs-small); line-height: var(--rv-lh-small); color: var(--rv-text-muted); text-align: center; }
.m03-rep-row { display: flex; align-items: flex-end; gap: var(--rv-space-2); padding: var(--rv-space-2); border: 1px solid var(--rv-divider); border-radius: var(--rv-radius-card); background: var(--rv-surface-subtle); }
.m03-rep-row__n { flex: 0 0 auto; align-self: center; min-width: 20px; font-size: var(--rv-fs-small); color: var(--rv-text-muted); text-align: center; font-variant-numeric: tabular-nums; }
.m03-rep-row__fields { flex: 1 1 auto; min-width: 0; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.4fr) minmax(90px, .6fr); gap: var(--rv-space-2); }
.m03-rep-f { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.m03-rep-f.is-wide { grid-column: 1 / -1; }
.m03-rep-f__label { font-size: var(--rv-fs-small); line-height: var(--rv-lh-small); color: var(--rv-neutral-700); }
.m03-rep-row__acts { flex: 0 0 auto; display: flex; gap: 2px; }
.m03-repeat.is-invalid .m03-rep-row { border-color: var(--rv-danger-border); }
.m03-form-actions { position: sticky; bottom: 0; z-index: var(--rv-z-sticky); padding-bottom: var(--rv-space-3); background: var(--rv-surface); }

/* ---------- responsive ---------- */
@media (max-width: 1199px) {
  .m03-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
  .m03-facts { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--rv-space-2) var(--rv-space-3); }
  .m03-inline-field { flex: 1 1 100%; }
  .m03-rep-row { flex-wrap: wrap; align-items: stretch; }
  .m03-rep-row__fields { grid-template-columns: minmax(0, 1fr); flex-basis: calc(100% - 28px); }
  .m03-rep-row__acts { width: 100%; justify-content: flex-end; }
  .m03-profile__head { flex-direction: column; }
  .m03-sub { margin-left: 6px; padding-left: var(--rv-space-3); }
  .m03-sub__empty::before { left: calc(var(--rv-space-3) * -1); width: 8px; }
  .m03-form-actions { bottom: calc(var(--rv-mobile-nav-height) + env(safe-area-inset-bottom)); }
  .m03-chipsinput__row { max-width: none; }
}
