/* === HEADER GENERAL === */
header {
  background: radial-gradient(circle at top left, #0f172a, #1e293b 80%);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  z-index: 1000;
  position: relative;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  color: #fff; /* preluat din index.css */
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1rem; /* mai mult padding sus-jos decât 0.6rem */
  width: 100%;
  max-width: none;
  gap: 2rem;
  flex-wrap: nowrap;
}

.logo {
  display: flex;
  align-items: center;
}

.logo-img {
  height: 48px;
  object-fit: contain;
}

/* === MAIN NAVIGATION === */

.main-nav {
  flex-grow: 1;
  display: flex;
  justify-content: center;
}

.main-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 1.25rem;
}

.main-nav > ul > li {
  position: relative;
}

.main-nav > ul > li > a {
  color: #e2e8f0;
  text-decoration: none;
  font-weight: 700;
  padding: 0.5rem 1.1rem;
  display: block;
  transition: all 0.3s ease;
  white-space: nowrap;
  font-family: 'Segoe UI', sans-serif;
  position: relative;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(4px);
  font-size: 1rem;
  transition: background 0.4s ease, box-shadow 0.3s ease;
}

.main-nav > ul > li:hover > a {
  color: #3abff8;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 8px rgba(56, 189, 248, 0.25);
}

.main-nav .has-sub > a::after {
  content: '▶';
  font-size: 0.75rem;
  margin-left: 6px;
  transition: transform 0.3s ease;
  display: inline-block;
}

.main-nav > ul > li.servicii > a::after {
  content: '▼';
}

/* === SUBMENU === */
.main-nav .sub-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: rgba(15, 23, 42, 0.95);
  border-radius: 0.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  min-width: 240px;
  padding: 0.4rem 0;
  z-index: 1001;
  border: 1px solid rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(6px);
}

.main-nav li:hover > .sub-menu,
.main-nav .sub-menu li:hover > .sub-menu {
  display: block;
  animation: fadeInUp 0.3s ease forwards;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.main-nav .sub-menu li {
  position: relative;
  padding-right: 0.5rem;
  padding-left: 0.5rem;
}

.main-nav .sub-menu a {
  color: #cbd5e1;
  padding: 0.5rem 1rem;
  display: block;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  transition: background 0.3s ease;
  border-radius: 4px;
  position: relative;
}

.main-nav .sub-menu .sub-menu a::before {
  content: '▶';
  font-size: 0.75rem;
  margin-right: 6px;
  display: inline-block;
  color: #38bdf8;
}

.main-nav .sub-menu a:hover {
  background-color: #1e293b;
}

/* === NESTED SUBMENU (LEVEL 2) === */
.main-nav .sub-menu .sub-menu {
  left: 100%;
  top: 0;
  position: absolute;
  background: rgba(15, 23, 42, 0.95);
  border-radius: 0.5rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  margin-left: 4px;
  padding: 0.4rem 0;
  z-index: 1002;
  backdrop-filter: blur(6px);
  pointer-events: auto;
}

.main-nav .sub-menu li:hover {
  background-color: rgba(255, 255, 255, 0.03);
}

.main-nav .sub-menu li {
  margin-bottom: 2px;
  padding: 2px 0;
}

/* Buffer zone to prevent accidental close */
.main-nav .sub-menu li {
  padding-bottom: 6px;
}

/* === Decorative Border (optional) === */
.main-nav > ul > li > a {
  border-bottom: 2px solid transparent;
}

.main-nav > ul > li:hover > a {
  border-bottom: 2px solid #38bdf8;
}

/* === Visual Accent Animation === */
.main-nav > ul > li > a::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0%;
  height: 2px;
  background: #38bdf8;
  transition: width 0.3s ease-in-out;
}

.main-nav > ul > li:hover > a::before {
  width: 100%;
}


/* Language */

.language-selector {
  position: relative;
  display: inline-block;
  user-select: none;
  z-index: 1000;
  font-family: 'Segoe UI', sans-serif;
}

/* Blocul selectat */
.selected-language {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 12px;
  border: 1px solid #3b82f6;
  border-radius: 6px;
  background-color: #1e293b; /* albastru închis */
  color: #f1f5f9; /* text albicios */
  font-weight: 500;
  min-width: 120px;
  transition: background-color 0.2s;
}

.selected-language:hover {
  background-color: #334155;
}

.selected-language img {
  width: 20px;
  height: 14px;
  object-fit: cover;
  border: 1px solid #3b82f6;
  border-radius: 2px;
}

/* Lista opțiuni */
.language-options {
  display: none;
  position: absolute;
  background-color: #1f2937; /* fundal întunecat */
  border: 1px solid #3b82f6;
  margin-top: 4px;
  padding: 0;
  list-style: none;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  min-width: 120px;
}

.language-options li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  color: #e2e8f0;
  transition: background-color 0.2s;
}

.language-options li:hover {
  background-color: #3b82f6;
  color: white;
}

.language-options img {
  width: 20px;
  height: 14px;
  object-fit: cover;
  border: 1px solid #3b82f6;
  border-radius: 2px;
}


/* ===============================
   MOBILE HEADER — BARĂ SUBȚIRE + MENIU SCROLLABIL
   + FIX DROPDOWN LIMBĂ ÎN VIEWPORT
   =============================== */
@media screen and (max-width: 768px) {
  /* Înălțimea barei mobile (ajustează dacă vrei) */
  header { 
    position: sticky;
    top: 0;
    z-index: 1000;
    --mobile-header-h: 52px;
  }

  /* Container compact, pe un singur rând */
  header .container {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;

    padding: 0.5rem 0.75rem !important; /* bară subțire */
    gap: 0.5rem;
  }

  /* Logo mai mic pe mobil */
  .logo-img {
    height: 32px;
  }

  /* Meniu pe o singură linie, orizontal scrollabil */
  .main-nav {
    flex: 1 1 auto;
    overflow-x: auto;
    overflow-y: visible;               /* IMPORTANT: să nu taie dropdown-ul */
    -webkit-overflow-scrolling: touch; /* scroll fluid iOS */
    scrollbar-width: none;             /* ascunde scrollbar Firefox */
  }
  .main-nav::-webkit-scrollbar { display: none; } /* ascunde scrollbar WebKit */

  .main-nav ul {
    display: flex !important;
    flex-direction: row !important;    /* forțează rând */
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;               /* totul pe un rând */
    margin: 0;
    padding: 0;
  }

  .main-nav > ul > li {
    display: inline-block;
  }

  /* „Pills” compacte pentru itemii din meniu */
  .main-nav > ul > li > a {
    font-size: 0.9rem;
    padding: 0.35rem 0.6rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: 0 !important;       /* stabil pe mobil */
  }
  .main-nav > ul > li > a::before { display: none !important; }

  /* Ascundem indicatorii de submeniu pe mobil (nu afișăm submeniuri) */
  .main-nav .has-sub > a::after,
  .main-nav > ul > li.servicii > a::after {
    display: none !important;
    content: none !important;
  }

  /* Dezactivăm complet submeniurile pe mobil ca să nu crească header-ul */
  .main-nav .sub-menu,
  .main-nav .sub-menu .sub-menu {
    display: none !important;
    position: fixed !important;  /* scos din flux */
    opacity: 0 !important;
    pointer-events: none !important;
    height: 0 !important;
  }

  /* === SELECTOR LIMBĂ — COMPACT + DROPDOWN FIX === */

  /* Buton compact (doar steagul) */
  .language-selector {
    position: relative;
    flex: 0 0 auto;
    order: 3;            /* după meniu */
    z-index: 1200;       /* peste nav */
  }
  .selected-language {
    padding: 4px 6px;
    min-width: auto;
    font-size: 0;        /* ascunde textul */
    cursor: pointer;
  }
  .selected-language span { display: none; }
  .selected-language img {
    width: 18px;
    height: 12px;
  }

  /* Dropdown-ul este ancorat la VIEWPORT, nu la containerul scrollabil */
  .language-options {
    position: fixed !important;
    top: calc(env(safe-area-inset-top, 0px) + var(--mobile-header-h)); /* sub header */
    right: 8px;
    left: auto;
    width: min(220px, 90vw);
    max-height: 60vh;
    overflow: auto;
    margin-top: 0;       /* anulăm offset-ul inițial */
    z-index: 1400;       /* peste toate elementele din header */
    transform: none !important;

    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,.45);
  }
}

/* === ANDROID/CHROME/FIREFOX NAV SCROLL FIX === */
@media screen and (max-width: 768px) {
  /* Flex itemul trebuie să se poată micșora ca să permită scroll intern */
  .main-nav {
    justify-content: flex-start;     /* evita centrare care poate „tăia” stânga */
    min-width: 0;                    /* CRITIC pentru flex + overflow pe Chromium */
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;             /* asigură gestul de glisare orizontală */
    direction: ltr;                  /* previne interpretări RTL pe unele locale */
  }

  /* Lățimea listei = exact cât conținutul (nu „împinsă” de flex) */
  .main-nav ul {
    inline-size: max-content;        /* face banda scrollabilă corect */
    white-space: nowrap;
  }

  /* Opțional: snap ușor pe itemi (poți elimina dacă nu-l vrei) */
  .main-nav {
    scroll-snap-type: x proximity;
  }
  .main-nav > ul > li {
    scroll-snap-align: start;
  }
}

/* ===============================
   HEADER FX: Ultrasound + Radioactive Waves
   =============================== */

/* IMPORTANT: header-ul NU taie dropdown-uri */
header{
  position: relative;
  overflow: visible;
}

/* conținutul header-ului peste efecte */
header .container{
  position: relative;
  z-index: 2;
}

/* overlay pentru efecte */
.header-fx{
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden; /* taie DOAR undele */
  mask-image: radial-gradient(120% 80% at 50% 20%, #000 60%, transparent 100%);
  opacity: .9;
}

/* unde ultrasunete */
.header-fx .wave{
  position: absolute;
  left: -35%;
  width: 170%;
  height: 2px;
  transform: rotate(var(--rot)) translateZ(0);
  opacity: var(--op);
  filter: blur(var(--blur));
  will-change: transform, opacity;

  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(34,211,238,.0) 18%,
    rgba(34,211,238,.75) 50%,
    rgba(96,165,250,.45) 62%,
    transparent 100%
  );

  box-shadow:
    0 0 16px rgba(34,211,238,.18),
    0 0 28px rgba(96,165,250,.10);

  animation: wave-travel var(--dur) linear forwards;
}

.header-fx .wave.thin{ height: 1px; }
.header-fx .wave.thick{ height: 3px; }

/* pulse radioactive */
.header-fx .rad{
  position: absolute;
  left: -30%;
  width: 160%;
  height: 10px;
  transform: rotate(var(--rot)) translateZ(0);
  opacity: var(--op);
  filter: blur(var(--blur));
  will-change: transform, opacity;

  background: radial-gradient(
    ellipse at center,
    rgba(34,197,94,.0) 0%,
    rgba(34,197,94,.55) 35%,
    rgba(34,197,94,.18) 58%,
    transparent 72%
  );

  animation: rad-travel var(--dur) ease-in-out forwards;
}

@keyframes wave-travel{
  0%   { transform: rotate(var(--rot)) translateX(0); opacity: 0; }
  12%  { opacity: var(--op); }
  88%  { opacity: var(--op); }
  100% { transform: rotate(var(--rot)) translateX(45%); opacity: 0; }
}

@keyframes rad-travel{
  0%   { transform: rotate(var(--rot)) translateX(0) scaleY(.7); opacity: 0; }
  15%  { opacity: var(--op); }
  50%  { transform: rotate(var(--rot)) translateX(26%) scaleY(1.15); }
  100% { transform: rotate(var(--rot)) translateX(45%) scaleY(.85); opacity: 0; }
}

@media (prefers-reduced-motion: reduce){
  .header-fx{ display:none !important; }
}
