/* ========================================================================== */
/*                         PREMIUM MISCORD — DARK CRYSTAL                     */
/*        High-Gloss Dark Theme + Waveform Overlay + Mobile Responsive        */
/* ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=SF+Pro+Display:wght@300;400;600;700&display=swap');

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background: radial-gradient(circle at top left, #301a4b 0, #090910 50%, #040409 100%);
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Vazirmatn', sans-serif;
    display: flex;
    height: 100vh;
    overflow: hidden;
    direction: rtl;
    color: #E4E4F0;
}

/* ================= LAYOUT ================= */
#sidebar {
    width: 280px;
    background: rgba(10, 10, 18, 0.94);
    backdrop-filter: blur(26px) saturate(180%);
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    direction: ltr;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
}

#main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

#voice-panel {
    width: 280px;
    background: radial-gradient(circle at top, rgba(25, 20, 40, 0.95), rgba(10, 10, 16, 0.95));
    backdrop-filter: blur(28px);
    border-right: 1px solid rgba(31, 31, 40, 0.7);
    padding: 20px;
    display: flex;
    flex-direction: column;
    color: #ccc;
    overflow-y: auto;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.6);
}

/* ================= SIDEBAR HEADER ================= */
#sidebar-header {
    padding: 18px 20px;
    text-align: center;
    background: linear-gradient(135deg, #181822 0, #3a1656 80%);
    font-weight: 700;
    color: #F2ECFF;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 0 0 18px 18px;
}

#sidebar-header h2 {
    margin: 0;
    font-size: 20px;
}

/* ================= SCROLLBARS ================= */
#sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 12px;
}

#sidebar-scroll,
#chat-box,
#voice-panel {
    scrollbar-width: thin;
    scrollbar-color: rgba(56, 56, 70, 0.7) rgba(16, 16, 24, 0.85);
}

#sidebar-scroll::-webkit-scrollbar,
#chat-box::-webkit-scrollbar,
#voice-panel::-webkit-scrollbar {
    width: 6px;
}

#sidebar-scroll::-webkit-scrollbar-track,
#chat-box::-webkit-scrollbar-track,
#voice-panel::-webkit-scrollbar-track {
    background: rgba(16, 16, 24, 0.8);
}

#sidebar-scroll::-webkit-scrollbar-thumb,
#chat-box::-webkit-scrollbar-thumb,
#voice-panel::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(88, 88, 112, 0.9), rgba(40, 40, 60, 0.9));
    border-radius: 999px;
}

/* ================= CATEGORY TITLES ================= */
.category {
    padding: 14px 20px 6px;
    font-size: 11px;
    color: rgba(140, 140, 160, 0.9);
    margin-top: 12px;
    font-weight: 600;
    letter-spacing: 0.7px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 6px;
    direction: rtl;
    text-align: right;
}

.category .cat-icon {
    font-size: 13px;
}

/* ================= CHANNELS ================= */
#text-channels,
#voice-channels {
    direction: rtl;
    text-align: right;
}

.channel,
.voice-channel {
    padding: 10px 16px;
    cursor: pointer;
    color: #c9c9d1;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 12px;
    margin: 2px 10px;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    background: transparent;
}

.channel .ch-icon {
    opacity: 0.7;
}

.channel:hover,
.voice-channel:hover {
    background: radial-gradient(circle at right, rgba(123, 47, 247, 0.28), rgba(40, 18, 80, 0.7));
    border-right: 4px solid rgba(123, 47, 247, 0.75);
    color: #fff;
    transform: translateX(-2px);
}

.channel.active,
.voice-channel.active {
    background: linear-gradient(135deg, rgba(123, 47, 247, 0.5), rgba(210, 111, 255, 0.4));
    border-right: 5px solid #7B2FF7;
    color: #fff;
    box-shadow: 0 4px 18px rgba(123, 47, 247, 0.4);
}

/* VOICE CHANNEL ROW */
.voice-channel {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
}

.voice-channel .vc-name {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.voice-channel .vc-name span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.voice-channel .vc-icon {
    font-size: 16px;
}

.voice-channel .vc-users {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
    padding-right: 4px;
}

/* mini users in sidebar under each voice room */
.voice-user-mini {
    display: inline-flex;
    align-items: center;
    padding: 3px 7px;
    border-radius: 10px;
    background: rgba(123, 47, 247, 0.16);
    border: 1px solid rgba(123, 47, 247, 0.35);
    backdrop-filter: blur(10px);
}

.voice-user-mini img {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(123, 47, 247, 0.7);
    margin-left: 6px;
    object-fit: cover;
}

.voice-user-mini .mini-name {
    font-size: 11px;
    color: #eee;
}

/* ================= USER PANEL (STATUS) ================= */
#user-panel {
    padding: 12px 14px;
    background: rgba(22, 22, 30, 0.98);
    backdrop-filter: blur(30px);
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
    border-top: 1px solid rgba(40, 40, 55, 0.7);
    flex-shrink: 0;
    border-radius: 18px 18px 0 0;
    margin: 0 8px 4px;
}

#user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid rgba(123, 47, 247, 0.7);
    box-shadow: 0 4px 14px rgba(123, 47, 247, 0.35);
}

#user-info {
    margin-right: 10px;
}

#username-display {
    font-weight: 600;
    color: #f5f5ff;
    font-size: 14px;
}

#status-display {
    font-size: 12px;
    color: rgba(153, 153, 175, 0.95);
}

/* STATUS MENU DROPDOWN */
#status-menu {
    position: absolute;
    right: 58px;
    bottom: 50px;
    background: rgba(18, 18, 26, 0.98);
    backdrop-filter: blur(26px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    display: none;
    box-shadow: 0 12px 38px rgba(0, 0, 0, 0.45);
    overflow: hidden;
    min-width: 160px;
}

#status-menu div {
    padding: 10px 14px;
    font-size: 13px;
    transition: all 0.2s ease;
    color: #e6e6f5;
}

#status-menu div:hover {
    background: rgba(123, 47, 247, 0.2);
}

/* STATUS POPUP SIMPLE */
.status-popup {
    position: absolute;
    bottom: 70px;
    left: 20px;
    background: #1f1f25;
    padding: 10px;
    border-radius: 10px;
    display: none;
    width: 160px;
}

.status-popup div {
    padding: 8px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-popup div:hover {
    background: rgba(255,255,255,0.1);
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.dot.online { background:#3ddc84; }
.dot.idle { background:#fbc531; }
.dot.dnd { background:#e84118; }
.dot.offline { background:#718093; }

/* ================= ADVANCED USER PANEL (VOICE CONTROLS) ================= */
.user-panel-advanced {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px 14px;
    background: linear-gradient(145deg, rgba(14, 14, 22, 0.98), rgba(24, 16, 40, 0.98));
    border-radius: 12px 12px 0 0;
    color: #e6e6e6;
    margin: 0 8px 8px;
    border-top: 1px solid rgba(40, 40, 55, 0.7);
}

.user-panel-advanced .up-left {
    display: flex;
    gap: 8px;
    align-items: center;
}

.avatar-wrapper {
    position: relative;
    width: 46px;
    height: 46px;
}

.avatar-wrapper img {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 2px solid rgba(123, 47, 247, 0.5);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

#bottom-avatar.speaking {
    box-shadow:
        0 0 0 3px rgba(66, 255, 138, 0.9),
        0 0 20px rgba(66, 255, 138, 0.75);
    border-color: rgba(66, 255, 138, 1);
    transform: scale(1.06);
    transition: 130ms ease-out;
}

.status-dot {
    position: absolute;
    bottom: 0;
    right: -2px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    border: 2px solid #14141a;
}

.status-dot.online { background: #3ba55d; }
.status-dot.idle { background: #faa61a; }
.status-dot.dnd { background: #ed4245; }
.status-dot.offline { background: #747f8d; }

.user-panel-advanced .user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mini-username {
    font-weight: 700;
    color: #ffffff;
    font-size: 14px;
}

.mini-status {
    font-size: 11px;
    color: rgba(180, 180, 205, 0.95);
}

/* PING */
.user-panel-advanced .up-right {
    margin-left: auto;
}

.ping {
    font-size: 11px;
    color: #bdbdbd;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ping-icon {
    font-size: 14px;
}

/* CONTROLS */
.controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.btn {
    background: radial-gradient(circle at top left, #7B2FF7 0, #5b1fb3 70%);
    color: #fff;
    padding: 6px 10px;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
    box-shadow: 0 3px 10px rgba(123, 47, 247, 0.35);
}

.btn span:first-child {
    font-size: 14px;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(123, 47, 247, 0.55);
}

.btn[disabled] {
    background: rgba(60, 60, 80, 0.7);
    box-shadow: none;
    cursor: not-allowed;
}

.more {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-right: auto;
    font-size: 11px;
}

.mic-label {
    opacity: 0.9;
}

#input-select {
    background: rgba(18, 18, 26, 0.9);
    color: #f0f0ff;
    border-radius: 999px;
    border: 1px solid rgba(120, 120, 150, 0.6);
    padding: 3px 8px;
    font-size: 11px;
    outline: none;
}

/* ================= MAIN CHAT ================= */
#header {
    background: rgba(14, 14, 20, 0.97);
    backdrop-filter: blur(30px);
    padding: 18px 20px;
    border-bottom: 1px solid rgba(31, 31, 40, 0.8);
    color: #ECECEC;
    font-size: 18px;
    font-weight: 600;
    border-radius: 0 0 18px 0;
}

#header h3 {
    margin: 0;
    font-size: 17px;
}

#chat-box {
    flex: 1;
    padding: 18px 20px;
    overflow-y: auto;
    background: radial-gradient(circle at top, rgba(40, 25, 65, 0.45), rgba(5, 5, 10, 0.96));
}

/* Chat bubbles */
.message {
    background: rgba(27, 28, 36, 0.95);
    backdrop-filter: blur(20px);
    padding: 12px 14px;
    margin-bottom: 10px;
    border-radius: 18px;
    width: fit-content;
    max-width: 70%;
    animation: msgIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.04);
    box-shadow: 0 3px 16px rgba(0, 0, 0, 0.35);
    font-size: 14px;
}

.message .author {
    font-size: 13px;
    font-weight: 700;
    color: #D08BFF;
    margin-bottom: 4px;
}

.message.self {
    background: radial-gradient(circle at top left, rgba(123, 47, 247, 0.8), rgba(55, 0, 130, 0.95));
    margin-right: auto;
    color: #fff;
    border: 1px solid rgba(190, 140, 255, 0.9);
}

@keyframes msgIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.97);
        filter: blur(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

/* Chat Input */
#chat-input {
    padding: 12px 16px;
    display: flex;
    background: rgba(14, 14, 20, 0.97);
    backdrop-filter: blur(24px);
    border-top: 1px solid rgba(31, 31, 40, 0.85);
    gap: 8px;
}

#chat-input input {
    flex: 1;
    padding: 11px 14px;
    background: rgba(9, 9, 15, 0.96);
    backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    outline: none;
    color: #fff;
    font-size: 14px;
    transition: all 0.2s ease;
}

#chat-input input::placeholder {
    color: rgba(150, 150, 170, 0.8);
}

#chat-input input:focus {
    border-color: rgba(123, 47, 247, 0.6);
    box-shadow: 0 0 0 2px rgba(123, 47, 247, 0.22);
}

#send-btn {
    padding: 11px 18px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, #7B2FF7 0, #D16FFF 100%);
    color: #fff;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(123, 47, 247, 0.55);
}

/* ================= VOICE PANEL (RIGHT) ================= */
#voice-room-title {
    font-size: 16px;
    font-weight: 700;
    color: #B67BFF;
    margin-bottom: 14px;
    text-align: center;
}

/* Users in voice */
.voice-user {
    background: rgba(27, 28, 36, 0.96);
    backdrop-filter: blur(18px);
    padding: 12px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
}

.voice-user:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

/* Avatar wrapper for voice users (for waveform overlay) */
.voice-user .avatar-wrapper {
    position: relative;
    width: 44px;
    height: 44px;
}

.voice-user img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(123, 47, 247, 0.7);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
    position: relative;
    z-index: 2;
}

/* Waveform canvas inside avatar */
.voice-user canvas.waveform {
    position: absolute;
    top: 0;
    left: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    pointer-events: none;
    mix-blend-mode: screen;
    opacity: 0.9;
    z-index: 3;
}

/* Speaking Glow (Discord style) */
.voice-user.speaking img {
    border-color: rgba(66, 255, 138, 1);
    box-shadow:
        0 0 14px rgba(66, 255, 138, 0.95),
        0 0 30px rgba(66, 255, 138, 0.6);
    transform: scale(1.06);
    transition: 120ms ease-out;
}

.voice-user.speaking {
    background: radial-gradient(circle at right, rgba(66, 255, 138, 0.16), rgba(20, 40, 28, 0.95));
    border-color: rgba(66, 255, 138, 0.55);
}

.voice-user .name {
    margin-right: 12px;
    font-weight: 600;
    color: #fff;
    font-size: 14px;
}

/* Hidden legacy buttons */
#voice-controls button {
    width: 100%;
    padding: 12px;
    background: rgba(123, 47, 247, 0.8);
    border: none;
    border-radius: 18px;
    color: #fff;
    cursor: pointer;
    margin-top: 8px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.25s ease;
}

#voice-controls button:hover:not(:disabled) {
    background: rgba(123, 47, 247, 1);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(123, 47, 247, 0.35);
}

#voice-controls button:disabled {
    background: rgba(42, 42, 60, 0.6);
    cursor: not-allowed;
}

#join-voice,
#leave-voice,
#mute-btn {
    display: none !important;
}

/* ========================================================================== */
/*                               RESPONSIVE                                   */
/* ========================================================================== */

@media (max-width: 900px) {
    #sidebar {
        width: 80px;
    }

    #sidebar-header h2 {
        font-size: 15px;
    }

    #voice-panel {
        width: 230px;
        padding: 14px;
    }

    .voice-user {
        padding: 10px;
        border-radius: 14px;
    }

    .voice-user .name {
        font-size: 13px;
        margin-right: 8px;
    }
}

@media (max-width: 600px) {
    body {
        flex-direction: column;
        overflow: auto;
    }

    #sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        overflow-x: auto;
    }

    #main {
        order: 2;
        min-height: 50vh;
    }

    #voice-panel {
        width: 100%;
        height: auto;
        order: 3;
        padding: 12px;
    }

    .voice-user {
        padding: 10px;
        border-radius: 14px;
    }

    .voice-user .avatar-wrapper,
    .voice-user img,
    .voice-user canvas.waveform {
        width: 40px;
        height: 40px;
    }

    .voice-user .name {
        font-size: 13px;
    }

    #header {
        border-radius: 0;
    }
}




/* ========================================================================== */
/*                               CHAT AREA                                    */
/* ========================================================================== */

.search-box {
  width: 260px;
  margin: 10px 20px 0 auto;
  padding: 7px 12px;
  background: rgba(9, 9, 15, 0.96);
  color: #f5f5ff;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  outline: none;
  font-size: 13px;
}

.search-box::placeholder {
  color: rgba(150, 150, 170, 0.8);
}

.chat-box {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 12px;
  background: radial-gradient(circle at top, rgba(40, 25, 65, 0.45), rgba(5, 5, 10, 0.96));
}

/* ---------- message bubbles ---------- */

.message-bubble {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  animation: msgIn 0.25s ease-out;
  align-items: flex-start;
}

.message-bubble .avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(123, 47, 247, 0.5);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.6);
}

.message-bubble .content {
  background: rgba(27, 28, 36, 0.96);
  padding: 8px 12px 10px;
  border-radius: 14px;
  max-width: 70%;
  border: 1px solid rgba(255, 255, 255, 0.04);
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.45);
  font-size: 13px;
}

.message-bubble .meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  margin-bottom: 3px;
  opacity: 0.8;
}

.message-bubble .user {
  font-weight: 600;
  color: #d08bff;
}

.message-bubble .time {
  color: #888aa0;
}

.message-bubble .text {
  color: #e9e9f5;
  white-space: pre-wrap;
}

/* self messages (current user) */

.message-bubble.self {
  flex-direction: row-reverse;
}

.message-bubble.self .content {
  background: radial-gradient(circle at top left, rgba(123, 47, 247, 0.85), rgba(55, 0, 130, 0.98));
  border-color: rgba(190, 140, 255, 0.9);
}

.message-bubble.self .user {
  color: #ffe8ff;
}

.message-bubble.self .text {
  color: #ffffff;
}

/* image message */

.message-bubble .image-msg {
  max-width: 260px;
  border-radius: 10px;
  display: block;
  margin-top: 4px;
}

/* animation */

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
    filter: blur(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

/* ---------- input row ---------- */

.chat-input-container {
  padding: 12px 18px 16px;
  display: flex;
  gap: 8px;
  background: rgba(14, 14, 20, 0.97);
  backdrop-filter: blur(24px);
  border-top: 1px solid rgba(31, 31, 40, 0.85);
}

.chat-input-container input#message-input {
  flex: 1;
  padding: 10px 14px;
  background: rgba(9, 9, 15, 0.96);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  outline: none;
  color: #fff;
  font-size: 14px;
  transition: all 0.2s ease;
}

.chat-input-container input#message-input::placeholder {
  color: rgba(150, 150, 170, 0.8);
}

.chat-input-container input#message-input:focus {
  border-color: rgba(123, 47, 247, 0.6);
  box-shadow: 0 0 0 2px rgba(123, 47, 247, 0.22);
}

/* buttons */

.chat-input-container button {
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#emoji-btn,
#upload-btn {
  width: 40px;
  background: rgba(22, 22, 32, 0.95);
  color: #f1f1ff;
  border: 1px solid rgba(120, 120, 150, 0.8);
}

#emoji-btn:hover,
#upload-btn:hover {
  background: rgba(40, 40, 55, 0.95);
}

#send-btn {
  padding: 0 18px;
  background: linear-gradient(135deg, #7B2FF7 0, #D16FFF 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(123, 47, 247, 0.55);
}

#send-btn:hover {
  transform: translateY(-1px);
}

/* ---------- emoji picker ---------- */

.emoji-picker {
  position: absolute;
  bottom: 80px;
  left: 320px;
  background: rgba(18, 18, 26, 0.98);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px;
  display: none;
  grid-template-columns: repeat(5, 1.8em);
  gap: 6px;
  font-size: 20px;
  z-index: 50;
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.6);
}

.emoji-picker div {
  cursor: pointer;
  text-align: center;
}

.emoji-picker div:hover {
  transform: scale(1.15);
}

