/* Reset and base styles */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #74ebd5 0%, #ACB6E5 100%);
  color: #222;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  position: relative; /* Important for #userInfo absolute positioning */
  background-color: rgba(255 255 255 / 0.9);
  padding: 1rem 2rem;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.15);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: 0.06em;
  user-select: none;
}

header .tagline {
  font-weight: 400;
  font-size: 0.9rem;
  color: #555;
  font-style: italic;
}

/* User Info - top right corner */
#userInfo {
  position: absolute;
  top: 15px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: rgba(255, 255, 255, 0.85);
  padding: 6px 12px;
  border-radius: 20px;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.1);
  z-index: 100;
  font-size: 0.9rem;
  color: #333;
  font-family: monospace;
}

#userInfo img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

/* Main container */
main {
  flex: 1;
  display: flex;
  padding: 1rem 2rem;
  gap: 1rem;
  overflow: hidden;
  background: rgba(255 255 255 / 0.85);
  border-radius: 12px;
  margin: 1rem 2rem 2rem;
  box-shadow: 0 8px 30px rgb(0 0 0 / 0.1);
}

/* Messages */
#messages {
  flex: 3;
  background: #f9f9f9;
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  height: calc(100vh - 200px);
  overflow-y: auto;
  scroll-behavior: smooth;
  box-shadow: inset 0 0 5px #ddd;
}

.message {
  display: flex;
  align-items: flex-start;
  max-width: 80%;
  padding: 0.5rem 0.7rem;
  border-radius: 12px;
  font-size: 0.95rem;
  background-color: #e3e3e3;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.1);
  transition: background-color 0.3s;
}

.message.mine {
  margin-left: auto;
  background-color: #d0f0fd;
  box-shadow: 0 1px 4px rgb(0 128 255 / 0.3);
}

.message:hover {
  background-color: #cce5ff;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  margin-right: 10px;
  border: 2px solid #ccc;
  flex-shrink: 0;
}

.message-content {
  flex: 1;
}

.message-header {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  color: #444;
  margin-bottom: 3px;
  user-select: text;
  font-size: 0.8rem;
  color: #555;
}

.message-body {
  white-space: pre-wrap;
  word-break: break-word;
  color: #333;
}

.time {
  font-style: italic;
  margin-left: 10px;
}

/* Sidebar - Online Users */
aside {
  flex: 1;
  background: #fff;
  border-radius: 8px;
  padding: 1rem;
  box-shadow: inset 0 0 8px #ddd;
  display: flex;
  flex-direction: column;
}

aside h2 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
  border-bottom: 2px solid #74b9ff;
  padding-bottom: 0.3rem;
  color: #333;
}

#usersList {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0;
}

#usersList li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.3rem 0;
  font-size: 0.9rem;
  color: #444;
  border-bottom: 1px solid #eee;
  user-select: none;
}

#usersList li img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid #74b9ff;
}

/* Chat input form */
form#chatForm {
  display: flex;
  justify-content: center;
  padding: 0 2rem 1rem;
  background: rgba(255 255 255 / 0.95);
  box-shadow: 0 -2px 10px rgb(0 0 0 / 0.1);
}

#messageInput {
  flex: 1;
  max-width: 800px;
  font-size: 1rem;
  padding: 0.7rem 1rem;
  border-radius: 25px;
  border: 2px solid #74b9ff;
  outline-offset: 2px;
  transition: border-color 0.3s ease;
  font-family: inherit;
}

#messageInput:focus {
  border-color: #0984e3;
}

button#sendBtn {
  background-color: #0984e3;
  color: white;
  font-weight: 700;
  border: none;
  border-radius: 25px;
  padding: 0 1.5rem;
  margin-left: 1rem;
  cursor: pointer;
  transition: background-color 0.3s ease;
  font-size: 1rem;
}

button#sendBtn:hover {
  background-color: #74b9ff;
}

/* Responsive */
@media (max-width: 900px) {
  main {
    flex-direction: column;
    margin: 1rem;
  }
  aside {
    flex-direction: row;
    height: auto;
    overflow-x: auto;
    padding: 0.5rem;
  }
  #usersList {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding: 0;
    border-bottom: none;
  }
  #usersList li {
    border-bottom: none;
    flex-direction: column;
    align-items: center;
    font-size: 0.8rem;
    min-width: 50px;
  }
  #usersList li img {
    border: none;
    margin-bottom: 0.3rem;
  }
}

#sideLogo {
  position: fixed;
  bottom: 10px;
  left: 10px;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-weight: 600;
  font-size: 1rem;
  color: #555;
  background: rgba(255, 255, 255, 0.9);
  padding: 8px 12px;
  border-radius: 8px 8px 0 0;
  user-select: none;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.1);
  z-index:1000;
  
}



@media (max-width: 900px) {
  main {
    flex-direction: column;
    margin: 1rem;
    margin-left: 75px; /* space for sideLogo */
  }

  form#chatForm {
    margin-left: 75px; /* same space as main */
  }

  #messageInput {
    max-width: calc(100% - 75px); /* prevent overflow */
  }
}

#messages {
  border-radius: 16px;   /* Increase radius for a smoother round */
  background-color: #fff; /* White background to see the rounding */
  padding: 1rem;
  box-shadow: inset 0 0 10px #ccc; /* subtle inner shadow */
}