/**
 * Admission — responsive shell (Desktop / Tablet / Mobile)
 * โหลดหลัง mainstyle / dasstyle เพื่อ override กฎ nav ซ้ำซ้อน
 */

:root {
  --adm-touch-min: 44px;
  --adm-nav-bg: #0a0a5a;
  --adm-header-h: 80px;
  --bp-tablet: 1024px;
  --bp-mobile: 768px;
}

/* ฐานเอกสาร — ลดเลื่อนแนวนอนโดยไม่ตัดการเลื่อนแนวตั้งที่จำเป็น */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

.ui-view-main {
  width: 100%;
  max-width: 100vw;
  min-height: 0;
  position: relative;
}

.ui-view-main img,
.maincontent img {
  max-width: 100%;
  height: auto;
}

/* ---------- Tablet: 769px – 1024px ---------- */
@media (min-width: 769px) and (max-width: 1024px) {
  nav ul#menu {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: flex-end !important;
    align-items: center !important;
    gap: 0.25rem 0.65rem !important;
    float: none !important;
    margin-right: 12px !important;
    margin-left: auto !important;
    max-width: calc(100vw - 240px) !important;
    padding: 4px 8px 8px !important;
  }

  nav ul#menu li a {
    font-size: clamp(0.78rem, 1.35vw, 0.95rem) !important;
    padding: 0.4rem 0.55rem !important;
    white-space: nowrap;
  }

  .logo_title {
    width: min(220px, 42vw) !important;
    height: auto !important;
    min-height: 56px !important;
    padding: 16px 20px !important;
  }

  .logo_title .logo {
    max-width: 100%;
    height: auto;
  }

  .footer_main ul.footer_item,
  footer .footer_item {
    flex-wrap: wrap !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 8px 20px !important;
    padding: 10px 16px !important;
  }

  footer ul li {
    line-height: 1.5 !important;
  }
}

/* ---------- Mobile + small tablet: ≤768px ---------- */
@media (max-width: 768px) {
  /* ปิดพฤติกรรม nav เต็มจอแบบเก่า (860px) — ใช้แผงขวาเหมือน mainmenu */
  nav ul#menu {
    position: fixed !important;
    left: auto !important;
    right: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    width: min(300px, 88vw) !important;
    height: auto !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    padding: 4.25rem 1rem 1.5rem !important;
    float: none !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 0.25rem !important;
    background: var(--adm-nav-bg) !important;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.2) !important;
    z-index: 11000 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    transform: translate3d(100%, 0, 0) !important;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }

  nav ul#menu.active {
    transform: translate3d(0, 0, 0) !important;
  }

  /* เลิกใช้สไลด์จากซ้ายของ #check:checked ~ ul */
  #check:checked ~ ul#menu {
    left: auto !important;
  }

  nav ul#menu li {
    display: block !important;
    margin: 0 !important;
    line-height: 1.35 !important;
  }

  nav ul#menu li a,
  nav ul#menu li span {
    display: block !important;
    min-height: var(--adm-touch-min) !important;
    padding: 0.65rem 0.75rem !important;
    font-size: 1rem !important;
    border-radius: 6px;
  }

  nav ul#menu li a:active {
    background: rgba(255, 255, 255, 0.12);
  }

  /* แถบนำทาง mobile — โลโก้ซ้าย ปุ่ม "สมัครเรียน" ขวา ไม่ทับกัน */
  nav {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    height: 52px !important;
    min-height: 52px !important;
    max-height: 52px !important;
    padding: 0 6px 0 0 !important;
    box-sizing: border-box !important;
    overflow: visible !important;
  }

  nav #check {
    order: 0 !important;
    flex: 0 0 0 !important;
  }

  .logo_title {
    order: 1 !important;
    position: relative !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: auto !important;
    max-width: calc(100% - 108px) !important;
    height: 52px !important;
    min-height: 52px !important;
    padding: 4px 6px 4px 10px !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    background: #ffffff !important;
    box-sizing: border-box !important;
  }

  nav img.logo,
  .logo_title .logo {
    position: static !important;
    float: none !important;
    left: auto !important;
    top: auto !important;
    width: auto !important;
    max-width: 100% !important;
    max-height: 42px !important;
    height: auto !important;
    object-fit: contain !important;
  }

  /* ปุ่มเมนู "สมัครเรียน" — อยู่ในแถบ nav ไม่ล้น */
  label[for="check"] {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    flex: 0 0 auto !important;
    order: 2 !important;
    margin-left: auto !important;
    min-width: 0 !important;
    width: auto !important;
    max-width: 104px !important;
    min-height: 36px !important;
    height: 36px !important;
    margin: 0 6px 0 4px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 8px !important;
    box-sizing: border-box !important;
    border-radius: 6px !important;
    background: #CFE3F1 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12) !important;
  }

  label[for="check"] #btn,
  label[for="check"] #cancel {
    float: none !important;
    line-height: 1.15 !important;
    margin: 0 !important;
    font-size: inherit !important;
    display: none !important;
  }

  #check:checked + label #cancel {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  #check:not(:checked) + label #btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  label[for="check"] .menu-toggle-label {
    font-size: clamp(10px, 2.85vw, 12px) !important;
    font-weight: 700 !important;
    color: #213760 !important;
    white-space: nowrap !important;
    letter-spacing: 0 !important;
    line-height: 1.15 !important;
  }

  label[for="check"] .menu-toggle-label--close {
    color: #213760 !important;
    font-size: clamp(11px, 3vw, 13px) !important;
  }

  nav ul#menu {
    padding-top: 3.35rem !important;
  }

  /* Footer บางจอ */
  .footer_main ul.footer_item,
  footer .footer_item {
    flex-direction: column !important;
    align-items: center !important;
    padding: 12px !important;
    gap: 10px !important;
  }

  footer ul li {
    line-height: 1.45 !important;
    margin: 0 !important;
  }

  .inconfooterlink {
    font-size: clamp(0.85rem, 3.5vw, 1rem) !important;
  }
}

/* ---------- Large desktop: โฟกัสความกว้างสูงสุด ---------- */
@media (min-width: 1400px) {
  .ui-view-main {
    margin-left: auto;
    margin-right: auto;
  }
}

/* ปุ่มหลัก — พื้นที่แตะ */
@media (max-width: 768px) {
  a.buttonpolicy,
  a.buttonpolicymaster,
  .loginbtn,
  .button-grouppolicy a {
    min-height: var(--adm-touch-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
}

/* ---------- Tablet portrait: หน้าแรกรูป hero ไม่สูงเกิน ---------- */
@media (max-width: 940px) and (min-width: 481px) {
  section .responsive-imgmobile {
    max-height: 85vh !important;
    height: auto !important;
    min-height: 280px;
    object-fit: cover;
  }
}
