* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}

body {
  background: #222830;
  color: #ffffff;
  overflow: hidden;
}

.section {
  display: none;
  height: 100vh;
  padding: 20px;
}
.section.active {
  display: block;
}

.loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #222830;
  color: #ffdd00;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.spinner {
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top: 3px solid #ffdd00;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.auth-container {
  max-width: 320px;
  margin: 100px auto;
  background: #2d3340;
  padding: 25px;
  border-radius: 10px;
  text-align: center;
}
.auth-container .form {
  display: none;
}
.auth-container .form.active {
  display: block;
  animation: fadeIn 0.6s;
}
.auth-container input {
  width: 100%;
  margin: 10px 0;
  padding: 10px;
  border: none;
  border-radius: 5px;
  background: #1c1f26;
  color: #fff;
}
.auth-container button {
  width: 100%;
  padding: 10px;
  background: #ffdd00;
  border: none;
  color: #222830;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
}
.auth-container .switch {
  font-size: 13px;
  margin-top: 10px;
}
.auth-container .switch span {
  color: #ffdd00;
  cursor: pointer;
}

/* ROOMS */
.rooms-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 15px;
  padding-top: 60px;
}
.room-item {
  background: #2d3340;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  transition: 0.3s;
}
.room-item:hover {
  transform: scale(1.03);
}
.room-thumb {
  width: 100%;
  border-radius: 8px;
}
.room-details {
  margin-top: 10px;
}
.room-name {
  font-weight: 600;
  font-size: 16px;
}
.room-meta {
  font-size: 14px;
  color: #ccc;
}

/* ==================== 🟡 CHAT SECTION ==================== */
#chat-section {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #222830;
  color: #fff;
  font-family: "Poppins", sans-serif;
}

/* 🔝 الشريط العلوي */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1e232a;
  padding: 12px 18px;
  border-bottom: 2px solid #ffdd00;
}
.topbar i {
  font-size: 20px;
  color: #ffdd00;
  cursor: pointer;
  transition: transform 0.2s;
}
.topbar i:hover {
  transform: scale(1.2);
}
.topbar h2 {
  font-size: 18px;
  font-weight: 500;
  color: #fff;
}

/* 💬 محتوى الشات */
.chat-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* 👥 الأعضاء */
#members-container {
  width: 260px;
  background: #1e232a;
  border-left: 2px solid rgba(255, 221, 0, 0.2);
  display: flex;
  flex-direction: column;
  padding: 10px;
  overflow-y: auto;
}
.members-title {
  text-align: center;
  color: #ffdd00;
  font-size: 15px;
  margin-bottom: 10px;
}
.members-list {
  flex: 1;
}
.member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.2s;
  border-radius: 8px;
}
.member:hover {
  background: rgba(255, 255, 255, 0.05);
}
.member img.avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}
.member .name {
  font-size: 14px;
  color: #fff;
}

/* 💬 الرسائل */
.chat-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 18px;
  background: #2b303a;
  scrollbar-width: thin;
  scrollbar-color: #ffdd00 #1e232a;
}
.message {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  animation: fadeIn 0.3s ease;
}
.message.me {
  background: rgba(255, 221, 0, 0.15);
  border: 1px solid #ffdd00;
}
.msg-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.msg-header img.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}
.msg-header .name {
  font-weight: 500;
}
.msg-header .time {
  font-size: 12px;
  color: #aaa;
  margin-left: auto;
}
.msg-content {
  font-size: 14px;
  color: #fff;
  line-height: 1.4;
}

/* 🧩 إدخال الرسائل */
.chat-input {
  display: flex;
  align-items: center;
  background: #1e232a;
  padding: 10px;
  border-top: 2px solid #ffdd00;
}
.chat-input i {
  color: #ffdd00;
  font-size: 22px;
  margin-right: 10px;
  cursor: pointer;
  transition: transform 0.2s;
}
.chat-input i:hover {
  transform: scale(1.2);
}
.chat-input input {
  flex: 1;
  background: #2b303a;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  color: #fff;
  outline: none;
  font-size: 14px;
}
.chat-input button {
  background: none;
  border: none;
  color: #ffdd00;
  font-size: 20px;
  margin-left: 8px;
  cursor: pointer;
  transition: transform 0.2s;
}
.chat-input button:hover {
  transform: scale(1.2);
}

/* 🎛️ قائمة أدوات الأدمن */
.admin-menu {
  display: none;
  position: absolute;
  background: #2d3340;
  border: 1px solid #ffdd00;
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  z-index: 9999;
}
.admin-menu button {
  display: block;
  width: 100%;
  background: none;
  color: #fff;
  border: none;
  padding: 6px 10px;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s;
}
.admin-menu button:hover {
  background: rgba(255, 221, 0, 0.15);
}

/* 📱 تحسين للموبايل */
@media (max-width: 768px) {
  #members-container {
    display: none;
  }
  .chat-input input {
    font-size: 13px;
  }
  .topbar h2 {
    font-size: 16px;
  }
}

/* PROFILE */
.profile-card {
  max-width: 350px;
  margin: 50px auto;
  background: #2d3340;
  border-radius: 10px;
  text-align: center;
  padding: 20px;
}
.profile-avatar {
  width: 100px;
  border-radius: 50%;
  border: 3px solid #ffdd00;
}
.profile-stats {
  display: flex;
  justify-content: space-around;
  margin: 15px 0;
}
.progress-bar {
  width: 100%;
  height: 8px;
  background: #1c1f26;
  border-radius: 5px;
  overflow: hidden;
}
#xp-progress {
  height: 8px;
  background: #ffdd00;
  width: 0%;
}
.profile-actions button {
  margin: 5px;
  padding: 8px 15px;
  border: none;
  background: #ffdd00;
  color: #222830;
  border-radius: 5px;
  cursor: pointer;
}

/* POPUP SETTINGS */
.popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  background: rgba(0, 0, 0, 0.6);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.popup-content {
  background: #2d3340;
  padding: 20px;
  border-radius: 10px;
  width: 90%;
  max-width: 400px;
}
.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tabs {
  display: flex;
  justify-content: space-around;
  margin: 10px 0;
}
.tab {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-weight: 500;
}
.tab.active {
  color: #ffdd00;
}

.color-buttons button {
  margin: 5px;
  background: #1c1f26;
  color: #fff;
  border: 1px solid #ffdd00;
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
}
.save-btn {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  background: #ffdd00;
  color: #222830;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.settings-tabs {
  display: flex;
  justify-content: space-around;
  margin-bottom: 10px;
}
.tab-btn {
  background: none;
  border: none;
  color: #fff;
  padding: 8px 15px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab-btn.active {
  border-bottom: 2px solid #ffdd00;
  color: #ffdd00;
}
.tab-section {
  display: none;
}
.tab-section.active {
  display: block;
  margin-top: 10px;
}

.avatar-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.avatar-upload img {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 3px solid #ffdd00;
  object-fit: cover;
}
.avatar-upload input[type="file"] {
  background: #1c1f26;
  color: #fff;
  border: 1px solid #ffdd00;
  padding: 6px;
  border-radius: 5px;
  cursor: pointer;
}

.colored-preview {
  background: #1c1f26;
  padding: 10px;
  border-radius: 5px;
  text-align: center;
  margin: 10px 0;
}

#tab-security label,
#tab-profile label {
  display: block;
  margin-top: 10px;
  color: #ffdd00;
  font-size: 14px;
}

#tab-security input,
#tab-profile input {
  width: 100%;
  margin-top: 5px;
  padding: 8px;
  border-radius: 5px;
  border: none;
  background: #1c1f26;
  color: #fff;
}

#tab-profile .avatar-upload img {
  transition: transform 0.3s;
}
#tab-profile .avatar-upload img:hover {
  transform: scale(1.05);
}

.colored-name {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.role-badge {
  font-size: 14px;
  margin-left: 4px;
}
.role-badge.admin {
  color: #ff4d4d;
}
.role-badge.mod {
  color: #00bfff;
}
.role-badge.vip {
  color: #ffdd00;
}

/* 🏠 ROOMS SECTION */
#rooms-section {
  position: relative;
  padding-top: 70px;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background: #2d3340;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  z-index: 50;
  border-bottom: 2px solid #ffdd00;
}
.topbar .title {
  font-size: 18px;
  font-weight: 600;
}
.topbar i {
  color: #ffdd00;
  cursor: pointer;
  font-size: 20px;
  margin: 0 8px;
  transition: 0.2s;
}
.topbar i:hover {
  transform: scale(1.2);
}

.rooms-loader {
  display: none;
  text-align: center;
  color: #ffdd00;
  margin-top: 80px;
}
.rooms-loader.active {
  display: block;
}

.rooms-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  padding: 20px;
  margin-top: 60px;
}
.room-item {
  background: #2d3340;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s ease;
  border: 1px solid #333;
}
.room-item:hover {
  transform: scale(1.03);
}

.room-thumb {
  width: 100%;
  height: 150px;
  object-fit: cover;
}
.room-details {
  padding: 10px;
}
.room-name {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}
.room-meta {
  font-size: 14px;
  color: #ccc;
  margin-top: 5px;
}

.message {
  background: #2d3340;
  border-radius: 10px;
  padding: 8px 10px;
  margin: 6px 0;
  max-width: 80%;
  word-wrap: break-word;
}
.message.me {
  margin-left: auto;
  background: #ffdd00;
  color: #222830;
}
.msg-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}
.msg-header .avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
}
.msg-content {
  font-size: 14px;
}

/* 🎛️ ADMIN MENU STYLE */
.admin-menu {
  position: absolute;
  display: none;
  background: #2d3340;
  border: 2px solid #ffdd00;
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
  z-index: 3000;
  overflow: hidden;
  min-width: 180px;
  animation: fadeIn 0.2s ease-in-out;
}

.admin-menu button {
  display: block;
  width: 100%;
  background: none;
  border: none;
  padding: 10px 15px;
  color: #fff;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease;
}

.admin-menu button:hover {
  background: #ffdd00;
  color: #222830;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.members-container {
  position: absolute;
  top: 70px;
  right: 20px;
  width: 250px;
  background: #2d3340;
  border: 2px solid #ffdd00;
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
  z-index: 2000;
  padding: 15px;
  display: none;
}

.members-title {
  color: #ffdd00;
  margin-bottom: 10px;
  text-align: center;
}

.members-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #1c1f26;
  padding: 10px;
  border-radius: 10px;
  max-height: 300px;
  overflow-y: auto;
}

.member {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #2d3340;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.3s;
  cursor: pointer;
}

.member:hover {
  background: #ffdd00;
  color: #222830;
}

.avatar-sm {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  object-fit: cover;
}
