/* ================= Base Styles ================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  font-family: "Segoe UI", sans-serif;
  background-color: #d9fdd3;
}

/* ================= Overlay ================= */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

/* ================= Onboarding Form ================= */
.onboarding {
  background: #fff;
  padding: 30px 40px;
  border-radius: 12px;
  text-align: center;
  width: 90%;
  max-width: 400px;
}

.onboarding input,
.onboarding button {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  border-radius: 8px;
  font-size: 1rem;
  border: 1px solid #ccc;
}

.onboarding button {
  background-color: #25d366;
  color: #fff;
  border: none;
  cursor: pointer;
}

.developer-credit {
  margin-top: 20px;
  font-size: 16px;
  color: #333;
  text-align: center;
  font-weight: 500;
  opacity: 0.9;
}

/* ================= Layout ================= */
.container {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

/* ========== Sidebar ========== */
.sidebar {
  width: 250px;
  background-color: #f0f2f5;
  border-right: 1px solid #ccc;
  padding: 20px;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.sidebar.hidden {
  display: none;
}

#userList {
  list-style: none;
  padding: 0;
}

.user-item {
  margin: 12px 0;
  font-size: 14px;
  color: #333;
}

.user-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-left {
  display: flex;
  align-items: center;
}

.online-dot {
  width: 10px;
  height: 10px;
  background-color: #25d366;
  border-radius: 50%;
  margin-right: 8px;
}

.video-call-btn {
  background: none;
  border: none;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.video-call-btn:hover {
  background-color: #e0f7e9;
}

.video-call-btn i {
  font-size: 18px;
  color: #25d366;
}

/* ========== Chatbox ========== */
.chatbox {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #e5ddd5;
  position: relative;
}

.chat-header {
  padding: 15px;
  background-color: #075e54;
  color: #fff;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.users-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: #fff;
  cursor: pointer;
}

.messages {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.message {
  display: flex;
  align-items: flex-end;
  margin-bottom: 10px;
}

.message img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-right: 8px;
}

.message-content {
  background-color: #dcf8c6;
  padding: 10px 15px;
  border-radius: 10px 10px 0 10px;
  max-width: 80%;
  font-size: 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message-content .meta {
  font-size: 11px;
  color: #555;
  margin-bottom: 5px;
}

.system-message {
  text-align: center;
  font-size: 13px;
  color: #888;
  font-style: italic;
  margin: 10px 0;
}

.typing-indicator {
  padding: 0 20px;
  font-style: italic;
  font-size: 13px;
  color: #888;
}

/* ========== Input Area ========== */
.input-area {
  display: flex;
  align-items: center;
  padding: 10px;
  border-top: 1px solid #ddd;
  background-color: #fff;
}

#messageInput {
  flex: 1;
  padding: 10px 12px;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 20px;
}

.input-area button {
  margin-left: 10px;
  padding: 10px 16px;
  background-color: #25d366;
  color: #fff;
  font-size: 1.2rem;
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

/* ================= Video Popup ================= */
.video-popup {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  overflow-y: auto;
}

.video-popup.hidden {
  display: none;
}

.popup-content {
  background: #111827;
  color: #f0f0f0;
  padding: 24px;
  border-radius: 16px;
  width: 98%;
  max-width: 1600px;
  max-height: 98vh;
  overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 24px;
  text-align: center;
  position: relative;
}

.popup-content h3 {
  font-size: 24px;
}

.video-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 24px;
}

.video-wrapper {
  width: 45%;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.video-wrapper video {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: black;
  border-radius: 12px;
  border: 3px solid #25d366;
  object-fit: cover;
}

.video-username {
  margin-top: 10px;
  font-size: 18px;
  font-weight: 600;
}

/* ========== Popup Controls ========== */
.popup-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
}

.popup-controls button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 16px;
  background-color: #1f2937;
  color: #f1f1f1;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.popup-controls button:hover {
  background-color: #374151;
}

.popup-controls button#callBtn {
  background-color: #10b981;
}

.popup-controls button#callBtn:hover {
  background-color: #059669;
}

.popup-controls button#disconnectBtn {
  background-color: #ef4444;
}

.popup-controls button#disconnectBtn:hover {
  background-color: #dc2626;
}

.close-btn {
  position: absolute;
  top: 10px;
  right: 15px;
  background: transparent;
  border: none;
  font-size: 24px;
  color: #f0f0f0;
  cursor: pointer;
}

.close-btn:hover {
  color: #f87171;
}

/* ================= Responsive Design ================= */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 60px;
    right: 0;
    height: calc(100% - 60px);
    z-index: 20;
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.2);
    background-color: #fff;
  }

  .container {
    flex-direction: column;
  }

  .message-content {
    max-width: 95%;
  }

  .input-area button {
    padding: 8px 12px;
  }
}

@media (max-width: 600px) {
  .popup-content {
    padding: 16px;
    width: 100%;
    max-height: 100vh;
  }

  .video-container {
    flex-direction: column;
    gap: 16px;
  }

  .video-wrapper {
    width: 100%;
  }

  .video-username {
    font-size: 16px;
    margin-top: 6px;
  }

  .popup-controls {
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
  }

  .popup-controls button {
    width: 100%;
    justify-content: center;
    padding: 12px 0;
  }

  .close-btn {
    font-size: 22px;
    right: 12px;
  }
}

@media (min-width: 1280px) {
  .popup-content {
    max-width: 1600px;
    max-height: 98vh;
  }

  .video-wrapper {
    width: 42%;
  }

  .video-username {
    font-size: 20px;
  }
}

/* ================= Emoji ================= */

.emoji-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
}

.input-area {
  display: flex;
  align-items: center;
  padding: 10px;
  border-top: 1px solid #ddd;
  background-color: #fff;
  gap: 10px;
}

.input-area button {
  padding: 10px 10px;
  background-color: #25d366;
  color: #fff;
  font-size: 1.2rem;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
}

#submitBtn {
  padding-left: 14px;
  padding-right: 14px;
  flex-shrink: 0;
}

.message-content div {
  font-size: 18px;
}

@media (max-width: 600px) {
  .chatbox {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
  }

  .messages {
    flex: 1;
    overflow-y: auto;
  }

  .input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
  }

  #messageInput {
    flex: 1;
    min-width: 0;
  }

  #submitBtn {
    flex-shrink: 0;
    margin-left: 0px;
  }
}

/* ================= Incoming call popup ================= */

.call-popup.hidden {
  display: none !important;
}

.call-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #ffffff;
  border-radius: 16px;
  padding: 24px 32px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  z-index: 2000;
  width: 90%;
  max-width: 400px;
  text-align: center;
  animation: fadeIn 0.3s ease-in-out;
}

.call-text {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: #333;
}

.call-buttons {
  display: flex;
  justify-content: center;
  gap: 20px;
}

.btn {
  border: none;
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}

.btn.accept {
  background-color: #28c76f;
  color: white;
}

.btn.accept:hover {
  background-color: #22b05f;
  box-shadow: 0 0 12px rgba(40, 199, 111, 0.6);
}

.btn.reject {
  background-color: #ea5455;
  color: white;
}

.btn.reject:hover {
  background-color: #d63d3e;
  box-shadow: 0 0 12px rgba(234, 84, 85, 0.6);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, -60%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

/* ================= Custom alert popup ================= */

.custom-alert {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.custom-alert-box {
  background-color: white;
  padding: 24px 32px;
  border-radius: 10px;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.25);
  text-align: center;
  max-width: 90%;
  width: 400px;
  font-family: sans-serif;
}

.custom-alert-box p {
  font-size: 16px;
  margin-bottom: 20px;
}

#customAlertOkBtn {
  background-color: #4caf50;
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

#customAlertOkBtn:hover {
  background-color: #45a049;
}

.hidden {
  display: none !important;
}
