/* Telegram-like Chat App Styling */

:root {
  --tg-primary: #3390ec;
  --tg-secondary: #8774e1;
  --tg-button: #2481cc;
  --tg-bg: #f5f5f5;
  --tg-sidebar: #ffffff;
  --tg-msg-out: #eeffde;
  --tg-msg-in: #ffffff;
  --tg-text-primary: #000000;
  --tg-text-secondary: #707579;
  --tg-border: #dadce0;
  --tg-online: #4fae4e;
  --tg-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --tg-radius: 8px;
  --tg-transition: all 0.2s ease;
}

html {
  max-width: 100vw;
  overflow-x: hidden;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--tg-bg);
  color: var(--tg-text-primary);
}

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

body {
  display: flex;
  overflow: hidden;
  width: 100%;
  height: 100vh;
  height: 100svh;
}

/* Sidebar Styling */
#sidebar {
  width: 280px;
  background: var(--tg-sidebar);
  color: var(--tg-text-primary);
  padding: 12px;
  box-sizing: border-box;
  border-right: 1px solid var(--tg-border);
  overflow-y: auto;
  transition: var(--tg-transition);
  box-shadow: var(--tg-shadow);
}

#sidebar h4 {
  color: var(--tg-text-secondary);
  margin-top: 0;
  font-weight: 500;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 16px 16px 8px;
}

/* sidebar */
#user-list {
  margin-top: 10px;
}

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

.user-item.unread::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--tg-primary);
  display: block;
}

.user-item:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.user-item.current-user {
  background-color: rgba(51, 144, 236, 0.08);
  border-bottom: 1px solid var(--tg-border);
  margin-bottom: 28px;
  padding: 10px 12px;
  cursor: default;
  position: relative;
}

.user-item.current-user::after {
  content: "";
  position: absolute;
  right: 0;
  left: 0;
  bottom: -20px;
  width: 100%;
  height: 1px;
  background-color: var(--tg-border);
}

.user-item.current-user:hover {
  background-color: rgba(51, 144, 236, 0.1);
}

.user-item.current-user .user-name {
  font-weight: 600;
  color: var(--tg-primary);
}

.user-item.current-user .user-avatar {
  width: 48px;
  height: 48px;
  font-size: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.active-chat {
  background-color: rgba(51, 144, 236, 0.1);
}

.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  margin-right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 500;
  color: white;
  flex-shrink: 0;
}

.user-details {
  flex: 1;
  overflow: hidden;
}

.user-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-status {
  font-size: 12px;
  color: var(--tg-text-secondary);
  display: flex;
  align-items: center;
  margin-top: 2px;
}

.online-dot {
  width: 8px;
  height: 8px;
  background-color: var(--tg-online);
  border-radius: 50%;
  margin-right: 4px;
  display: inline-block;
}

.separator {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--tg-text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  margin-top: 10px;
}

/* Main chat container */
#chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: white;
  overflow: hidden;
  box-shadow: var(--tg-shadow);
}

/* Add this to your CSS for offline dot indicator */
.offline-dot {
  width: 8px;
  height: 8px;
  background-color: #a0a0a0;
  border-radius: 50%;
  margin-right: 4px;
  display: inline-block;
}

/* Make the unread indicator more prominent */
.user-item.unread::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--tg-primary);
  box-shadow: 0 0 0 2px white;
  display: block;
  z-index: 2;
}

/* Chat area styling */
.chat-box {
  flex: 1;
  display: flex;
  flex-direction: column-reverse;
  overflow-y: auto;
  padding: 20px;
  background: #e6ebee;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23d4dbde' fill-opacity='0.4'%3E%3Cpath opacity='.5' d='M96 95h4v1h-4v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9zm-1 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm9-10v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm9-10v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm9-10v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  scroll-behavior: smooth;
}

.msg-left,
.msg-right {
  max-width: 75%;
  padding: 8px 12px;
  margin: 2px 0;
  border-radius: 12px;
  line-height: 1.4;
  position: relative;
  word-wrap: break-word;
}

.msg-left {
  background-color: var(--tg-msg-in);
  color: var(--tg-text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
  margin-right: auto;
}

.msg-right {
  background-color: var(--tg-msg-out);
  color: var(--tg-text-primary);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
  margin-left: auto;
}

/* Input bar styling */
#input-bar {
  display: flex;
  padding: 8px 12px;
  border-top: 1px solid var(--tg-border);
  gap: 8px;
  background-color: white;
  align-items: center;
}

#message {
  flex: 1;
  padding: 10px 14px;
  font-size: 15px;
  border: 1px solid var(--tg-border);
  border-radius: 22px;
  outline: none;
  min-width: 100px;
  transition: var(--tg-transition);
}

#message:focus {
  border-color: var(--tg-primary);
}

button {
  background-color: transparent;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 8px;
  border-radius: 50%;
  transition: var(--tg-transition);
  color: var(--tg-text-secondary);
}

#send {
  background-color: var(--tg-primary);
  color: white;
  font-weight: bold;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#send svg {
  width: 100%;
  height: 100%;
}

#send:hover {
  background-color: var(--tg-button);
}

#emoji-btn,
#gif-btn,
#img-btn {
  padding: 8px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
}

#emoji-btn:hover,
#gif-btn:hover,
#img-btn:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--tg-primary);
}

/* Emoji picker styling */
#emoji-picker {
  position: absolute;
  bottom: 65px;
  right: 16px;
  z-index: 10;
  display: none;
  border-radius: var(--tg-radius);
  box-shadow: var(--tg-shadow);
}

/* GIF box styling */
#giphy-box {
  position: absolute;
  bottom: 65px;
  left: 16px;
  background: white;
  border-radius: var(--tg-radius);
  box-shadow: var(--tg-shadow);
  padding: 12px;
  display: none;
  z-index: 10;
  width: 300px;
}

#giphy-box input {
  width: calc(100% - 16px);
  padding: 8px;
  border: 1px solid var(--tg-border);
  border-radius: 20px;
  margin-bottom: 8px;
  outline: none;
}

/* Initial overlay styling */
#overlay {
  position: fixed;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

#modal {
  background: white;
  padding: 24px;
  margin: 0 10px;
  border-radius: 12px;
  text-align: center;
  box-shadow: var(--tg-shadow);
  max-width: 400px;
  width: 90%;
}

#modal h2 {
  margin-top: 0;
  color: var(--tg-text-primary);
}

#username-input {
  width: 100%;
  padding: 12px;
  margin: 16px 0;
  font-size: 16px;
  border: 1px solid var(--tg-border);
  border-radius: var(--tg-radius);
  box-sizing: border-box;
  outline: none;
}

#start-chat {
  background-color: var(--tg-primary);
  color: white;
  padding: 10px 20px;
  font-size: 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
}

.timestamp {
  font-size: 10px;
  color: var(--tg-text-secondary);
  display: inline-block;
  position: relative;
  top: 2px;
}

/* Add chat header styling */
#chat-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background-color: white;
  border-bottom: 1px solid var(--tg-border);
}

.header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 500;
  font-size: 18px;
  margin-right: 12px;
}

.header-info {
  flex: 1;
}

.header-name {
  font-weight: 600;
  font-size: 16px;
  color: var(--tg-text-primary);
}

.header-status {
  font-size: 13px;
  color: var(--tg-text-secondary);
  display: flex;
  align-items: center;
}

.back-arrow {
  display: none;
}

.header-call-btn {
  display: flex;
  justify-content: center;
  align-items: center;
}

.header-back-btn {
  display: none;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  margin-right: 8px;
  border-radius: 50%;
  color: var(--tg-text-secondary);
  font-size: 20px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--tg-transition);
}

.header-back-btn:hover {
  background-color: rgba(51, 144, 236, 0.1);
  color: var(--tg-primary);
}

/* Responsive design */

@media (max-width: 768px) {
  body {
    overflow: hidden;
  }

  #sidebar {
    width: 100%;
    height: 100%;
    position: absolute;
    left: -100%;
    z-index: 100;
    transition: left 0.3s ease;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
  }

  #sidebar.open {
    left: 0;
  }

  #chat-container {
    width: 100%;
    max-width: 100%;
  }

  #chat-header {
    padding: 10px;
  }

  .header-back-btn {
    display: flex;
  }

  #user-list {
    margin-top: 46px;
  }

  /* Add menu button to header */
  .menu-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 32px;
    height: 32px;
    margin-right: 12px;
    padding: 4px;
    cursor: pointer;
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 4px;
    z-index: 99;
  }

  .menu-btn span {
    display: block;
    width: 20px;
    height: 2px;
    margin: 2px 0;
    background-color: var(--tg-primary);
    border-radius: 1px;
  }

  .menu-btn:hover {
    background-color: rgba(51, 144, 236, 0.1);
  }

  .menu-btn:hover span {
    background-color: var(--tg-button);
  }

  .msg-left,
  .msg-right {
    max-width: 85%;
    padding: 6px 10px;
  }

  #input-bar {
    padding: 6px 8px;
  }

  #message {
    font-size: 14px;
    padding: 8px 12px;
  }

  #send {
    width: 40px;
    height: 40px;
  }

  /* Make the emoji, gif, and image buttons smaller on mobile */
  #emoji-btn,
  #gif-btn,
  #img-btn {
    padding: 3px;
  }

  /* Position emoji picker better on mobile */
  #emoji-picker {
    bottom: 55px;
    right: 0;
    width: 100%;
    max-width: 100%;
  }

  #giphy-box {
    bottom: 55px;
    left: 0;
    width: calc(100% - 24px);
  }

  /* Collapse/expand arrow for mobile */
  .back-arrow {
    display: block;
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 20px;
    color: var(--tg-text-secondary);
    cursor: pointer;
  }

  /* Overlay when sidebar is open */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
  }

  .sidebar-overlay.active {
    display: block;
  }
}

/* Small mobile screens */
@media (max-width: 480px) {
  .user-item {
    padding: 6px 10px;
  }

  .user-avatar {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .user-item.current-user .user-avatar {
    width: 40px;
    height: 40px;
  }

  .header-avatar {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }

  .header-name {
    font-size: 14px;
  }

  .header-status {
    font-size: 12px;
  }
}
