/* ==========================================================================
   Shared Header – CSS
   All selectors scoped under .bks-header to avoid collisions.
   ========================================================================== */

/* ---------- Page background (match Flutter app) ---------- */
body {
  background-color: #F6F3EF !important;
}

/* ---------- Reset / base ---------- */
.bks-header {
  font-family: 'Fredoka', sans-serif;
  color: #111111;
  background: transparent;
  padding: 24px 24px 20px;
  position: relative;
  z-index: 1000;
  box-sizing: border-box;
}

.bks-header *,
.bks-header *::before,
.bks-header *::after {
  box-sizing: border-box;
}

/* ---------- Desktop layout (≥ 700px) ---------- */
.bks-header .bks-header__inner {
  position: relative;
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Centered logo */
.bks-header .bks-header__logo {
  position: absolute;
  left: 50%;
  top: -10px;
  transform: translateX(-50%);
  cursor: pointer;
  display: block;
}

.bks-header .bks-header__logo-desktop {
  width: 400px;
  height: auto;
  display: block;
}

.bks-header .bks-header__logo-mobile {
  display: none;
}

/* Left / Right button groups */
.bks-header .bks-header__left,
.bks-header .bks-header__right {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.bks-header .bks-header__left {
  left: 0;
}

.bks-header .bks-header__right {
  right: 0;
}

/* ---------- Icon buttons ---------- */
.bks-header .bks-icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid #E84921;
  background: transparent;
  color: #E84921;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s ease;
  padding: 0;
  text-decoration: none;
  position: relative;
}

.bks-header .bks-icon-btn:hover {
  background-color: #F6F3EF;
}

.bks-header .bks-icon-btn .material-icons-outlined {
  font-size: 28px;
}

/* Cart notification dot */
.bks-header .bks-icon-btn .bks-cart-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #E84921;
  display: none;
}

.bks-header.has-cart-items .bks-cart-dot {
  display: block;
}

/* ---------- Sign-in pill button ---------- */
.bks-header .bks-signin-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: auto;
  padding: 4px 16px 4px 14px;
  border: 2px solid #E84921;
  border-radius: 30px;
  background: transparent;
  color: #E84921;
  font-family: 'Fredoka', sans-serif;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 1.1px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease;
  white-space: nowrap;
}

.bks-header .bks-signin-btn:hover {
  background-color: #F6F3EF;
}

.bks-header .bks-signin-btn .bks-signin-icon {
  height: 26px;
  width: auto;
  /* Recolor PNG to match #E84921 */
  filter: brightness(0) saturate(100%) invert(28%) sepia(93%) saturate(2048%) hue-rotate(10deg) brightness(92%) contrast(89%);
  position: relative;
  top: 2px;
  margin-right: 4px;
}

/* ---------- Auth state visibility ---------- */
/* Default: hide everything until auth state is known */
.bks-header .bks-auth-only {
  display: none !important;
}

.bks-header .bks-noauth-only {
  display: none !important;
}

/* Once auth state is resolved, show the appropriate UI */
.bks-header.auth-ready .bks-noauth-only {
  display: inline-flex !important;
}

/* When authenticated */
.bks-header.authenticated .bks-auth-only {
  display: inline-flex !important;
}

.bks-header.authenticated .bks-noauth-only {
  display: none !important;
}

/* Child profile button */
.bks-header .bks-child-profile-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid #E84921;
  background: #E84921;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  font-size: 26px;
  line-height: 1;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}

/* Adult/child visibility — extra specificity to override .authenticated rules */
.bks-header.authenticated .bks-adult-only { display: inline-flex !important; }
.bks-header.authenticated .bks-child-only { display: none !important; }

.bks-header.authenticated.is-child .bks-adult-only { display: none !important; }
.bks-header.authenticated.is-child .bks-child-only { display: inline-flex !important; }

/* Admin-only items */
.bks-header .bks-admin-only {
  display: none !important;
}

.bks-header.is-admin .bks-admin-only {
  display: flex !important;
}

/* ---------- Account dropdown menu ---------- */
.bks-header .bks-menu-wrapper {
  position: relative;
}

.bks-header .bks-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 324px;
  background: #FFFFFF;
  border-radius: 20px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  z-index: 2000;
  padding: 8px 0;
}

.bks-header .bks-dropdown.open {
  display: block;
}

/* Profile row at top of dropdown */
.bks-header .bks-dropdown__profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px 14px 12px;
  position: relative;
}

.bks-header .bks-dropdown__profile-swap {
  position: absolute;
  right: 20px;
  top: 14px;
}

.bks-header .bks-dropdown__profile-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #E84921;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fredoka', sans-serif;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.bks-header .bks-dropdown__profile-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.bks-header .bks-dropdown__profile-name {
  font-size: 19px;
  font-weight: 400;
  color: #111111;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bks-header .bks-dropdown__profile-actions {
  display: flex;
  gap: 8px;
}

.bks-header .bks-dropdown__profile-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid #999;
  color: #999;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.bks-header .bks-dropdown__profile-action-btn:hover {
  background-color: #F6F3EF;
}

/* Divider */
.bks-header .bks-dropdown__divider {
  height: 1px;
  background: #E0E0E0;
  margin: 4px 0;
}

/* Menu items */
.bks-header .bks-dropdown__item {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 20px;
  color: #111111;
  text-decoration: none;
  font-family: 'Fredoka', sans-serif;
  font-size: 18px;
  font-weight: 300;
  cursor: pointer;
  transition: background-color 0.15s ease;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.bks-header .bks-dropdown__item:hover {
  background-color: #F6F3EF;
}

.bks-header .bks-dropdown__item .material-icons-outlined,
.bks-header .bks-dropdown__item .material-icons {
  font-size: 24px;
  color: #111111;
}

/* Overlay to close dropdown when clicking outside */
.bks-header .bks-dropdown-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1999;
}

.bks-header .bks-dropdown-overlay.open {
  display: block;
}

/* Mobile search button — hidden on desktop */
.bks-header .bks-mobile-search {
  display: none;
}

/* ---------- Mobile (< 700px) ---------- */
@media (max-width: 699px) {
  .bks-header {
    padding: 10px 16px;
  }

  .bks-header .bks-header__inner {
    height: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .bks-header .bks-header__logo {
    position: static;
    transform: none;
  }

  .bks-header .bks-header__logo-desktop {
    display: none;
  }

  .bks-header .bks-header__logo-mobile {
    display: block;
    width: 156px;
    height: auto;
  }

  .bks-header .bks-header__left {
    display: none;
  }

  .bks-header .bks-mobile-search {
    display: inline-flex;
  }

  .bks-header .bks-header__right {
    position: static;
  }

  .bks-header .bks-signin-btn .bks-signin-icon {
    display: none;
  }

  .bks-header .bks-dropdown {
    position: fixed;
    top: auto;
    left: 20px;
    right: 20px;
    width: auto;
    max-width: none;
    min-width: auto;
  }
}
