.call-overlay.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.call-window {
  background: #1c1e21;
  border-radius: 16px;
  overflow: hidden;
  width: 90vw;
  max-width: 1200px;
  height: 85vh;
  max-height: 85vh;
  min-height: 400px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.8);
  animation: slideUp 0.3s ease-out;
}

.call-video-container {
  flex: 1;
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}

.remote-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  max-height: 100%;
}

@media (max-width: 768px) {
  .call-window {
    width: 95vw;
    height: 90vh;
    max-height: 90vh;
    min-height: 500px;
    border-radius: 12px;
  }

  .call-header {
    padding: 12px 16px;
  }

  #activeCallUsername {
    font-size: 16px;
  }

  #activeCallStatus {
    font-size: 12px;
  }

  .local-video {
    width: 120px;
    height: 90px;
    bottom: 16px;
    right: 16px;
    border-radius: 8px;
  }

  .call-controls {
    padding: 16px;
    gap: 12px;
  }

  .call-control-btn {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }

  .call-overlay.minimized {
    right: 12px;
    bottom: 12px;
    width: 280px;
    height: 200px;
  }

  .call-overlay.minimized .call-control-btn {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }
}

@media (max-width: 480px) {
  .call-window {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    min-height: 100vh;
    border-radius: 0;
  }

  .incoming-call-card {
    min-width: 280px;
    padding: 32px 24px;
    margin: 0 16px;
  }

  .incoming-call-avatar {
    width: 64px;
    height: 64px;
    font-size: 32px;
    margin-bottom: 16px;
  }

  #incomingCallerName {
    font-size: 20px;
  }

  .incoming-call-buttons {
    flex-direction: row;
    gap: 12px;
  }

  .call-action-btn {
    padding: 12px 16px;
    flex: 1;
  }

  .call-action-btn span:first-child {
    font-size: 24px;
  }

  .call-header {
    padding: 10px 12px;
  }

  .call-header-btn {
    width: 32px;
    height: 32px;
    font-size: 18px;
  }

  .local-video {
    width: 100px;
    height: 75px;
    bottom: 80px;
    right: 12px;
    border-radius: 6px;
    border: 1px solid #3a3b3c;
  }

  .call-controls {
    padding: 12px;
    gap: 8px;
  }

  .call-control-btn {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }

  .call-overlay.minimized {
    right: 8px;
    bottom: 8px;
    width: calc(100vw - 16px);
    max-width: 240px;
    height: 160px;
  }

  .call-overlay.minimized .call-header {
    padding: 6px 8px;
  }

  .call-overlay.minimized #activeCallUsername {
    font-size: 12px;
  }

  .call-overlay.minimized #activeCallStatus {
    font-size: 10px;
  }

  .call-overlay.minimized .call-controls {
    padding: 8px;
    gap: 6px;
  }

  .call-overlay.minimized .call-control-btn {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }
}

@media (max-height: 600px) {
  .call-window {
    height: 95vh;
    max-height: 95vh;
    min-height: 300px;
  }

  .call-header {
    padding: 10px 16px;
  }

  .call-controls {
    padding: 12px;
  }

  .call-control-btn {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }

  .local-video {
    width: 160px;
    height: 120px;
    bottom: 80px;
  }
}

@media (max-height: 400px) {
  .call-window {
    min-height: 100vh;
    height: 100vh;
    max-height: 100vh;
  }

  .local-video {
    width: 120px;
    height: 90px;
    bottom: 60px;
  }

  .call-controls {
    padding: 8px;
    gap: 6px;
  }

  .call-control-btn {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
}

.call-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  overflow: hidden;
}

.call-header,
.call-controls {
  flex-shrink: 0;
}

body.call-active {
  overflow: hidden;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  font-size: 14px;
  display: grid;
  grid-template-columns: 340px 1fr;
  height: 100vh;
  background: #f0f2f5;
  color: #050505;
}

#friendsPanel {
  background: #fff;
  border-right: 1px solid #e4e6eb;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#friendsPanel h3 {
  padding: 20px 16px 12px 16px;
  font-size: 24px;
  font-weight: 700;
  color: #050505;
}

#searchBar {
  padding: 0 16px 12px 16px;
}

#searchInput {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 20px;
  background: #f0f2f5;
  font-size: 14px;
  outline: none;
  transition: background 0.2s;
}

#searchInput:focus {
  background: #e4e6eb;
}

#searchInput::placeholder {
  color: #65676b;
}

#friendsList {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}

.friend {
  display: flex;
  align-items: center;
  padding: 12px 8px;
  cursor: pointer;
  border-radius: 8px;
  margin-bottom: 2px;
  transition: background 0.2s;
  position: relative;
}

.friend:hover {
  background: #f0f2f5;
}

.friend.active {
  background: #e7f3ff;
}

.friend-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 20px;
  flex-shrink: 0;
  position: relative;
}

.friend-avatar .status-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #31a24c;
  border: 2px solid #fff;
  display: none;
}

.friend.online .status-dot {
  display: block;
}

.friend-info {
  flex: 1;
  margin-left: 12px;
  overflow: hidden;
}

.friend-name {
  font-weight: 600;
  font-size: 15px;
  color: #050505;
  margin-bottom: 2px;
}

.friend-last-message {
  font-size: 13px;
  color: #65676b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#chatPanel {
  display: flex;
  flex-direction: column;
  background: #fff;
  height: 100vh;
  position: relative;
}

#chatHeader {
  padding: 12px 20px;
  border-bottom: 1px solid #e4e6eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  flex-shrink: 0;
}

#chatHeaderLeft {
  display: flex;
  align-items: center;
  gap: 12px;
}

#chatTitle {
  font-size: 17px;
  font-weight: 600;
  color: #050505;
}

#onlineStatus {
  font-size: 12px;
  color: #65676b;
}

#chatHeaderButtons {
  display: flex;
  gap: 8px;
}

.header-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #f0f2f5;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  font-size: 18px;
}

.header-btn:hover {
  background: #e4e6eb;
}

.header-btn:active {
  background: #d8dadf;
}

#messagesContainer {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column-reverse;
  background: #f0f2f5;
  position: relative;
}

#loadingIndicator {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  display: none;
  align-items: center;
  gap: 8px;
  z-index: 100;
}

#loadingIndicator.show {
  display: flex;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#messagesList {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  position: relative;
  max-width: 70%;
}

.message.sent {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.received {
  align-self: flex-start;
}

.message-bubble {
  padding: 8px 12px;
  border-radius: 18px;
  position: relative;
  word-wrap: break-word;
  max-width: 100%;
}

.message.sent .message-bubble {
  background: #0084ff;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message.received .message-bubble {
  background: #e4e6eb;
  color: #050505;
  border-bottom-left-radius: 4px;
}

.message-content {
  font-size: 15px;
  line-height: 1.4;
}

.message.unsent .message-content {
  font-style: italic;
  opacity: 0.6;
}

.message.edited .message-content::after {
  content: " (edited)";
  font-size: 11px;
  opacity: 0.7;
  margin-left: 4px;
}

.message.forwarded .message-bubble::before {
  content: " Forwarded";
  display: block;
  font-size: 11px;
  opacity: 0.7;
  margin-bottom: 4px;
  font-style: italic;
}

.reply-preview {
  background: rgba(0, 0, 0, 0.1);
  padding: 6px 8px;
  border-radius: 8px;
  margin-bottom: 6px;
  border-left: 3px solid rgba(0, 0, 0, 0.3);
  font-size: 12px;
}

.message.sent .reply-preview {
  background: rgba(255, 255, 255, 0.2);
  border-left-color: rgba(255, 255, 255, 0.5);
}

.message-meta {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.read-status {
  font-size: 11px;
  margin-top: 2px;
  text-align: right;
}

.message.sent .read-status {
  color: #0084ff;
}

.reactions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.reaction {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  background: #fff;
  border: 1px solid #e4e6eb;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message-actions {
  position: absolute;
  top: -12px;
  right: 8px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: row;
  gap: 4px;
  padding: 4px;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.2s;
}

.message.received .message-actions {
  left: 8px;
  right: auto;
}

.message-actions.visible {
  display: flex;
  opacity: 1;
}

.action-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  font-size: 16px;
}

.action-btn:hover {
  background: #f0f2f5;
}

.reaction-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  padding: 8px 12px;
  display: none;
  gap: 4px;
  z-index: 20;
}

.message.received .reaction-picker {
  left: 0;
  right: auto;
}

.reaction-picker.show {
  display: flex;
}

.reaction-option {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.reaction-option:hover {
  transform: scale(1.3);
  background: #f0f2f5;
}

#typingIndicator {
  padding: 8px 20px;
  font-style: italic;
  color: #65676b;
  min-height: 32px;
  font-size: 13px;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

#inputArea {
  padding: 12px 20px;
  background: #fff;
  border-top: 1px solid #e4e6eb;
  position: sticky;
  bottom: 0;
  flex-shrink: 0;
}

#replyingTo {
  padding: 8px 12px;
  background: #e7f3ff;
  border-left: 3px solid #0084ff;
  border-radius: 4px;
  font-size: 13px;
  display: none;
  margin-bottom: 8px;
  position: relative;
}

#replyingTo.show {
  display: block;
}

#cancelReplyBtn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#cancelReplyBtn:hover {
  background: rgba(0, 0, 0, 0.1);
}

#inputRow {
  display: flex;
  gap: 8px;
  align-items: center;
}

#messageInput {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 20px;
  background: #f0f2f5;
  font-size: 15px;
  outline: none;
  font-family: inherit;
  resize: none;
  max-height: 100px;
}

#messageInput:focus {
  background: #e4e6eb;
}

#sendBtn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #0084ff;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background 0.2s;
}

#sendBtn:hover {
  background: #0073e6;
}

#sendBtn:active {
  background: #0062cc;
}

#modalOverlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 999;
  backdrop-filter: blur(2px);
}

#modalOverlay.show {
  display: block;
}

#forwardModal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: 12px;
  padding: 24px;
  z-index: 1000;
  min-width: 320px;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

#forwardModal.show {
  display: block;
}

#forwardModal h3 {
  margin-bottom: 16px;
  font-size: 20px;
}

#forwardList {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 16px;
}

#forwardList button {
  width: 100%;
  padding: 12px;
  margin: 4px 0;
  border: 1px solid #e4e6eb;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s;
}

#forwardList button:hover {
  background: #f0f2f5;
}

.modal-close-btn {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: #e4e6eb;
  cursor: pointer;
  font-weight: 600;
}

.modal-close-btn:hover {
  background: #d8dadf;
}

.message-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  padding: 8px 0;
  display: none;
  min-width: 160px;
  z-index: 20;
}

.message.received .message-menu {
  left: 0;
  right: auto;
}

.message-menu.show {
  display: block;
}

.menu-item {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.menu-item:hover {
  background: #f0f2f5;
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #bcc0c4;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8abad;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #65676b;
  font-size: 16px;
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.3;
}
.call-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
}

.call-overlay.show {
  display: flex;
}

.incoming-call-card {
  background: #fff;
  border-radius: 20px;
  padding: 40px 32px;
  text-align: center;
  min-width: 320px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.incoming-call-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  margin: 0 auto 20px;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 20px rgba(102, 126, 234, 0);
  }
}

#incomingCallerName {
  font-size: 24px;
  font-weight: 700;
  color: #050505;
  margin-bottom: 8px;
}

#incomingCallType {
  font-size: 14px;
  color: #65676b;
  margin-bottom: 32px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

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

.call-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 24px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
}

.call-action-btn span:first-child {
  font-size: 28px;
}

.call-action-btn.accept {
  background: #31a24c;
  color: #fff;
}

.call-action-btn.accept:hover {
  background: #2d8f44;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(49, 162, 76, 0.4);
}

.call-action-btn.reject {
  background: #f02849;
  color: #fff;
}

.call-action-btn.reject:hover {
  background: #d32341;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(240, 40, 73, 0.4);
}

.call-window {
  background: #1c1e21;
  border-radius: 16px;
  overflow: hidden;
  width: 90vw;
  max-width: 1200px;
  height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.8);
  animation: slideUp 0.3s ease-out;
}

.call-header {
  background: #242527;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #3a3b3c;
}

.call-status-info {
  color: #fff;
}

#activeCallUsername {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

#activeCallStatus {
  font-size: 13px;
  color: #b0b3b8;
}

.call-header-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #3a3b3c;
  color: #fff;
  cursor: pointer;
  font-size: 20px;
  font-weight: 300;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.call-header-btn:hover {
  background: #4e4f50;
}

.call-video-container {
  flex: 1;
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.remote-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.local-video {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 240px;
  height: 180px;
  border-radius: 12px;
  object-fit: cover;
  background: #1c1e21;
  border: 2px solid #3a3b3c;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.call-controls {
  background: #242527;
  padding: 24px;
  display: flex;
  gap: 16px;
  justify-content: center;
  border-top: 1px solid #3a3b3c;
}

.call-control-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: #3a3b3c;
  color: #fff;
  cursor: pointer;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.call-control-btn:hover {
  background: #4e4f50;
}

.call-control-btn.end-call {
  background: #f02849;
}

.call-control-btn.end-call:hover {
  background: #d32341;
}

.call-overlay.minimized {
  top: auto;
  left: auto;
  right: 20px;
  bottom: 20px;
  width: 320px;
  height: 240px;
  max-width: none;
  max-height: none;
  background: transparent;
  backdrop-filter: none;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  pointer-events: none;
}

.call-overlay.minimized .call-window {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  animation: none;
  transform: translateX(0) translateY(0) scale(1);
  pointer-events: auto;
}

.call-overlay.minimized .call-header {
  padding: 8px 12px;
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.call-overlay.minimized #activeCallUsername {
  font-size: 14px;
  margin-bottom: 2px;
}

.call-overlay.minimized #activeCallStatus {
  font-size: 11px;
}

.call-overlay.minimized .call-header-btn {
  width: 28px;
  height: 28px;
  font-size: 16px;
}

.call-overlay.minimized .call-video-container {
  display: none;
  flex: 0;
}

.call-overlay.minimized .local-video,
.call-overlay.minimized .remote-video {
  display: none;
}

.call-overlay.minimized .call-controls {
  padding: 12px;
  gap: 8px;
  border-top: none;
  border-radius: 0 0 12px 12px;
  background: #242527;
}

.call-overlay.minimized .call-control-btn {
  width: 40px;
  height: 40px;
  font-size: 20px;
}