﻿/* ===== CSS Variables & Theming ===== */
:root {
  --bg-color: #f4f4f4;
  --container-bg: #ffffff;
  --text-color: #333;
  --border-color: #ddd;
  --message-bg: #ffffff;
  --message-shadow: 0 1px 2px rgba(0,0,0,0.05);
  --username-color: #007bff;
  --timestamp-color: #888;
  --typing-color: #666;
  --input-bg: #ffffff;
  --button-bg: #007bff;
  --button-hover: #0056b3;
  --danger: #dc3545;
  --danger-hover: #c82333;
}

body.dark-mode {
  --bg-color: #1a1a1a;
  --container-bg: #2d2d2d;
  --text-color: #e0e0e0;
  --border-color: #444;
  --message-bg: #3a3a3a;
  --message-shadow: 0 1px 2px rgba(0,0,0,0.3);
  --username-color: #66b0ff;
  --timestamp-color: #aaa;
  --typing-color: #bbb;
  --input-bg: #3a3a3a;
  --button-bg: #1e90ff;
  --button-hover: #0077cc;
  --danger: #dc3545;
  --danger-hover: #c82333;
}

/* ===== Base ===== */
* {
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  background-color: var(--bg-color);
  margin: 0;
  padding: 20px;
  color: var(--text-color);
  transition: background-color 0.3s, color 0.3s;
}

.chat-container {
  max-width: 900px;
  margin: 0 auto;
  background: var(--container-bg);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  padding: 20px;
  transition: background-color 0.3s, color 0.3s;
}

h1 {
  text-align: center;
  color: var(--text-color);
  margin-bottom: 15px;
}

/* ===== Top Bar ===== */
.top-bar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
  margin-bottom: 15px;
  padding: 5px 0;
}

#language-select {
  padding: 5px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text-color);
}

#theme-toggle,
#sound-toggle {
  background: none;
  border: none;
  font-size: 1.5em;
  cursor: pointer;
  padding: 0;
}

#logout-button {
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 8px 12px;
  cursor: pointer;
}

#logout-button:hover {
  background: var(--danger-hover);
}

/* ===== Auth Area ===== */
#auth-area {
  max-width: 400px;
  margin: 0 auto;
}

.auth-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.auth-tabs button {
  flex: 1;
  padding: 8px;
  background: var(--button-bg);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.auth-tabs button.active {
  background: var(--button-hover);
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#auth-form input {
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text-color);
}

.error {
  color: red;
  margin-top: 10px;
  font-size: 0.9em;
}

/* ===== Chat Layout ===== */
.chat-layout {
  display: flex;
  gap: 15px;
  align-items: flex-start;
}

/* Left: Room Users */
.user-list-container,
.room-list-container {
  width: 160px;
  flex-shrink: 0;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 10px;
  background: var(--container-bg);
}

.user-list-container h3,
.room-list-container h3 {
  margin: 0 0 8px 0;
  font-size: 1em;
  color: var(--text-color);
  text-align: center;
}

#room-user-list,
#room-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 300px;
  overflow-y: auto;
}

#room-user-list li,
#room-list li {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  margin-bottom: 4px;
  border-radius: 4px;
  font-size: 0.9em;
  border-bottom: 1px solid var(--border-color);
  cursor: default; /* room list items are clickable; we'll override below */
}

#room-list li {
  cursor: pointer;
  border-bottom: none;
}

#room-list li:hover {
  background: var(--button-bg);
  color: white;
}

#room-list li.active {
  background: var(--button-bg);
  color: white;
}

#room-user-list li {
  border-bottom: 1px solid var(--border-color);
  cursor: default;
}

/* Center: Chat */
.chat-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

#current-room-name {
  font-size: 1.2em;
  font-weight: bold;
  margin-bottom: 10px;
  color: var(--text-color);
  text-align: center;
}

#messages {
  list-style: none;
  padding: 10px;
  margin: 0;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--message-bg);
}

#messages li {
  margin-bottom: 10px;
  padding: 8px;
  background: var(--message-bg);
  border-radius: 4px;
  box-shadow: var(--message-shadow);
}

/* ===== Message content ===== */
.message-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.username {
  display: flex;
  align-items: center;
  font-weight: bold;
  color: var(--username-color);
}

.timestamp {
  font-size: 0.8em;
  color: var(--timestamp-color);
}

.message-text {
  color: var(--text-color);
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-image {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  display: block;
  margin-top: 5px;
}

/* ===== Avatars ===== */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  margin-right: 6px;
  font-size: 0.8em;
  font-weight: bold;
  color: white;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.admin-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  background-color: var(--danger);
  color: white;
  border-radius: 4px;
  font-size: 0.7em;
  vertical-align: middle;
}

/* ===== Typing indicator ===== */
#typing-indicator {
  height: 20px;
  margin: 5px 0;
  font-style: italic;
  color: var(--typing-color);
}

/* ===== Message Form ===== */
#message-form {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  align-items: flex-end;
  position: relative;
}

#message-form textarea {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  resize: none;
  min-height: 36px;
  max-height: 150px;
  overflow-y: auto;
  font-family: inherit;
  font-size: 1em;
  background: var(--input-bg);
  color: var(--text-color);
}

#emoji-button,
#image-button {
  background: none;
  border: none;
  font-size: 1.2em;
  cursor: pointer;
  padding: 0 5px;
}

button {
  padding: 8px 15px;
  background: var(--button-bg);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

button:hover {
  background: var(--button-hover);
}

#char-counter {
  font-size: 0.8em;
  color: var(--timestamp-color);
  align-self: center;
}

#char-counter.warning {
  color: #e67e22;
  font-weight: bold;
}

/* ===== Emoji Picker ===== */
#emoji-picker {
  display: none;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  width: 280px;
  max-width: 100%;
  z-index: 9999;
}

.emoji-item {
  font-size: 1.5em;
  text-align: center;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  line-height: 1.2;
}

.emoji-item:hover {
  background: var(--button-bg);
  color: white;
}

/* ===== Room Actions ===== */
.room-actions {
  margin-top: 10px;
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
}

#create-room-btn,
#delete-room-btn,
#manage-members-btn {
  background: var(--button-bg);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 5px 8px;
  cursor: pointer;
}

#delete-room-btn {
  background: var(--danger);
}

#delete-room-btn:hover {
  background: var(--danger-hover);
}

#manage-members-btn {
  background: #6c757d;
}

#manage-members-btn:hover {
  background: #5a6268;
}

.unread-badge {
  display: inline-block;
  margin-left: auto;
  background-color: var(--danger);
  color: white;
  border-radius: 10px;
  padding: 2px 6px;
  font-size: 0.7em;
  min-width: 18px;
  text-align: center;
}

/* ===== Modals ===== */
.modal-content {
  background: var(--container-bg);
  color: var(--text-color);
  border-radius: 8px;
  padding: 20px;
  max-width: 350px;
  width: 90%;
  position: relative;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.close-modal {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 1.5em;
  cursor: pointer;
  color: var(--text-color);
}

/* Profile modal */
#profile-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.profile-avatar-large {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8em;
  color: white;
  margin: 0 auto 10px;
  overflow: hidden;
}

.profile-avatar-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#profile-modal h2 {
  text-align: center;
  margin: 0 0 5px;
}

#profile-modal p {
  margin: 5px 0;
}

#profile-pm-btn,
#profile-avatar-upload-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  background: var(--button-bg);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#profile-pm-btn:hover,
#profile-avatar-upload-btn:hover {
  background: var(--button-hover);
}

/* Create room modal */
#create-room-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

#room-name-input {
  width: 100%;
  padding: 8px;
  margin: 10px 0 5px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text-color);
}

#create-room-error {
  margin-bottom: 5px;
}

.member-checkboxes {
  max-height: 150px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 5px;
  margin: 5px 0;
}

.member-checkboxes label {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 0;
  cursor: pointer;
}

#selected-count {
  font-size: 0.8em;
  color: var(--timestamp-color);
  margin: 0 0 5px;
}

#confirm-create-room {
  width: 100%;
  margin-top: 10px;
}

/* Manage members modal */
#manage-members-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

#manage-members-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 5px;
  margin: 10px 0;
}

#manage-members-list .member-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 0;
}

#manage-members-list .remove-member-btn {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: red;
  font-size: 1.2em;
}

#manage-members-add {
  display: flex;
  gap: 5px;
  margin-top: 10px;
}

#add-member-select {
  flex: 1;
  padding: 5px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text-color);
}

#manage-members-error {
  margin-top: 5px;
}
.edit-btn, .delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9em;
  padding: 2px 5px;
  border-radius: 4px;
  outline: none;               /* remove blue focus outline */
  box-shadow: none;            /* remove any default focus ring */
}

.edit-btn:focus,
.delete-btn:focus {
  outline: none;
  box-shadow: none;
}

.edit-btn:hover {
  background: var(--button-hover);   /* subtle hover */
  color: white;
}

.delete-btn:hover {
  background: var(--danger);
  color: white;
}
.close-modal {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 1.5em;
  cursor: pointer;
  color: var(--text-color);
  z-index: 10;
  background: none;
  border: none;
}
#load-older-btn {
  display: block;
  width: 100%;
  padding: 8px;
  margin-bottom: 5px;
  background: var(--button-bg);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#load-older-btn:hover {
  background: var(--button-hover);
}

#load-older-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
#new-messages-btn {
  position: absolute;
  bottom: 80px;
  right: 20px;
  z-index: 1000;
  padding: 8px 12px;
  background: var(--button-bg);
  color: white;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

#new-messages-btn:hover {
  background: var(--button-hover);
}
.search-container {
  position: relative;
  margin-bottom: 10px;
}

#search-input {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text-color);
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 300px;
  overflow-y: auto;
  background: var(--container-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.search-result-item {
  padding: 8px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
}

.search-result-item:hover {
  background: var(--message-bg);
}

.search-result-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.search-result-username {
  font-weight: bold;
  color: var(--username-color);
}

.search-result-timestamp {
  font-size: 0.8em;
  color: var(--timestamp-color);
}

.search-result-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9em;
}
@keyframes highlightFade {
  0% { background-color: #fff3cd; }
  100% { background-color: transparent; }
}

.highlight-message {
  animation: highlightFade 2s ease-out;
}
body.dark-mode .highlight-message {
  animation-name: highlightFadeDark;
}

@keyframes highlightFadeDark {
  0% { background-color: #4a3f00; }
  100% { background-color: transparent; }
}
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 200px;
  max-width: 300px;
  padding: 12px 16px;
  border-radius: 4px;
  color: white;
  font-size: 0.9em;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  animation: toast-in 0.3s ease-out, toast-out 0.3s ease-in 4.7s forwards;
}

.toast-info {
  background: var(--button-bg);
}

.toast-success {
  background: #28a745;
}

.toast-error {
  background: var(--danger);
}

@keyframes toast-in {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes toast-out {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(20px); }
}
#online-room-user-list,
#offline-room-user-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

#online-room-user-list li,
#offline-room-user-list li {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9em;
}
#confirm-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2500; /* higher than other modals */
}

.confirm-content {
  max-width: 300px;
  text-align: center;
}

.confirm-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 15px;
}

.confirm-buttons button {
  min-width: 80px;
}

#confirm-no {
  background: #6c757d;
}

#confirm-no:hover {
  background: #5a6268;
}
#edit-message-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2600;
}

#edit-message-text {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text-color);
  resize: vertical;
  min-height: 60px;
  margin-top: 10px;
  font-family: inherit;
  font-size: 1em;
}
.edited-indicator {
  font-size: 0.8em;
  color: var(--timestamp-color);
  font-style: italic;
}
.profile-modal-content {
  background: var(--container-bg);
  color: var(--text-color);
  border-radius: 8px;
  padding: 20px;
  max-width: 350px;
  width: 90%;
  position: relative;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
.close-modal:hover {
  background: var(--border-color);
  color: var(--button-hover);
}

.user-search-container {
  position: relative;
  margin-bottom: 10px;
}

#user-search-input {
  width: 100%;
  padding: 5px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text-color);
  font-size: 0.9em;
}

.user-search-all-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8em;
  color: var(--text-color);
  margin-top: 4px;
  cursor: pointer;
}

.user-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 250px;
  overflow-y: auto;
  background: var(--container-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  margin-top: 4px;
}

.user-search-result-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  cursor: pointer;
}

.user-search-result-item:hover {
  background: var(--button-bg);
  color: white;
}
.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
}

.reaction {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--message-bg);
  border: 1px solid var(--border-color);
  font-size: 0.8em;
  cursor: default;
}

.reaction.mine {
  background: var(--button-bg);
  color: white;
  border-color: var(--button-bg);
}

.react-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9em;
  padding: 2px 4px;
  margin-top: 5px;
}

.react-btn:hover {
  background: var(--border-color);
  border-radius: 4px;
}

.reaction-picker {
  display: flex;
  gap: 4px;
  padding: 5px;
  background: var(--container-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 1500;
}

.reaction-picker button {
  background: none;
  border: none;
  font-size: 1.2em;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}

.reaction-picker button:hover {
  background: var(--button-bg);
  color: white;
}
.react-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9em;
  padding: 2px 4px;
  margin-top: 5px;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s, visibility 0.2s;
}

li:hover .react-btn {
  visibility: visible;
  opacity: 1;
}
.edit-btn,
.delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85em;
  padding: 2px 5px;
  border-radius: 4px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.edit-btn:hover,
.delete-btn:hover {
  opacity: 1;
  background: var(--border-color);
}

.delete-btn:hover {
  background: var(--danger);
  color: white;
}
.message-actions {
  display: flex;
  gap: 5px;
  margin-top: 5px;
  justify-content: flex-end;   /* move buttons to the right */
}
#messages {
  scrollbar-width: none;          /* Firefox */
  -ms-overflow-style: none;       /* IE/Edge legacy */
}

#messages::-webkit-scrollbar {
  display: none;                  /* Chrome/Safari/Opera */
}
#emoji-customizer-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2700;
}

.emoji-library-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  max-height: 300px;
  overflow-y: auto;
  margin: 10px 0;
}

.emoji-library-item {
  font-size: 1.8em;
  text-align: center;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}

.emoji-library-item:hover {
  background: var(--border-color);
}

.emoji-library-item.selected {
  background: var(--button-bg);
  color: white;
  box-shadow: 0 0 0 2px var(--button-hover);
}

.reaction-customize-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1em;
  padding: 2px 4px;
  border-radius: 4px;
}

.reaction-customize-btn:hover {
  background: var(--border-color);
}
#emoji-customizer-modal .modal-content {
  max-width: 500px;   /* wider than default 350px */
}
.reaction-picker button.mine {
  background: var(--button-bg);
  color: white;
}
.reaction {
  cursor: pointer;
}

.reaction:hover {
  border-color: var(--button-bg);
}
.reaction-picker-separator {
  width: 1px;
  height: 1.2em;
  background: var(--border-color);
  margin: 0 4px;
  align-self: center;
}

.reaction-customize-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1em;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.reaction-customize-btn:hover {
  opacity: 1;
  background: var(--border-color);
}
#emoji-library-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2800;
}

.emoji-library-modal-content {
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
}

#emoji-search-input {
  width: 100%;
  padding: 8px;
  margin: 10px 0;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text-color);
}

.emoji-category-tabs {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.emoji-category-tab {
  padding: 4px 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  background: var(--message-bg);
  color: var(--text-color);
}

.emoji-category-tab.active {
  background: var(--button-bg);
  color: white;
  border-color: var(--button-bg);
}

.emoji-library-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
}

.emoji-library-item {
  font-size: 1.8em;
  text-align: center;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}

.emoji-library-item:hover {
  background: var(--border-color);
}

.emoji-library-item.selected {
  background: var(--button-bg);
  color: white;
  box-shadow: 0 0 0 2px var(--button-hover);
}

.emoji-customize-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2em;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.emoji-customize-btn:hover {
  background: var(--border-color);
}
.add-member-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: var(--container-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  margin-top: 4px;
}

.add-member-result-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  cursor: pointer;
}

.add-member-result-item:hover {
  background: var(--button-bg);
  color: white;
}

#add-member-search {
  width: 100%;
  padding: 5px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text-color);
}

#manage-members-add {
  position: relative;
}
.selected-members {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}

.selected-member-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--button-bg);
  color: white;
  border-radius: 12px;
  font-size: 0.85em;
}

.selected-member-chip button {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 1em;
  padding: 0 2px;
}

.member-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 150px;
  overflow-y: auto;
  background: var(--container-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  margin-top: 4px;
}

.member-search-result-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  cursor: pointer;
}

.member-search-result-item:hover {
  background: var(--button-bg);
  color: white;
}

#member-search-input {
  width: 100%;
  padding: 5px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text-color);
}

#member-select {
  position: relative;
}
.public-room-search {
  position: relative;
  margin-bottom: 10px;
}

#public-room-search {
  width: 100%;
  padding: 5px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text-color);
  font-size: 0.9em;
}

.public-room-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: var(--container-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.public-room-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  cursor: pointer;
}

.public-room-result-item:hover {
  background: var(--message-bg);
}

.public-room-result-item button {
  background: var(--button-bg);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
}
#room-list li .leave-room-btn {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1em;
  color: var(--danger);
  padding: 0 2px;
  border-radius: 4px;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s, visibility 0.2s;
}

#room-list li:hover .leave-room-btn {
  visibility: visible;
  opacity: 1;
}

#room-list li .leave-room-btn:hover {
  background: var(--danger);
  color: white;
}
li.new-day::before {
  content: attr(data-date-label);
  display: block;
  text-align: center;
  margin: 10px 0;
  font-weight: bold;
  color: var(--timestamp-color);
  font-size: 0.85em;
  background: var(--message-bg);
  border-radius: 4px;
  padding: 4px;
}

#connection-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5000;
  background: #e74c3c;
  color: white;
  text-align: center;
  padding: 8px;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  transition: background 0.3s ease;
}

#connection-banner.success {
  background: #2ecc71;
}
.current-user-summary {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 15px;
}

.current-user-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8em;
  color: white;
  margin-bottom: 5px;
  overflow: hidden;
  background-color: var(--button-bg);
}

.current-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.current-user-name {
  font-weight: bold;
  color: var(--text-color);
  font-size: 0.95em;
  word-break: break-word;
  text-align: center;
}
#profile-change-password-btn,
#profile-delete-account-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#profile-change-password-btn {
  background: var(--button-bg);
  color: white;
}

#profile-change-password-btn:hover {
  background: var(--button-hover);
}

#profile-delete-account-btn {
  background: var(--danger);
  color: white;
}

#profile-delete-account-btn:hover {
  background: var(--danger-hover);
}

#change-password-modal,
#delete-account-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

#change-password-modal .modal-content,
#delete-account-modal .modal-content {
  max-width: 320px;
}

#change-password-modal input,
#delete-account-modal input {
  width: 100%;
  margin-bottom: 10px;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text-color);
}
.forgot-password-link {
  text-align: center;
  margin-top: 10px;
}

.forgot-password-link a {
  color: var(--button-bg);
  cursor: pointer;
  text-decoration: none;
}

.forgot-password-link a:hover {
  text-decoration: underline;
}

#forgot-password-modal,
#reset-password-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3200;
}

#forgot-password-modal .modal-content,
#reset-password-modal .modal-content {
  max-width: 340px;
}

#forgot-password-modal input,
#reset-password-modal input {
  width: 100%;
  margin-bottom: 10px;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text-color);
}

.resend-verification-link {
  text-align: center;
  margin-top: 5px;
}

.resend-verification-link a {
  color: var(--button-bg);
  cursor: pointer;
  text-decoration: none;
}

.resend-verification-link a:hover {
  text-decoration: underline;
}

#resend-verification-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3400;
}

#resend-verification-modal .modal-content {
  max-width: 340px;
}

#resend-verification-modal input {
  width: 100%;
  margin-bottom: 10px;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text-color);
}
.auth-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
}

.auth-links a {
  color: var(--button-bg);
  cursor: pointer;
  text-decoration: none;
  font-size: 0.9em;
}

.auth-links a:hover {
  text-decoration: underline;
}
#profile-admin-delete-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#profile-admin-delete-btn:hover {
  background: var(--danger-hover);
}
#profile-admin-ban-btn,
#profile-admin-unban-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#profile-admin-ban-btn {
  background: #e67e22;
  color: white;
}

#profile-admin-ban-btn:hover {
  background: #d35400;
}

#profile-admin-unban-btn {
  background: #2ecc71;
  color: white;
}

#profile-admin-unban-btn:hover {
  background: #27ae60;
}
#ban-duration-select {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text-color);
}
/* Admin Dashboard Styles */
.admin-dashboard-content {
  max-width: 900px;
  width: 95%;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 12px;
  padding: 25px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.admin-dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

.admin-dashboard-header h2 {
  margin: 0;
  color: white;
  font-size: 28px;
  font-weight: 600;
}

.admin-tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 25px;
  background: rgba(255, 255, 255, 0.1);
  padding: 5px;
  border-radius: 8px;
}

.admin-tab {
  flex: 1;
  padding: 12px 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.8);
  border-radius: 6px;
  transition: all 0.3s ease;
  font-weight: 500;
}

.admin-tab:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.admin-tab.active {
  background: white;
  color: #667eea;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  font-weight: 600;
}

.admin-tab-content {
  display: none;
}

.admin-tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

/* User List Styles */
.admin-user-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  flex-wrap: wrap;
}

.admin-user-item:hover {
  transform: translateX(5px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.admin-user-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 150px;
}

.admin-user-name {
  font-weight: 600;
  color: #333;
  margin-bottom: 5px;
  cursor: pointer;
  transition: color 0.2s;
}

.admin-user-name:hover {
  color: #667eea;
}

.admin-user-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.admin-status-badge.online {
  background: #e8f5e9;
  color: #4caf50;
}

.admin-status-badge.offline {
  background: #f5f5f5;
  color: #9e9e9e;
}

.admin-status-badge.active {
  background: #e8f5e9;
  color: #4caf50;
}

.admin-status-badge.banned {
  background: #ffebee;
  color: #f44336;
}

.admin-status-badge.admin {
  background: #fff3e0;
  color: #ff9800;
}

.admin-status-badge.user {
  background: #e3f2fd;
  color: #2196f3;
}

.admin-user-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.admin-action-btn {
  padding: 8px 16px;
  border: none;
  background: #667eea;
  color: white;
  cursor: pointer;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.admin-action-btn:hover {
  background: #5a67d8;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.admin-action-btn.unban {
  background: #4caf50;
}

.admin-action-btn.unban:hover {
  background: #45a049;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.admin-action-btn.delete {
  background: #f44336;
}

.admin-action-btn.delete:hover {
  background: #d32f2f;
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

/* Ban Item Styles */
.ban-item, .ban-history-item {
  padding: 20px;
  margin-bottom: 15px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  border-left: 4px solid #f44336;
  transition: all 0.3s ease;
}

.ban-item:hover, .ban-history-item:hover {
  transform: translateX(5px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.ban-item-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.ban-item-username {
  font-weight: 600;
  color: #333;
  font-size: 16px;
}

.ban-item-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.ban-detail {
  display: flex;
  flex-direction: column;
}

.ban-detail-label {
  font-size: 11px;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
}

.ban-detail-value {
  color: #333;
  font-size: 14px;
}

/* Ban History Specific */
.ban-history-item {
  border-left-color: #ff9800;
}

.ban-history-item.inactive {
  border-left-color: #4caf50;
  opacity: 0.7;
}

/* Search Input */
#admin-user-search {
  width: 100%;
  padding: 15px 20px;
  margin-bottom: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  font-size: 15px;
  transition: all 0.3s ease;
}

#admin-user-search:focus {
  outline: none;
  border-color: white;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
  background: white;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: rgba(255, 255, 255, 0.8);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 15px;
}

.empty-state-text {
  font-size: 16px;
  font-weight: 500;
}

/* Responsive Design */
@media (max-width: 600px) {
  .admin-dashboard-content {
    padding: 15px;
    width: 98%;
  }
  
  .admin-tabs {
    flex-direction: column;
    gap: 5px;
  }
  
  .admin-tab {
    padding: 10px;
  }
  
  .admin-user-item {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .admin-user-actions {
    margin-left: 0;
    width: 100%;
  }
  
  .admin-action-btn {
    flex: 1;
  }
}
.tab-count {
  display: inline-block;
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  margin-left: 5px;
}
.admin-dashboard-content {
  cursor: default;
}

.admin-dashboard-header {
  cursor: move;
  user-select: none;
}

.admin-dashboard-content.dragging {
  transition: none;
  cursor: grabbing;
  opacity: 0.95;
}
.drag-handle {
  cursor: grab;
  font-size: 24px;
  color: rgba(255, 255, 255, 0.7);
  margin-right: 10px;
  display: flex;
  align-items: center;
  transition: color 0.2s;
}

.drag-handle:hover {
  color: white;
}

.drag-handle:active {
  cursor: grabbing;
}
#admin-bans-search,
#admin-history-search {
  width: 100%;
  padding: 15px 20px;
  margin-bottom: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  font-size: 15px;
  transition: all 0.3s ease;
}

#admin-bans-search:focus,
#admin-history-search:focus {
  outline: none;
  border-color: white;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
  background: white;
}

#admin-bans-search::placeholder,
#admin-history-search::placeholder {
  color: #999;
}
#ban-duration-modal {
  position: fixed;
  z-index: 1001; /* Higher than dashboard if needed */
}

#ban-duration-modal .modal-content {
  max-width: 400px;
  width: 90%;
}
#ban-duration-modal h2 {
  cursor: move;
  user-select: none;
}
.file-message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 12px;
  margin: 5px 0;
  transition: all 0.2s ease;
  max-width: 450px;
}

.file-message:hover {
  background: #e9ecef;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.file-icon {
  font-size: 40px;
  flex-shrink: 0;
}

.file-info {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-weight: 500;
  color: #333;
  margin-bottom: 5px;
  word-break: break-word;
}

.file-size {
  font-size: 12px;
  color: #666;
}

.file-download-btn {
  padding: 8px 15px;
  background: #007bff;
  color: white;
  text-decoration: none;
  border-radius: 5px;
  font-size: 14px;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}

.file-download-btn:hover {
  background: #0056b3;
  text-decoration: none;
  color: white;
}

/* Dark mode support */
.dark-mode .file-message {
  background: #2d2d2d;
  border-color: #444;
}

.dark-mode .file-name {
  color: #e0e0e0;
}

.dark-mode .file-size {
  color: #aaa;
}
/* Audio Player */
.audio-player {
  width: 100%;
  margin-top: 10px;
  height: 40px;
}

/* Video Player */
.video-player {
  width: 100%;
  max-width: 400px;
  max-height: 300px;
  margin-top: 10px;
  border-radius: 8px;
  background: #000;
}

/* File Header */
.file-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.file-header .file-icon {
  font-size: 24px;
  flex-shrink: 0;
}

/* Image Preview */
.file-image-preview {
  max-width: 300px;
  max-height: 300px;
  margin-top: 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s;
}

.file-image-preview:hover {
  transform: scale(1.02);
}

/* PDF Preview Button */
.file-preview-btn {
  display: inline-block;
  padding: 6px 12px;
  background: #6c757d;
  color: white;
  text-decoration: none;
  border-radius: 5px;
  font-size: 13px;
  margin-top: 5px;
  transition: all 0.2s;
}

.file-preview-btn:hover {
  background: #5a6268;
  text-decoration: none;
  color: white;
}

/* Dark Mode */
.dark-mode .video-player {
  background: #000;
}

.dark-mode .file-preview-btn {
  background: #495057;
}

.dark-mode .file-preview-btn:hover {
  background: #343a40;
}
/* ============ AUDIO PLAYER ============ */
.audio-message {
  flex-direction: column;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  padding: 18px 20px 15px 20px;
  max-width: 320px;
  min-width: 260px;
}

.audio-message:hover {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.audio-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.audio-icon-wrapper {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  backdrop-filter: blur(5px);
}

.audio-info {
  flex: 1;
  min-width: 0;
}

.audio-name {
  color: white;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 2px;
  word-break: break-word;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.audio-size {
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
}

.audio-player {
  width: 100%;
  height: 36px;
  margin-top: 5px;
  border-radius: 18px;
  outline: none;
}

.audio-player::-webkit-media-controls-panel {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 18px;
  padding: 0 5px;
}

.audio-player::-webkit-media-controls-play-button {
  background-color: white;
  border-radius: 50%;
}

.audio-player::-webkit-media-controls-current-time-display,
.audio-player::-webkit-media-controls-time-remaining-display {
  color: white;
  font-size: 10px;
}

.audio-player::-webkit-media-controls-timeline {
  border-radius: 10px;
  margin: 0 5px;
}

.audio-player::-webkit-media-controls-volume-slider {
  border-radius: 10px;
}

.audio-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  text-decoration: none;
  border-radius: 20px;
  font-size: 13px;
  margin-top: 12px;
  transition: all 0.2s;
  align-self: flex-start;
}

.audio-download-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  color: white;
  text-decoration: none;
  transform: translateY(-2px);
}

/* ============ VIDEO PLAYER ============ */
/* ============ VIDEO PLAYER ============ */
.video-message {
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  max-width: 450px;
  background: #000;
  border: none;
  border-radius: 12px;
}

.video-message:hover {
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.video-player {
  width: 100%;
  max-width: 450px;
  max-height: 300px;
  display: block;
  background: #000;
  border-radius: 12px 12px 0 0;
}

.video-info-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 15px;
  background: #f8f9fa;
  border-top: 1px solid #e9ecef;
}

.video-info {
  flex: 1;
  min-width: 0;
}

.video-name {
  font-weight: 600;
  color: #333;
  font-size: 13px;
  margin-bottom: 2px;
  word-break: break-word;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

.video-size {
  font-size: 11px;
  color: #666;
}
.video-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  background: #007bff;
  color: white;
  text-decoration: none;
  border-radius: 20px;
  font-size: 13px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.video-download-btn:hover {
  background: #0056b3;
  color: white;
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

/* ============ IMAGE PREVIEW ============ */
.image-message {
  padding: 0;
  overflow: hidden;
  background: transparent;
  border: none;
  max-width: 350px;
}

.image-message:hover {
  background: transparent;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.file-image-preview {
  width: 100%;
  max-width: 350px;
  max-height: 350px;
  display: block;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.2s;
}

.file-image-preview:hover {
  transform: scale(1.02);
}

.image-info-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 15px;
  background: #f8f9fa;
  border-radius: 0 0 12px 12px;
}

/* ============ DARK MODE ============ */
.dark-mode .file-message {
  background: #2d2d2d;
  border-color: #444;
}

.dark-mode .file-message:hover {
  background: #363636;
}

.dark-mode .audio-message {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.dark-mode .audio-message:hover {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.dark-mode .video-info-bar,
.dark-mode .image-info-bar {
  background: #2d2d2d;
  border-color: #444;
}

.dark-mode .video-name {
  color: #e0e0e0;
}

.dark-mode .video-size {
  color: #aaa;
}

.dark-mode .file-name {
  color: #e0e0e0;
}

.dark-mode .file-size {
  color: #aaa;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 600px) {
  .file-message,
  .audio-message,
  .video-message,
  .image-message {
    max-width: 100%;
  }
  
  .video-player {
    max-height: 250px;
  }
  
  .file-image-preview {
    max-height: 250px;
  }
}
.audio-download-btn,
.video-download-btn {
  display: none;
}
/* Make file messages fit better in the message list */
#messages li .file-message {
  margin: 0;
}

/* Smooth transition for media players */
.audio-player,
.video-player {
  transition: all 0.3s ease;
}

/* Hover effect on video player */
.video-player:hover {
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

/* Dark mode video info bar */
.dark-mode .video-info-bar {
  background: #2d2d2d;
  border-color: #444;
}

.dark-mode .video-name {
  color: #e0e0e0;
}

.dark-mode .video-size {
  color: #aaa;
}
.video-message {
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  max-width: 450px;
  background: transparent;
  border: none;
  border-radius: 12px;
  position: relative;
}

.video-message:hover {
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.video-player {
  width: 100%;
  max-width: 450px;
  max-height: 300px;
  display: block;
  background: #000;
  border-radius: 12px;
}

/* Info bar - now at top, hidden by default */
.video-info-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 15px 20px 15px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
  border: none;
  pointer-events: none;
  
  /* Hide by default */
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Show info bar on hover */
.video-message:hover .video-info-bar {
  opacity: 1;
}

.video-info {
  flex: 1;
  min-width: 0;
}

.video-name {
  font-weight: 500;
  color: white;
  font-size: 12px;
  margin-bottom: 2px;
  word-break: break-word;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.video-size {
  font-size: 10px;
  color: rgba(255,255,255,0.7);
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* Optional: Add a slight zoom effect on video hover */
.video-player {
  transition: transform 0.3s ease;
}

.video-message:hover .video-player {
  transform: scale(1.01);
}
/* Settings Modal */
.settings-modal-content {
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
}

.settings-tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}

.settings-tab {
  padding: 8px 15px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-color);
  font-size: 14px;
  border-radius: 4px;
  transition: all 0.2s;
}

.settings-tab:hover {
  background: var(--border-color);
}

.settings-tab.active {
  background: var(--button-bg);
  color: white;
}

.settings-tab-content {
  display: none;
}

.settings-tab-content.active {
  display: block;
}

.settings-section {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border-color);
}

.settings-section h3 {
  margin: 0 0 10px 0;
  font-size: 16px;
  color: var(--text-color);
}

.settings-avatar-row {
  display: flex;
  align-items: center;
  gap: 15px;
}

.settings-avatar-large {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5em;
  color: white;
  overflow: hidden;
}

.settings-avatar-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.settings-input-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.settings-input-row input {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text-color);
}

.settings-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 5px 0;
}

.settings-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.danger-btn {
  background: var(--danger);
  color: white;
}

.danger-btn:hover {
  background: var(--danger-hover);
}

#settings-blocked-users-list {
  margin-bottom: 10px;
}

.blocked-user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px;
  background: var(--message-bg);
  border-radius: 4px;
  margin-bottom: 5px;
}

.blocked-user-item button {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--danger);
  font-size: 1.2em;
}
.settings-btn {
  background: none;
  border: none;
  font-size: 1.2em;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: all 0.2s;
  margin-top: 5px;
}

.settings-btn:hover {
  background: var(--border-color);
  transform: rotate(30deg);
}
#settings-modal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background: rgba(0, 0, 0, 0.5) !important;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000 !important;
  margin: 0 !important;
  padding: 0 !important;
}

#settings-modal[style*="display: flex"],
#settings-modal[style*="display:flex"] {
  display: flex !important;
  align-items: center;
  justify-content: center;
}
.session-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--message-bg);
  border-radius: 4px;
  margin-bottom: 5px;
}

.session-info {
  flex: 1;
}

.session-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.audit-log-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 6px;
  margin-bottom: 5px;
  font-size: 13px;
  flex-wrap: wrap;
}

.audit-badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 11px;
  white-space: nowrap;
}

.audit-danger {
  background: #ffebee;
  color: #f44336;
}

.audit-warning {
  background: #fff3e0;
  color: #ff9800;
}

.audit-success {
  background: #e8f5e9;
  color: #4caf50;
}

.audit-info {
  background: #e3f2fd;
  color: #2196f3;
}
/* Reply preview in message */
.reply-preview {
  background: rgba(0, 0, 0, 0.05);
  border-left: 3px solid #007bff;
  padding: 8px;
  margin-bottom: 5px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

.reply-preview:hover {
  background: rgba(0, 123, 255, 0.1);
}

.reply-preview-header {
  font-size: 0.85em;
  font-weight: bold;
  color: #007bff;
  margin-bottom: 3px;
}

.reply-preview-text {
  font-size: 0.9em;
  color: #666;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}

.reply-icon {
  margin-right: 5px;
}

/* Reply button in message actions */
.reply-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 5px;
  font-size: 14px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.reply-btn:hover {
  opacity: 1;
}

/* Reply preview container above input */
.reply-preview-container {
  display: flex;
  align-items: center;
  background: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 5px;
}

.reply-preview-content {
  flex: 1;
}

.cancel-reply-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 0 8px;
  color: #666;
}

.cancel-reply-btn:hover {
  color: #333;
}

/* Dark mode */
.dark-mode .reply-preview {
  background: rgba(255, 255, 255, 0.1);
  border-left-color: #4da3ff;
}

.dark-mode .reply-preview-header {
  color: #4da3ff;
}

.dark-mode .reply-preview-text {
  color: #aaa;
}

.dark-mode .reply-preview-container {
  background: #2a2a2a;
  border-color: #444;
}
/* Reply preview container - positioned above message form */
.reply-preview-container {
  display: flex;
  align-items: center;
  background: var(--container-bg, #f8f9fa);
  border: 1px solid var(--border-color, #dee2e6);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  position: relative;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  animation: slideDown 0.2s ease-out;
}

.reply-preview-content {
  flex: 1;
  min-width: 0; /* Prevent overflow */
}

.reply-preview-header {
  font-size: 0.85em;
  font-weight: 600;
  color: #007bff;
  margin-bottom: 4px;
}

.reply-preview-header strong {
  font-weight: 700;
}

.reply-preview-text {
  font-size: 0.9em;
  color: #6c757d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.reply-icon {
  margin-right: 4px;
}

.cancel-reply-btn {
  background: none;
  border: none;
  color: #6c757d;
  font-size: 18px;
  cursor: pointer;
  padding: 0 8px;
  margin-left: 8px;
  transition: color 0.2s;
  flex-shrink: 0;
}

.cancel-reply-btn:hover {
  color: #dc3545;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Dark mode support */
.dark-mode .reply-preview-container {
  background: #2a2a2a;
  border-color: #444;
}

.dark-mode .reply-preview-header {
  color: #4da3ff;
}

.dark-mode .reply-preview-text {
  color: #aaa;
}

.dark-mode .cancel-reply-btn {
  color: #aaa;
}

.dark-mode .cancel-reply-btn:hover {
  color: #ff6b6b;
}