/**
 * Site Header Block - Frontend Styles
 *
 * Note: Most header styles are already defined in assets/css/main.css
 * This file is for any additional block-specific frontend styles.
 *
 * @package Eucon
 */

/* Block wrapper - ensure proper display */
.wp-block-eucon-site-header {
  display: block;
  width: 100%;
}

/* Ensure the header block doesn't add extra spacing */

.wp-block-eucon-site-header > header {
  margin: 0;

  padding: 0;
}

/* Symmetric 3-column header grid: left anchor | centered content | balance column */
.wp-block-eucon-site-header .content-topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  justify-content: unset;
}

.wp-block-eucon-site-header .content-topbar .left-top-bar {
  grid-column: 1;
  justify-self: start;
}

.wp-block-eucon-site-header .content-topbar .right-top-bar {
  grid-column: 2;
  justify-self: center;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}

.wp-block-eucon-site-header .limiter-menu-desktop {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.wp-block-eucon-site-header .limiter-menu-desktop .logo {
  grid-column: 1;
  justify-self: start;
}

.wp-block-eucon-site-header .limiter-menu-desktop .menu-desktop {
  grid-column: 2;
  justify-self: center;
}

.wp-block-eucon-site-header .limiter-menu-desktop > .wrap-icon-header:last-child {
  grid-column: 3;
}

.wp-block-eucon-site-header .limiter-menu-desktop .wrap-icon-header {
  flex-grow: unset;
}

@media (min-width: 992px) and (max-width: 1200px) {
  .wp-block-eucon-site-header .main-menu > li {
    margin-left: 8px;
    margin-right: 2px;
    padding-right: 6px;
  }

  .wp-block-eucon-site-header .main-menu > li > a {
    font-size: 1.05rem;
  }
}

/* Modern Custom Dropdown for Polylang <ul>-based Language Switcher */

/* Hide all but current language by default */
.lang-switcher > li:not(.current-lang) {
  display: none !important;
}

.lang-switcher {
  position: relative;
  display: inline-block;
  min-width: 120px;
  font-size: 15px;
  z-index: 9999 !important; /* Force above header/top-bar */
  cursor: pointer;
}

/* Language Switcher Dropdown Styles */
.header-language-switcher,
.lang-switcher,
.lang-switcher.open > li:not(.current-lang) {
  z-index: 99999 !important;
  position: relative;
}
.lang-switcher > li:not(.current-lang) {
  display: none !important;
}
.lang-switcher.open > li {
  display: flex !important;
}
/* Default (light) dropdown to fit normal header */
.lang-switcher.open > li:not(.current-lang) {
  position: absolute;
  top: 100%;
  left: 0;
  background: rgba(255, 255, 255, 0.98);
  color: #222;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.12);
  min-width: 140px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 6px;
  margin-top: 6px;
  padding: 10px 16px;
  z-index: 99999 !important;
  transition:
    background 0.15s,
    color 0.15s;
}

.lang-switcher.open > li:not(.current-lang) a {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
}

/* Prevent current language link from navigating while dropdown is open */
.lang-switcher.open .current-lang > a {
  pointer-events: none;
  cursor: pointer;
}

/* Transparent header variant - dark, semi-transparent dropdown to match overlay/header */
.header-v3 .lang-switcher.open > li:not(.current-lang),
.header-v3
  .header-language-switcher
  .lang-switcher.open
  > li:not(.current-lang),
.header-v3
  .eucon-mobile-menu-overlay__lang
  .lang-switcher.open
  > li:not(.current-lang) {
  background: rgba(30, 30, 30, 0.92);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
  padding: 10px 16px;
}

/* Ensure links inside dark dropdown are white */
.header-v3 .lang-switcher.open > li:not(.current-lang) a {
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
}

.header-v3 .lang-switcher.open > li:not(.current-lang):hover {
  background: rgba(50, 50, 50, 0.95);
}

/* Normal header variant - light dropdown with subtle shadow */
.header-v4 .lang-switcher.open > li:not(.current-lang),
.header-v4
  .header-language-switcher
  .lang-switcher.open
  > li:not(.current-lang),
.header-v4
  .eucon-mobile-menu-overlay__lang
  .lang-switcher.open
  > li:not(.current-lang) {
  background: rgba(255, 255, 255, 0.98);
  color: #222;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 6px;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.12);
  padding: 10px 16px;
}

/* Ensure links inside light dropdown are dark */
.header-v4 .lang-switcher.open > li:not(.current-lang) a {
  color: #222;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
}

.header-v4 .lang-switcher.open > li:not(.current-lang):hover {
  background: rgba(240, 244, 248, 1);
}

.header-language-switcher .lang-switcher > ul,
.eucon-mobile-header__lang .lang-switcher > ul,
.eucon-mobile-menu-overlay__lang .lang-switcher > ul {
  list-style: none;
  margin: 0;
  padding: 0;
  background: #fff;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  min-width: 70px;
  position: relative;
  transition: border 0.2s;
  display: flex;
  align-items: center;
}

.header-language-switcher .lang-switcher > ul > li,
.eucon-mobile-header__lang .lang-switcher > ul > li,
.eucon-mobile-menu-overlay__lang .lang-switcher > ul > li {
  display: flex;
  align-items: center;
  padding: 6px 32px 6px 12px;
  position: relative;
}

.header-language-switcher .lang-switcher > ul > li > a,
.eucon-mobile-header__lang .lang-switcher > ul > li > a,
.eucon-mobile-menu-overlay__lang .lang-switcher > ul > li > a {
  display: flex;
  align-items: center;
  color: #222;
  text-decoration: none;
  font-weight: 500;
  gap: 8px;
}

.header-language-switcher .lang-switcher img,
.eucon-mobile-header__lang .lang-switcher img,
.eucon-mobile-menu-overlay__lang .lang-switcher img {
  margin-right: 6px;
  vertical-align: middle;
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07);
  width: 20px;
  height: 14px;
  object-fit: cover;
}

.header-language-switcher .lang-switcher > ul:after,
.eucon-mobile-header__lang .lang-switcher > ul:after,
.eucon-mobile-menu-overlay__lang .lang-switcher > ul:after {
  content: "";
  display: block;
  position: absolute;
  right: 12px;
  top: 50%;
  width: 16px;
  height: 16px;
  pointer-events: none;
  background: url('data:image/svg+xml;utf8,<svg fill="#333" height="16" viewBox="0 0 24 24" width="16" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>')
    no-repeat center center/16px 16px;
  transform: translateY(-50%);
}

.lang-switcher.open > li {
  display: flex !important;
}

/* The detailed dropdown visuals (positioning, background, shadow, etc.)
   are defined above and scoped for header variants (header-v3/header-v4). */

.header-language-switcher
  .lang-switcher
  > ul
  > li:not(.lang-item-current):hover,
.eucon-mobile-header__lang
  .lang-switcher
  > ul
  > li:not(.lang-item-current):hover,
.eucon-mobile-menu-overlay__lang
  .lang-switcher
  > ul
  > li:not(.lang-item-current):hover {
  background: #f0f4f8;
}

.lang-switcher .lang-item-current > a {
  font-weight: 700;
}

.lang-switcher > ul > li.lang-item-current {
  z-index: 2;
}

.lang-switcher > ul > li:not(.lang-item-current) {
  cursor: pointer;
}

/* Mobile specific adjustments: flag-only trigger and left-opening dropdown next to hamburger */
@media (max-width: 800px) {
  /* Make the switcher compact on mobile */
  .lang-switcher {
    min-width: 40px;
    line-height: 1;
  }

  /* Mobile flag-only trigger (hide name text by default) */
  .mobile-flag-switcher > li > a {
    padding: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35em;
  }
  .mobile-flag-switcher > li > a span {
    display: none !important; /* hide language name on flag-only trigger */
  }
  .mobile-flag-switcher img {
    width: 18px;
    height: 12px;
    object-fit: cover;
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  }

  /* Layout: place the flag left of the hamburger (we output the flag before the button in the template) */
  .eucon-mobile-header__actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  /* Dropdown should open to the left of the hamburger (i.e. to the left of the flag trigger) */
  .mobile-flag-switcher.open > li:not(.current-lang) {
    display: flex !important;
    position: absolute;
    /* position left of the trigger */
    right: calc(100% + 8px); /* 8px gap between flag and dropdown */
    top: 50%;
    transform: translateY(-50%);
    min-width: 70px;
    margin-top: 0;
    border-radius: 6px;
    z-index: 99999 !important;
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.18);
  }

  /* when dropdown is open on mobile, show names inside the dropdown entries */
  .mobile-flag-switcher.open > li:not(.current-lang) a span {
    display: inline-block !important;
    margin-left: 0.4em;
  }

  /* Adjust colors for header variants on mobile */
  .header-v3 .mobile-flag-switcher.open > li:not(.current-lang),
  .header-v3
    .eucon-mobile-menu-overlay__lang
    .mobile-flag-switcher.open
    > li:not(.current-lang) {
    background: rgba(12, 12, 12, 0.72);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.06);
  }
  .header-v3 .mobile-flag-switcher.open > li:not(.current-lang) a,
  .header-v3 .mobile-flag-switcher.open > li:not(.current-lang) a span {
    color: #fff;
  }

  .header-v4 .mobile-flag-switcher.open > li:not(.current-lang),
  .header-v4
    .eucon-mobile-menu-overlay__lang
    .mobile-flag-switcher.open
    > li:not(.current-lang) {
    background: rgba(255, 255, 255, 0.98);
    color: #222;
    border: 1px solid rgba(0, 0, 0, 0.06);
  }
  .header-v4 .mobile-flag-switcher.open > li:not(.current-lang) a,
  .header-v4 .mobile-flag-switcher.open > li:not(.current-lang) a span {
    color: #222;
  }
}

/* Ensure parent containers have high z-index so the mobile dropdown isn't clipped by header stacking contexts */
.header-language-switcher,
.eucon-mobile-header__lang,
.eucon-mobile-menu-overlay__lang {
  position: relative;
  z-index: 99999 !important;
}
