/* Variables for colors */
:root {
  --primary-color: #06a3da;    /* LINE blue */
  --received-bg: #f0f0f0;      /* light gray for received messages */
  --sent-bg: #dcf8c6;          /* light green for sent messages */
  --text-color: #000;
  --background-color: #ffffff;
  --status-online: #00cc44;
  --status-offline: #cc0000;
}

/* Base resets */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  display: flex;
  flex-direction: column;
  background: #e5ddd5; /* LINE background color */
  font-family: Arial, sans-serif;
  height: 100vh;
  overflow: hidden;
}

/* Notification popup */
.notification {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(50,50,50,0.9);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  display: none;
  z-index: 1000;
  font-size: 0.9rem;
}

/* Connection status bar */
.status-bar {
  text-align: center;
  padding: 0.5rem;
  font-size: 0.9rem;
  color: #fff;
}
.status-bar.online {
  background: var(--status-online);
}
.status-bar.offline {
  background: var(--status-offline);
}

/* Header */
.chat-header {
  background: #fff;
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #ddd;
}
.chat-header .user-name {
  font-weight: bold;
  color: var(--primary-color);
}
.chat-header button {
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
}

/* Auth forms */
.auth-form {
  background: #fff;
  padding: 1rem;
  max-width: 400px;
  width: 90%;
  margin: 3rem auto;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
}
.auth-form h2 {
  text-align: center;
  margin-bottom: 1rem;
  color: var(--primary-color);
}
.auth-form input {
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}
.auth-form .btn {
  margin-top: 0.5rem;
}
.auth-form p {
  text-align: center;
  margin-top: 0.5rem;
  font-size: 0.9rem;
}
.auth-form a {
  color: var(--primary-color);
  text-decoration: none;
}
.hidden {
  display: none;
}

/* Messages container */
.messages-container {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  background: var(--background-color);
  display: flex;
  flex-direction: column;
}
.messages-container::-webkit-scrollbar {
  width: 4px;
}
.messages-container::-webkit-scrollbar-thumb {
  background-color: rgba(0,0,0,0.2);
  border-radius: 2px;
}

/* Each message */
.message {
  max-width: 70%;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: flex-end;
}
.message.sent {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.message.received {
  align-self: flex-start;
}

/* Avatar */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin: 0 0.5rem;
  object-fit: cover;
  background: #ccc;
  color: #fff;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Message bubble */
.bubble {
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  position: relative;
  font-size: 0.95rem;
  word-wrap: break-word;
}
.message.sent .bubble {
  background: var(--sent-bg);
  color: var(--text-color);
  border-top-right-radius: 0;
}
.message.received .bubble {
  background: var(--received-bg);
  color: var(--text-color);
  border-top-left-radius: 0;
}

/* Timestamp and reaction/icons row */
.message-meta {
  display: flex;
  align-items: center;
  font-size: 0.75rem;
  margin-top: 0.25rem;
}
.message-meta span {
  margin-left: 0.5rem;
  color: #999;
}
.message-meta .edit-btn,
.message-meta .delete-btn,
.message-meta .reaction-btn {
  cursor: pointer;
  margin-left: 0.5rem;
}
.message-meta .edit-btn:hover,
.message-meta .delete-btn:hover,
.message-meta .reaction-btn:hover {
  color: var(--primary-color);
}

/* Date divider */
.date-divider {
  text-align: center;
  margin: 1rem 0;
  font-size: 0.8rem;
  color: #666;
  position: relative;
}
.date-divider::before,
.date-divider::after {
  content: "";
  display: inline-block;
  width: 30%;
  height: 1px;
  background: #ccc;
  vertical-align: middle;
  margin: 0 0.5em;
}

/* Message input bar */
.message-input-bar {
  background: #fff;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  border-top: 1px solid #ddd;
}
.message-input-bar input[type="text"] {
  flex: 1;
  padding: 0.5rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 18px;
  margin-right: 0.5rem;
}
.file-input {
  margin-right: 0.5rem;
}
.message-input-bar .btn {
  padding: 0.5rem 1rem;
}

/* Buttons */
.btn {
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
}
.btn-primary {
  background: var(--primary-color);
  color: #fff;
}
.btn-outline {
  background: transparent;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
}
.btn-primary:hover {
  background: #0288a8;
}
