/* ============================================================
   TamilAI — GLOBAL LANGUAGE SELECTOR
   ------------------------------------------------------------
   Layout:
   Theme → Language → Profile
   Design:
   • Glassmorphism
   • Soft 3D depth
   • Smooth entrance animation
   • Hover / press animations
   • Responsive
   • Dark mode support
   • No duplicate selectors
   ============================================================ */
/* ============================================================
   01. LANGUAGE VARIABLES
   ============================================================ */
:root {
  --tamilai-language-font: Inter, system-ui, sans-serif;
  --language-accent: #4f72ff;
  --language-accent-soft: rgba(79, 114, 255, 0.12);
  --language-accent-border: rgba(79, 114, 255, 0.24);
  --language-text: #202124;
  --language-muted: #7c8290;
  --language-surface: rgba(255, 255, 255, 0.88);
  --language-surface-strong: rgba(255, 255, 255, 0.96);
  --language-border: rgba(120, 130, 150, 0.18);
  --language-shadow:
    0 20px 55px rgba(20, 25, 45, 0.14), 0 8px 22px rgba(20, 25, 45, 0.08);
  --language-shadow-hover:
    0 24px 65px rgba(20, 25, 45, 0.18), 0 10px 28px rgba(20, 25, 45, 0.1);
}
/* ============================================================
   02. LANGUAGE FONT
   ============================================================ */
html,
body {
  --tamilai-active-font: var(--tamilai-language-font);
}
/* ============================================================
   03. BOTTOM CONTROL BAR
   ------------------------------------------------------------
   Theme → Language → Profile
   ============================================================ */
.sidebar-bottom-controls {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 58px;
  padding: 6px 8px;
  box-sizing: border-box;
  isolation: isolate;
}
/* ============================================================
   04. LANGUAGE CONTROL HOST
   ------------------------------------------------------------
   JavaScript inserts the language button here.
   ============================================================ */
.language-control-host {
  position: relative;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
/* ============================================================
   05. LANGUAGE BUTTON
   ------------------------------------------------------------
   IMPORTANT:
   This button is NOT fixed.
   It stays beside Theme and Profile.
   ============================================================ */
.tamilai-language-button {
  position: relative;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--language-border);
  border-radius: 50%;
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.92),
    rgba(238, 241, 248, 0.72)
  );
  color: var(--language-text);
  box-shadow:
    0 5px 12px rgba(20, 25, 45, 0.08),
    inset 0 1px 1px rgba(255, 255, 255, 0.95),
    inset 0 -2px 4px rgba(100, 110, 140, 0.08);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  cursor: pointer;
  overflow: hidden;
  z-index: 30;
  transition:
    transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.25s ease,
    border-color 0.25s ease,
    background 0.25s ease;
}
/* ============================================================
   06. BUTTON LIGHT EFFECT
   ============================================================ */
.tamilai-language-button::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: inherit;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.72),
    transparent 48%,
    rgba(79, 114, 255, 0.05)
  );
  pointer-events: none;
  opacity: 0.9;
}
/* ============================================================
   07. BUTTON GLOW
   ============================================================ */
.tamilai-language-button::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  top: -7px;
  left: -7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  filter: blur(7px);
  opacity: 0;
  transform: translate(-10px, -10px);
  transition:
    opacity 0.3s ease,
    transform 0.45s ease;
}
/* ============================================================
   08. BUTTON HOVER
   ============================================================ */
.tamilai-language-button:hover {
  transform: translateY(-3px) scale(1.05);
  border-color: var(--language-accent-border);
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.98),
    rgba(235, 239, 255, 0.88)
  );
  box-shadow:
    0 12px 25px rgba(45, 65, 130, 0.14),
    0 5px 12px rgba(79, 114, 255, 0.1),
    inset 0 1px 2px rgba(255, 255, 255, 1);
}
.tamilai-language-button:hover::after {
  opacity: 1;
  transform: translate(48px, 48px);
}
/* ============================================================
   09. BUTTON PRESS
   ============================================================ */
.tamilai-language-button:active {
  transform: translateY(1px) scale(0.94);
  box-shadow:
    0 3px 7px rgba(20, 25, 45, 0.12),
    inset 0 2px 5px rgba(30, 40, 70, 0.08);
}
/* ============================================================
   10. GLOBE ICON
   ============================================================ */
.tamilai-language-globe {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 19px;
  line-height: 1;
  z-index: 2;
  transform: translateZ(0);
  transition:
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.25s ease;
}
.tamilai-language-button:hover .tamilai-language-globe {
  transform: rotate(-8deg) scale(1.08);
  filter: drop-shadow(0 3px 5px rgba(79, 114, 255, 0.2));
}
/* ============================================================
   11. LANGUAGE PANEL
   ------------------------------------------------------------
   Opens ABOVE the language button.
   ============================================================ */
.tamilai-language-panel {
  position: fixed;
  /* Position is calculated by language-manager.js */
  left: auto;
  top: auto;
  right: auto;
  bottom: auto;
  width: 300px;
  max-width: calc(100vw - 24px);
  max-height: 520px;
  box-sizing: border-box;
  padding: 14px;
  border: 1px solid var(--language-border);
  border-radius: 22px;
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.97),
    rgba(247, 249, 253, 0.91)
  );
  backdrop-filter: blur(28px) saturate(140%);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
  box-shadow:
    var(--language-shadow),
    inset 0 1px 1px rgba(255, 255, 255, 0.95),
    inset 0 -1px 3px rgba(80, 90, 120, 0.05);
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px) scale(0.94);
  pointer-events: none;
  z-index: 99999;
  transition:
    opacity 0.25s ease,
    visibility 0.25s ease,
    transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.3s ease;
}
/* ============================================================
   12. PANEL OPEN
   ============================================================ */
.tamilai-language-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  box-shadow:
    var(--language-shadow-hover),
    inset 0 1px 1px rgba(255, 255, 255, 0.98);
}
/* ============================================================
   13. PANEL TOP HIGHLIGHT
   ============================================================ */
.tamilai-language-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 12%;
  right: 12%;
  height: 1px;
  border-radius: 50%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.95),
    transparent
  );
  pointer-events: none;
}
/* ============================================================
   14. PANEL HEADER
   ============================================================ */
.tamilai-language-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 7px 13px 9px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(120, 130, 150, 0.12);
}
/* ============================================================
   15. TITLE
   ============================================================ */
.tamilai-language-title {
  font-family: var(--tamilai-language-font);
  font-size: 15px;
  font-weight: 750;
  line-height: 1.25;
  color: var(--language-text);
  letter-spacing: -0.15px;
}
/* ============================================================
   16. SUBTITLE
   ============================================================ */
.tamilai-language-subtitle {
  margin-top: 4px;
  font-family: var(--tamilai-language-font);
  font-size: 11px;
  font-weight: 450;
  line-height: 1.3;
  color: var(--language-muted);
}
/* ============================================================
   17. CLOSE BUTTON
   ============================================================ */
.tamilai-language-close {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(120, 130, 150, 0.12);
  border-radius: 10px;
  background: rgba(120, 130, 150, 0.07);
  color: var(--language-muted);
  font-family: system-ui, sans-serif;
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  transition:
    transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
    background 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
}
.tamilai-language-close:hover {
  transform: rotate(90deg) scale(1.05);
  background: rgba(79, 114, 255, 0.1);
  color: var(--language-accent);
  box-shadow: 0 4px 10px rgba(79, 114, 255, 0.1);
}
.tamilai-language-close:active {
  transform: rotate(90deg) scale(0.92);
}
/* ============================================================
   18. LANGUAGE LIST
   ============================================================ */
.tamilai-language-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 430px;
  overflow-y: auto;
  padding: 2px 3px 2px 1px;
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 110, 130, 0.25) transparent;
}
/* ============================================================
   19. WEBKIT SCROLLBAR
   ============================================================ */
.tamilai-language-list::-webkit-scrollbar {
  width: 5px;
}
.tamilai-language-list::-webkit-scrollbar-track {
  background: transparent;
}
.tamilai-language-list::-webkit-scrollbar-thumb {
  background: rgba(100, 110, 130, 0.24);
  border-radius: 20px;
}
.tamilai-language-list::-webkit-scrollbar-thumb:hover {
  background: rgba(79, 114, 255, 0.38);
}
/* ============================================================
   20. LANGUAGE ITEM
   ============================================================ */
.tamilai-language-item {
  position: relative;
  width: 100%;
  min-height: 55px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: var(--language-text);
  font-family: var(--tamilai-language-font);
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  transition:
    transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    background 0.22s ease,
    border-color 0.22s ease,
    box-shadow 0.22s ease;
}
/* ============================================================
   21. ITEM LIGHT SWEEP
   ============================================================ */
.tamilai-language-item::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -80px;
  width: 55px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.75),
    transparent
  );
  transform: skewX(-20deg);
  opacity: 0;
  transition:
    left 0.5s ease,
    opacity 0.2s ease;
  pointer-events: none;
}
.tamilai-language-item:hover::before {
  left: calc(100% + 30px);
  opacity: 1;
}
/* ============================================================
   22. ITEM HOVER
   ============================================================ */
.tamilai-language-item:hover {
  transform: translateX(3px) translateY(-1px);
  background: linear-gradient(
    135deg,
    rgba(79, 114, 255, 0.08),
    rgba(120, 90, 255, 0.045)
  );
  border-color: rgba(79, 114, 255, 0.14);
  box-shadow: 0 5px 14px rgba(45, 65, 130, 0.06);
}
/* ============================================================
   23. ITEM ACTIVE
   ============================================================ */
.tamilai-language-item.active {
  background: linear-gradient(
    135deg,
    rgba(79, 114, 255, 0.13),
    rgba(125, 90, 255, 0.07)
  );
  border-color: rgba(79, 114, 255, 0.25);
  box-shadow:
    0 6px 16px rgba(79, 114, 255, 0.08),
    inset 0 1px 1px rgba(255, 255, 255, 0.6);
}
.tamilai-language-item.active:hover {
  transform: translateX(3px) translateY(-1px) scale(1.005);
}
/* ============================================================
   24. FLAG / LANGUAGE ICON
   ============================================================ */
.tamilai-language-flag {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: linear-gradient(
    145deg,
    rgba(120, 130, 150, 0.1),
    rgba(120, 130, 150, 0.045)
  );
  font-size: 21px;
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.7),
    0 2px 5px rgba(30, 40, 60, 0.04);
  transition:
    transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
    background 0.25s ease;
}
.tamilai-language-item:hover .tamilai-language-flag {
  transform: scale(1.08) rotate(-3deg);
  background: rgba(79, 114, 255, 0.1);
}
/* ============================================================
   25. LANGUAGE NAMES
   ============================================================ */
.tamilai-language-names {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* ============================================================
   26. NATIVE LANGUAGE NAME
   ============================================================ */
.tamilai-language-native {
  display: block;
  font-family: var(--tamilai-language-font);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--language-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s ease;
}
.tamilai-language-item:hover .tamilai-language-native {
  color: var(--language-accent);
}
/* ============================================================
   27. ENGLISH LANGUAGE NAME
   ============================================================ */
.tamilai-language-english {
  display: block;
  margin-top: 2px;
  font-family: var(--tamilai-language-font);
  font-size: 10px;
  font-weight: 450;
  line-height: 1.25;
  color: var(--language-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* ============================================================
   28. SELECTED CHECK
   ============================================================ */
.tamilai-language-check {
  width: 25px;
  height: 25px;
  flex: 0 0 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.55) rotate(-20deg);
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
  background: linear-gradient(145deg, #6685ff, #4f72ff);
  box-shadow:
    0 4px 10px rgba(79, 114, 255, 0.24),
    inset 0 1px 1px rgba(255, 255, 255, 0.45);
  transition:
    opacity 0.22s ease,
    transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.tamilai-language-item.active .tamilai-language-check {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}
/* ============================================================
   29. ACCESSIBILITY
   ============================================================ */
.tamilai-language-button:focus-visible,
.tamilai-language-close:focus-visible,
.tamilai-language-item:focus-visible {
  outline: 2px solid rgba(79, 114, 255, 0.55);
  outline-offset: 2px;
}
/* ============================================================
   30. MOBILE
   ============================================================ */
@media (max-width: 600px) {
  .sidebar-bottom-controls {
    min-height: 54px;
    padding: 5px 7px;
  }
  .language-control-host {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
  }
  .tamilai-language-button {
    width: 40px;
    height: 40px;
  }
  .tamilai-language-globe {
    font-size: 18px;
  }
  .tamilai-language-panel {
    left: auto;
    top: auto;
    right: auto;
    bottom: auto;
    width: min(300px, calc(100vw - 24px));
    max-height: min(520px, calc(100vh - 90px));
    border-radius: 20px;
  }
  .tamilai-language-list {
    max-height: calc(100vh - 180px);
  }
}
/* ============================================================
   31. VERY SMALL MOBILE
   ============================================================ */
@media (max-width: 380px) {
  .sidebar-bottom-controls {
    padding-left: 5px;
    padding-right: 5px;
  }
  .language-control-host {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }
  .tamilai-language-button {
    width: 38px;
    height: 38px;
  }
  .tamilai-language-panel {
    left: auto;
    top: auto;
    right: auto;
    bottom: auto;
    width: calc(100vw - 24px);
    padding: 11px;
  }
  .tamilai-language-item {
    min-height: 52px;
  }
}
/* ============================================================
   32. DARK MODE
   ------------------------------------------------------------
   Supports system dark mode without changing JavaScript.
   ============================================================ */
@media (prefers-color-scheme: dark) {
  :root {
    --language-text: #f2f4f8;
    --language-muted: #9da4b1;
    --language-surface: rgba(28, 31, 40, 0.9);
    --language-surface-strong: rgba(25, 28, 36, 0.97);
    --language-border: rgba(255, 255, 255, 0.1);
    --language-shadow:
      0 22px 65px rgba(0, 0, 0, 0.38), 0 8px 25px rgba(0, 0, 0, 0.22);
  }
  .tamilai-language-button {
    background: linear-gradient(
      145deg,
      rgba(45, 48, 58, 0.95),
      rgba(29, 32, 41, 0.88)
    );
    color: #f1f3f7;
    box-shadow:
      0 6px 16px rgba(0, 0, 0, 0.25),
      inset 0 1px 1px rgba(255, 255, 255, 0.08),
      inset 0 -2px 4px rgba(0, 0, 0, 0.18);
  }
  .tamilai-language-button:hover {
    background: linear-gradient(
      145deg,
      rgba(58, 62, 75, 0.98),
      rgba(34, 38, 50, 0.94)
    );
    border-color: rgba(110, 135, 255, 0.3);
  }
  .tamilai-language-panel {
    background: linear-gradient(
      145deg,
      rgba(31, 34, 43, 0.98),
      rgba(24, 27, 35, 0.96)
    );
    border-color: rgba(255, 255, 255, 0.09);
    box-shadow:
      0 25px 70px rgba(0, 0, 0, 0.42),
      inset 0 1px 1px rgba(255, 255, 255, 0.05);
  }
  .tamilai-language-header {
    border-bottom-color: rgba(255, 255, 255, 0.08);
  }
  .tamilai-language-close {
    background: rgba(255, 255, 255, 0.07);
    color: #cbd0da;
    border-color: rgba(255, 255, 255, 0.08);
  }
  .tamilai-language-close:hover {
    background: rgba(100, 125, 255, 0.15);
    color: #9db0ff;
  }
  .tamilai-language-item:hover {
    background: linear-gradient(
      135deg,
      rgba(100, 125, 255, 0.13),
      rgba(130, 100, 255, 0.07)
    );
    border-color: rgba(110, 135, 255, 0.18);
  }
  .tamilai-language-item.active {
    background: linear-gradient(
      135deg,
      rgba(100, 125, 255, 0.18),
      rgba(130, 100, 255, 0.1)
    );
    border-color: rgba(110, 135, 255, 0.28);
  }
  .tamilai-language-flag {
    background: linear-gradient(
      145deg,
      rgba(255, 255, 255, 0.08),
      rgba(255, 255, 255, 0.035)
    );
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.06);
  }
  .tamilai-language-item:hover .tamilai-language-flag {
    background: rgba(100, 125, 255, 0.14);
  }
}
/* ============================================================
   33. OPTIONAL APP DARK THEME SUPPORT
   ------------------------------------------------------------
   If TamilAI later uses a data-theme attribute,
   the language selector will follow it.
   ============================================================ */
html[data-theme="dark"] {
  --language-text: #f2f4f8;
  --language-muted: #9da4b1;
  --language-border: rgba(255, 255, 255, 0.1);
}
html[data-theme="dark"] .tamilai-language-button {
  background: linear-gradient(
    145deg,
    rgba(45, 48, 58, 0.95),
    rgba(29, 32, 41, 0.88)
  );
  color: #f1f3f7;
}
html[data-theme="dark"] .tamilai-language-panel {
  background: linear-gradient(
    145deg,
    rgba(31, 34, 43, 0.98),
    rgba(24, 27, 35, 0.96)
  );
  border-color: rgba(255, 255, 255, 0.09);
}
/* ============================================================
   34. REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .tamilai-language-button,
  .tamilai-language-globe,
  .tamilai-language-panel,
  .tamilai-language-item,
  .tamilai-language-flag,
  .tamilai-language-check,
  .tamilai-language-close {
    transition: none !important;
    animation: none !important;
  }
}
