/* css/components/header.css */
.main-header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: none;
  padding: 16px 24px 12px;
  z-index: 1000;
}

.header-stripe-bar {
  height: 12px;
  background: linear-gradient(
    to bottom,
    #CD1025 0%, #CD1025 33.33%,
    #FFFFFF 33.33%, #FFFFFF 66.66%,
    #002A7E 66.66%, #002A7E 100%
  );
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  cursor: pointer;
}

.logo i {
  font-size: 1.4rem;
  color: white;
  background: linear-gradient(135deg, #2D2E5F, #1E9D8E);
  padding: 6px;
  border-radius: 16px;
}

.logo .logo-icon {
  height: 34px;
  width: auto;
  display: block;
}

.logo-text {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-dark);
}

.logo-text span {
  font-size: 0.7rem;
  font-weight: 400;
  opacity: 0.7;
  color: var(--text-medium);
}

.level-nav {
  display: flex;
  gap: 12px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.level-btn {
  padding: 8px 16px;
  border-radius: 40px;
  border: 2px solid rgba(45, 46, 95, 0.12);
  background: rgba(45, 46, 95, 0.04);
  color: var(--text-medium);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.level-btn:hover {
  transform: translateY(-2px);
  background: rgba(45, 46, 95, 0.08);
  border-color: rgba(45, 46, 95, 0.2);
}

.level-btn.active {
  background: linear-gradient(135deg, #2D2E5F, #1E9D8E);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(45, 46, 95, 0.2);
}

/* ── Header mode navigation ── */
.header-mode-nav {
  display: flex;
  gap: 8px;
  align-items: center;
}

.header-mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 40px;
  border: 2px solid rgba(45, 46, 95, 0.10);
  background: rgba(45, 46, 95, 0.04);
  color: var(--text-medium);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.25s;
  white-space: nowrap;
}

.header-mode-btn:hover {
  background: rgba(45, 46, 95, 0.08);
  border-color: rgba(45, 46, 95, 0.18);
  transform: translateY(-1px);
}

.header-mode-btn.active {
  background: linear-gradient(135deg, #2D2E5F, #1E9D8E);
  color: white;
  border-color: transparent;
  box-shadow: 0 3px 12px rgba(45, 46, 95, 0.18);
}

.header-mode-icon {
  font-size: 1rem;
  line-height: 1;
}

/* ── Header quick navigation ── */
.header-quick-nav {
  display: flex;
  gap: 4px;
  align-items: center;
  flex: 1;
  justify-content: center;
}

.header-nav-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 13px;
  border-radius: 40px;
  border: 2px solid transparent;
  background: transparent;
  color: var(--text-medium);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.header-nav-btn:hover {
  background: rgba(45, 46, 95, 0.06);
  border-color: rgba(45, 46, 95, 0.12);
  color: var(--text-dark);
  transform: translateY(-1px);
}

.header-nav-btn.active {
  background: linear-gradient(135deg, #2D2E5F, #1E9D8E);
  color: white;
  border-color: transparent;
  box-shadow: 0 3px 12px rgba(45, 46, 95, 0.18);
}

.header-nav-btn .material-symbols-outlined {
  font-size: 1.1rem;
  line-height: 1;
}

@media (max-width: 960px) {
  .header-nav-label {
    display: none;
  }

  .header-nav-btn {
    padding: 7px 9px;
  }
}

@media (max-width: 560px) {
  .header-quick-nav {
    display: flex;
  }
}

/* ── Header calculator button ── */
.header-calc-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border-radius: 40px;
  border: 2px solid rgba(45, 46, 95, 0.10);
  background: rgba(45, 46, 95, 0.04);
  color: var(--text-medium);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.25s;
  white-space: nowrap;
}

.header-calc-btn:hover {
  background: rgba(45, 46, 95, 0.08);
  border-color: rgba(45, 46, 95, 0.18);
  transform: translateY(-1px);
}

.header-calc-btn i,
.header-calc-btn .material-symbols-outlined {
  color: #1E9D8E;
  font-size: 1.3rem;
}

/* ── Header dictionaries dropdown ── */
.header-dict-dropdown {
  position: relative;
  display: inline-block;
}

.header-dict-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: 40px;
  border: 2px solid rgba(45, 46, 95, 0.10);
  background: rgba(45, 46, 95, 0.04);
  color: var(--text-medium);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.25s;
  white-space: nowrap;
}

.header-dict-btn .material-symbols-outlined {
  font-size: 1.2rem;
  color: #1E9D8E;
}

.header-dict-btn .header-dict-arrow {
  font-size: 0.9rem;
  color: var(--text-medium);
  transition: transform 0.2s;
}

.header-dict-dropdown:hover .header-dict-btn {
  background: rgba(45, 46, 95, 0.08);
  border-color: rgba(45, 46, 95, 0.18);
  color: var(--text-dark);
  transform: translateY(-1px);
}

.header-dict-dropdown:hover .header-dict-arrow {
  transform: rotate(180deg);
}

.header-dict-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.14);
  min-width: 230px;
  padding: 6px 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  z-index: 1100;
  border: 1px solid rgba(45, 46, 95, 0.08);
}

.header-dict-dropdown:hover .header-dict-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.header-dict-dropdown:focus-within .header-dict-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.header-dict-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-dark, #0f172a);
  cursor: pointer;
  transition: background 0.15s;
}

.header-dict-menu-item:hover {
  background: rgba(45, 46, 95, 0.05);
}

.header-dict-menu-item .material-symbols-outlined {
  font-size: 1.1rem;
}

.header-dict-menu-divider {
  height: 1px;
  background: rgba(45, 46, 95, 0.07);
  margin: 4px 12px;
}

@media (max-width: 560px) {
  .header-dict-label {
    display: none;
  }
}

@media (max-width: 768px), (max-height: 520px) and (orientation: landscape) and (max-width: 1024px) {
  .main-header {
    position: sticky;
    top: 0;
    padding: 10px 12px 8px;
    border-bottom: 1px solid rgba(45, 46, 95, 0.08);
  }

  .header-container {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    align-items: center;
  }

  .logo {
    min-width: 0;
  }

  .logo .logo-icon {
    height: 30px;
  }

  .header-quick-nav {
    order: 4;
    grid-column: 1 / -1;
    justify-content: flex-start;
    gap: 6px;
    overflow-x: auto;
    padding: 2px 2px 6px;
    margin: 0 -2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .header-quick-nav::-webkit-scrollbar {
    display: none;
  }

  .header-nav-btn {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 8px 12px;
    background: rgba(45, 46, 95, 0.04);
    border-color: rgba(45, 46, 95, 0.08);
  }

  .header-nav-label {
    display: inline;
    font-size: 0.78rem;
  }

  .header-nav-group {
    gap: 6px;
    justify-content: flex-end;
    min-width: 0;
  }

  .header-dict-dropdown {
    position: static;
  }

  .header-dict-btn,
  .header-calc-btn {
    min-height: 40px;
    padding: 8px 10px;
  }

  .header-dict-menu {
    position: fixed;
    top: 106px;
    left: 12px;
    right: 12px;
    min-width: 0;
    max-height: calc(100dvh - 124px);
    overflow-y: auto;
  }
}

@media (max-width: 420px) {
  .header-container {
    grid-template-columns: auto 1fr;
    row-gap: 8px;
  }

  .header-nav-group {
    grid-column: 2;
    gap: 4px;
  }

  .header-nav-label {
    display: none;
  }

  .header-quick-nav {
    grid-column: 1 / -1;
    gap: 8px;
    padding: 4px 1px 8px;
  }

  .header-nav-btn {
    min-width: 46px;
    justify-content: center;
    padding: 8px 10px;
  }
}
