/* =========================================
   GLOBAL ELEMENTS
   ========================================= */
html, body {
    height: 100%;
    margin: 0;
}

body {
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #1a1d22, #111318);
}

:link,
a:visited {
    color: #9fc5ff;
}

/* ============================================================
   APP SHELL (3-column layout)
   ============================================================ */
.app-shell {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
    padding: 10px;
    gap: 10px;
    box-sizing: border-box;
}

/* LEFT SIDEBAR */
.sidebar-left {
    flex: 0 0 230px;
    display: flex;
    flex-direction: column;
	padding-right: 10px;
    gap: 10px;
}

/* RIGHT SIDEBAR */
.sidebar-right {
    flex: 0 0 230px;
    display: flex;
    flex-direction: column;
	padding-right: 10px;
}

/* CENTER COLUMN */
.main-column {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;     /* NEW: center column scrolls */
    min-height: 0;
}

/* ============================================================
   PROFILE OVERLAY
   ============================================================ */
 #profile-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.profile-card {
    background: #1e2126;
    border: 1px solid #333;
    border-radius: 10px;
    padding: 20px;
    width: 380px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 0 20px rgba(0,0,0,0.6);
    color: #e8e8e8;
    position: relative;
}

.profile-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: #aaa;
    font-size: 20px;
    cursor: pointer;
}

.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    margin: 0 auto 10px;
}

.profile-section {
    margin-top: 15px;
}

.profile-section h3 {
    margin-bottom: 4px;
    color: #9fc5ff;
}

#profile-edit-controls button {
    margin-right: 8px;
    margin-top: 10px;
}

/* =============================================================
	DM OVERLAY
   ============================================================= */
	#dm-new-message-popup, #chat-new-message-popup {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: #1157F2;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    opacity: 0.9;
    z-index: 50;
}

#dm-new-message-popup.hidden {
    display: none;
}

/************************************************************
 *  DIRECT MESSAGE PANEL
 ************************************************************/

#dm-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0;
    background: #1e1f22;
	width: 80vw;
	height: 100vh;
}

/* Header */
#dm-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid #2a2b2f;
    background: #1b1c1f;
}

#dm-header img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

#dm-header #dm-username {
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
}

.dm-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}

.dm-header-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;          /* THIS is the missing piece */
}

.dm-msg-actions {
    margin-left: auto;    /* pushes to right */
    display: flex;        /* allows spacing */
    gap: 8px;
}

.dm-avatar-inline {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.dm-user {
    font-weight: bold;
}

.dm-time {
    font-size: 0.75rem;
    opacity: 0.7;
}

.grouped-message .dm-avatar-inline,
.grouped-message .dm-user,
.grouped-message .dm-time {
    display: none;
}

/* Message list */
#dm-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Scrollbar styling */
#dm-messages::-webkit-scrollbar {
    width: 8px;
}
#dm-messages::-webkit-scrollbar-thumb {
    background: #2e2f33;
    border-radius: 4px;
}
#dm-messages::-webkit-scrollbar-track {
    background: transparent;
}

/* Message bubbles */
.dm-message {
    max-width: 99%;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.95rem;
    line-height: 1.35;
    word-wrap: break-word;
}

/* Input row */
#dm-input-row {
    display: flex;
    padding: 14px;
    gap: 10px;
    border-top: 1px solid #2a2b2f;
    background: #1b1c1f;
}

#dm-input {
    flex: 1;
    padding: 10px 12px;
    border-radius: 6px;
    border: none;
    outline: none;
    background: #2b2d31;
    color: #fff;
    font-size: 0.95rem;
}

#dm-input:focus {
    background: #323438;
}

#dm-send {
    padding: 10px 16px;
    background: #5865f2;
    border: none;
    border-radius: 6px;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

#dm-send:hover {
    background: #4752c4;
}

.dm-back-btn {
    background: none;
    border: none;
    color: #aaa;
    font-size: 0.9rem;
    cursor: pointer;
    margin-right: 10px;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
}

.dm-back-btn:hover {
    background: #2b2d31;
    color: #fff;
}

/* ============================================================
   CHAT CONTAINER
   ============================================================ */
#chatContainer {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* CHATBOX fills remaining space */
#chatbox {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: visible;   /* no longer scrolls */
}

/* Remove old floats */
#user_menu,
#online-users {
    float: none !important;
    width: 100% !important;
    height: auto;
}


/* =========================================
   NAVIGATION
   ========================================= */
#navigation {
    text-align: center;
}

#navigation button,
#navigation input {
    display: block;
    width: 100%;              /* full width of the sidebar */
    box-sizing: border-box;   /* padding stays inside the width */
    background: #2b2f36;
    color: #f2f2f2;
    border: none;
    padding: 10px 14px;
    margin-bottom: 8px;
    text-align: center;
    cursor: pointer;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
}

#navigation button.unread {
    background-color: #ffcc66;
}

#navigation button:hover {
    background: #3a3f47;
}

#navigation button.active {
    background: #4a505a;
    font-weight: bold;
}


/* MARKET DASHBOARD / TICKER */
#marketDashboard {
    position: sticky;
    top: 0;
    z-index: 50;
    background: linear-gradient(180deg, #1c1f24, #15171b);
    padding: 10px;
    font-family: monospace;
    color: white;
    border-bottom: 1px solid #333;
}

/* Ticker bar inside the dashboard */
.ticker-container {
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    background: #111;
    border-bottom: 1px solid #333;
    padding: 6px 0;
}

.ticker-scroll {
    display: inline-block;
    white-space: nowrap;
    animation: tickerMove 25s linear infinite;
}

@keyframes tickerMove {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}


/* =========================================
   USER MENU (LEFT SIDEBAR)
   ========================================= */
#user_menu {
    text-align: center;
    color: white;
    background-color: #1e2126;
    border-color: #071257;
    border-left: 5px solid #071257;
    border-right: 5px solid #071257;
    border-radius: 5px;
}

input[name="username"],
input[name="password"] {
    width: 99%;
    background: #1b1d21;
    color: #f2f2f2;
    border: 1px solid #3d3d3d;
}

#user_menu table {
    width: 100%;
    text-align: center;
}

#user_menu td {
    text-align: center;
}


/* =========================================
   ONLINE USERS (RIGHT SIDEBAR)
   ========================================= */
#online-users {
    text-align: center;
    color: white;
    height: 50%;
	overflow-y: scroll;
	scrollbar-width: none;
    background-color: #1e2126;
    border-color: #071257;
    border-left: 5px solid #071257;
    border-right: 5px solid #071257;
    border-radius: 5px;
}

#online-users div {
    margin-bottom: 10px;
}

.user-entry {
    display: flex;
    align-items: center;
    gap: 10%;
    padding: 4px 0;
}

.user-avatar {
    width:40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: #000; /* fallback if image missing */
}

.online-user-link {
    color: #9fc5ff;
    text-decoration: none;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#online-list img {
	border: solid;
	border-width: 3px;
	border-color: green;
}

#offline-list img {
	border: solid;
	border-width: 3px;
	border-color: #DBC165;
}

/* Pulse animation for avatar borders */
@keyframes avatarPulse {
    0% {
        box-shadow: 0 0 4px var(--dm-pulse-color);
        border-color: var(--dm-pulse-color);
    }
    50% {
        box-shadow: 0 0 12px var(--dm-pulse-color);
        border-color: var(--dm-pulse-color);
    }
    100% {
        box-shadow: 0 0 4px var(--dm-pulse-color);
        border-color: var(--dm-pulse-color);
    }
}

/* Apply pulse to avatar */
.user-avatar.dm-pulse, .profile-avatar.dm-pulse {
    animation: avatarPulse 1.4s infinite ease-in-out;
}

/* Online pulse color */
.user-avatar.dm-online {
    --dm-pulse-color: #1157F2; /* blue */
}

/* Offline pulse color */
.user-avatar.dm-offline {
    --dm-pulse-color: #ffb400; /* yellow */
}

/* Allow profile avatar to pulse too */
.profile-avatar.dm-pulse {
    animation: avatarPulse 1.4s infinite ease-in-out;
}

.profile-avatar.dm-online {
    --dm-pulse-color: #1157F2; /* blue */
}

.profile-avatar.dm-offline {
    --dm-pulse-color: #ffb400;
}

.user-avatar {
    border-radius: 50%;
    border: 3px solid #ced6e0;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.qb-pulse {
    animation: qbPulse 1.2s infinite;
}

@keyframes qbPulse {
    0%   { box-shadow: 0 0 4px var(--mood-color); }
    50%  { box-shadow: 0 0 12px var(--mood-color); }
    100% { box-shadow: 0 0 4px var(--mood-color); }
}

.user-entry {
    position: relative;
}

.user-tooltip {
    position: absolute;
    /*top: 100%;*/
    left: 50%;
    transform: translateX(-50%);
    background: #1e1e1e;
    color: #fff;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 15px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
    margin-bottom: 6px;
    z-index: 20;
}

.user-entry:hover .user-tooltip {
    opacity: 1;
}

.qb-crypto-mode {
    border-color: #8A2BE2 !important;
    box-shadow: 0 0 12px rgba(138, 43, 226, 0.7);
    animation: qbCryptoPulse 2.5s infinite ease-in-out;
}

@keyframes qbCryptoPulse {
    0%   { box-shadow: 0 0 6px rgba(138, 43, 226, 0.4); }
    50%  { box-shadow: 0 0 16px rgba(138, 43, 226, 0.9); }
    100% { box-shadow: 0 0 6px rgba(138, 43, 226, 0.4); }
}


/* =========================================
   CHAT CONTAINER & CHATBOX
   ========================================= */
#chatContainer {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
	color: white;
    border-style: solid;
    background-color: #1e2126;
    border-color: #071257;
    border-left: 5px solid #071257;
    border-right: 5px solid #071257;
    border-radius: 5px;
}

/* CHATBOX fills remaining space */
#chatbox {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

/* Remove old floats */
#user_menu,
#online-users {
    float: none !important;
    width: 100% !important;
    height: auto;
}

#chatbox div {
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    padding-bottom: 10px;
}

#chatbox::-webkit-scrollbar {
    display: none;
}


/* =========================================
   CHAT MESSAGES
   ========================================= */
.chat-message {
    padding: 4px 0;
    border-bottom: 1px solid #2d2f33;
}

.chat-message:last-child {
    border-bottom: none;
}

.chat-message:hover {
    background: rgba(255,255,255,0.04);
}

.chat-timestamp {
    color: #9a9a9a;
    margin-right: 6px;
    font-size: 12px;
}

.chat-username {
    font-weight: bold;
    color: #7fb8ff;
}

.chat-text {
    color: #e8e8e8;
}

.mention {
    background: rgba(255, 255, 0, 0.35);
    padding: 1px 4px;
    border-radius: 4px;
    font-weight: bold;
}

#mention-menu {
    position: absolute;
    bottom: 48px;               /* aligns with input bar height */
    left: 0;
    background: #1e2126;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 6px 0;
    width: 240px;               /* fixed width for consistency */
    max-height: 220px;
    overflow-y: auto;
    z-index: 999;
    color: #e8e8e8;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    font-size: 14px;
    box-sizing: border-box;
}

#mention-menu div {
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s ease;
}

#mention-menu div:hover {
    background: #2b2f36;
}

/* =========================================
   MESSAGE HEADERS & ACTIONS
   ========================================= */
.msg-header,
.msg-header-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}

.msg-avatar-inline {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

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

.edit-btn,
.delete-btn,
.dm-edit-btn,
.dm-delete-btn {
    cursor: pointer;
    font-size: 12px;
    color: #888;
}

.edit-btn:hover,
.delete-btn:hover,
.dm-edit-btn:hover,
.dm-delete-btn:hover {
    color: #fff;
}

.inline-actions {
    display: inline-flex;
    float: right;
    gap: 6px;
    margin-left: 8px;
    vertical-align: middle;
}

.edit-box, .dm-edit-box {
	background-color: #1e2126;
	color: white;
	width: 99%;
}


/* =========================================
   DAY DIVIDERS
   ========================================= */
.day-divider {
    text-align: center;
    margin: 12px 0;
    padding: 4px 0;
    font-size: 0.85rem;
    color: #666;
    line-height: 1px;
}

.day-divider::before,
.day-divider::after {
    content: "";
    display: inline-block;
    width: 20%;
    border-top: 1px solid #ccc;
}

.day-divider::before {
    margin-right: 10px;
}

.day-divider::after {
    margin-left: 10px;
}


/* =========================================
   IMAGES & EMBEDS
   ========================================= */
.chat-image {
    max-width: 30%;
    max-height: 300px;
    border-radius: 6px;
	border:solid;
	border-color:grey;
    margin: 6px 0;
    cursor: zoom-in;
    transition: all 0.25s ease;
    object-fit: contain;
}

.chat-image.expanded {
    max-width: 90vw;
    max-height: 90vh;
    cursor: zoom-out;
    z-index: 9999;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 20px rgba(0,0,0,0.6);
    border-radius: 8px;
}

#image-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 9998;
}

#image-backdrop.overlay-active,
#image-backdrop.image-active {
    opacity: 1;
    pointer-events: all;
}

img.emoji {
	padding-top: 10px;
    width: 50px;
    height: 50px;
}

.youtube-embed iframe {
    width: 100%;
    max-width: 480px;
    height: 270px;
    border-radius: 6px;
    margin-top: 6px;
}


/* =========================================
   CHAT INPUT AREA
   ========================================= */
#chatForm {
    margin-top: 8px;
    width: 100%;
    display: flex;
}

#chatInput {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #4a4a4a;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
    background: #1b1d21;
    color: #f2f2f2;
}

#uploadBtn, #uploadBtnDM {
    background: #222;
    border: 1px solid #444;
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 10px;
}


/* =========================================
   EMOJI PICKER
   ========================================= */
.emoji-picker-container, .dm-emoji-picker-container {
    position: relative;
    display: inline-block;
}

.emoji-btn, .dm-emoji-btn {
    background: #222;
    border: 1px solid #444;
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
}

.emoji-picker, .dm-emoji-picker {
    position: absolute;
    bottom: 50px;
    right: 6px;
    background: #1a1a1a;
    border: 1px solid #333;
    padding: 10px;
    border-radius: 8px;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    width: 220px;
    box-shadow: 0 0 12px rgba(0,0,0,0.4);
    z-index: 999;
}

.emoji-picker img, .dm-emoji-picker img {
    width: 28px;
    height: 28px;
    cursor: pointer;
    transition: transform 0.1s ease;
}

.emoji-picker img:hover, .dm-emoji-picker img:hover {
    transform: scale(1.2);
}


/* =========================================
   LINK PREVIEWS
   ========================================= */
.link-preview {
    border: 1px solid #2f3136;
    background: #202225;
    padding: 10px;
    border-radius: 6px;
    display: flex;
    gap: 10px;
    margin-top: 6px;
    max-width: 420px;
}

.link-preview .lp-img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
}

.link-preview .lp-body {
    display: flex;
    flex-direction: column;
}

.link-preview .lp-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.link-preview .lp-desc {
    font-size: 0.85em;
    opacity: 0.8;
    margin-bottom: 4px;
}

.link-preview .lp-site {
    font-size: 0.75em;
    opacity: 0.6;
}


/* =========================================
   UTILITIES
   ========================================= */
.hidden {
    display: none !important;
}