/* =========================
   Core Chat Modal
   ========================= */
.core-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(0, 0, 0, 0.6);
  overflow: hidden;
  transition: opacity 0.3s ease;
}

.core-modal.show {
  display: flex;
  justify-content: center;
  align-items: stretch; /* full height */
  opacity: 1;
}

/* =========================
   Fullscreen Chat Dialog
   ========================= */
.core-dialog.core-fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: 100%;
  max-height: 100%;
  border-radius: 0;
  background: linear-gradient(135deg, #0f0f0f, #1e1e2f);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  animation: fadeIn 0.3s ease;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
}

/* =========================
   Header
   ========================= */
.core-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(135deg, #6a0dad, #8a2be2, #da70d6);
  color: white;
  border-bottom: 2px solid #4b0082;
  box-shadow: 0 4px 15px rgba(138, 43, 226, 0.5);
}

.chat-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  margin-right: 12px;
  box-shadow: 0 0 10px rgba(138, 43, 226, 0.8);
  transition: box-shadow 0.3s ease;
}

.chat-avatar:hover {
  box-shadow: 0 0 20px rgba(138, 43, 226, 1);
}

.chat-info .chat-name {
  margin: 0;
  font-size: 1.1rem;
  font-weight: bold;
}

.chat-status {
  font-size: 0.85rem;
  opacity: 0.9;
}

.chat-status.online {
  color: #4caf50;
}

/* =========================
   Messages Body
   ========================= */
.core-body {
  flex: 1; /* fill space above footer */
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto; /* scrollable */
  background-color: #111;
  scroll-behavior: smooth;
}

.message {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 15px;
  font-size: 0.9rem;
  word-wrap: break-word;
  animation: fadeIn 0.5s ease forwards;
  line-height: 1.4;
}

.message.sent {
  background: linear-gradient(135deg, #8a2be2, #da70d6);
  color: white;
  align-self: flex-end;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.message.received {
  background: #444;
  color: white;
  align-self: flex-start;
  margin-right: auto;
  border-bottom-left-radius: 4px;
}

.message-time {
  display: block;
  font-size: 0.7rem;
  margin-top: 2px;
  opacity: 0.7;
  text-align: right;
}

.message .chat-audio {
  width: 150px; /* smaller width */
  height: 30px; /* smaller height */
  margin-top: 6px;
  border-radius: 6px;
}

/* =========================
   Footer
   ========================= */
.core-footer {
  position: sticky;
  bottom: 0;
  z-index: 10;
}

#chatInput {
  flex: 1;
  min-width: 0; /* Important for flex shrinking */
}

#chatInput:focus {
  outline: 2px solid #6a11cb;
}

#translateLang,
#sendBtn {
  height: 42px;
  padding: 0 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  color: white;
}

#translateLang {
  background: #1f1f2f;
}

#sendBtn {
  background: linear-gradient(135deg, #6a11cb, #2575fc);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#sendBtn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 12px rgba(97, 59, 224, 0.7);
}

/* =========================
   Scrollbar
   ========================= */
.core-body::-webkit-scrollbar {
  width: 8px;
}

.core-body::-webkit-scrollbar-thumb {
  background-color: #555;
  border-radius: 4px;
}

.core-body::-webkit-scrollbar-track {
  background-color: #222;
}

.chat-input {
  background-color: #222 !important;
  color: #fff !important;
  border: 1px solid #555 !important;
  border-radius: 6px;
}

.chat-input::placeholder {
  color: #aaa !important;
}

/* =========================
   Animations
   ========================= */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.media-popup {
  position: fixed;
  bottom: 60px; /* above footer */
  right: 20px;
  background: #222;
  border-radius: 8px;
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 6px;
  z-index: 1000000; /* higher than modal */
}
.media-popup button {
  background: #555;
  color: #fff;
  border: none;
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
}

.message.sent {
  display: flex;
  justify-content: flex-end; /* Align to right */
  margin-bottom: 8px;
}

.chat-images-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 250px;
}

.chat-images-group img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  position: relative;
}

.chat-images-group .overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 80px;
  height: 80px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 20px;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 8px;
}

#imageModal {
  display: none;
  position: fixed;
  z-index: 2000000;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  justify-content: center;
  align-items: center;
}

#imageModal img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
}

#imageModal .close,
#imageModal .prev,
#imageModal .next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: #fff;
  font-size: 32px;
  font-weight: bold;
  cursor: pointer;
  user-select: none;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 12px;
  border-radius: 6px;
}

#imageModal .close {
  top: 20px;
  right: 30px;
  transform: none;
}

#imageModal .prev {
  left: 20px;
}
#imageModal .next {
  right: 20px;
}

/* Received images aligned left */
.message.received .chat-images-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-start; /* left side */
}

.message.received .chat-images-group img {
  max-width: 120px;
  max-height: 120px;
  border-radius: 8px;
  cursor: pointer;
}

#videoModal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#videoModal .modal-content {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#videoModal video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
}

#videoModal .close {
  position: absolute;
  top: 0;
  right: 15px;
  font-size: 28px;
  color: white;
  cursor: pointer;
  z-index: 10000;
}

.chat-video {
  max-width: 200px; /* adjust thumbnail width */
  max-height: 150px; /* adjust thumbnail height */
  border-radius: 8px;
  object-fit: cover;
}

.recording-indicator {
  display: inline-block;
  width: 10px;
  height: 10px;
  background: red;
  border-radius: 50%;
  margin-right: 5px;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%,
  50%,
  100% {
    opacity: 1;
  }
  25%,
  75% {
    opacity: 0;
  }
}

#voiceLang {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #ccc;
  background-color: #fff;
  font-size: 14px;
  color: #333;
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}

#voiceLang:hover {
  border-color: #007bff;
}

#voiceLang:focus {
  border-color: #007bff;
  box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
}

#voiceLang option {
  padding: 6px;
}

/* Ensure modals are always on top */
.modal {
  z-index: 999999 !important;
}
