/* Language Toggle Switch - Neumorphic Design (matching theme toggle) */
.language-toggle {
  position: relative;
  width: 76px;
  height: 36px;
  background: #e0e0e6;
  border-radius: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1),
    0 2px 4px rgba(255, 255, 255, 0.5);
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
  overflow: hidden;
  will-change: background-color, box-shadow;
  border: none;
}

/* Dark mode state */
body.dark-mode .language-toggle,
[data-theme="dark"] .language-toggle {
  background: #4a4c5c;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3),
    0 2px 4px rgba(71, 85, 105, 0.2);
}

/* Toggle button (the sliding circle) */
.language-toggle .toggle-button {
  position: absolute;
  left: 4px;
  width: 28px;
  height: 28px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.1),
    inset 0 -1px 1px rgba(0, 0, 0, 0.05),
    inset 0 1px 1px rgba(255, 255, 255, 0.7);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  will-change: transform;
}

/* Italian language state - toggle on right */
.language-toggle.it .toggle-button {
  transform: translateX(40px);
}

/* Hover effect - enhanced 3D */
.language-toggle:hover .toggle-button {
  transform: scale(1.05);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.25), 0 2px 3px rgba(0, 0, 0, 0.15),
    inset 0 -1px 1px rgba(0, 0, 0, 0.05),
    inset 0 1px 2px rgba(255, 255, 255, 0.7);
}

.language-toggle.it:hover .toggle-button {
  transform: translateX(40px) scale(1.05);
}

.language-toggle:active .toggle-button {
  transform: scale(0.95);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.1),
    inset 0 -1px 1px rgba(0, 0, 0, 0.05),
    inset 0 1px 1px rgba(255, 255, 255, 0.7);
}

.language-toggle.it:active .toggle-button {
  transform: translateX(40px) scale(0.95);
}

/* Text labels - fixed positions */
.language-toggle .lang-text {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  z-index: 3;
  transition: opacity 0.3s ease, color 0.3s ease;
  will-change: opacity;
}

/* EN text (right side when English is active) */
.language-toggle .lang-text.en {
  right: 10px;
  opacity: 0;
  color: #2563eb;
}

.language-toggle:not(.it) .lang-text.en {
  opacity: 1;
}

/* IT text (left side when Italian is active) */
.language-toggle .lang-text.it {
  left: 10px;
  opacity: 0;
  color: #22c55e;
}

.language-toggle.it .lang-text.it {
  opacity: 1;
}

/* Dark mode text colors */
body.dark-mode .language-toggle .lang-text.en,
[data-theme="dark"] .language-toggle .lang-text.en {
  color: #ffffff;
}

body.dark-mode .language-toggle .lang-text.it,
[data-theme="dark"] .language-toggle .lang-text.it {
  color: #ffffff;
}

/* Active flag on toggle button */
/* EN flag on toggle button when English is active */
.language-toggle .toggle-button::before {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  background: url("../images/icons/en.png") no-repeat center center;
  background-size: contain;
  opacity: 1;
  transition: opacity 0.3s ease;
  will-change: opacity;
  border-radius: 50%;
}

.language-toggle.it .toggle-button::before {
  opacity: 0;
}

/* IT flag on toggle button when Italian is active */
.language-toggle .toggle-button::after {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  background: url("../images/icons/it.png") no-repeat center center;
  background-size: contain;
  opacity: 0;
  transition: opacity 0.3s ease;
  will-change: opacity;
  border-radius: 50%;
}

.language-toggle.it .toggle-button::after {
  opacity: 1;
}

/* Performance-optimized transitions */
.language-toggle {
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.language-toggle .toggle-button {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.language-toggle .toggle-button::before,
.language-toggle .toggle-button::after {
  transition: opacity 0.3s ease;
}

/* Language Toggle in Header - gap handled by .nav-actions */

/* Responsive adjustments */
/* Tablet landscape - slightly smaller */
@media (max-width: 1024px) and (min-width: 769px) {
  .language-toggle {
    width: 72px;
    height: 34px;
  }

  .language-toggle .toggle-button {
    width: 26px;
    height: 26px;
  }

  .language-toggle.it .toggle-button {
    transform: translateX(38px);
  }

  .language-toggle.it:hover .toggle-button {
    transform: translateX(38px) scale(1.05);
  }

  .language-toggle.it:active .toggle-button {
    transform: translateX(38px) scale(0.95);
  }

  .language-toggle .lang-text {
    font-size: 10.5px;
  }
}

/* Mobile and small tablets */
@media (max-width: 768px) {
  .language-toggle {
    width: 70px;
    height: 34px;
  }

  .language-toggle .toggle-button {
    width: 28px;
    height: 28px;
  }

  .language-toggle.it .toggle-button {
    transform: translateX(35px);
  }

  .language-toggle.it:hover .toggle-button {
    transform: translateX(35px) scale(1.05);
  }

  .language-toggle.it:active .toggle-button {
    transform: translateX(35px) scale(0.95);
  }

  .language-toggle .lang-text {
    font-size: 10px;
  }

  .language-toggle .toggle-button::before,
  .language-toggle .toggle-button::after {
    width: 18px;
    height: 18px;
  }
}
