:root {
    --bg-primary: #313338;
    --bg-secondary: #2b2d31;
    --bg-tertiary: #1e1f22;
    --bg-secondary-alt: #232428;
    --bg-modifier-hover: rgba(255, 255, 255, 0.08);
    --bg-modifier-active: rgba(255, 255, 255, 0.12);
    --bg-modifier-selected: rgba(255, 255, 255, 0.16);

    --interactive-normal: #dbdee1;
    --interactive-hover: #f2f3f5;
    --interactive-active: #ffffff;
    --interactive-muted: #80848e;

    --text-normal: #dbdee1;
    --text-muted: #949ba4;
    --text-link: #00a8fc;
    --text-danger: #fa777c;

    --brand-experiment: #5865F2;
    --brand-experiment-hover: #4752C4;

    --scrollbar-auto-thumb: #1a1b1e;
    --scrollbar-auto-track: #2b2d31;

    --border-color: rgba(255, 255, 255, 0.06);

    --channel-icon: #80848e;
    --divider-color: rgba(255, 255, 255, 0.06);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-normal);
    height: 100vh;
    overflow: hidden;
    /* Prevent body scroll, layout handles it */
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-auto-track);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-auto-thumb);
    border-radius: 4px;
}

/* Common */
a {
    color: var(--text-link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.hidden {
    display: none !important;
}

/* Authentication Pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: var(--bg-tertiary);
    background-image: url('/assets/img/auth_bg.jpg');
    /* Optional background */
    background-size: cover;
    background-position: center;
}

.auth-box {
    background-color: var(--bg-primary);
    padding: 32px;
    border-radius: 8px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.auth-header h2 {
    color: var(--interactive-active);
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 15px;
}

.auth-error {
    background-color: var(--bg-secondary);
    color: var(--text-danger);
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 20px;
    font-size: 14px;
    border: 1px solid var(--text-danger);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: var(--interactive-muted);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.form-group label .required {
    color: var(--text-danger);
}

.form-group input {
    width: 100%;
    padding: 10px;
    background-color: var(--bg-tertiary);
    border: none;
    border-radius: 3px;
    color: var(--interactive-active);
    font-size: 16px;
    outline: none;
}

.form-group input:focus {
    outline: 2px solid var(--brand-experiment);
}

.btn-primary {
    width: 100%;
    background-color: var(--brand-experiment);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 3px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: var(--brand-experiment-hover);
}

.auth-footer {
    margin-top: 20px;
    font-size: 14px;
    color: var(--text-muted);
}

/* Main App Layout */
.app-container {
    display: flex;
    height: 100vh;
}

/* 1. Server Sidebar (Far Left) */
.server-sidebar {
    width: 72px;
    min-width: 72px;
    background-color: var(--bg-tertiary);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    overflow-y: auto;
    scrollbar-width: none;
    /* Hide scrollbar Firefox */
}

.server-sidebar::-webkit-scrollbar {
    display: none;
}

.server-icon {
    width: 48px;
    height: 48px;
    border-radius: 24px;
    background-color: var(--bg-primary);
    color: var(--interactive-normal);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 18px;
    transition: all 0.2s ease;
    position: relative;
    user-select: none;
}

.server-icon img {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
}

.server-icon:hover {
    border-radius: 16px;
    background-color: var(--brand-experiment);
    color: white;
}

.server-icon.active {
    border-radius: 16px;
    background-color: var(--brand-experiment);
    color: white;
}

.server-icon.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 4px;
    bottom: 4px;
    width: 8px;
    background-color: var(--interactive-active);
    border-radius: 0 4px 4px 0;
}

.global-icon {
    background-color: var(--brand-experiment);
    color: white;
}

.global-icon:hover {
    background-color: var(--brand-experiment-hover);
}

.sidebar-separator {
    width: 32px;
    height: 2px;
    background-color: var(--divider-color);
    margin-bottom: 8px;
    border-radius: 1px;
}

.add-server-btn,
.join-server-btn {
    color: #23a559;
    background-color: var(--bg-primary);
}

.add-server-btn:hover,
.join-server-btn:hover {
    background-color: #23a559;
    color: white;
}

/* 2. Channel Sidebar */
.channel-sidebar {
    width: 240px;
    min-width: 240px;
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
}

.channel-header {
    height: 48px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: background-color 0.2s;
}

.channel-header:hover {
    background-color: var(--bg-modifier-hover);
}

.channel-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--interactive-active);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px 8px;
}

.channel-category {
    font-size: 12px;
    font-weight: 600;
    color: var(--interactive-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
    margin-top: 16px;
    padding-left: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.channel-category i {
    cursor: pointer;
}

.channel-category i:hover {
    color: var(--interactive-hover);
}

.channel-item {
    padding: 6px 8px;
    margin-bottom: 2px;
    border-radius: 4px;
    color: var(--interactive-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    font-weight: 500;
}

.channel-item i {
    color: var(--channel-icon);
    margin-right: 8px;
    font-size: 18px;
}

.channel-item:hover {
    background-color: var(--bg-modifier-hover);
    color: var(--interactive-hover);
}

.channel-item.active {
    background-color: var(--bg-modifier-selected);
    color: var(--interactive-active);
}

.channel-item.active i {
    color: var(--interactive-normal);
}

.empty-state {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* User Panel */
.user-panel {
    height: 52px;
    background-color: var(--bg-secondary-alt);
    padding: 0 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
}

.user-info:hover {
    background-color: var(--bg-modifier-hover);
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 8px;
    object-fit: cover;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-details .username {
    font-size: 14px;
    font-weight: 600;
    color: var(--interactive-active);
    line-height: 1.2;
}

.user-details .user-status {
    font-size: 12px;
    color: var(--interactive-muted);
    line-height: 1.2;
}

.user-controls {
    display: flex;
}

.control-btn {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--interactive-normal);
    cursor: pointer;
    background: none;
    border: none;
    font-size: 16px;
}

.control-btn:hover {
    background-color: var(--bg-modifier-hover);
    color: var(--interactive-hover);
}

/* 3. Main Chat Area */
.chat-area {
    flex: 1;
    background-color: var(--bg-primary);
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Important for flex child text truncation */
}

.chat-header {
    height: 48px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.channel-info {
    display: flex;
    align-items: center;
}

.channel-info i {
    color: var(--channel-icon);
    font-size: 20px;
    margin-right: 8px;
}

.channel-info h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--interactive-active);
}

/* WebRTC Controls */
.rtc-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary);
    padding: 4px 8px;
    border-radius: 4px;
}

#rtc-status {
    font-size: 12px;
    color: #23a559;
    font-weight: 600;
    margin-right: 8px;
}

.rtc-btn {
    background: var(--bg-tertiary);
    border: none;
    color: var(--interactive-normal);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rtc-btn:hover {
    background: var(--bg-modifier-hover);
    color: var(--interactive-hover);
}

.rtc-btn.leave {
    background: var(--text-danger);
    color: white;
}

.rtc-btn.leave:hover {
    background: #d85c61;
}

.rtc-btn.muted {
    color: var(--text-danger);
}

/* Messages */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0 24px 0;
    display: flex;
    flex-direction: column;
}

.message {
    padding: 4px 16px 4px 72px;
    position: relative;
    display: flex;
    flex-direction: column;
}

.message:hover {
    background-color: var(--bg-modifier-hover);
}

.message.first {
    margin-top: 17px;
    padding-top: 2px;
}

.message-avatar {
    position: absolute;
    left: 16px;
    top: 2px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    object-fit: cover;
}

.message-header {
    display: flex;
    align-items: baseline;
    margin-bottom: 2px;
}

.message-author {
    font-size: 15px;
    font-weight: 500;
    color: var(--interactive-active);
    margin-right: 8px;
    cursor: pointer;
}

.message-author:hover {
    text-decoration: underline;
}

.message-timestamp {
    font-size: 12px;
    color: var(--text-muted);
}

.message-content {
    font-size: 15px;
    color: var(--text-normal);
    line-height: 1.375rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-attachment {
    margin-top: 4px;
    max-width: 400px;
    border-radius: 4px;
}

.message-attachment img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 4px;
    cursor: pointer;
}

.message-attachment .file-link {
    display: inline-flex;
    align-items: center;
    background: var(--bg-secondary);
    padding: 10px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.message-attachment .file-link i {
    font-size: 24px;
    margin-right: 10px;
    color: var(--brand-experiment);
}

/* Chat Input */
.chat-input-area {
    padding: 0 16px 24px 16px;
    position: relative;
}

.chat-form {
    background-color: var(--bg-secondary-alt);
    border-radius: 8px;
    display: flex;
    align-items: center;
    padding: 0 16px;
}

.upload-btn {
    color: var(--interactive-normal);
    cursor: pointer;
    font-size: 20px;
    padding: 10px;
    margin-right: 8px;
}

.upload-btn:hover {
    color: var(--interactive-hover);
}

.message-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-normal);
    font-size: 15px;
    padding: 14px 0;
    outline: none;
    font-family: inherit;
}

.message-input::placeholder {
    color: var(--text-muted);
}

.message-input:disabled {
    cursor: not-allowed;
}

.typing-indicator {
    position: absolute;
    bottom: 2px;
    left: 16px;
    font-size: 12px;
    color: var(--interactive-normal);
    font-weight: 600;
}

.upload-preview {
    background-color: var(--bg-secondary);
    padding: 10px;
    border-radius: 8px 8px 0 0;
    margin-bottom: -4px;
    border-bottom: 1px solid var(--bg-primary);
}

.preview-content {
    display: inline-flex;
    align-items: center;
    background: var(--bg-tertiary);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
}

.preview-content i {
    margin-right: 8px;
}

.cancel-upload {
    background: none;
    border: none;
    color: var(--text-danger);
    margin-left: 12px;
    cursor: pointer;
}

/* 4. Members Sidebar (Right) */
.members-sidebar {
    width: 240px;
    min-width: 240px;
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    padding: 16px 8px;
    border-left: 1px solid var(--border-color);
}

.members-sidebar h3 {
    font-size: 12px;
    font-weight: 600;
    color: var(--interactive-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
    padding-left: 8px;
}

.member-list {
    flex: 1;
    overflow-y: auto;
}

.member-item {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
}

.member-item:hover {
    background-color: var(--bg-modifier-hover);
}

.member-avatar-wrapper {
    position: relative;
    width: 32px;
    height: 32px;
    margin-right: 12px;
}

.member-avatar-wrapper img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.status-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--bg-secondary);
    background-color: var(--interactive-muted);
    /* Offline */
}

.status-indicator.online {
    background-color: #23a559;
}

.status-indicator.idle {
    background-color: #f0b232;
}

.status-indicator.dnd {
    background-color: #f23f43;
}

.member-name {
    font-size: 15px;
    color: var(--interactive-muted);
    font-weight: 500;
}

.member-item.admin .member-name {
    color: #f0b232;
    /* Admin Color */
}

.member-item.online .member-name {
    color: var(--interactive-active);
}

/* Tooltip */
.global-tooltip {
    position: fixed;
    background-color: var(--bg-tertiary);
    color: var(--text-normal);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.1s;
}

/* Modal */
.modal-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
}

.modal-content {
    position: relative;
    background-color: var(--bg-primary);
    border-radius: 4px;
    width: 440px;
    box-shadow: 0 0 0 1px rgba(32, 34, 37, 0.6), 0 2px 10px 0 rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.modal-header {
    padding: 16px;
    text-align: center;
}

.modal-header h2 {
    color: var(--interactive-active);
    font-size: 24px;
    font-weight: 600;
}

.modal-header p {
    color: var(--header-secondary);
    font-size: 15px;
    margin-top: 8px;
}

.modal-body {
    padding: 16px;
}

.modal-footer {
    background-color: var(--bg-secondary);
    padding: 16px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.btn-cancel {
    background: transparent;
    color: var(--interactive-active);
    border: none;
    padding: 10px 24px;
    cursor: pointer;
}

.btn-cancel:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    .members-sidebar {
        display: none;
    }
}

/* ============================================================
   DM Sidebar Items
   ============================================================ */
.dm-avatar-wrap {
    position: relative;
    width: 32px;
    height: 32px;
    margin-right: 10px;
    flex-shrink: 0;
}

.dm-avatar-wrap img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.dm-username {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dm-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.channel-item:hover .dm-close-btn {
    opacity: 1;
}

.dm-close-btn:hover {
    color: var(--text-danger);
}

/* ============================================================
   Friends Panel
   ============================================================ */
.friends-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.friends-header {
    display: flex;
    align-items: center;
    padding: 0 16px;
    height: 48px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--interactive-active);
    gap: 8px;
}

/* Tabs */
.friends-tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: 8px;
}

.friends-tab {
    background: none;
    border: none;
    color: var(--interactive-muted);
    font-size: 14px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}

.friends-tab:hover {
    background: var(--bg-modifier-hover);
    color: var(--interactive-hover);
}

.friends-tab.active {
    background: var(--bg-modifier-selected);
    color: var(--interactive-active);
}

.friends-tab-add {
    background: var(--brand-experiment);
    color: white !important;
    font-weight: 600;
}

.friends-tab-add:hover {
    background: var(--brand-experiment-hover) !important;
}

.friends-badge {
    background: var(--text-danger);
    color: white;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 6px;
    min-width: 18px;
    text-align: center;
    display: inline-block;
}

.friends-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
}

.friends-section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.friend-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 20px;
}

/* Friend Card */
.friend-card {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: default;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-color);
}

.friend-card:hover {
    background: var(--bg-modifier-hover);
}

.friend-card:last-child {
    border-bottom: none;
}

.friend-avatar-wrap {
    position: relative;
    width: 40px;
    height: 40px;
    margin-right: 14px;
    flex-shrink: 0;
}

.friend-avatar-wrap img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.friend-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.friend-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--interactive-active);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friend-status {
    font-size: 13px;
    color: var(--text-muted);
}

/* Friend buttons */
.friend-actions {
    display: flex;
    gap: 8px;
    margin-left: 12px;
    flex-shrink: 0;
}

.friend-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    transition: background 0.15s, color 0.15s;
    background: var(--bg-secondary);
    color: var(--interactive-muted);
}

.friend-btn:hover {
    background: var(--bg-modifier-hover);
    color: var(--interactive-hover);
}

.btn-accept {
    background: rgba(35, 165, 89, 0.15);
    color: #23a559;
}

.btn-accept:hover {
    background: #23a559;
    color: white;
}

.btn-decline {
    background: rgba(237, 66, 69, 0.12);
    color: var(--text-danger);
}

.btn-decline:hover {
    background: var(--text-danger);
    color: white;
}

.btn-message:hover {
    background: var(--brand-experiment);
    color: white;
}

.friends-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    text-align: center;
    font-size: 14px;
}

/* ============================================================
   Add Friend Panel
   ============================================================ */
.add-friend-panel {
    max-width: 700px;
    padding: 20px 0;
}

.add-friend-panel h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--interactive-active);
    margin-bottom: 8px;
}

.add-friend-panel p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.add-friend-search-wrap {
    display: flex;
    gap: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 4px 4px 4px 16px;
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

.add-friend-search-wrap:focus-within {
    border-color: var(--brand-experiment);
}

.add-friend-search-wrap input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--interactive-active);
    font-size: 15px;
    padding: 8px 0;
    font-family: inherit;
}

.add-friend-search-wrap input::placeholder {
    color: var(--text-muted);
}

.add-friend-feedback {
    margin-top: 12px;
    font-size: 14px;
    font-weight: 500;
    min-height: 20px;
}

.add-friend-feedback .ok {
    color: #23a559;
}

.add-friend-feedback .err {
    color: var(--text-danger);
}

.add-friend-results {
    margin-top: 12px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    background: var(--bg-secondary);
    transition: background 0.15s;
}

.search-result-item:hover {
    background: var(--bg-modifier-hover);
}

.search-result-item img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.search-result-item span:first-of-type {
    flex: 1;
    font-weight: 500;
    color: var(--interactive-active);
}

.search-no-result {
    padding: 12px 16px;
    color: var(--text-muted);
    font-size: 14px;
    background: var(--bg-secondary);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--interactive-muted);
    flex-shrink: 0;
}

.status-dot.online {
    background: #23a559;
}

.status-dot.idle {
    background: #f0b232;
}

.status-dot.dnd {
    background: #f23f43;
}

/* ============================================================
   Friend Context Menu
   ============================================================ */
.friend-context-menu {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px;
    min-width: 200px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
    animation: friendMenuIn 0.1s ease;
}

.context-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    color: var(--interactive-normal);
    cursor: pointer;
    transition: background 0.1s;
}

.context-item:hover {
    background: var(--bg-modifier-hover);
    color: var(--interactive-hover);
}

.context-item.danger {
    color: var(--text-danger);
}

.context-item.danger:hover {
    background: var(--text-danger);
    color: white;
}

.context-separator {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

/* ============================================================
   Notification Badge on Server Icon
   ============================================================ */
.server-notif-badge {
    position: absolute;
    bottom: -4px;
    right: -4px;
    background: var(--text-danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 5px;
    border: 2px solid var(--bg-tertiary);
    pointer-events: none;
}

.server-icon.has-notification::after {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: var(--interactive-active);
    border-radius: 0 4px 4px 0;
}

@keyframes friendMenuIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* DM Unread Indicators */
.channel-item.has-unread .dm-username {
    color: var(--interactive-active);
    font-weight: 600;
}

.dm-unread-count {
    background: var(--text-danger);
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    pointer-events: none;
}

/* ============================================================
   File Preview Modal
   ============================================================ */
.preview-modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 90vw;
    max-height: 80vh;
}

.preview-frame {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
}

.preview-image {
    max-width: 100%;
    max-height: 60vh;
    object-fit: contain;
    border-radius: 4px;
}

.preview-file-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 40px;
    color: var(--text-muted);
}

.preview-file-icon i {
    font-size: 80px;
    color: var(--brand-experiment);
}

.preview-file-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--interactive-active);
    word-break: break-all;
    text-align: center;
}

.preview-actions {
    display: flex;
    gap: 12px;
    width: 100%;
    justify-content: center;
}

.btn-preview-action {
    background: var(--bg-secondary);
    color: var(--interactive-normal);
    border: none;
    padding: 10px 20px;
    border-radius: 3px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s, color 0.2s;
    text-decoration: none !important;
}

.btn-preview-action:hover {
    background: var(--bg-modifier-hover);
    color: var(--interactive-hover);
}

.btn-preview-action.primary {
    background: var(--brand-experiment);
    color: white;
}

.btn-preview-action.primary:hover {
    background: var(--brand-experiment-hover);
}

/* ============================================================
   Profile Edit Modal
   ============================================================ */
.profile-edit-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.profile-edit-avatar-wrap {
    position: relative;
    width: 100px;
    height: 100px;
    margin-bottom: 10px;
}

.profile-edit-avatar-wrap img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--bg-tertiary);
    transition: transform 0.2s;
}

.avatar-edit-label {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    font-size: 24px;
}

.profile-edit-avatar-wrap:hover .avatar-edit-label {
    opacity: 1;
}

.avatar-edit-label:hover {
    background: rgba(0, 0, 0, 0.4);
}

.profile-edit-avatar-wrap:hover img {
    transform: scale(1.05);
}

/* ============================================================
   Admin Dashboard
   ============================================================ */
.admin-icon {
    color: var(--text-warning) !important;
}

.admin-icon:hover {
    background: var(--text-warning) !important;
    color: white !important;
}

.admin-tabs {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.admin-tab {
    background: none;
    border: none;
    color: var(--interactive-normal);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 5px 0;
    border-bottom: 2px solid transparent;
}

.admin-tab.active {
    color: var(--interactive-active);
    border-bottom-color: var(--brand-experiment);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    font-size: 14px;
}

.admin-table th,
.admin-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.admin-table th {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 700;
}

.admin-table tr:hover {
    background: var(--bg-modifier-hover);
}

.btn-text-danger {
    background: none;
    border: none;
    color: var(--text-danger);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.btn-text-danger:hover {
    text-decoration: underline;
}

.loading {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
}

/* DM Inspector */
.dm-inspector-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.dm-inspector-header h3 {
    margin: 0;
}

.dm-inspector-conv {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.dm-inspector-conv h4 {
    margin-top: 0;
    color: var(--text-muted);
    font-size: 0.9em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}

.dm-inspector-messages {
    max-height: 400px;
    overflow-y: auto;
    margin-top: 10px;
    padding-right: 5px;
}

.dm-inspector-message {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.dm-inspector-time {
    font-size: 0.75em;
    color: var(--text-muted);
    margin-left: 10px;
}

/* App Logo Icon */
.app-logo-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.server-icon img {
    user-select: none;
    -webkit-user-drag: none;
}

.empty-state img {
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

/* ============================================================ 
   Report System Refinement 2
   ============================================================ */
.message {
    position: relative;
    padding-right: 60px !important;
    transition: background-color 0.1s ease;
}

.message:hover {
    background-color: var(--bg-modifier-hover);
}

.message-actions {
    position: absolute;
    right: 16px;
    top: -12px;
    display: flex;
    opacity: 0;
    pointer-events: none;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 4px 4px rgba(0, 0, 0, 0.16);
    z-index: 100;
    transition: opacity 0.1s ease, transform 0.1s ease;
    transform: translateY(4px);
}

.message:hover .message-actions {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

.btn-msg-report {
    background: none !important;
    border: none !important;
    color: var(--interactive-normal) !important;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 4px;
    transition: color 0.1s, background-color 0.1s;
    font-size: 14px;
    box-shadow: none !important;
}

.btn-msg-report:hover {
    color: #ed4245 !important;
    background-color: rgba(237, 66, 69, 0.1) !important;
}

.btn-msg-report i {
    pointer-events: none;
}

.modal-select,
.modal-body textarea {
    width: 100%;
    margin-top: 8px;
    background-color: var(--bg-tertiary) !important;
    border: 1px solid rgba(0, 0, 0, 0.3) !important;
    border-radius: 3px;
    color: var(--text-normal);
    padding: 10px;
    font-family: inherit;
    font-size: 15px;
    transition: border-color 0.2s;
    outline: none;
}

#report-details {
    margin-top: 8px;
    resize: none;
}

.modal-select:focus,
.modal-body textarea:focus {
    border-color: #ed4245 !important;
}

/* Server Context Menu */
.server-context-menu {
    position: fixed;
    background-color: var(--bg-tertiary);
    border-radius: 4px;
    padding: 6px;
    width: 180px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.24);
    z-index: 1000;
}

.context-item {
    padding: 8px 10px;
    font-size: 14px;
    color: var(--interactive-normal);
    border-radius: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
}

.context-item:hover {
    background-color: var(--brand-experiment);
    color: white;
}

.context-item.danger {
    color: var(--text-danger);
}

.context-item.danger:hover {
    background-color: var(--text-danger);
    color: white;
}

.context-separator {
    height: 1px;
    background-color: var(--divider-color);
    margin: 4px 0;
}

/* Modal Themes */
.modal-content.danger {
    border-top: 4px solid var(--text-danger);
}

.modal-header.danger h2 {
    color: var(--text-danger);
}

.modal-footer .btn-danger {
    background-color: var(--text-danger);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 3px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.modal-footer .btn-danger:hover {
    background-color: #d85c61;
}