/* =========================================================
   EasyHRM - Header (namespace: .ehd)
   Desktop >= 1200px: menu ngang + dropdown
   < 1200px: off-canvas drawer + accordion
   ========================================================= */
.ehd {
  --ehd-h: 70px;
  --ehd-text: #040f3e;
  --ehd-muted: #575e7e;
  --ehd-primary: #ef5627;
  --ehd-primary-soft: #fff3ee;
  --ehd-blue: #2951a0;
  --ehd-line: #e9ecf3;
  --ehd-radius: 12px;
  --ehd-shadow: 0 16px 40px rgba(4, 15, 62, 0.14);

  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 990; /* dưới exit-popup (998/999) */
  width: 100%;
}

.ehd *,
.ehd *::before,
.ehd *::after {
  box-sizing: border-box;
}

.ehd :where(ul) {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ehd :where(a) {
  text-decoration: none;
}

.ehd :where(button) {
  font-family: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  color: inherit;
  cursor: pointer;
}

.ehd a:focus-visible,
.ehd button:focus-visible {
  outline: 2px solid var(--ehd-blue);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ---------- Bar ---------- */
.ehd-bar {
  height: var(--ehd-h);
  background: #fff;
  box-shadow: 0 1px 0 rgba(4, 15, 62, 0.08);
  transition: box-shadow 0.25s ease;
}

.ehd.is-scrolled .ehd-bar {
  box-shadow: 0 6px 24px rgba(4, 15, 62, 0.1);
}

.ehd-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.ehd-logo {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.ehd-logo img {
  display: block;
  width: 126px;
  height: auto;
}

/* ---------- Nav (reset rule `nav {}` của style.css) ---------- */
.ehd .ehd-nav {
  width: auto;
  height: auto;
  background: transparent;
  box-shadow: none;
}

.ehd-drawer-head,
.ehd-drawer-cta {
  display: none;
}

.ehd-menu {
  display: flex;
  align-items: center;
}

.ehd-item {
  position: relative;
}

.ehd-row {
  display: flex;
  align-items: center;
}

.ehd-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ehd-text);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.ehd-link:hover,
.ehd-link:focus {
  color: var(--ehd-primary);
}

.ehd-toggle i {
  font-size: 11px;
  transition: transform 0.25s ease;
}

/* ---------- Actions ---------- */
.ehd-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.ehd-hotline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px 5px 12px;
  border: 1px solid var(--ehd-primary);
  border-radius: 999px;
  background: #fff;
  color: var(--ehd-primary);
  line-height: 1.15;
  transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.ehd-hotline i {
  font-size: 15px;
}

.ehd-hotline-text {
  display: flex;
  flex-direction: column;
}

.ehd-hotline small {
  font-size: 11px;
  font-weight: 500;
  color: var(--ehd-primary);
}

.ehd-hotline strong {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.ehd-hotline:hover {
  color: var(--ehd-primary);
  background: var(--ehd-primary-soft);
  transform: translateY(-1px);
}

.ehd-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 22px;
  border-radius: 999px;
  background: linear-gradient(287deg, #f15922 12.78%, #f6921e 95.8%);
  box-shadow: 0 8px 16px rgba(241, 89, 34, 0.24);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ehd-cta:hover,
.ehd-cta:focus {
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(241, 89, 34, 0.32);
}

/* Hamburger */
.ehd .ehd-burger {
  display: none;
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  flex-shrink: 0;
}

.ehd-burger span {
  position: absolute;
  left: 11px;
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: var(--ehd-text);
  transition: transform 0.25s ease, opacity 0.2s ease;
}

.ehd-burger span:nth-child(1) {
  top: 15px;
}

.ehd-burger span:nth-child(2) {
  top: 21px;
}

.ehd-burger span:nth-child(3) {
  top: 27px;
}

.ehd-burger:hover {
  background: #f3f5f9;
}

.ehd-overlay {
  display: none;
}

/* =========================================================
   DESKTOP (>= 1200px)
   ========================================================= */
@media (min-width: 1200px) {
  .ehd .ehd-nav {
    flex: 1 1 auto;
    display: flex;
    justify-content: center;
    min-width: 0;
  }

  .ehd-item {
    height: var(--ehd-h);
    display: flex;
    align-items: center;
  }

  .ehd-item > .ehd-link,
  .ehd-item > .ehd-row > .ehd-link {
    padding: 8px 0;
  }

  .ehd-item {
    padding: 0 12px;
  }

  .ehd-item > .ehd-row .ehd-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 28px;
    margin-left: 4px;
    color: var(--ehd-text);
  }

  /* Gạch chân trạng thái active / hover */
  .ehd-item::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 14px;
    height: 2px;
    border-radius: 2px;
    background: var(--ehd-primary);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.25s ease;
  }

  .ehd-item.is-active::after,
  .ehd-item:hover::after {
    transform: scaleX(1);
  }

  .ehd-item.is-active > .ehd-link,
  .ehd-item.is-active > .ehd-row > .ehd-link,
  .ehd-item.is-active > .ehd-row > .ehd-toggle,
  .ehd-item:hover > .ehd-link,
  .ehd-item:hover > .ehd-row > .ehd-link,
  .ehd-item:hover > .ehd-row > .ehd-toggle {
    color: var(--ehd-primary);
  }

  /* Dropdown cấp 1 */
  .ehd-sub {
    position: absolute;
    top: calc(100% - 8px);
    left: 0;
    min-width: 240px;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--ehd-line);
    border-radius: var(--ehd-radius);
    box-shadow: var(--ehd-shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    z-index: 5;
  }

  /* Cầu nối hover để không bị mất dropdown khi rê chuột */
  .ehd-sub::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -10px;
    height: 10px;
  }

  .ehd-item:hover > .ehd-sub,
  .ehd-item.is-open > .ehd-sub,
  .ehd-sub-item:hover > .ehd-sub,
  .ehd-sub-item.is-open > .ehd-sub {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  /* Điều hướng bằng bàn phím (rule riêng để trình duyệt cũ không bỏ cả cụm trên) */
  .ehd-item:has(:focus-visible) > .ehd-sub,
  .ehd-sub-item:has(:focus-visible) > .ehd-sub {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .ehd-item:hover > .ehd-row > .ehd-toggle i,
  .ehd-item:hover > .ehd-toggle--full i,
  .ehd-item.is-open > .ehd-row > .ehd-toggle i,
  .ehd-item.is-open > .ehd-toggle--full i {
    transform: rotate(180deg);
  }

  /* Item trong dropdown */
  .ehd-sub-item {
    position: relative;
  }

  .ehd-sub-item > .ehd-link,
  .ehd-sub-item > .ehd-row > .ehd-link {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    text-align: left;
  }

  .ehd-sub-item > .ehd-link:hover,
  .ehd-sub-item > .ehd-link:focus-visible,
  .ehd-sub-item.is-active > .ehd-link,
  .ehd-sub-item.is-open > .ehd-link,
  .ehd-sub-item:hover > .ehd-link {
    color: var(--ehd-primary);
    background: var(--ehd-primary-soft);
  }

  .ehd-sub-item.is-active > .ehd-link {
    font-weight: 700;
  }

  /* Dropdown cấp 2 (flyout sang phải) */
  .ehd-sub--d2 {
    top: -9px;
    left: calc(100% + 8px);
  }

  .ehd-sub--d2::before {
    top: 0;
    bottom: 0;
    left: -12px;
    right: auto;
    width: 12px;
    height: auto;
  }

  .ehd .ehd-drawer-cta,
  .ehd .ehd-drawer-head {
    display: none;
  }
}

/* Desktop nhỏ (1200 - 1399px): thu gọn khoảng cách */
@media (min-width: 1200px) and (max-width: 1399.98px) {
  .ehd-inner {
    gap: 10px;
  }

  .ehd-logo img {
    width: 112px;
  }

  .ehd-item {
    padding: 0 8px;
  }

  .ehd-item::after {
    left: 8px;
    right: 8px;
  }

  .ehd-item > .ehd-link,
  .ehd-item > .ehd-row > .ehd-link,
  .ehd-item > .ehd-toggle--full {
    font-size: 15px;
  }

  .ehd-item > .ehd-row .ehd-toggle {
    width: 16px;
    margin-left: 2px;
  }

  .ehd-actions {
    gap: 8px;
  }

  .ehd-hotline {
    padding: 5px 12px 5px 10px;
  }

  .ehd-hotline strong {
    font-size: 14px;
  }

  .ehd-cta {
    padding: 10px 18px;
    font-size: 15px;
  }
}

/* =========================================================
   TABLET + MOBILE (< 1200px): drawer
   ========================================================= */
@media (max-width: 1199.98px) {
  .ehd .ehd-burger {
    display: inline-block;
  }

  .ehd-actions {
    gap: 8px;
  }

  .ehd .ehd-nav {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    width: min(380px, 88vw);
    height: 100vh;
    height: 100dvh;
    background: #fff;
    box-shadow: -12px 0 40px rgba(4, 15, 62, 0.18);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.3s ease, visibility 0.3s;
  }

  .ehd.is-menu-open .ehd-nav {
    transform: translateX(0);
    visibility: visible;
  }

  .ehd .ehd-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1;
    background: rgba(4, 15, 62, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s;
  }

  .ehd.is-menu-open .ehd-overlay {
    opacity: 1;
    visibility: visible;
  }

  /* Hamburger -> X */
  .ehd.is-menu-open .ehd-burger span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }

  .ehd.is-menu-open .ehd-burger span:nth-child(2) {
    opacity: 0;
  }

  .ehd.is-menu-open .ehd-burger span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }

  .ehd .ehd-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    height: var(--ehd-h);
    padding: 0 12px 0 20px;
    border-bottom: 1px solid var(--ehd-line);
  }

  .ehd-drawer-head .ehd-logo img {
    width: 112px;
  }

  .ehd-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    font-size: 20px;
    color: var(--ehd-text);
  }

  .ehd-close:hover {
    background: #f3f5f9;
    color: var(--ehd-primary);
  }

  .ehd-menu {
    flex: 1 1 auto;
    display: block;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 8px 12px 16px;
  }

  .ehd-item {
    border-bottom: 1px solid var(--ehd-line);
  }

  .ehd-item:last-child {
    border-bottom: 0;
  }

  .ehd-row {
    justify-content: space-between;
  }

  .ehd-item > .ehd-link,
  .ehd-item > .ehd-row > .ehd-link {
    flex: 1 1 auto;
    display: flex;
    min-height: 52px;
    padding: 12px 8px;
    font-size: 16px;
  }

  .ehd-item > .ehd-toggle--full {
    width: 100%;
    justify-content: space-between;
    text-align: left;
  }

  .ehd-toggle--full i {
    width: 44px;
    text-align: center;
    margin-right: -8px;
  }

  .ehd-row > .ehd-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    color: var(--ehd-text);
  }

  .ehd-row > .ehd-toggle:hover {
    background: #f3f5f9;
  }

  .ehd-item.is-active > .ehd-link,
  .ehd-item.is-active > .ehd-row > .ehd-link,
  .ehd-item.is-active > .ehd-toggle--full {
    color: var(--ehd-primary);
  }

  .ehd .is-open > .ehd-row > .ehd-toggle i,
  .ehd .is-open > .ehd-toggle--full i {
    transform: rotate(180deg);
  }

  .ehd-sub-item.is-open > .ehd-toggle--full i {
    transform: rotate(90deg);
  }

  /* Accordion */
  .ehd-sub {
    display: none;
    padding: 0 0 10px 8px;
  }

  .is-open > .ehd-sub {
    display: block;
    animation: ehd-fade 0.2s ease;
  }

  .ehd-sub-item > .ehd-link,
  .ehd-sub-item > .ehd-row > .ehd-link {
    display: flex;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border-left: 2px solid var(--ehd-line);
    font-size: 15px;
    font-weight: 500;
    color: var(--ehd-muted);
    white-space: normal;
  }

  .ehd-sub-item > .ehd-toggle--full {
    justify-content: space-between;
    text-align: left;
  }

  .ehd-sub-item > .ehd-toggle--full i {
    width: 32px;
    margin-right: -8px;
  }

  .ehd-sub-item > .ehd-link:hover,
  .ehd-sub-item.is-active > .ehd-link {
    color: var(--ehd-primary);
    border-left-color: var(--ehd-primary);
    background: var(--ehd-primary-soft);
  }

  .ehd-sub-item.is-active > .ehd-link {
    font-weight: 700;
  }

  .ehd-sub--d2 {
    padding: 0 0 4px 14px;
  }

  .ehd .ehd-drawer-cta {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
    padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--ehd-line);
    background: #fafbfd;
  }

  .ehd-hotline--block,
  .ehd-cta--block {
    width: 100%;
    justify-content: center;
    min-height: 48px;
  }

  .ehd-hotline--block .ehd-hotline-text {
    flex-direction: row;
    align-items: baseline;
    gap: 6px;
  }

  .ehd-hotline--block small {
    font-size: 13px;
  }

  .ehd-hotline--block strong {
    font-size: 16px;
  }

  /* Hotline trên thanh: chỉ còn số */
  .ehd-actions .ehd-hotline small {
    display: none;
  }

  .ehd-actions .ehd-hotline {
    min-height: 44px;
  }
}

/* Mobile (< 768px): hotline trên thanh thành nút tròn */
@media (max-width: 767.98px) {
  .ehd-actions .ehd-hotline {
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
  }

  .ehd-actions .ehd-hotline .ehd-hotline-text {
    display: none;
  }

  .ehd-actions .ehd-hotline i {
    font-size: 16px;
  }

  .ehd-actions .ehd-cta {
    min-height: 44px;
    padding: 8px 16px;
    font-size: 15px;
    box-shadow: 0 6px 12px rgba(241, 89, 34, 0.22);
  }

  .ehd-inner > .ehd-logo img {
    width: 110px;
  }
}

/* Mobile nhỏ (< 400px) */
@media (max-width: 399.98px) {
  .ehd-inner {
    gap: 8px;
  }

  .ehd-actions {
    gap: 6px;
  }

  .ehd-inner > .ehd-logo img {
    width: 96px;
  }

  .ehd-actions .ehd-hotline {
    width: 40px;
    height: 40px;
    min-height: 40px;
  }

  .ehd-actions .ehd-cta {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 14px;
  }

  .ehd .ehd-burger {
    width: 40px;
    height: 40px;
  }

  .ehd-burger span {
    left: 9px;
  }

  .ehd-burger span:nth-child(1) {
    top: 13px;
  }

  .ehd-burger span:nth-child(2) {
    top: 19px;
  }

  .ehd-burger span:nth-child(3) {
    top: 25px;
  }
}

/* Khoá cuộn trang khi mở drawer + đưa header lên trên các thanh sticky khác */
html.ehd-lock,
html.ehd-lock body {
  overflow: hidden;
}

html.ehd-lock .ehd {
  z-index: 10500;
}

@keyframes ehd-fade {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ehd *,
  .ehd *::before,
  .ehd *::after {
    transition: none !important;
    animation: none !important;
  }
}
