/**
 * @file
 * Styles for UNIS Auto Translate language switcher widget.
 */

/* ========== Widget Container ========== */

#unis-autotranslate-widget {
  position: fixed;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* Position variants */
.unis-at-top-right {
  top: 80px;
  right: 20px;
}

.unis-at-top-left {
  top: 80px;
  left: 20px;
}

.unis-at-bottom-right {
  bottom: 20px;
  right: 20px;
}

.unis-at-bottom-left {
  bottom: 20px;
  left: 20px;
}

/* Adjust for admin toolbar if present */
.toolbar-fixed #unis-autotranslate-widget.unis-at-top-right,
.toolbar-fixed #unis-autotranslate-widget.unis-at-top-left {
  top: 120px;
}

/* ========== Toggle Button ========== */

.unis-at-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #1a73e8 0%, #1557b0 100%);
  color: #ffffff;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(26, 115, 232, 0.4), 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.unis-at-toggle:hover {
  background: linear-gradient(135deg, #1557b0 0%, #104a9e 100%);
  box-shadow: 0 6px 16px rgba(26, 115, 232, 0.5), 0 3px 6px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

.unis-at-toggle:focus {
  outline: 3px solid rgba(26, 115, 232, 0.5);
  outline-offset: 2px;
}

.unis-at-toggle:active {
  transform: translateY(0);
}

.unis-at-current-flag {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.unis-at-flag-img {
  display: block;
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  object-fit: cover;
}

.unis-at-current-name {
  font-size: 13px;
}

.unis-at-arrow {
  font-size: 10px;
  transition: transform 0.2s ease;
}

.unis-at-toggle[aria-expanded="true"] .unis-at-arrow {
  transform: rotate(180deg);
}

/* ========== Dropdown Menu ========== */

.unis-at-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  list-style: none;
  margin: 0;
  padding: 6px 0;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.08);
  min-width: 180px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

/* Position dropdown on left side if widget is on the left */
.unis-at-top-left .unis-at-dropdown,
.unis-at-bottom-left .unis-at-dropdown {
  right: auto;
  left: 0;
}

/* Position dropdown above if widget is at bottom */
.unis-at-bottom-right .unis-at-dropdown,
.unis-at-bottom-left .unis-at-dropdown {
  top: auto;
  bottom: calc(100% + 8px);
}

/* ========== Language Options ========== */

.unis-at-lang-option {
  margin: 0;
  padding: 0;
}

.unis-at-lang-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  color: #333333;
  font-size: 14px;
  transition: background-color 0.15s ease;
}

.unis-at-lang-btn:hover {
  background-color: #f0f4ff;
}

.unis-at-lang-btn:focus {
  outline: none;
  background-color: #e3ecff;
}

.unis-at-active .unis-at-lang-btn {
  background-color: #e8f0fe;
  color: #1a73e8;
  font-weight: 600;
}

.unis-at-flag {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  flex-shrink: 0;
}

.unis-at-flag .unis-at-flag-img {
  border-radius: 3px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.unis-at-name {
  flex-grow: 1;
}

.unis-at-check {
  color: #1a73e8;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

/* ========== Loading Overlay ========== */

.unis-at-loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  backdrop-filter: blur(2px);
}

.unis-at-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e8f0fe;
  border-top-color: #1a73e8;
  border-radius: 50%;
  animation: unis-at-spin 0.8s linear infinite;
  margin-bottom: 16px;
}

@keyframes unis-at-spin {
  to {
    transform: rotate(360deg);
  }
}

.unis-at-loading-text {
  color: #333333;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* ========== Responsive ========== */

@media screen and (max-width: 768px) {
  #unis-autotranslate-widget {
    font-size: 13px;
  }

  .unis-at-top-right,
  .unis-at-top-left {
    top: 70px;
    right: 10px;
    left: auto;
  }

  .unis-at-bottom-right,
  .unis-at-bottom-left {
    bottom: 10px;
    right: 10px;
    left: auto;
  }

  .unis-at-toggle {
    padding: 8px 12px;
    gap: 6px;
  }

  .unis-at-current-name {
    display: none;
  }

  .unis-at-dropdown {
    right: 0;
    left: auto;
    min-width: 160px;
  }
}

/* ========== Dark mode support ========== */

@media (prefers-color-scheme: dark) {
  .unis-at-dropdown {
    background: #2d2d2d;
    border-color: rgba(255, 255, 255, 0.1);
  }

  .unis-at-lang-btn {
    color: #e0e0e0;
  }

  .unis-at-lang-btn:hover {
    background-color: #383838;
  }

  .unis-at-lang-btn:focus {
    background-color: #404040;
  }

  .unis-at-active .unis-at-lang-btn {
    background-color: #1a3a5c;
    color: #8ab4f8;
  }

  .unis-at-check {
    color: #8ab4f8;
  }

  .unis-at-loading {
    background: rgba(0, 0, 0, 0.85);
  }

  .unis-at-loading-text {
    color: #e0e0e0;
  }

  .unis-at-spinner {
    border-color: #1a3a5c;
    border-top-color: #8ab4f8;
  }
}

/* ========== Animation ========== */

#unis-autotranslate-widget {
  animation: unis-at-fadein 0.5s ease forwards;
}

@keyframes unis-at-fadein {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========== Print ========== */

@media print {
  #unis-autotranslate-widget {
    display: none !important;
  }
}

/* ========== No-translate class ========== */

.no-translate {
  /* This class can be added to any element to prevent translation */
}
