
/* ── Live Translated Chat Panel ── */
.chat-overlay {
  position: absolute;
  right: 22px;
  bottom: 112px;
  width: min(380px, calc(100vw - 28px));
  max-height: min(66vh, 560px);
  background:
    linear-gradient(180deg, rgba(12, 18, 33, 0.96), rgba(6, 10, 24, 0.98));
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  border: 1px solid rgba(34, 211, 238, 0.28);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 28px 80px rgba(0,0,0,0.55),
    0 0 0 1px rgba(255,255,255,0.05) inset,
    0 0 38px rgba(34, 211, 238, 0.12);
  transition: all 0.3s ease;
  z-index: 100;
  overflow: hidden;
  color: #f8fafc;
}

.chat-overlay.hidden {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

.chat-header {
  padding: 14px 16px;
  background:
    linear-gradient(90deg, rgba(14, 165, 233, 0.18), rgba(99, 102, 241, 0.12));
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: grab;
}

.chat-header:active {
  cursor: grabbing;
}

.chat-header h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: #e0f2fe;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  pointer-events: none;
  letter-spacing: 0;
}

.chat-header h3 svg,
.chat-header button svg,
.chat-input-area button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-lang-select {
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 0.8rem;
  outline: none;
  cursor: pointer;
}

.chat-header button {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 10px;
  color: #cbd5e1;
  cursor: pointer;
  opacity: 1;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.chat-header button:hover {
  background: rgba(244, 63, 94, 0.18);
  color: #ffffff;
  transform: scale(1.04);
}

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 240px;
}

.chat-msg {
  background:
    linear-gradient(180deg, rgba(30, 41, 59, 0.92), rgba(15, 23, 42, 0.94));
  padding: 12px 13px;
  border-radius: 14px;
  font-size: 0.92rem;
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.24);
  color: #f8fafc;
}

.chat-msg.me {
  background:
    linear-gradient(180deg, rgba(6, 78, 86, 0.9), rgba(8, 47, 73, 0.94));
  border: 1px solid rgba(34, 211, 238, 0.42);
  box-shadow: 0 14px 30px rgba(6, 182, 212, 0.14), 0 0 0 1px rgba(255,255,255,0.04) inset;
}

.chat-msg-header {
  font-size: 0.76rem;
  color: #bae6fd;
  margin-bottom: 7px;
  display: flex;
  justify-content: space-between;
  font-weight: 800;
}

.chat-msg-original {
  font-weight: 700;
  margin-bottom: 7px;
  color: #f8fafc;
  line-height: 1.45;
}

.chat-msg-translated {
  color: #67e8f9;
  font-style: italic;
  font-weight: 700;
  line-height: 1.45;
  transition: all 0.3s ease;
}

/* ── Loading Animation for Pending Translation ── */
.translating-text {
  color: #a5b4fc !important;
  display: flex;
  align-items: center;
  gap: 4px;
}

.typing-dots {
  display: inline-flex;
}

.typing-dots span {
  animation: typing 1.4s infinite both;
  font-size: 1.2rem;
  line-height: 1;
  color: #22d3ee;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-3px); opacity: 1; }
}

.chat-input-area {
  padding: 14px;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  display: flex;
  gap: 10px;
  background: rgba(2, 6, 23, 0.62);
}

/* ── Typing Indicator Bar ── */
.chat-typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 18px;
  background: rgba(34, 211, 238, 0.07);
  border-top: 1px solid rgba(34, 211, 238, 0.15);
  font-size: 0.78rem;
  color: #67e8f9;
  font-style: italic;
  transition: all 0.25s ease;
  overflow: hidden;
  max-height: 38px;
}

.chat-typing-indicator.hidden {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  border-top-color: transparent;
  pointer-events: none;
}

.chat-typing-indicator .typing-dots {
  display: inline-flex;
  gap: 2px;
  flex-shrink: 0;
}

.chat-typing-indicator .typing-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: rtl;       /* makes Arabic + · + Portuguese render naturally */
  unicode-bidi: plaintext;
}


.chat-input-area input {
  flex: 1;
  background: rgba(2, 6, 23, 0.86);
  border: 1px solid rgba(34, 211, 238, 0.45);
  color: #ffffff;
  border-radius: 999px;
  padding: 11px 14px;
  font-size: 0.92rem;
  font-weight: 600;
  outline: none;
  min-width: 0;
}

.chat-input-area input::placeholder {
  color: #94a3b8;
  font-weight: 500;
}

.chat-input-area input:focus {
  border-color: #67e8f9;
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.16);
}

.chat-input-area button {
  background: linear-gradient(135deg, #22d3ee, #14b8a6);
  color: #03131c;
  border: none;
  border-radius: 999px;
  padding: 0 15px;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  box-shadow: 0 10px 24px rgba(20, 184, 166, 0.28);
  transition: transform 0.18s ease, filter 0.18s ease, box-shadow 0.18s ease;
}

.chat-input-area button:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(20, 184, 166, 0.36);
}

@media (max-width: 768px) {
  .chat-overlay {
    right: 10px;
    left: 10px;
    bottom: 86px;
    width: auto;
    max-height: 58vh;
  }

  .chat-scroll {
    min-height: 180px;
    padding: 14px;
  }

  .chat-input-area {
    padding: 12px;
  }

  .chat-input-area button span {
    display: none;
  }
}
