/* =========================================================
   CHATVERIX — PREMIUM DARK UI
   ========================================================= */

:root {
  --bg: #06090d;
  --bg-2: #0a0f15;
  --panel: rgba(15, 22, 30, 0.88);
  --panel-solid: #0f161e;
  --panel-2: #121b24;

  --border: rgba(255, 255, 255, 0.075);
  --border-hover: rgba(255, 255, 255, 0.14);

  --text: #f4f7fa;
  --muted: #8996a3;
  --muted-2: #5f6b77;

  --accent: #25d366;
  --accent-2: #16b957;

  --purple: #7c5cff;
  --purple-2: #6242e9;

  --danger: #ff4d67;
  --warning: #ffb84d;

  --incoming: rgba(255, 255, 255, 0.065);
  --outgoing: linear-gradient(135deg, #7656ff, #5940d7);

  --shadow: 0 20px 60px rgba(0, 0, 0, 0.42);

  --radius: 18px;
  --radius-sm: 12px;

  --header-height: 76px;
}


/* =========================================================
   RESET
   ========================================================= */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;

  background:
    radial-gradient(
      circle at 15% 10%,
      rgba(124, 92, 255, 0.10),
      transparent 28%
    ),
    radial-gradient(
      circle at 90% 85%,
      rgba(37, 211, 102, 0.055),
      transparent 28%
    ),
    var(--bg);

  color: var(--text);
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
}

button,
img {
  user-select: none;
}

input,
textarea {
  outline: none;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.tiny {
  font-size: 10px;
}


/* =========================================================
   SCROLLBAR
   ========================================================= */

::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.10);
  border-radius: 20px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}


/* =========================================================
   MAIN
   ========================================================= */

#main {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
}


/* =========================================================
   HEADER
   ========================================================= */

#profileBar {
  height: var(--header-height);
  min-height: var(--header-height);

  display: flex;
  align-items: center;

  padding: 0 24px;

  border-bottom: 1px solid var(--border);

  background: rgba(6, 9, 13, 0.78);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);

  position: relative;
  z-index: 100;
}

.profile-trigger {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 7px 10px;
  border-radius: 14px;
  transition:
    background 0.2s ease,
    transform 0.2s ease;
}

.profile-trigger:hover {
  background: rgba(255, 255, 255, 0.055);
}

.profile-trigger:active {
  transform: scale(0.98);
}

.avatar-wrapper {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

#userStatus {
  position: absolute;
  right: 0;
  bottom: 0;
}

.avatar {
  width: 44px;
  height: 44px;

  border-radius: 50%;
  object-fit: cover;

  background: #1c2630;

  border: 2px solid rgba(255, 255, 255, 0.09);

  cursor: pointer;

  transition:
    transform 0.25s ease,
    border-color 0.25s ease;
}

.avatar:hover {
  transform: scale(1.05);
  border-color: rgba(124, 92, 255, 0.7);
}

.profile-info {
  min-width: 130px;
}

.username {
  font-size: 14px;
  font-weight: 700;
}

.header-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.header-brand,
.brand-mobile {
  display: flex;
  align-items: center;
  gap: 9px;

  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.brand-mark {
  width: 29px;
  height: 29px;

  display: grid;
  place-items: center;

  border-radius: 9px;

  background: linear-gradient(
    135deg,
    var(--purple),
    var(--accent)
  );

  color: white;

  font-weight: 900;
  font-size: 13px;

  box-shadow:
    0 7px 25px rgba(124, 92, 255, 0.25);
}

.brand-mobile {
  display: none;
}

.header-actions {
  margin-left: auto;

  display: flex;
  align-items: center;
  gap: 8px;
}

.ghost {
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);

  border: 1px solid var(--border);

  padding: 9px 13px;
  border-radius: 11px;

  cursor: pointer;

  transition:
    0.2s ease;
}

.ghost:hover {
  color: white;
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-hover);
}

.logout-icon {
  margin-left: 4px;
  opacity: 0.6;
}

.icon-btn {
  display: none;
}


/* =========================================================
   APP CONTAINER
   ========================================================= */

#appContainer {
  flex: 1;
  min-height: 0;

  display: flex;

  padding: 14px;

  gap: 14px;
}


/* =========================================================
   SIDEBAR
   ========================================================= */

#sidebar {
  width: 320px;
  min-width: 280px;

  display: flex;
  flex-direction: column;

  background:
    linear-gradient(
      180deg,
      rgba(15, 22, 30, 0.92),
      rgba(10, 15, 21, 0.92)
    );

  border: 1px solid var(--border);

  border-radius: var(--radius);

  overflow: hidden;

  box-shadow: var(--shadow);
}

.sidebar-top {
  padding: 18px 16px 14px;
}

.sidebar-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;

  margin-bottom: 17px;
}

.eyebrow {
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.4px;
  margin-bottom: 4px;
}

.sidebar-title-row h2 {
  font-size: 20px;
  letter-spacing: -0.6px;
}

.room-count {
  min-width: 27px;
  height: 27px;

  display: grid;
  place-items: center;

  border-radius: 9px;

  background: rgba(124, 92, 255, 0.14);
  color: #a995ff;

  font-size: 11px;
  font-weight: 800;
}


/* =========================================================
   SIDEBAR ACTIONS
   ========================================================= */

.sidebar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.action-btn {
  height: 42px;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;

  border-radius: 12px;

  cursor: pointer;

  font-size: 12px;
  font-weight: 700;

  transition:
    transform 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.action-btn:hover {
  transform: translateY(-1px);
}

.action-btn:active {
  transform: scale(0.97);
}

.action-btn.primary {
  color: white;

  background:
    linear-gradient(
      135deg,
      var(--purple),
      var(--purple-2)
    );

  box-shadow:
    0 8px 25px rgba(124, 92, 255, 0.18);
}

.action-btn.primary:hover {
  box-shadow:
    0 11px 32px rgba(124, 92, 255, 0.28);
}

.action-btn.secondary {
  color: #d6dde3;

  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--border);
}

.action-icon {
  font-size: 16px;
}


/* =========================================================
   FORMS
   ========================================================= */

.room-form {
  margin-top: 10px;

  padding: 12px;

  background: rgba(255, 255, 255, 0.035);

  border: 1px solid var(--border);

  border-radius: 14px;

  animation: slideDown 0.22s ease;
}

.form-title {
  display: flex;
  align-items: center;
  justify-content: space-between;

  font-size: 12px;
  font-weight: 800;

  margin-bottom: 10px;
}

.form-close {
  width: 25px;
  height: 25px;

  border-radius: 7px;

  background: rgba(255, 255, 255, 0.055);

  color: var(--muted);

  cursor: pointer;

  transition: 0.2s;
}

.form-close:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.room-form input {
  width: 100%;

  margin-top: 7px;

  padding: 11px 12px;

  border-radius: 10px;

  border: 1px solid var(--border);

  background: rgba(0, 0, 0, 0.20);

  color: white;

  font-size: 12px;
}

.room-form input:focus {
  border-color: rgba(124, 92, 255, 0.65);

  box-shadow:
    0 0 0 3px rgba(124, 92, 255, 0.09);
}

.form-submit {
  width: 100%;

  margin-top: 9px;

  padding: 11px;

  border-radius: 10px;

  background:
    linear-gradient(
      135deg,
      var(--accent),
      var(--accent-2)
    );

  color: #031108;

  font-weight: 850;

  cursor: pointer;

  transition:
    transform 0.18s ease,
    filter 0.18s ease;
}

.form-submit:hover {
  filter: brightness(1.08);
}

.form-submit:active {
  transform: scale(0.98);
}


/* =========================================================
   FILTER
   ========================================================= */

.room-filter {
  display: flex;
  gap: 4px;

  padding: 4px;

  margin-top: 13px;

  background: rgba(0, 0, 0, 0.22);

  border: 1px solid var(--border);

  border-radius: 11px;
}

.filter-btn {
  flex: 1;

  padding: 8px 4px;

  border-radius: 8px;

  background: transparent;

  color: var(--muted);

  cursor: pointer;

  font-size: 10px;
  font-weight: 700;

  transition: 0.2s;
}

.filter-btn:hover {
  color: white;
}

.filter-btn.active {
  background: rgba(124, 92, 255, 0.17);
  color: #b6a9ff;
}


/* =========================================================
   SEARCH
   ========================================================= */

.room-search {
  position: relative;

  margin-top: 11px;
}

.room-search input {
  width: 100%;

  height: 39px;

  padding:
    0 34px;

  border-radius: 11px;

  border: 1px solid var(--border);

  background: rgba(255, 255, 255, 0.035);

  color: white;

  font-size: 12px;

  transition: 0.2s;
}

.room-search input::placeholder {
  color: var(--muted-2);
}

.room-search input:focus {
  background: rgba(255, 255, 255, 0.05);

  border-color:
    rgba(124, 92, 255, 0.45);

  box-shadow:
    0 0 0 3px rgba(124, 92, 255, 0.06);
}

.search-icon {
  position: absolute;

  left: 12px;
  top: 50%;

  transform: translateY(-52%);

  color: var(--muted);

  pointer-events: none;
}

.search-clear {
  position: absolute;

  right: 7px;
  top: 7px;

  width: 25px;
  height: 25px;

  border-radius: 7px;

  background: rgba(255,255,255,0.06);

  color: var(--muted);

  cursor: pointer;
}


/* =========================================================
   ROOM LIST
   ========================================================= */

.room-list-heading {
  padding: 8px 17px;

  display: flex;
  align-items: center;
  justify-content: space-between;

  font-size: 10px;
  font-weight: 800;

  color: var(--muted);

  text-transform: uppercase;
  letter-spacing: 1px;
}

#roomList {
  flex: 1;

  min-height: 0;

  overflow-y: auto;

  padding: 0 8px 10px;
}

.room-row {
  position: relative;

  display: flex;
  align-items: center;

  gap: 5px;

  padding: 3px;

  border-radius: 12px;

  animation: roomAppear 0.22s ease both;
}

.room-row:hover {
  background: rgba(255,255,255,0.035);
}

.room-row.active {
  background:
    linear-gradient(
      90deg,
      rgba(124,92,255,0.13),
      rgba(124,92,255,0.04)
    );
}

.room-row > button:first-child {
  flex: 1;

  min-width: 0;

  padding: 10px 11px;

  text-align: left;

  border-radius: 10px;

  background: transparent;

  color: #dbe2e8;

  cursor: pointer;

  overflow: hidden;

  white-space: nowrap;

  text-overflow: ellipsis;

  font-size: 12px;
  font-weight: 650;

  transition: 0.18s;
}

.room-row.active > button:first-child {
  color: white;
}

.room-row:hover > button:first-child {
  color: white;
}

.room-dots {
  width: 30px;
  height: 30px;

  display: grid;
  place-items: center;

  border-radius: 9px;

  color: var(--muted);

  cursor: pointer;

  font-size: 17px;

  transition: 0.18s;
}

.room-dots:hover {
  color: white;
  background: rgba(255,255,255,0.08);
}


/* =========================================================
   EMPTY ROOMS
   ========================================================= */

.empty-rooms {
  padding: 30px 20px;

  text-align: center;

  color: var(--muted);

  display: flex;
  flex-direction: column;
  align-items: center;

  gap: 5px;

  font-size: 11px;
}

.empty-rooms strong {
  color: #cbd3da;
  font-size: 12px;
}

.empty-icon {
  width: 42px;
  height: 42px;

  display: grid;
  place-items: center;

  border-radius: 13px;

  background: rgba(124,92,255,0.09);

  color: #9b88ff;

  font-size: 25px;

  margin-bottom: 4px;
}


/* =========================================================
   SIDEBAR FOOTER
   ========================================================= */

.sidebar-footer {
  padding: 12px 16px;

  border-top: 1px solid var(--border);

  color: var(--muted-2);

  font-size: 10px;

  display: flex;
  align-items: center;
  gap: 7px;
}

.online-pulse {
  width: 6px;
  height: 6px;

  border-radius: 50%;

  background: var(--accent);

  box-shadow:
    0 0 0 4px rgba(37,211,102,0.08);

  animation: pulse 2s infinite;
}


/* =========================================================
   CHAT
   ========================================================= */

#chat {
  position: relative;

  flex: 1;

  min-width: 0;
  min-height: 0;

  border-radius: var(--radius);

  overflow: hidden;

  border: 1px solid var(--border);

  background:
    radial-gradient(
      circle at 50% 0%,
      rgba(124,92,255,0.055),
      transparent 32%
    ),
    rgba(10,15,21,0.82);

  box-shadow: var(--shadow);
}

.chat-content {
  width: 100%;
  height: 100%;

  display: flex;
  flex-direction: column;
}


/* =========================================================
   EMPTY CHAT
   ========================================================= */

.empty-chat-state {
  height: 100%;

  display: flex;
  flex-direction: column;

  align-items: center;
  justify-content: center;

  text-align: center;

  padding: 30px;

  animation: fadeIn 0.4s ease;
}

.empty-chat-logo {
  width: 75px;
  height: 75px;

  display: grid;
  place-items: center;

  border-radius: 24px;

  background:
    linear-gradient(
      135deg,
      rgba(124,92,255,0.9),
      rgba(37,211,102,0.85)
    );

  box-shadow:
    0 20px 60px rgba(124,92,255,0.20);

  margin-bottom: 20px;

  animation: floating 4s ease-in-out infinite;
}

.empty-chat-logo span {
  color: white;
  font-weight: 900;
  font-size: 30px;
}

.empty-chat-state h1 {
  font-size: 24px;
  letter-spacing: -0.8px;
  margin-bottom: 7px;
}

.empty-chat-state p {
  color: var(--muted);
  font-size: 13px;
}

.empty-features {
  margin-top: 18px;

  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: center;
}

.empty-features span {
  padding: 7px 10px;

  border-radius: 20px;

  border: 1px solid var(--border);

  background: rgba(255,255,255,0.035);

  color: var(--muted);

  font-size: 10px;
}


/* =========================================================
   CHAT HEADER
   ========================================================= */

#chatHeaderBar {
  min-height: 68px;

  display: flex;
  align-items: center;

  padding: 10px 16px;

  border-bottom: 1px solid var(--border);

  background:
    rgba(10,15,21,0.78);

  backdrop-filter: blur(20px);

  z-index: 5;
}

.chat-room-avatar {
  width: 42px;
  height: 42px;

  flex-shrink: 0;

  display: grid;
  place-items: center;

  border-radius: 13px;

  background:
    linear-gradient(
      135deg,
      rgba(124,92,255,0.8),
      rgba(94,68,218,0.8)
    );

  box-shadow:
    0 7px 22px rgba(124,92,255,0.16);
}

.chat-room-avatar span {
  font-size: 15px;
  font-weight: 900;
}

.chat-room-details {
  min-width: 0;
  margin-left: 11px;
}

#chatHeader {
  font-size: 14px;
  font-weight: 800;

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-room-subtitle {
  margin-top: 3px;

  display: flex;
  align-items: center;
  gap: 6px;

  color: var(--muted);

  font-size: 10px;
}

.mini-online {
  width: 5px;
  height: 5px;

  border-radius: 50%;

  background: var(--accent);

  box-shadow:
    0 0 0 3px rgba(37,211,102,0.08);
}

.chat-header-actions {
  margin-left: auto;

  display: flex;
  gap: 5px;
}

.header-icon-btn {
  width: 35px;
  height: 35px;

  border-radius: 10px;

  background: transparent;

  color: var(--muted);

  cursor: pointer;

  transition: 0.2s;
}

.header-icon-btn:hover {
  background: rgba(255,255,255,0.07);
  color: white;
  transform: translateY(-1px);
}


/* =========================================================
   ROOM INFO
   ========================================================= */

#roomInfoWrapper {
  max-height: 0;

  overflow: hidden;

  border-bottom: 0 solid var(--border);

  background:
    rgba(8,12,17,0.96);

  transition:
    max-height 0.3s ease,
    border-bottom-width 0.3s ease;
}

#roomInfoWrapper.open {
  max-height: 220px;
  border-bottom-width: 1px;
}

#roomInfoContent {
  padding: 14px 18px;
}

.room-info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.room-info-item {
  padding: 10px 11px;

  border-radius: 11px;

  background: rgba(255,255,255,0.035);

  border: 1px solid var(--border);

  min-width: 0;
}

.info-label {
  display: block;

  color: var(--muted-2);

  font-size: 8px;
  font-weight: 800;

  letter-spacing: 1px;

  margin-bottom: 5px;
}

.room-info-item > span:last-child {
  font-size: 11px;
  color: #dfe5ea;

  word-break: break-word;
}

.room-url-item {
  grid-column: span 3;
}

.room-link-row {
  display: flex;
  gap: 6px;
}

.room-link-row input {
  flex: 1;

  min-width: 0;

  padding: 8px 9px;

  border-radius: 8px;

  background: rgba(0,0,0,0.25);

  border: 1px solid var(--border);

  color: var(--muted);

  font-size: 10px;
}

.room-link-row button {
  padding: 0 12px;

  border-radius: 8px;

  background: rgba(124,92,255,0.15);

  color: #ad9fff;

  cursor: pointer;

  font-size: 10px;
  font-weight: 700;
}


/* =========================================================
   MESSAGES
   ========================================================= */

.messages {
  flex: 1;

  min-height: 0;

  overflow-y: auto;

  padding:
    20px
    clamp(12px, 4vw, 48px)
    25px;

  display: flex;
  flex-direction: column;

  gap: 7px;

  scroll-behavior: smooth;
}

.center {
  margin: auto;
  text-align: center;
  font-size: 12px;
}


/* =========================================================
   MESSAGE
   ========================================================= */

.message {
  position: relative;

  display: flex;

  align-items: flex-end;

  gap: 7px;

  width: 100%;

  animation:
    messageIn 0.25s ease both;
}

.message.mine {
  justify-content: flex-end;
}

.msg-avatar {
  width: 29px;
  height: 29px;

  border-radius: 50%;

  object-fit: cover;

  cursor: pointer;

  border: 1px solid rgba(255,255,255,0.08);

  transition:
    transform 0.2s ease,
    border-color 0.2s ease;

  flex-shrink: 0;
}

.msg-avatar:hover {
  transform: scale(1.08);
  border-color: rgba(124,92,255,0.7);
}

.bubble {
  position: relative;

  max-width: min(75%, 580px);

  padding: 9px 11px 7px;

  border-radius: 15px;

  background: var(--incoming);

  border: 1px solid rgba(255,255,255,0.055);

  color: #e9eef2;

  box-shadow:
    0 5px 20px rgba(0,0,0,0.08);

  line-height: 1.45;

  font-size: 13px;

  word-break: break-word;

  transition:
    transform 0.18s ease,
    background 0.18s ease;
}

.message:not(.mine) .bubble {
  border-bottom-left-radius: 5px;
}

.message.mine .bubble {
  background: var(--outgoing);

  border-color: rgba(255,255,255,0.09);

  box-shadow:
    0 8px 25px rgba(89,64,215,0.14);
}

.message.mine .bubble {
  border-bottom-right-radius: 5px;
}

.message:hover .bubble {
  transform: translateY(-1px);
}

.msg-name {
  font-size: 9px;

  font-weight: 800;

  margin-bottom: 3px;

  opacity: 0.85;
}

.message.mine .msg-name {
  color: #d8d1ff !important;
}


/* =========================================================
   TIME
   ========================================================= */

.msg-time {
  margin-top: 5px;

  text-align: right;

  color: rgba(255,255,255,0.42);

  font-size: 8px;

  line-height: 1;
}


/* =========================================================
   SYSTEM MESSAGE
   ========================================================= */

.system-message {
  align-self: center;

  max-width: 85%;

  padding: 5px 10px;

  margin: 5px 0;

  border-radius: 20px;

  background: rgba(255,255,255,0.035);

  border: 1px solid var(--border);

  color: var(--muted);

  font-size: 9px;

  text-align: center;

  animation: fadeIn 0.3s ease;
}


/* =========================================================
   REPLY
   ========================================================= */

.reply-box {
  padding: 7px 9px;

  margin-bottom: 7px;

  border-left: 3px solid #a28fff;

  border-radius: 7px;

  background: rgba(0,0,0,0.18);

  cursor: pointer;

  transition: 0.2s;
}

.reply-box:hover {
  background: rgba(0,0,0,0.28);
}

.reply-name {
  font-size: 9px;

  font-weight: 800;

  color: #b5a7ff;

  margin-bottom: 2px;
}

.reply-text {
  color: rgba(255,255,255,0.62);

  font-size: 9px;

  white-space: nowrap;

  overflow: hidden;

  text-overflow: ellipsis;

  max-width: 350px;
}


/* =========================================================
   REACTIONS
   ========================================================= */

.reaction-box {
  position: absolute;

  bottom: -10px;
  right: 9px;

  display: flex;
  gap: 3px;

  padding: 3px 6px;

  border-radius: 20px;

  background: #10161d;

  border: 1px solid rgba(255,255,255,0.10);

  box-shadow:
    0 5px 15px rgba(0,0,0,0.3);

  z-index: 2;
}

.reaction-item {
  font-size: 9px;

  color: white;
}


/* =========================================================
   CHAT IMAGE
   ========================================================= */

.chat-image {
  max-width: min(340px, 100%);

  max-height: 330px;

  display: block;

  object-fit: cover;

  border-radius: 10px;

  cursor: pointer;

  transition:
    transform 0.2s ease,
    filter 0.2s ease;
}

.chat-image:hover {
  transform: scale(1.015);
  filter: brightness(1.06);
}


/* =========================================================
   LINKS
   ========================================================= */

.chat-link {
  color: #b7aaff;

  text-decoration: none;

  word-break: break-all;
}

.chat-link:hover {
  text-decoration: underline;
}


/* =========================================================
   DOCUMENT
   ========================================================= */

.chat-document {
  min-width: 210px;

  display: flex;
  align-items: center;

  gap: 9px;

  padding: 9px;

  border-radius: 10px;

  background: rgba(0,0,0,0.16);

  color: white;

  text-decoration: none;

  transition: 0.2s;
}

.chat-document:hover {
  background: rgba(0,0,0,0.27);
}

.doc-icon {
  width: 34px;
  height: 34px;

  display: grid;
  place-items: center;

  border-radius: 9px;

  background: rgba(255,255,255,0.08);

  font-size: 16px;
}

.doc-name {
  font-size: 11px;

  font-weight: 700;

  max-width: 180px;

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-size {
  margin-top: 2px;

  color: rgba(255,255,255,0.45);

  font-size: 8px;
}


/* =========================================================
   MESSAGE MENU
   ========================================================= */

.room-menu {
  min-width: 155px;

  padding: 5px;

  border-radius: 12px;

  background:
    rgba(18,24,32,0.97);

  border: 1px solid var(--border);

  box-shadow:
    0 18px 45px rgba(0,0,0,0.48);

  backdrop-filter: blur(18px);

  overflow: hidden;

  animation: menuIn 0.14s ease;
}

.room-menu-item {
  padding: 9px 11px;

  border-radius: 8px;

  color: #dce3e8;

  cursor: pointer;

  font-size: 11px;

  transition: 0.15s;
}

.room-menu-item:hover {
  background: rgba(255,255,255,0.07);
  color: white;
}

.room-menu-item.danger {
  color: #ff7183;
}

.room-menu-item.danger:hover {
  background: rgba(255,77,103,0.09);
}


/* =========================================================
   COMPOSER
   ========================================================= */

#chatBottomWrapper {
  position: relative;

  padding: 9px 14px 14px;

  background:
    linear-gradient(
      180deg,
      transparent,
      rgba(6,9,13,0.72) 18%
    );
}

#replyBar {
  display: none;

  margin: 0 auto 7px;

  max-width: 850px;

  padding: 8px 11px;

  border-radius: 11px;

  border: 1px solid var(--border);

  border-left: 3px solid var(--purple);

  background: rgba(17,23,31,0.92);

  animation: slideUp 0.2s ease;
}

.reply-bar-inner {
  display: flex;

  align-items: center;

  gap: 10px;
}

.reply-bar-copy {
  flex: 1;

  min-width: 0;
}

.reply-bar-title {
  font-size: 9px;

  color: #a99aff;

  font-weight: 800;
}

.reply-bar-text {
  margin-top: 2px;

  color: var(--muted);

  font-size: 10px;

  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.reply-cancel {
  width: 26px;
  height: 26px;

  border-radius: 8px;

  background: rgba(255,255,255,0.05);

  color: var(--muted);

  cursor: pointer;
}

.reply-cancel:hover {
  color: white;
}

#typingIndicator {
  position: absolute;

  left: 20px;
  bottom: 76px;

  z-index: 10;
}

.typing-bubble {
  display: flex;

  align-items: center;

  gap: 7px;

  padding: 5px 8px;

  border-radius: 20px;

  background: rgba(18,24,32,0.95);

  border: 1px solid var(--border);

  box-shadow:
    0 8px 25px rgba(0,0,0,0.25);

  animation: slideUp 0.2s ease;
}

.typing-avatar {
  width: 23px;
  height: 23px;

  border-radius: 50%;

  object-fit: cover;
}

.typing-dots {
  display: flex;
  gap: 3px;
}

.typing-dots .dot {
  width: 4px;
  height: 4px;

  border-radius: 50%;

  background: #a9b2bb;

  animation: typingBounce 1.1s infinite;
}

.typing-dots .dot:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots .dot:nth-child(3) {
  animation-delay: 0.3s;
}

#chatBottom {
  width: 100%;

  max-width: 950px;

  margin: 0 auto;

  display: flex;
  align-items: flex-end;

  gap: 7px;

  padding: 7px;

  border-radius: 16px;

  background:
    rgba(17,24,32,0.94);

  border: 1px solid var(--border);

  box-shadow:
    0 10px 40px rgba(0,0,0,0.25);

  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

#chatBottom:focus-within {
  border-color: rgba(124,92,255,0.38);

  box-shadow:
    0 10px 40px rgba(0,0,0,0.3),
    0 0 0 3px rgba(124,92,255,0.05);
}

.composer-left {
  flex-shrink: 0;
}

.composer-icon {
  width: 38px;
  height: 38px;

  border-radius: 11px;

  background: rgba(255,255,255,0.045);

  color: #aeb8c1;

  cursor: pointer;

  font-size: 20px;

  transition:
    transform 0.2s ease,
    background 0.2s ease,
    color 0.2s ease;
}

.composer-icon:hover {
  color: white;
  background: rgba(124,92,255,0.13);
  transform: rotate(90deg);
}

.attachment-wrapper {
  position: relative;
}

.attachment-menu {
  position: absolute;

  left: 0;
  bottom: 49px;

  width: 190px;

  padding: 6px;

  border-radius: 14px;

  background:
    rgba(18,24,32,0.97);

  border: 1px solid var(--border);

  box-shadow:
    0 18px 45px rgba(0,0,0,0.45);

  backdrop-filter: blur(18px);

  opacity: 0;

  transform:
    translateY(7px)
    scale(0.96);

  pointer-events: none;

  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.attachment-menu.show {
  opacity: 1;

  transform:
    translateY(0)
    scale(1);

  pointer-events: auto;
}

.attachment-menu button {
  width: 100%;

  display: flex;
  align-items: center;

  gap: 9px;

  padding: 9px;

  border-radius: 9px;

  background: transparent;

  color: white;

  text-align: left;

  cursor: pointer;

  transition: 0.15s;
}

.attachment-menu button:hover {
  background: rgba(255,255,255,0.07);
}

.attachment-menu button > span {
  width: 28px;
  height: 28px;

  display: grid;
  place-items: center;

  border-radius: 8px;

  background: rgba(255,255,255,0.06);
}

.attachment-menu strong {
  display: block;
  font-size: 10px;
}

.attachment-menu small {
  display: block;

  margin-top: 2px;

  color: var(--muted);

  font-size: 8px;
}

.message-input-wrap {
  flex: 1;

  min-width: 0;

  position: relative;
}

#msgInput {
  width: 100%;

  min-height: 38px;
  max-height: 120px;

  resize: none;

  border: 0;

  padding: 10px 55px 10px 9px;

  background: transparent;

  color: white;

  font-size: 12px;

  line-height: 18px;
}

#msgInput::placeholder {
  color: var(--muted-2);
}

.input-hint {
  position: absolute;

  right: 8px;
  bottom: 7px;

  color: var(--muted-2);

  font-size: 8px;

  pointer-events: none;
}

.send-button {
  width: 38px;
  height: 38px;

  flex-shrink: 0;

  display: grid;
  place-items: center;

  border-radius: 11px;

  background:
    linear-gradient(
      135deg,
      var(--accent),
      var(--accent-2)
    );

  color: #041108;

  cursor: pointer;

  font-size: 16px;
  font-weight: 900;

  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    filter 0.18s ease;
}

.send-button:hover {
  transform: translateY(-2px) rotate(-3deg);

  box-shadow:
    0 8px 25px rgba(37,211,102,0.22);

  filter: brightness(1.06);
}

.send-button:active {
  transform: scale(0.92);
}

.send-button:disabled {
  cursor: wait;
  opacity: 0.55;
  transform: none;
  box-shadow: none;
  filter: grayscale(0.35);
}


/* =========================================================
   STATUS
   ========================================================= */

.status-dot {
  width: 10px;
  height: 10px;

  border-radius: 50%;

  border: 2px solid var(--panel-solid);

  background: #606a73;

  transition: background 0.25s ease;

  display: inline-block;
}

.status-dot.online {
  background: var(--accent);

  box-shadow:
    0 0 0 3px rgba(37,211,102,0.09);
}

.status-dot.offline {
  background: #59636c;
}


/* =========================================================
   USERS PANEL
   ========================================================= */

#usersPanelMenu {
  position: fixed;

  top: 0;
  right: 0;

  width: 330px;
  max-width: calc(100vw - 25px);

  height: 100vh;

  z-index: 5000;

  background:
    rgba(11,16,23,0.97);

  border-left: 1px solid var(--border);

  box-shadow:
    -20px 0 60px rgba(0,0,0,0.38);

  backdrop-filter: blur(25px);

  transform: translateX(105%);

  transition:
    transform 0.3s cubic-bezier(.2,.8,.2,1);

  display: flex;
  flex-direction: column;
}

#usersPanelMenu.open {
  transform: translateX(0);
}

.users-panel-header {
  min-height: 75px;

  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 14px 17px;

  border-bottom: 1px solid var(--border);
}

.users-panel-header h3 {
  font-size: 17px;
}

.users-panel-header button {
  width: 33px;
  height: 33px;

  border-radius: 10px;

  background: rgba(255,255,255,0.05);

  color: var(--muted);

  cursor: pointer;

  font-size: 20px;
}

.users-panel-header button:hover {
  color: white;
  background: rgba(255,255,255,0.09);
}

#liveUsersList {
  flex: 1;

  overflow-y: auto;

  padding: 13px;
}

.userItem {
  padding: 10px;

  border-radius: 12px;

  border: 1px solid transparent;

  transition: 0.18s;

  animation: roomAppear 0.2s ease both;
}

.userItem:hover {
  background: rgba(255,255,255,0.04);
  border-color: var(--border);
}

.user-avatar {
  border: 2px solid rgba(255,255,255,0.08);
}


/* =========================================================
   PROFILE MODAL
   ========================================================= */

#profileModal {
  position: fixed;

  inset: 0;

  z-index: 10000;

  display: none;

  align-items: center;
  justify-content: center;

  padding: 20px;
}

#profileModal.show {
  display: flex;

  animation: fadeIn 0.2s ease;
}

.modal-backdrop {
  position: absolute;

  inset: 0;

  background: rgba(0,0,0,0.67);

  backdrop-filter: blur(8px);
}

.modal-content {
  position: relative;

  width: min(430px, 100%);

  padding: 22px;

  border-radius: 20px;

  background:
    linear-gradient(
      180deg,
      #111922,
      #0d141b
    );

  border: 1px solid var(--border);

  box-shadow:
    0 30px 90px rgba(0,0,0,0.58);

  animation:
    modalIn 0.25s cubic-bezier(.2,.8,.2,1);
}

.modal-close {
  position: absolute;

  top: 13px;
  right: 13px;

  width: 30px;
  height: 30px;

  border-radius: 9px;

  background: rgba(255,255,255,0.05);

  color: var(--muted);

  cursor: pointer;

  font-size: 19px;

  transition: 0.2s;
}

.modal-close:hover {
  color: white;
  background: rgba(255,255,255,0.09);
}

.modal-header {
  display: flex;
  align-items: center;

  gap: 14px;

  margin-bottom: 20px;
}

.modal-header h2 {
  font-size: 18px;
}

.modal-avatar-wrapper {
  position: relative;

  width: 68px;
  height: 68px;
}

#modalPhoto {
  width: 68px;
  height: 68px;

  object-fit: cover;

  border-radius: 20px;

  border: 2px solid rgba(255,255,255,0.09);

  background: #1a232d;
}

#changeAvatarButton {
  position: absolute;

  right: -4px;
  bottom: -4px;

  width: 25px;
  height: 25px;

  border-radius: 8px;

  background: var(--purple);

  color: white;

  cursor: pointer;
}

#modalStatusRow {
  display: flex;

  align-items: center;

  gap: 6px;

  color: var(--muted);

  font-size: 10px;

  margin-top: 5px;
}

.modal-fields {
  display: grid;
  gap: 12px;
}

.modal-fields label {
  display: grid;
  gap: 6px;

  color: var(--muted);

  font-size: 10px;
  font-weight: 700;
}

.modal-fields input {
  width: 100%;

  padding: 11px;

  border-radius: 10px;

  background: rgba(255,255,255,0.035);

  border: 1px solid var(--border);

  color: white;

  font-size: 12px;
}

.modal-fields input:focus {
  border-color: rgba(124,92,255,0.5);

  box-shadow:
    0 0 0 3px rgba(124,92,255,0.06);
}

.modal-fields input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.modal-note {
  margin-top: 12px;

  padding: 10px;

  border-radius: 10px;

  background: rgba(124,92,255,0.07);

  border: 1px solid rgba(124,92,255,0.12);

  color: var(--muted);

  font-size: 9px;

  line-height: 1.5;
}


/* =========================================================
   IMAGE VIEWER
   ========================================================= */

.image-viewer {
  position: fixed;

  inset: 0;

  z-index: 20000;

  display: flex;

  align-items: center;
  justify-content: center;

  padding: 50px;

  background:
    rgba(0,0,0,0.86);

  backdrop-filter: blur(12px);

  opacity: 0;

  pointer-events: none;

  transition:
    opacity 0.25s ease;
}

.image-viewer.show {
  opacity: 1;

  pointer-events: auto;
}

.image-viewer img {
  max-width: min(1100px, 92vw);
  max-height: 82vh;

  object-fit: contain;

  border-radius: 12px;

  box-shadow:
    0 30px 90px rgba(0,0,0,0.6);

  transform: scale(0.95);

  transition:
    transform 0.3s cubic-bezier(.2,.8,.2,1);
}

.image-viewer.show img {
  transform: scale(1);
}

.viewer-close {
  position: absolute;

  top: 20px;
  right: 25px;

  width: 42px;
  height: 42px;

  border-radius: 12px;

  background: rgba(255,255,255,0.08);

  color: white;

  cursor: pointer;

  font-size: 25px;

  z-index: 3;
}

.viewer-download {
  position: absolute;

  bottom: 22px;

  right: 25px;

  padding: 10px 14px;

  border-radius: 10px;

  background: rgba(255,255,255,0.92);

  color: #101010;

  cursor: pointer;

  font-size: 11px;

  font-weight: 800;
}


/* =========================================================
   SEEN OVERLAY
   ========================================================= */

.seen-overlay {
  position: fixed;

  inset: 0;

  z-index: 15000;

  display: flex;

  align-items: center;
  justify-content: center;

  padding: 20px;

  background: rgba(0,0,0,0.6);

  backdrop-filter: blur(8px);

  animation: fadeIn 0.2s ease;
}

.seen-box {
  width: min(370px, 100%);
  max-height: 75vh;

  overflow: hidden;

  display: flex;
  flex-direction: column;

  background: #10171f;

  border: 1px solid var(--border);

  border-radius: 18px;

  box-shadow: var(--shadow);
}

.seen-header {
  padding: 15px 17px;

  display: flex;
  justify-content: space-between;
  align-items: center;

  border-bottom: 1px solid var(--border);
}

.seen-header h3 {
  font-size: 16px;
}

.seen-header button {
  width: 30px;
  height: 30px;

  border-radius: 9px;

  background: rgba(255,255,255,0.05);

  color: var(--muted);

  cursor: pointer;

  font-size: 18px;
}

#seenList {
  padding: 14px;

  overflow-y: auto;
}


/* =========================================================
   TOAST
   ========================================================= */

#toastContainer {
  position: fixed;

  top: 88px;
  right: 20px;

  z-index: 30000;

  display: flex;
  flex-direction: column;

  gap: 8px;

  pointer-events: none;
}

.toast {
  max-width: 320px;

  padding: 11px 13px;

  border-radius: 11px;

  background: rgba(18,24,32,0.96);

  border: 1px solid var(--border);

  color: #e9eef2;

  font-size: 11px;

  box-shadow:
    0 15px 40px rgba(0,0,0,0.35);

  animation:
    toastIn 0.25s ease both;
}

.toast.error {
  border-color: rgba(255,77,103,0.3);
}

.toast.success {
  border-color: rgba(37,211,102,0.3);
}

.toast.out {
  animation:
    toastOut 0.2s ease forwards;
}


/* =========================================================
   ANIMATIONS
   ========================================================= */

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(7px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes roomAppear {
  from {
    opacity: 0;
    transform: translateX(-5px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes menuIn {
  from {
    opacity: 0;
    transform: translateY(-5px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(15px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes floating {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-7px);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.45;
  }
}

@keyframes typingBounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }

  30% {
    transform: translateY(-4px);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(15px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(15px);
  }
}


/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 900px) {

  #appContainer {
    padding: 8px;
  }

  #sidebar {
    width: 290px;
    min-width: 260px;
  }

  .room-info-grid {
    grid-template-columns: 1fr 1fr;
  }

  .room-url-item {
    grid-column: span 2;
  }

}


@media (max-width: 720px) {

  #profileBar {
    height: 64px;
    min-height: 64px;

    padding: 0 12px;
  }

  .header-center {
    display: none;
  }

  .brand-mobile {
    display: flex;

    position: absolute;

    left: 50%;

    transform: translateX(-50%);
  }

  .profile-info {
    display: none;
  }

  .logout-btn span:first-child {
    display: none;
  }

  .icon-btn {
    display: grid;
    place-items: center;

    width: 34px;
    height: 34px;

    border-radius: 9px;

    background: rgba(255,255,255,0.05);

    color: var(--muted);

    cursor: pointer;
  }

  #appContainer {
    padding: 6px;
  }

  #sidebar {
    position: fixed;

    top: 70px;
    left: 6px;
    bottom: 6px;

    width: min(330px, calc(100vw - 12px));

    z-index: 900;

    transform: translateX(-110%);

    transition:
      transform 0.28s cubic-bezier(.2,.8,.2,1);
  }

  #sidebar.mobile-open {
    transform: translateX(0);
  }

  #chat {
    width: 100%;
  }

  .messages {
    padding:
      15px
      9px
      20px;
  }

  .bubble {
    max-width: 82%;
  }

  .input-hint {
    display: none;
  }

  .chat-room-details {
    max-width: 55%;
  }

  .room-info-grid {
    grid-template-columns: 1fr;
  }

  .room-url-item {
    grid-column: span 1;
  }

}


@media (max-width: 470px) {

  #profileBar {
    padding: 0 8px;
  }

  .logout-btn {
    padding: 8px 9px;
  }

  #chatBottomWrapper {
    padding:
      7px
      6px
      8px;
  }

  #chatBottom {
    border-radius: 14px;
  }

  .composer-icon,
  .send-button {
    width: 35px;
    height: 35px;
  }

  #msgInput {
    font-size: 11px;
  }

  .bubble {
    font-size: 12px;
  }

  .chat-image {
    max-width: 240px;
  }

  .attachment-menu {
    width: 175px;
  }

}


/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

}
