/* ========================================
   DISCORD DESKTOP LAYOUT - CSS GRID
   ======================================== */

/* === 1) BODY & ROOT CONTAINER === */
html,
body {
    margin: 0;
    padding: 0;
    height: 100vh;
    width: 100vw;
    overflow: hidden !important;
    /* No body scroll */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #1e1f22 !important;
    /* Discord dark background */
}

#main {
    display: grid;
    grid-template-columns: 72px 260px 1fr 300px;
    grid-template-rows: 100vh;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    background: #1e1f22;
}

/* === 2) SERVER RAIL (LEFT MOST) === */
#leftRail {
    grid-column: 1;
    grid-row: 1;
    background: #0b0c0f;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    gap: 8px;
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 1px solid rgba(0, 0, 0, 0.3);
}

#leftRail::-webkit-scrollbar {
    width: 4px;
}

#leftRail::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* === 3) CHANNEL SIDEBAR === */
#left {
    grid-column: 2;
    grid-row: 1;
    background: #2b2d31;
    display: flex !important;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    height: 100vh;
    /* Ensure full height */
    border-right: 1px solid rgba(0, 0, 0, 0.2);
}

/* Server header - fixed at top */
#serverTitle,
#currentGuildName {
    flex-shrink: 0;
    padding: 16px;
    font-size: 16px;
    font-weight: 700;
    color: #f2f3f5;
    border-bottom: 1px solid rgba(0, 0, 0, 0.2);
    box-shadow: 0 1px 0 rgba(4, 4, 5, 0.2);
}

/* Channel list - scrollable */
#categoryList {
    flex: 1 1 auto;
    /* Grow to fill remaining space */
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
}

#categoryList::-webkit-scrollbar {
    width: 6px;
}

#categoryList::-webkit-scrollbar-thumb {
    background: #1a1b1e;
    border-radius: 4px;
}

#categoryList::-webkit-scrollbar-track {
    background: transparent;
}

/* Profile footer - fixed at bottom via flex */
#profileFooter {
    flex-shrink: 0;
    margin-top: auto;
    /* Push to bottom if space available */
    padding: 10px 12px;
    background: #232428;
    border-top: 1px solid rgba(0, 0, 0, 0.3);
    z-index: 5;
    /* Ensure it stays above content if needed */
}

/* === 4) CHAT PANEL (CENTER) === */
#center {
    grid-column: 3;
    grid-row: 1;
    background: #313338;
    display: flex !important;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.center-main {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Chat header - fixed at top */
#centerHeader {
    flex-shrink: 0;
    padding: 12px 16px;
    background: #313338;
    border-bottom: 1px solid rgba(0, 0, 0, 0.2);
    box-shadow: 0 1px 0 rgba(4, 4, 5, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 48px;
}

/* Message tools */
#messageTools {
    flex-shrink: 0;
    padding: 8px 16px;
    background: #313338;
}

/* Messages area - scrollable */
.center-body {
    flex: 1;
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

#messages {
    flex: 1;
    overflow-y: auto !important;
    overflow-x: hidden;
    padding: 16px;
    padding-bottom: 24px;
    display: block !important;
}

#messages::-webkit-scrollbar {
    width: 8px;
}

#messages::-webkit-scrollbar-thumb {
    background: #1a1b1e;
    border-radius: 4px;
}

#messages::-webkit-scrollbar-track {
    background: #2b2d31;
}

/* Composer - fixed at bottom of chat */
#composer {
    flex-shrink: 0;
    padding: 16px;
    background: #313338;
    border-top: 1px solid rgba(0, 0, 0, 0.2);
    display: flex !important;
    align-items: flex-end;
    gap: 8px;
    position: relative !important;
    bottom: auto !important;
}

#composer .chat-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background: #383a40;
    border-radius: 8px;
    padding: 4px 8px;
}

#msgBox {
    flex: 1;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    color: #dcddde !important;
    font-size: 14px;
    line-height: 1.375;
    padding: 8px !important;
    resize: none;
    max-height: 200px;
    overflow-y: auto;
}

#msgBox::placeholder {
    color: #949ba4;
}

/* Composer buttons */
#btnAttachFile,
#emojiPickerBtn,
#sendBtn,
.btn-attach {
    flex-shrink: 0;
    padding: 8px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #b5bac1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#btnAttachFile:hover,
#emojiPickerBtn:hover,
.btn-attach:hover {
    background: #4e5058;
    color: #dcddde;
}

#sendBtn {
    background: #5865f2;
    color: white;
    padding: 8px 12px;
}

#sendBtn:hover {
    background: #4752c4;
}

/* === 5) MEMBERS SIDEBAR (RIGHT) === */
#right {
    grid-column: 4;
    grid-row: 1;
    background: #2b2d31;
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
    border-left: 1px solid rgba(0, 0, 0, 0.2);
}

/* Members list - scrollable */
#memberList {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 8px;
}

#memberList::-webkit-scrollbar {
    width: 6px;
}

#memberList::-webkit-scrollbar-thumb {
    background: #1a1b1e;
    border-radius: 4px;
}

/* === 6) CHANNEL STYLING === */
.channel {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    margin: 2px 0;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s ease;
    color: #949ba4;
    font-size: 15px;
    position: relative;
}

.channel:hover {
    background: #35373c;
    color: #dcddde;
}

.channel.active {
    background: #404249;
    color: #ffffff;
}

.channel.active::before {
    content: '';
    position: absolute;
    left: -8px;
    width: 4px;
    height: 24px;
    background: #ffffff;
    border-radius: 0 4px 4px 0;
}

.channel-icon {
    color: #80848e;
    font-size: 18px;
    flex-shrink: 0;
}

.channel.active .channel-icon {
    color: #ffffff;
}

/* === 7) MEMBER ITEM STYLING === */
.member-item,
.member-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    margin: 2px 0;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.member-item:hover,
.member-row:hover {
    background: #35373c;
}

.member-name {
    color: #dcddde;
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
}

/* === 8) EMPTY STATES === */
#centerEmpty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

#centerEmpty.hidden {
    display: none !important;
}

/* === 9) RESPONSIVE (MOBILE) ===
   NOTE: Mobile layout handled entirely by mobile-responsive.css
   to avoid conflicting breakpoints. See mobile-responsive.css
   for sidebar overlay, hamburger menu, and members panel logic.
   =============================== */

/* === 10) CATEGORY HEADERS === */
.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 8px 4px;
    color: #949ba4;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: color 0.15s ease;
}

.category-header:hover {
    color: #dcddde;
}

.category-channels {
    padding-left: 8px;
}

/* === 11) SCROLL BUTTON === */
#scrollLatestBtn {
    position: absolute;
    bottom: 100px;
    right: 20px;
    padding: 10px 16px;
    background: #5865f2;
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: background 0.15s ease, transform 0.15s ease;
    z-index: 10;
}

#scrollLatestBtn:hover {
    background: #4752c4;
    transform: translateY(-2px);
}

/* === 12) HIDE MOBILE ELEMENTS ON DESKTOP === */
.mobile-menu-btn,
.mobile-backdrop,
.mobile-sidebar,
.mobile-only {
    display: none !important;
}

/* === 13) VOICE PANEL === */
#voicePanel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #313338;
    z-index: 50;
}

#voicePanel.hidden {
    display: none !important;
}

/* === 14) LOADING OVERLAY === */
#appLoadingOverlay {
    position: fixed !important;
    z-index: 9999;
}

/* === 15) CHANNEL HEADER CENTERING === */
#centerHeader {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 12px !important;
}

#centerHeader .channel-title,
#centerHeader .header-title,
#centerHeader h2,
#centerHeader h3 {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    color: #f2f3f5 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Center the title text optically */
#centerHeader .channel-title::before,
#centerHeader .header-title::before {
    content: '#' !important;
    color: #949ba4 !important;
    font-weight: 500 !important;
}

/* Hide search from server/channel view */
#centerHeader .search-box,
#centerHeader .message-search,
#centerHeader input[type="search"],
body:not(.dm-view) .message-search-header,
body:not(.dm-view) #centerHeader .search-wrap {
    display: none !important;
}

/* Show search only in DM view */
body.dm-view #centerHeader .search-wrap,
body.dm-view .message-search-header {
    display: flex !important;
}

/* === 17) HIDE CALL/VIDEO BUTTONS IN SERVER VIEW === */
/* These buttons should ONLY be visible in DM view */
body:not(.dm-view) .call-btn,
body:not(.dm-view) .video-btn,
body:not(.dm-view) #callBtn,
body:not(.dm-view) #videoBtn,
body:not(.dm-view) .dm-call-btn,
body:not(.dm-view) .dm-video-btn,
body:not(.dm-view) [class*="call-btn"],
body:not(.dm-view) [class*="video-btn"],
body:not(.dm-view) #centerHeader button[title*="Ara"],
body:not(.dm-view) #centerHeader button[title*="Video"],
body:not(.dm-view) #centerHeader button[title*="Call"],
body:not(.dm-view) .header-actions .call-action,
body:not(.dm-view) .header-actions .video-action {
    display: none !important;
}

/* Show call/video buttons ONLY in DM view */
body.dm-view .call-btn,
body.dm-view .video-btn,
body.dm-view #callBtn,
body.dm-view #videoBtn,
body.dm-view .dm-call-btn,
body.dm-view .dm-video-btn {
    display: flex !important;
}

/* === 16) VOICE GAME PANEL FIX === */
.mg-popover {
    position: absolute !important;
    z-index: 1000 !important;
    max-height: 320px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

.mg-popover::-webkit-scrollbar {
    width: 6px;
}

.mg-popover::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 255, 0.3);
    border-radius: 4px;
}

.mg-card {
    position: relative !important;
    overflow: visible !important;
}

.mg-head {
    position: relative !important;
    z-index: 1 !important;
}

/* Game selection grid */
.mg-games-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)) !important;
    gap: 12px !important;
    max-height: 280px !important;
    overflow-y: auto !important;
    padding: 8px !important;
}

/* Ensure game panel doesn't overlap screen share */
.voice-mini-game {
    position: relative !important;
    z-index: 10 !important;
}

.screenshare-stage,
.voice-screen {
    position: relative !important;
    z-index: 5 !important;
}