/* MK AUTOMATION AI — Header Layout RC5 (TASK-WEB-003.0A)
   3-zone: Logo | Landing Nav | Account + Lang + Download
   Fixed height 64px — no wrap / no CLS on guest↔customer
*/

/* ── Bar container ───────────────────────────────────────── */
.hdr-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
  box-sizing: border-box;
}

#main-nav.navbar-glass {
  height: 64px;
  min-height: 64px;
  overflow: visible;
}

/* ── Zone left: brand ────────────────────────────────────── */
.hdr-zone-left {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  min-width: 0;
}

.hdr-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.hdr-brand-logo {
  width: 36px;
  height: 36px;
  object-fit: cover;
  transition: opacity 0.3s;
}

.hdr-brand:hover .hdr-brand-logo {
  opacity: 0.9;
}

.hdr-brand-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0a1628;
  white-space: nowrap;
  line-height: 1;
}

.hdr-brand-accent {
  color: #0e7490;
}

/* ── Zone center: landing nav ────────────────────────────── */
.hdr-zone-center {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  flex-shrink: 0;
}

.hdr-nav-link {
  font-size: 0.875rem;
  font-weight: 600;
  color: #334155;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.hdr-nav-link:hover {
  color: #0e7490;
}

.hdr-nav-link:focus-visible,
.hdr-brand:focus-visible,
.hdr-zone-right .auth-nav-btn:focus-visible,
.hdr-mobile-toggle:focus-visible,
.hdr-drawer-close:focus-visible,
.hdr-download-btn:focus-visible {
  outline: 2px solid #0e7490;
  outline-offset: 2px;
}

/* Desktop ≥1024: center nav. Below that the longer brand plus auth no longer fit. */
@media (min-width: 1024px) {
  .hdr-zone-center {
    display: flex;
    gap: 0.85rem;
  }
}

/* Desktop ≥1200: production gap */
@media (min-width: 1200px) {
  .hdr-zone-center {
    gap: 1.75rem;
  }
}

/* Mid tablets: slightly denser */
@media (min-width: 768px) and (max-width: 1199px) {
  .hdr-zone-center {
    gap: 0.65rem;
  }

  .hdr-nav-link {
    font-size: 0.8125rem;
  }

  .hdr-brand-text {
    font-size: 1rem;
  }
}

/* ── Zone right: account / guest / lang / download ───────── */
.hdr-zone-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
  margin-left: auto;
}

.hdr-zone-right .auth-nav-btn {
  min-height: 40px;
  padding: 0 0.85rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: #0f172a;
  font-size: 0.875rem;
  font-weight: 700;
}

.hdr-zone-right .auth-nav-btn:hover {
  background: #f8fafc;
  color: #0e7490;
}

.hdr-zone-right .auth-nav-btn-register,
.hdr-zone-right .auth-nav-btn-register:hover {
  color: #fff;
}

.hdr-zone-right .auth-nav-btn-register {
  background: #0e7490;
  border-color: #0e7490;
}

.hdr-zone-right .auth-nav-btn-register:hover {
  background: #155e75;
  border-color: #155e75;
}

a.hdr-download-btn {
  background: #0e7490;
  border-radius: 10px;
}

a.hdr-download-btn:hover {
  background: #155e75;
}

@media (max-width: 479px) {
  .hdr-brand-text {
    display: none;
  }

  .hdr-bar {
    padding-left: 12px;
    padding-right: 12px;
    gap: 8px;
  }

  .hdr-zone-right {
    gap: 6px;
  }

  .hdr-zone-right .auth-nav-btn {
    padding: 0 10px;
    font-size: 0.8125rem;
  }

  .lang-switch-btn > span:last-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
}

.hdr-guest.is-hidden,
#auth-guest-actions.is-hidden,
#hdr-guest.is-hidden {
  display: none !important;
}

/* Customer cluster */
.hdr-customer,
#hdr-customer {
  display: none;
  align-items: center;
  gap: 6px;
  position: relative;
  flex-shrink: 0;
}

.hdr-customer.is-visible,
#hdr-customer.is-visible {
  display: flex;
}

.hdr-account-wrap {
  position: relative;
  flex-shrink: 0;
}

/* Account chip — aligned with dashboard dash-account-chip */
.account-chip,
.hdr-account-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(100vw - 8rem, 220px);
  padding: 0.2rem 0.35rem 0.2rem 0.2rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  font: inherit;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  box-sizing: border-box;
  text-align: left;
}

.account-chip:hover,
.account-chip.is-open,
.hdr-account-chip:hover,
.hdr-account-chip.is-open {
  background: #f8fafc;
  border-color: #e2e8f0;
  box-shadow: none;
}

.account-chip:focus-visible,
.hdr-account-chip:focus-visible {
  outline: 2px solid #0e7490;
  outline-offset: 2px;
}

.hdr-account-meta {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  align-items: flex-start;
  justify-content: center;
}

.hdr-avatar {
  width: 28px;
  height: 28px;
  border-radius: 9999px;
  background: #e2e8f0;
  color: #0f172a;
  font-size: 0.68rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}

.hdr-dropdown-identity {
  padding: 0.55rem 0.75rem 0.45rem;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 0.25rem;
}

.hdr-email {
  display: block;
  margin: 0;
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.hdr-email:empty {
  display: none;
}

.hdr-account-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.2;
}

.hdr-plan-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  border-radius: 9999px;
  background: #ecfeff;
  border: 1px solid #a5f3fc;
  color: #0891b2;
  font-size: 0.625rem;
  font-weight: 700;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.hdr-plan-badge:empty,
.hdr-plan-badge[hidden] {
  display: none !important;
}

.hdr-account-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 9999px;
  color: #94a3b8;
  transition: transform 0.2s ease, color 0.15s ease;
}

.hdr-account-chevron-svg {
  width: 1rem;
  height: 1rem;
}

.account-chip.is-open .hdr-account-chevron,
.hdr-account-chip.is-open .hdr-account-chevron {
  transform: rotate(180deg);
  color: #0891b2;
}

.hdr-plan-badge.is-expired {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #64748b;
}

/* Mobile: chip = avatar + badge + chevron */
@media (max-width: 767px) {
  .account-chip,
  .hdr-account-chip {
    padding: 0.35rem 0.4rem 0.35rem 0.35rem;
    gap: 8px;
    max-width: none;
  }

  .hdr-account-label {
    display: none !important;
  }

  .hdr-zone-right {
    gap: 6px;
  }

  .hdr-bar {
    padding: 0 16px;
    gap: 10px;
  }
}

/* Narrow phones: keep brand + chip + lang + hamburger on one 64px row */
@media (max-width: 420px) {
  .hdr-brand-text {
    display: none;
  }

  .lang-switch-btn span:not(.lang-flag) {
    display: none;
  }

  .lang-switch-btn {
    padding: 5px 7px;
  }
}

.hdr-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  background: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.hdr-menu-btn:hover,
.hdr-menu-btn[aria-expanded='true'] {
  border-color: #67e8f9;
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.12);
}

.hdr-caret {
  width: 0.85rem;
  height: 0.85rem;
  color: #94a3b8;
}

.hdr-download-btn {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 700;
  border-radius: 10px;
  gap: 0.35rem;
}

.hdr-download-version {
  padding: 0;
  font-size: 0.625rem;
  font-weight: 500;
  background: transparent;
  border-radius: 0;
  color: rgba(255, 255, 255, 0.78);
  letter-spacing: 0;
}

.hdr-drawer-download {
  display: block;
  width: 100%;
  margin: 0 0 0.75rem;
  padding: 0.7rem 0.85rem;
  border: 0;
  border-radius: 0.6rem;
  background: #0891b2;
  color: #fff;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

@media (max-width: 1023px) {
  body.is-customer .hdr-download-btn {
    display: inline-flex;
    padding-left: 0.65rem;
    padding-right: 0.65rem;
    gap: 0.35rem;
  }

  body.is-customer .hdr-download-version {
    display: none;
  }

  body.is-customer .hdr-zone-right,
  body.is-customer .hdr-bar {
    min-width: 0;
  }
}

/* Logged-in row cannot fit landing links plus the download control below 900px. */
@media (max-width: 899px) {
  body.is-customer .hdr-zone-center {
    display: none;
  }

  body.is-customer .hdr-mobile-toggle {
    display: inline-flex;
  }
}

/* Phones: pull the logged-in cluster fully inside the viewport, including the hamburger. */
@media (max-width: 420px) {
  body.is-customer .hdr-bar {
    padding-left: 8px;
    padding-right: 8px;
    gap: 6px;
  }

  body.is-customer .hdr-zone-right {
    gap: 4px;
  }

  body.is-customer .hdr-download-btn {
    padding-left: 0.45rem;
    padding-right: 0.45rem;
  }

  body.is-customer .lang-switch-btn {
    padding: 4px 5px;
  }
}

/* Dropdown hangs from the account trigger, just below the 64px header. */
.hdr-dropdown {
  position: absolute;
  top: calc(100% + 18px);
  right: 0;
  width: 232px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 28px rgba(15, 23, 42, 0.08);
  padding: 0.35rem;
  z-index: 80;
  display: none;
}

.hdr-dropdown.is-open {
  display: block;
}

@media (max-width: 899px) {
  .hdr-dropdown {
    left: 0;
    right: auto;
    width: min(232px, calc(100vw - 16px));
    max-height: calc(100vh - 80px);
    overflow-y: auto;
  }
}

.hdr-dropdown a,
.hdr-dropdown button {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  min-height: 40px;
  padding: 0.45rem 0.7rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #334155;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  text-align: left;
}

.hdr-dropdown a:hover,
.hdr-dropdown button:hover {
  background: #f8fafc;
  color: #0f172a;
}

.hdr-dropdown a:focus-visible,
.hdr-dropdown button:focus-visible {
  outline: 2px solid #0e7490;
  outline-offset: 1px;
}

.hdr-dropdown-sep {
  height: 1px;
  background: #e2e8f0;
  margin: 0.35rem 0.4rem;
}

.hdr-dropdown-logout {
  color: #b91c1c !important;
}

.hdr-dropdown-logout:hover {
  background: #fef2f2 !important;
  color: #991b1b !important;
}

@media (max-width: 767px) {
  .hdr-zone-right .auth-nav-btn,
  .account-chip,
  .hdr-account-chip,
  .lang-switch-btn,
  .hdr-dropdown a,
  .hdr-dropdown button {
    min-height: 44px;
  }
}
.hdr-mobile-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid #e2e8f0;
  border-radius: 0.55rem;
  background: #fff;
  cursor: pointer;
  flex-shrink: 0;
}

@media (min-width: 1024px) {
  .hdr-mobile-toggle {
    display: none;
  }
}

/* Drawer */
.hdr-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 40, 0.45);
  z-index: 60;
}

.hdr-drawer-overlay.is-open {
  display: block;
}

.hdr-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(320px, 88vw);
  height: 100%;
  background: #fff;
  z-index: 65;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  box-shadow: -8px 0 28px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

.hdr-drawer.is-open {
  transform: translateX(0);
}

.hdr-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.hdr-drawer-user {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  border-radius: 0.75rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

body.is-customer .hdr-drawer-user:not([hidden]) {
  display: flex;
}

.hdr-drawer-email {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #0f172a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.hdr-drawer-badge:empty,
.hdr-drawer-badge[hidden] {
  display: none !important;
}

.hdr-drawer-badge {
  font-size: 0.7rem;
  font-weight: 700;
  color: #0e7490;
  margin-top: 0.15rem;
}

.hdr-drawer-links {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.hdr-drawer-links a,
.hdr-drawer-links button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.75rem 0.85rem;
  border-radius: 0.65rem;
  border: none;
  background: transparent;
  color: #334155;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.hdr-drawer-links a:hover,
.hdr-drawer-links button:hover {
  background: #f0f9ff;
  color: #0891b2;
}

.hdr-drawer-account {
  display: none;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e2e8f0;
}

body.is-customer .hdr-drawer-account {
  display: block;
}

.hdr-drawer-close {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 9999px;
  background: #f1f5f9;
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
}

/* Legacy: account link removed from center nav */
#nav-account-link {
  display: none !important;
}
