/* =====================================================================
   Navbar หน้าบ้าน (Shared/_Header.php) — มือถือ / แท็บเล็ต (< 992px)
   ---------------------------------------------------------------------
   ปัญหาเดิม: ชื่อสมาชิกยาว ๆ ตกบรรทัด navbar (fixed-top) สูงขึ้นแล้วทับเนื้อหา
             และช่วงแท็บเล็ต (768-991px) เมนูแนวนอนล้นจอ
   แนวทาง:  จอ < 992px ใช้แถบบนแบบย่อบรรทัดเดียว (โลโก้ + ป้าย env + ชิปชื่อสมาชิก)
             ชื่อยาวตัดด้วย ... เมนูหลักใช้แถบล่าง (Shared/_Footer.php .footer-nav d-lg-none)
   PC (>= 992px) ไม่เปลี่ยน — กฎทั้งหมดอยู่ใน media query
   สีหลักใช้ --theme-color-primary ของแต่ละ tenant (template.css)
   ===================================================================== */

.hm-site-prefix {
  color: #dc3545;
  font-size: 25px;
}

@media (max-width: 991.98px) {
  .hm-navbar {
    min-height: 56px;
  }
  .hm-navbar > .container {
    flex-wrap: nowrap;
    align-items: center;
  }
  .hm-navbar .navbar-brand {
    flex: 0 0 auto;
    margin-right: 8px;
    padding-top: 0;
    padding-bottom: 0;
  }
  /* โลโก้บาง tenant กว้างมาก: จำกัดความกว้างไว้ ให้เหลือที่ให้ชื่อสมาชิก */
  .hm-navbar .navbar-brand img {
    height: auto;
    max-height: 34px;
    width: auto;
    max-width: 38vw;
    object-fit: contain;
  }
  /* ป้าย env ([UAT] / [Dev]) ย่อเป็น badge เล็ก ไม่ดันชื่อตกบรรทัด */
  .hm-site-prefix {
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    padding: 4px 5px;
    margin-right: 8px;
    border: 1px solid #dc3545;
    border-radius: 6px;
    white-space: nowrap;
  }

  /* ชิปชื่อสมาชิกชิดขวา: กดไปหน้าโปรไฟล์ (ยังไม่ล็อกอิน = ไปหน้าเข้าสู่ระบบ) */
  .hm-nav-user {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    justify-content: flex-end;
  }
  .hm-user-chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-width: 0;
    padding: 4px 8px 4px 4px;
    border-radius: 999px;
    background: #f1f5f9;
    color: var(--theme-color-primary);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    text-transform: uppercase;
    text-decoration: none;
  }
  .hm-user-chip:hover,
  .hm-user-chip:focus {
    background: #e2e8f0;
    color: var(--theme-color-primary);
    text-decoration: none;
  }
  /* วงกลมไอคอน: ล็อกขนาดทั้ง width/height/min ทุกด้าน + ไม่ให้ flex บีบ จะได้กลมเสมอ */
  .hm-user-avatar {
    flex: 0 0 auto;
    box-sizing: border-box;
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    padding: 0;
    margin-right: 8px;
    border-radius: 50%;
    background: var(--theme-color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  .hm-user-avatar .mdi {
    display: block;
    font-size: 18px;
    line-height: 1;
  }
  .hm-user-avatar .mdi::before {
    display: block;
    line-height: 1;
  }

  /* ล็อกอินแล้ว: ปุ่มไอคอนอย่างเดียว (ไม่แสดงชื่อ) */
  .hm-user-icon-btn {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    text-decoration: none;
  }
  .hm-user-icon-btn .hm-user-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    margin-right: 0;
    box-shadow: 0 0 0 3px #f1f5f9;
  }
  .hm-user-icon-btn .hm-user-avatar .mdi {
    font-size: 22px;
  }
  .hm-user-icon-btn:hover .hm-user-avatar,
  .hm-user-icon-btn:focus .hm-user-avatar {
    box-shadow: 0 0 0 3px #e2e8f0;
  }
  .hm-user-icon-btn:hover,
  .hm-user-icon-btn:focus {
    text-decoration: none;
  }
  .hm-user-name {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .hm-user-caret {
    flex: 0 0 auto;
    margin-left: 2px;
    font-size: 18px;
    line-height: 1;
    color: #94a3b8;
  }
}

/* แท็บเล็ตมีที่เหลือเยอะกว่า: ชิปใหญ่ขึ้นเล็กน้อย แต่ไม่กว้างเกินครึ่งแถบ */
@media (min-width: 768px) and (max-width: 991.98px) {
  .hm-user-chip {
    max-width: 360px;
    font-size: 15px;
  }
}

/* จอแคบมาก (<= 360px): ลดโลโก้ลงอีก ให้ชื่อยังพอเห็น */
@media (max-width: 360px) {
  .hm-navbar .navbar-brand img {
    max-width: 30vw;
  }
  .hm-user-chip {
    font-size: 13px;
  }
}
