/* ============================================
   HUBBER - Main Stylesheet
   Modern chat platform with unique Hubber design
   ============================================ */

/* CSS Variables */
:root {
    /* Dark Theme (Default) - Hubber Modern Dark */
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --bg-tertiary: #374151;
    --bg-modifier-hover: rgba(99, 102, 241, 0.1);
    --bg-modifier-active: rgba(99, 102, 241, 0.2);
    --bg-modifier-selected: rgba(99, 102, 241, 0.3);

    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --text-link: #818cf8;

    --brand-primary: #6366f1;
    --brand-hover: #818cf8;
    --brand-active: #4f46e5;

    --status-online: #10b981;
    --status-away: #f59e0b;
    --status-busy: #ef4444;
    --status-offline: #6b7280;

    --danger: #ef4444;
    --danger-hover: #dc2626;

    --success: #10b981;
    --warning: #f59e0b;

    --input-bg: #1f2937;
    --input-border: #4b5563;

    --scrollbar-thin-thumb: #4b5563;
    --scrollbar-auto-thumb: #374151;
    --scrollbar-auto-track: #1f2937;

    --modal-bg: #1f2937;
    --modal-overlay: rgba(0, 0, 0, 0.75);

    --channel-icon: #6b7280;

    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-full: 50%;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.4);

    --transition-fast: 0.1s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;

    --server-sidebar-width: 72px;
    --channel-sidebar-width: 240px;
    --members-sidebar-width: 240px;

    --message-font-size: 16px;
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --bg-tertiary: #e5e7eb;
    --bg-modifier-hover: rgba(99, 102, 241, 0.08);
    --bg-modifier-active: rgba(99, 102, 241, 0.16);
    --bg-modifier-selected: rgba(99, 102, 241, 0.24);

    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    --text-link: #6366f1;

    --input-bg: #ffffff;
    --input-border: #d1d5db;

    --scrollbar-thin-thumb: #d1d5db;
    --scrollbar-auto-thumb: #d1d5db;
    --scrollbar-auto-track: #f3f4f6;

    --modal-bg: #ffffff;
    --modal-overlay: rgba(0, 0, 0, 0.5);

    --focus-ring: 0 0 0 3px rgba(99, 102, 241, 0.4);
    --mention-bg: rgba(99, 102, 241, 0.15);
}

/* Default focus ring for dark theme */
:root {
    --focus-ring: 0 0 0 2px rgba(99, 102, 241, 0.35);
    --mention-bg: rgba(99, 102, 241, 0.25);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Scrollbar Styles */
/* Firefox scrollbar support */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-auto-thumb) var(--scrollbar-auto-track);
}

/* Chrome/Safari scrollbar support */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-auto-track);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-auto-thumb);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thin-thumb);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   Loading Screen
   ============================================ */
.loading-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-content {
    text-align: center;
}

.loading-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 16px;
    animation: pulse 2s ease-in-out infinite;
}

.loading-content h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 1s linear infinite;
}

.loading-content p {
    color: var(--text-muted);
    font-size: 14px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
}

/* ============================================
   Modal Styles
   ============================================ */
.modal {
    position: fixed;
    inset: 0;
    background: var(--modal-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
    animation: fadeIn var(--transition-fast);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--modal-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp var(--transition-normal);
    box-shadow: var(--shadow-lg);
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-content.compact {
    max-width: 360px;
    text-align: center;
}

.modal-content.settings-modal {
    max-width: 900px;
    padding: 0;
    display: flex;
    height: 80vh;
}

.modal-content.settings-modal .modal-close {
    background: var(--bg-modifier-hover);
    color: var(--text-muted);
    top: 16px;
    right: 16px;
}

.modal-content.settings-modal .modal-close:hover {
    background: var(--bg-modifier-active);
    color: var(--text-primary);
}

.modal-content.user-profile {
    max-width: 400px;
    padding: 0;
    overflow: hidden;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.4);
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    transition: background var(--transition-fast);
    z-index: 10;
    border-radius: var(--radius-sm);
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
}

/* Non-profile modals use simpler close button */
.modal-content:not(.user-profile):not(.settings-modal) .modal-close {
    background: none;
    color: var(--text-muted);
}

.modal-content:not(.user-profile):not(.settings-modal) .modal-close:hover {
    background: var(--bg-modifier-hover);
    color: var(--text-primary);
}

.modal-logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    display: block;
}

.modal-content h1, .modal-content h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.modal-content h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.modal-content > p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Username Setup Modal */
.username-setup {
    text-align: center;
}

.username-setup .input-group {
    text-align: left;
}

/* Auth Switch (Login/Signup toggle) */
.auth-switch {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--input-border);
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.auth-switch .btn-link {
    background: none;
    border: none;
    color: var(--brand-primary);
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    margin-left: 4px;
    font-weight: 500;
}

.auth-switch .btn-link:hover {
    text-decoration: underline;
    color: var(--brand-hover);
}

/* Telegram Button */
.telegram-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #0088cc 0%, #0077b5 100%);
    color: white;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 136, 204, 0.3);
}

.telegram-btn:hover {
    background: linear-gradient(135deg, #0099dd 0%, #0088cc 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 136, 204, 0.4);
}

.telegram-btn:active {
    transform: translateY(0);
}

.telegram-btn svg {
    flex-shrink: 0;
}

/* Password change form in settings */
.password-change-form {
    margin-top: 16px;
}

.password-change-form .input-group {
    margin-bottom: 12px;
}

/* ============================================
   Form Elements
   ============================================ */
.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.input-group input[type="text"],
.input-group input[type="email"],
.input-group input[type="password"],
.input-group textarea,
.input-group select {
    width: 100%;
    padding: 12px 14px;
    background: var(--input-bg);
    border: 2px solid var(--input-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    transition: all var(--transition-fast);
}

.input-group input:hover,
.input-group textarea:hover,
.input-group select:hover {
    border-color: var(--text-muted);
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.input-group textarea {
    resize: vertical;
    min-height: 80px;
}

.input-hint {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.error-message {
    color: var(--danger);
    font-size: 14px;
    margin-top: 8px;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:focus-visible {
    outline: 2px solid var(--brand-hover);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--brand-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background: var(--brand-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
    background: var(--brand-active);
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-modifier-hover);
}

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: var(--danger-hover);
    transform: translateY(-1px);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    position: relative;
}

.icon-btn:hover {
    background: var(--bg-modifier-hover);
    color: var(--text-primary);
}

.icon-btn[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    z-index: 10000;
    margin-bottom: 4px;
}

/* Toggle/Checkbox */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.toggle-label input[type="checkbox"] {
    width: 40px;
    height: 24px;
    appearance: none;
    background: var(--bg-modifier-active);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.toggle-label input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    top: 3px;
    left: 3px;
    transition: transform var(--transition-fast);
}

.toggle-label input[type="checkbox"]:checked {
    background: var(--brand-primary);
}

.toggle-label input[type="checkbox"]:checked::before {
    transform: translateX(16px);
}

/* ============================================
   Main App Layout
   ============================================ */
.app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Server Sidebar */
.server-sidebar {
    width: var(--server-sidebar-width);
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    flex-shrink: 0;
}

.server-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    overflow-y: auto;
    padding: 0 12px;
}

.server-item {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

.server-item:active {
    cursor: grabbing;
}

.server-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.server-item:hover,
.server-item.active {
    border-radius: var(--radius-lg);
}

.server-item:hover {
    background: var(--brand-primary);
}

.server-item.active {
    background: var(--brand-primary);
}

.server-item:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.server-item.home-button {
    background: var(--bg-tertiary);
}

.server-item.home-button:hover,
.server-item.home-button.active {
    background: var(--brand-primary);
}

.server-item.home-button img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

/* Server list items need gap */
#server-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Mobile: server list horizontal */
@media (max-width: 768px) {
    #server-list {
        flex-direction: row;
        gap: 8px;
    }
}

.server-item.add-server {
    background: var(--bg-tertiary);
    color: var(--status-online);
    cursor: pointer;
}

.server-item.add-server svg {
    width: 24px;
    height: 24px;
    transition: transform var(--transition-fast);
}

.server-item.add-server:hover {
    background: var(--status-online);
    color: white;
}

.server-item.add-server:hover svg {
    transform: rotate(90deg);
}

.server-item::before {
    content: '';
    position: absolute;
    left: -12px;
    width: 4px;
    height: 0;
    background: var(--text-primary);
    border-radius: 0 4px 4px 0;
    transition: height var(--transition-fast);
}

.server-item:hover::before {
    height: 20px;
}

.server-item.active::before {
    height: 40px;
}

.server-item[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    padding: 8px 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    margin-left: 12px;
    max-width: 300px;
}

.sidebar-divider {
    width: 32px;
    height: 2px;
    background: var(--bg-modifier-active);
    border-radius: 1px;
    margin: 4px 0;
}

/* Channel Sidebar */
.channel-sidebar {
    width: var(--channel-sidebar-width);
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.channel-header {
    height: 48px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--bg-primary);
    box-shadow: var(--shadow-sm);
}

.channel-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.channel-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* Channel Category */
.channel-category {
    margin-bottom: 8px;
}

.category-header {
    display: flex;
    align-items: center;
    padding: 16px 4px 4px;
    cursor: grab;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    user-select: none;
    -webkit-user-select: none;
}

.category-header:active {
    cursor: grabbing;
}

.category-header:hover {
    color: var(--text-secondary);
}

.category-header svg {
    width: 12px;
    height: 12px;
    margin-right: 4px;
    transition: transform var(--transition-fast);
}

.category-header.collapsed svg {
    transform: rotate(-90deg);
}

.channel-category.collapsed .channel-item,
.channel-category.collapsed .voice-channel-users,
.channel-category.collapsed .voice-channel-empty {
    display: none;
}

.category-header .category-name {
    flex: 1;
}

.category-header .add-channel-btn {
    opacity: 0;
    transition: opacity var(--transition-fast);
    position: relative;
}

.category-header:hover .add-channel-btn {
    opacity: 1;
}

/* Add channel button uses native title attribute for tooltip (avoids overflow clipping issues) */

/* Channel Item */
.channel-item {
    display: flex;
    align-items: center;
    padding: 8px;
    margin: 2px 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    position: relative;
}

.channel-item:hover {
    background: var(--bg-modifier-hover);
    color: var(--text-secondary);
}

.channel-item.active {
    background: var(--bg-modifier-selected);
    color: var(--text-primary);
}

.channel-item.unread {
    color: var(--text-primary);
}

.channel-item.unread .channel-name {
    font-weight: 600;
}

.channel-item.unread::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 8px;
    background: var(--text-primary);
    border-radius: 0 4px 4px 0;
}

.channel-item .channel-icon {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--channel-icon);
    font-size: 18px;
    font-weight: 500;
}

.channel-item .channel-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}

.channel-item .channel-actions {
    display: none;
    gap: 4px;
}

.channel-item:hover .channel-actions {
    display: flex;
}

/* Voice Channel Users */
.voice-users {
    margin-left: 28px;
    margin-top: 4px;
}

.voice-user {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
}

.voice-user:hover {
    background: var(--bg-modifier-hover);
}

.voice-user-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 8px;
}

/* DM Item */
.dm-item {
    display: flex;
    align-items: center;
    padding: 8px;
    margin: 2px 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.dm-item:hover {
    background: var(--bg-modifier-hover);
}

.dm-item.active {
    background: var(--bg-modifier-selected);
}

.dm-item .dm-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 12px;
    position: relative;
}

.dm-item .dm-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.dm-item .dm-info {
    flex: 1;
    overflow: hidden;
}

.dm-item .dm-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dm-item .dm-status {
    font-size: 12px;
    color: var(--text-muted);
}

.dm-item .unread-badge {
    background: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
}

/* User Panel */
.user-panel {
    padding: 8px;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    padding: 4px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.user-info:hover {
    background: var(--bg-modifier-hover);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 8px;
    position: relative;
    flex-shrink: 0;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.status-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 3px solid var(--bg-primary);
}

.status-indicator.online { background: var(--status-online); }
.status-indicator.away { background: var(--status-away); }
.status-indicator.busy { background: var(--status-busy); }
.status-indicator.offline { background: var(--status-offline); }

.user-details {
    flex: 1;
    min-width: 0;
}

.user-details .username {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-details .user-status {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
}

.user-controls {
    display: flex;
    gap: 4px;
}

/* ============================================
   Main Content Area
   ============================================ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-tertiary);
}

/* Chat Header */
.chat-header {
    height: 48px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--bg-primary);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    min-width: 0;
}

.chat-header-info .channel-icon {
    color: var(--channel-icon);
    font-size: 20px;
    font-weight: 500;
    margin-right: 8px;
}

.chat-header-info h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-right: 12px;
}

.chat-header-info .channel-description {
    font-size: 14px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-left: 12px;
    border-left: 1px solid var(--bg-modifier-active);
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-box {
    position: relative;
}

.search-box input {
    width: 150px;
    padding: 6px 8px 6px 32px;
    background: var(--bg-primary);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    transition: width var(--transition-normal);
}

.search-box input:focus {
    width: 240px;
    outline: none;
}

.search-box svg {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.messages-list {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Spacer to push messages to bottom when few messages */
.messages-spacer {
    flex: 1 1 auto;
    min-height: 0;
}

/* Load more messages button */
.load-more-container {
    display: flex;
    justify-content: center;
    padding: 12px;
}

.load-more-btn {
    background: var(--bg-modifier-hover);
    border: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.load-more-btn:hover {
    background: var(--bg-modifier-active);
    color: var(--text-primary);
}

.load-more-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Messages Loading State */
.messages-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 16px;
    color: var(--text-muted);
    gap: 12px;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--bg-modifier-active);
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Messages Empty State */
.messages-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 16px;
    text-align: center;
    color: var(--text-muted);
}

.messages-empty .empty-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-modifier-active);
    border-radius: 50%;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.messages-empty .empty-icon svg {
    width: 32px;
    height: 32px;
}

.messages-empty h3 {
    color: var(--text-primary);
    margin-bottom: 8px;
}

.messages-empty p {
    max-width: 400px;
    line-height: 1.5;
}

/* Message */
.message {
    display: flex;
    padding: 4px 16px;
    margin: 0 -16px;
    position: relative;
    transition: background var(--transition-fast);
}

.message:hover {
    background: var(--bg-modifier-hover);
}

.message.grouped {
    padding-top: 0;
    margin-top: -2px;
}

.message.grouped .message-avatar {
    width: 40px;
    height: 0;
    margin-right: 16px;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.message.grouped .message-avatar img {
    visibility: hidden;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}

.message.grouped .message-header {
    display: none;
}

.message-author {
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
}

.message-author:hover {
    text-decoration: underline;
}

.message-timestamp {
    font-size: 12px;
    color: var(--text-muted);
}

.message-text {
    font-size: var(--message-font-size);
    color: var(--text-primary);
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message-text a {
    color: var(--text-link);
    text-decoration: none;
}

.message-text a:hover {
    text-decoration: underline;
}

.message-edited {
    font-size: 10px;
    color: var(--text-muted);
    margin-left: 4px;
}

/* Mentions */
.mention {
    background: var(--mention-bg);
    color: var(--brand-primary);
    padding: 0 4px;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 500;
}

.mention:hover {
    background: rgba(233, 69, 96, 0.5);
    color: #fff;
}

.mention.self-mention {
    background: rgba(233, 69, 96, 0.5);
    color: #fff;
}

/* Light theme mention adjustments */
[data-theme="light"] .mention {
    color: var(--brand-primary);
    background: rgba(233, 69, 96, 0.15);
}

[data-theme="light"] .mention:hover,
[data-theme="light"] .mention.self-mention {
    background: rgba(233, 69, 96, 0.3);
    color: var(--brand-primary);
}

.message.mentioned {
    background: rgba(250, 168, 26, 0.1);
    border-left: 2px solid #faa81a;
    padding-left: 14px;
    margin-left: -16px;
}

.message.mentioned::before {
    display: none;
}

/* Blocked User Messages */
.message.blocked {
    opacity: 0.5;
    background: rgba(0, 0, 0, 0.2);
}

.message.blocked .message-text {
    font-style: italic;
    color: var(--text-muted);
}

.message.blocked .message-text::before {
    content: '[Blocked] ';
    color: var(--danger);
    font-weight: 500;
}

.message-actions {
    position: absolute;
    right: 16px;
    top: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    display: none;
    padding: 4px;
}

.message:hover .message-actions {
    display: flex;
}

/* Welcome Message */
.welcome-message {
    padding: 16px;
    margin-bottom: 16px;
}

.welcome-message h2 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
}

.welcome-message p {
    color: var(--text-muted);
}

/* DM Welcome Screen */
.dm-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
    margin: auto;
}

.dm-welcome h2 {
    font-size: 24px;
    color: var(--text-primary);
}

.dm-welcome p {
    max-width: 400px;
    margin-top: 8px;
}

/* DM Empty State */
.dm-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* Message Input */
.message-input-container {
    padding: 0 16px 24px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.message-input-wrapper {
    flex: 1;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: flex-end;
}

.message-input-wrapper textarea {
    flex: 1;
    background: transparent;
    border: none;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    resize: none;
    max-height: 200px;
    line-height: 1.4;
}

.message-input-wrapper textarea:focus {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-sm);
}

.message-input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.attach-btn, .emoji-btn {
    flex-shrink: 0;
}

/* ============================================
   Voice Channel View
   ============================================ */
.voice-channel-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.voice-participants {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 24px;
    margin-bottom: 32px;
}

.voice-participant {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    min-width: 120px;
}

.voice-participant.speaking {
    box-shadow: 0 0 0 3px var(--status-online);
}

.voice-participant-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin-bottom: 12px;
    position: relative;
}

.voice-participant-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.voice-participant-name {
    font-weight: 600;
    color: var(--text-primary);
}

.voice-participant-status {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.voice-controls {
    display: flex;
    gap: 16px;
}

.voice-control-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border: none;
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.voice-control-btn:hover {
    background: var(--bg-modifier-hover);
}

.voice-control-btn.active {
    background: var(--danger);
}

.voice-control-btn.danger {
    background: var(--danger);
}

.voice-control-btn.danger:hover {
    background: var(--danger-hover);
}

/* ============================================
   Members Sidebar
   ============================================ */
.members-sidebar {
    width: var(--members-sidebar-width);
    background: var(--bg-secondary);
    flex-shrink: 0;
    overflow-y: auto;
    padding: 16px 8px;
}

.members-list h4 {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 8px;
    margin-top: 8px;
}

.members-list h4:first-child {
    margin-top: 0;
}

.member-item {
    display: flex;
    align-items: center;
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.member-item:hover {
    background: var(--bg-modifier-hover);
}

.member-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 12px;
    position: relative;
}

.member-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.member-info {
    flex: 1;
    min-width: 0;
}

.member-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.member-role {
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================
   Settings Modal - Clean Redesign
   ============================================ */
.settings-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Settings Navigation */
.settings-nav {
    width: 220px;
    background: var(--bg-secondary);
    padding: 20px 12px;
    flex-shrink: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.settings-nav-section {
    margin-bottom: 8px;
}

.settings-nav-header {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    padding: 8px 12px 4px;
}

.settings-nav ul {
    list-style: none;
}

.settings-nav li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin: 2px 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    transition: all var(--transition-fast);
}

.settings-nav li svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.settings-nav li:hover {
    background: var(--bg-modifier-hover);
    color: var(--text-primary);
}

.settings-nav li:hover svg {
    opacity: 1;
}

.settings-nav li.active {
    background: var(--bg-modifier-selected);
    color: var(--text-primary);
}

.settings-nav li.active svg {
    opacity: 1;
    color: var(--brand-primary);
}

.settings-nav li.danger {
    color: var(--danger);
}

.settings-nav li.danger svg {
    color: var(--danger);
}

.settings-nav li.danger:hover {
    background: rgba(242, 63, 67, 0.1);
}

.settings-nav-divider {
    height: 1px;
    background: var(--bg-modifier-active);
    margin: 12px 8px;
}

.settings-nav-bottom {
    margin-top: auto;
}

/* Settings Content Area */
.settings-content {
    flex: 1;
    padding: 32px 40px;
    overflow-y: auto;
    max-width: 740px;
}

.settings-panel {
    display: none;
}

.settings-panel.active {
    display: block;
}

/* Settings Header */
.settings-header {
    margin-bottom: 24px;
}

.settings-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.settings-header p {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0;
}

/* Settings Cards */
.settings-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
}

.settings-card h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.settings-card .card-description {
    font-size: 13px;
    color: var(--text-muted);
    margin: -8px 0 16px 0;
}

/* Settings Fields */
.settings-field {
    margin-bottom: 16px;
}

.settings-field:last-child {
    margin-bottom: 0;
}

.settings-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.settings-field input[type="text"],
.settings-field input[type="password"],
.settings-field textarea,
.settings-field select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color var(--transition-fast);
}

.settings-field input:focus,
.settings-field textarea:focus,
.settings-field select:focus {
    outline: none;
    border-color: var(--brand-primary);
}

.settings-field textarea {
    resize: vertical;
    min-height: 80px;
}

.field-hint {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Profile Preview Card */
.profile-preview {
    display: flex;
    align-items: center;
    gap: 20px;
}

.avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.avatar-wrapper {
    position: relative;
    width: 80px;
    height: 80px;
    cursor: pointer;
}

.avatar-wrapper img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-overlay {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.avatar-overlay svg {
    color: white;
}

.avatar-wrapper:hover .avatar-overlay {
    opacity: 1;
}

.avatar-hint {
    font-size: 11px;
    color: var(--text-muted);
}

.profile-info-preview {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.preview-username {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.preview-status {
    font-size: 13px;
    color: var(--status-online);
}

/* Status Options */
.status-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.status-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.status-option:hover {
    background: var(--bg-modifier-hover);
}

.status-option input[type="radio"] {
    display: none;
}

.status-option input[type="radio"]:checked + .status-indicator + span {
    color: var(--text-primary);
    font-weight: 500;
}

.status-option input[type="radio"]:checked ~ span:last-child::after {
    content: "✓";
    margin-left: 6px;
    font-size: 12px;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-indicator.online { background: var(--status-online); }
.status-indicator.away { background: var(--status-away); }
.status-indicator.busy { background: var(--status-busy); }
.status-indicator.offline { background: var(--status-offline); }

/* Settings Actions */
.settings-actions {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--bg-modifier-active);
}

/* Info Grid (Account Info) */
.info-grid {
    display: grid;
    gap: 16px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.info-label {
    font-size: 13px;
    color: var(--text-muted);
}

.info-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.info-value.mono {
    font-family: monospace;
    font-size: 12px;
}

/* Password Fields */
.password-fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

/* Theme Selector */
.theme-selector {
    display: flex;
    gap: 16px;
}

.theme-card {
    flex: 1;
    padding: 0;
    background: transparent;
    border: 2px solid var(--bg-modifier-active);
    border-radius: var(--radius-md);
    cursor: pointer;
    overflow: hidden;
    transition: all var(--transition-fast);
}

.theme-card:hover {
    border-color: var(--text-muted);
}

.theme-card.active {
    border-color: var(--brand-primary);
}

.theme-preview {
    height: 80px;
    display: flex;
    padding: 8px;
    gap: 8px;
}

.dark-preview {
    background: #1a1a2e;
}

.light-preview {
    background: #f5f5f5;
}

.preview-sidebar {
    width: 30%;
    border-radius: 4px;
}

.dark-preview .preview-sidebar {
    background: #16162a;
}

.light-preview .preview-sidebar {
    background: #e5e5e5;
}

.preview-content {
    flex: 1;
    border-radius: 4px;
}

.dark-preview .preview-content {
    background: #0f0f1a;
}

.light-preview .preview-content {
    background: #ffffff;
}

.theme-card span {
    display: block;
    padding: 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    text-align: center;
    background: var(--bg-tertiary);
}

/* Slider Container */
.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-container input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    background: var(--bg-tertiary);
    border-radius: 3px;
    outline: none;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--brand-primary);
    cursor: pointer;
}

.slider-label {
    font-size: 12px;
    color: var(--text-muted);
}

.slider-label.large {
    font-size: 18px;
}

.slider-value {
    min-width: 45px;
    font-size: 13px;
    color: var(--text-secondary);
    text-align: right;
}

/* Toggle Switch */
.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.toggle-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toggle-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.toggle-description {
    font-size: 13px;
    color: var(--text-muted);
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-modifier-active);
    border-radius: 12px;
    transition: background var(--transition-fast);
}

.toggle-slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition-fast);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--brand-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* Legacy support for old theme buttons */
.theme-options {
    display: none;
}

.theme-btn {
    display: none;
}

/* ============================================
   Server Options Modal
   ============================================ */
.server-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.server-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px;
    background: var(--bg-secondary);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
    color: var(--text-primary);
}

.server-option:hover {
    background: var(--bg-modifier-hover);
}

.server-option svg {
    color: var(--text-muted);
}

.server-option span {
    font-weight: 600;
}

/* ============================================
   Channel Type Options
   ============================================ */
.channel-type-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.channel-type-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.channel-type-option:hover {
    background: var(--bg-modifier-hover);
}

.channel-type-option.selected {
    background: var(--bg-modifier-selected);
}

.channel-type-option input {
    display: none;
}

.channel-type-icon {
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--text-muted);
}

.channel-type-option div strong {
    display: block;
    color: var(--text-primary);
}

.channel-type-option div p {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

/* ============================================
   User Profile Modal
   ============================================ */
.profile-banner {
    height: 100px;
    background: linear-gradient(135deg, var(--brand-primary), #8b5cf6);
}

.profile-info {
    padding: 16px 24px 24px;
    text-align: center;
    position: relative;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 6px solid var(--modal-bg);
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    object-fit: cover;
}

.profile-info h2 {
    margin-top: 48px;
    margin-bottom: 4px;
}

.profile-username {
    color: var(--text-muted);
    margin-bottom: 12px;
}

.profile-bio {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
}

.profile-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* ============================================
   Context Menu
   ============================================ */
.context-menu {
    position: fixed;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 8px;
    min-width: 180px;
    z-index: 1001;
}

.context-menu ul {
    list-style: none;
}

.context-menu li {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-fast);
}

.context-menu li:hover {
    background: var(--brand-primary);
    color: white;
}

.context-menu li.danger {
    color: var(--danger);
}

.context-menu li.danger:hover {
    background: var(--danger);
    color: white;
}

.context-menu .divider {
    height: 1px;
    background: var(--bg-modifier-active);
    margin: 4px 0;
    padding: 0;
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2000;
}

.toast {
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight var(--transition-normal);
    max-width: 400px;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    margin-left: auto;
}

/* ============================================
   Emoji Picker
   ============================================ */
.emoji-picker {
    position: fixed;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    width: 352px;
    max-height: 420px;
    z-index: 1000;
    overflow: hidden;
}

.emoji-search {
    padding: 12px;
    border-bottom: 1px solid var(--bg-modifier-active);
}

.emoji-search input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
}

.emoji-search input:focus {
    outline: none;
}

.emoji-list {
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    max-height: 350px;
    overflow-y: auto;
}

.emoji-item {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.emoji-item:hover {
    background: var(--bg-modifier-hover);
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 1200px) {
    .members-sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    .channel-sidebar {
        position: fixed;
        left: var(--server-sidebar-width);
        top: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
    }

    .channel-sidebar.open {
        transform: translateX(0);
    }

    .server-sidebar {
        width: 56px;
    }

    .server-item {
        width: 40px;
        height: 40px;
    }

    .chat-header-info .channel-description {
        display: none;
    }

    .search-box {
        display: none;
    }

    .modal-content.settings-modal {
        flex-direction: column;
        height: auto;
        max-height: 90vh;
    }

    .settings-nav {
        width: 100%;
        padding: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .settings-nav ul {
        display: flex;
        flex-wrap: nowrap;
        gap: 6px;
        padding-bottom: 4px;
    }

    .settings-nav li {
        padding: 8px 12px;
        font-size: 13px;
        white-space: nowrap;
        flex-shrink: 0;
        border-radius: var(--radius-sm);
    }

    .settings-nav li:hover,
    .settings-nav li.active {
        background: var(--bg-modifier-selected);
    }

    .toast-container {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }

    .toast {
        max-width: 100%;
        width: 100%;
    }
}

/* ============================================
   Animations
   ============================================ */
.message {
    animation: messageIn var(--transition-fast);
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    color: var(--text-muted);
    font-size: 14px;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); }
    40% { transform: scale(1); }
}

/* Connection Status */
.connection-status {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 8px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    transform: translateY(-100%);
    transition: transform var(--transition-normal);
}

.connection-status.visible {
    transform: translateY(0);
}

.connection-status.connecting {
    background: var(--warning);
    color: #000;
}

.connection-status.disconnected {
    background: var(--danger);
    color: #fff;
}

/* ============================================
   Server Settings Panel
   ============================================ */
.server-settings-panel {
    display: none;
}

.server-settings-panel.active {
    display: block;
}

/* Server settings avatar/icon sizing */
.server-settings-panel .profile-editor {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.server-settings-panel .avatar-editor {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.server-settings-panel .avatar-editor img,
#server-settings-icon {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
}

.server-settings-panel .profile-fields {
    flex: 1;
}

.invite-code-display {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
    padding: 16px 20px;
    border-radius: var(--radius-md);
}

.invite-code {
    font-size: 24px;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    letter-spacing: 4px;
    color: var(--text-primary);
    flex: 1;
}

.custom-invite-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.custom-invite-row .invite-prefix {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.custom-invite-row input {
    flex: 1;
    font-size: 14px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
}

.custom-invite-row input:focus {
    border-color: var(--brand-primary);
    outline: none;
}

.custom-invite-row .btn {
    padding: 8px 16px;
    white-space: nowrap;
}

/* Server drag and drop styles */
.server-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.server-item.drag-over {
    border: 2px dashed var(--brand-primary);
    border-radius: 50%;
}

.server-folder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    position: relative;
}

.server-folder-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    background: var(--bg-tertiary);
    display: flex;
    flex-wrap: wrap;
    padding: 4px;
    gap: 2px;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.server-folder-icon:hover {
    border-radius: var(--radius-md);
}

.server-folder-icon .folder-server-preview {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    background: var(--bg-secondary);
    overflow: hidden;
}

.server-folder-icon .folder-server-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.server-folder.expanded .folder-servers {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 0;
}

.server-folder:not(.expanded) .folder-servers {
    display: none;
}

/* Channel drag and drop styles */
.channel-item.dragging {
    opacity: 0.5;
}

.channel-item.drag-over {
    border-top: 2px solid var(--brand-primary);
}

.channel-category.drag-over {
    background: var(--bg-modifier-hover);
    border-radius: var(--radius-md);
}

.category-header.dragging {
    opacity: 0.5;
}

/* Edit channel modal */
.edit-channel-form .input-group {
    margin-bottom: 16px;
}

/* ============================================
   Improved Voice Channel Styling
   ============================================ */
.channel-item[data-type="voice"] {
    color: var(--text-muted);
}

.channel-item[data-type="voice"] .channel-icon {
    color: var(--status-online);
}

.channel-item[data-type="voice"].active {
    background: var(--bg-modifier-selected);
    color: var(--text-primary);
}

.channel-item[data-type="voice"] .channel-icon svg {
    width: 18px;
    height: 18px;
}

/* Voice Users in Channel Sidebar */
.voice-channel-users {
    margin-left: 28px;
    margin-top: 2px;
    margin-bottom: 4px;
}

.voice-channel-empty {
    margin-left: 28px;
    padding: 4px 8px;
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

/* Show "Empty" text only when hovering the voice channel */
.channel-item[data-type="voice"]:hover + .voice-channel-empty,
.channel-item[data-type="click_to_create"]:hover + .voice-channel-empty {
    opacity: 1;
}

.voice-channel-user {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    margin: 1px 0;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.voice-channel-user:hover {
    background: var(--bg-modifier-hover);
}

.voice-channel-user.speaking {
    color: var(--status-online);
}

.voice-channel-user-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 8px;
    object-fit: cover;
}

.voice-channel-user.speaking .voice-channel-user-avatar {
    box-shadow: 0 0 0 2px var(--status-online);
    animation: speakingPulse 1.5s ease-in-out infinite;
}

.voice-channel-user-icons {
    margin-left: auto;
    display: flex;
    gap: 4px;
    color: var(--text-muted);
}

.voice-channel-user-icons svg {
    width: 14px;
    height: 14px;
}

/* Speaking Animation */
@keyframes speakingPulse {
    0%, 100% { box-shadow: 0 0 0 2px var(--status-online); }
    50% { box-shadow: 0 0 0 4px rgba(35, 165, 90, 0.5); }
}

/* Voice Participant Speaking State */
.voice-participant.speaking {
    box-shadow: 0 0 0 3px var(--status-online);
    animation: voiceSpeaking 1.5s ease-in-out infinite;
}

.voice-participant.speaking .voice-participant-avatar {
    animation: avatarPulse 1.5s ease-in-out infinite;
}

@keyframes voiceSpeaking {
    0%, 100% { box-shadow: 0 0 0 3px var(--status-online); }
    50% { box-shadow: 0 0 0 6px rgba(35, 165, 90, 0.4); }
}

@keyframes avatarPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

/* ============================================
   Improved Mute/Deafen Buttons
   ============================================ */
.user-controls .icon-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    position: relative;
}

.user-controls .icon-btn.muted,
.user-controls .icon-btn.deafened {
    color: var(--danger);
    background: rgba(242, 63, 67, 0.1);
}

.user-controls .icon-btn.muted::after,
.user-controls .icon-btn.deafened::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 2px;
    background: var(--danger);
    transform: rotate(-45deg);
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -1px;
}

.voice-control-btn {
    min-width: 100px;
    font-size: 13px;
    font-weight: 500;
}

.voice-control-btn svg {
    width: 24px;
    height: 24px;
}

.voice-control-btn.muted,
.voice-control-btn.deafened {
    background: var(--danger);
}

.voice-control-btn.muted svg,
.voice-control-btn.deafened svg {
    position: relative;
}

/* Category Rename */
.category-header .category-name {
    cursor: text;
}

.category-header .category-name:hover {
    text-decoration: underline;
}

.category-rename-input {
    background: var(--input-bg);
    border: 1px solid var(--brand-primary);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 4px;
    width: 100%;
    outline: none;
}

/* Voice Connected State */
.voice-connected-banner {
    background: var(--status-online);
    color: white;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 500;
}

.voice-connected-banner .channel-name {
    display: flex;
    align-items: center;
    gap: 8px;
}

.voice-connected-banner .disconnect-btn {
    background: rgba(0, 0, 0, 0.2);
    border: none;
    color: white;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
}

.voice-connected-banner .disconnect-btn:hover {
    background: rgba(0, 0, 0, 0.4);
}

/* ============================================
   Custom Confirm Modal
   ============================================ */
.confirm-modal {
    text-align: center;
    padding: 32px;
    max-width: 400px;
}

.confirm-icon {
    color: var(--warning);
    margin-bottom: 16px;
    display: inline-flex;
    padding: 12px;
    background: rgba(240, 178, 50, 0.1);
    border-radius: 50%;
}

.confirm-modal h3 {
    margin-bottom: 8px;
    font-size: 20px;
}

.confirm-modal p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.confirm-actions .btn {
    min-width: 100px;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #d32f2f;
}

/* ============================================
   Improved Voice Controls (Icon Style)
   ============================================ */
.voice-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    padding: 24px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
}

.voice-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    transition: all var(--transition-fast);
}

.voice-btn:hover {
    background: var(--bg-modifier-hover);
    transform: scale(1.1);
}

.voice-btn.muted,
.voice-btn.deafened {
    background: rgba(242, 63, 67, 0.2);
    color: var(--danger);
}

.voice-btn.disconnect {
    background: var(--danger);
    color: white;
}

.voice-btn.disconnect:hover {
    background: #d32f2f;
}

/* ============================================
   Mobile Menu Buttons
   ============================================ */
.mobile-menu-btn {
    position: fixed;
    z-index: 1000;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--brand-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all var(--transition-fast);
    top: 56px;
    left: 12px;
}

/* Hide mobile menu button when modals are open */
.modal:not(.hidden) ~ .mobile-menu-btn,
body:has(.modal:not(.hidden)) .mobile-menu-btn {
    display: none !important;
}

.mobile-menu-btn:hover {
    transform: scale(1.1);
}

.mobile-menu-btn.hidden {
    display: none;
}

/* ============================================
   Mobile-First Responsive Design
   ============================================ */
@media (max-width: 768px) {
    /* Show mobile buttons */
    .mobile-menu-btn {
        display: flex;
    }

    /* App layout for mobile */
    .app {
        display: flex;
        flex-direction: column;
    }

    /* Server sidebar - horizontal at bottom on mobile */
    .server-sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100%;
        height: 60px;
        flex-direction: row;
        z-index: 100;
        border-top: 1px solid var(--border-color);
        padding: 4px 8px;
    }

    .server-sidebar .server-list {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 8px;
        padding: 0;
        width: 100%;
        justify-content: flex-start;
    }

    .server-sidebar .sidebar-divider {
        width: 1px;
        height: 32px;
        margin: 0 4px;
    }

    .server-item {
        flex-shrink: 0;
        width: 44px;
        height: 44px;
    }

    .server-item.home-button img {
        width: 28px;
        height: 28px;
    }

    /* Channel sidebar - slide in from left */
    .channel-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 60px;
        width: 280px;
        z-index: 99;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .channel-sidebar.open {
        transform: translateX(0);
    }

    /* Main content area */
    .main-content {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 60px;
        transition: transform 0.3s ease;
    }

    .main-content.sidebar-open {
        transform: translateX(280px);
    }

    /* Members sidebar - slide in from right on mobile */
    .members-sidebar {
        display: none;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 280px;
        max-width: 80vw;
        z-index: 1001;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
    }

    .members-sidebar.show {
        display: block;
        transform: translateX(0);
    }

    /* Overlay when members sidebar is open */
    .members-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
    }

    .members-overlay.show {
        display: block;
    }

    /* Chat header adjustments */
    .chat-header {
        padding: 8px 12px;
    }

    .chat-header-info h3 {
        font-size: 16px;
    }

    .chat-header-actions .search-box {
        display: none;
    }

    /* Message input */
    .message-input-container {
        padding: 8px 12px;
        padding-bottom: 12px;
    }

    /* Messages */
    .message {
        padding: 8px 12px;
    }

    .message-content {
        font-size: 15px;
    }

    /* Modals */
    .modal-content {
        margin: 16px;
        max-height: calc(100vh - 32px);
        width: calc(100% - 32px);
        max-width: 100%;
    }

    .modal-content.settings-modal {
        display: flex;
        flex-direction: column;
        height: 85vh;
        max-height: 85vh;
        padding: 0;
    }

    .settings-container {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    .settings-nav {
        width: 100%;
        max-height: 120px;
        overflow-y: auto;
        border-right: none;
        border-bottom: 1px solid var(--bg-modifier-active);
        padding: 12px;
        flex-shrink: 0;
    }

    .settings-nav h3 {
        display: none;
    }

    .settings-nav ul {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    .settings-nav li {
        padding: 8px 12px;
        font-size: 13px;
        border-radius: var(--radius-sm);
        background: var(--bg-modifier-hover);
    }

    .settings-nav li.active {
        background: var(--brand-primary);
        color: white;
    }

    .settings-content {
        display: block !important;
        padding: 16px;
        flex: 1;
        overflow-y: auto;
        min-height: 0;
    }

    .settings-panel {
        display: none !important;
    }

    .settings-panel.active {
        display: block !important;
    }

    .profile-editor {
        flex-direction: column;
        gap: 16px;
    }

    .avatar-editor {
        align-self: center;
        flex-shrink: 0;
    }

    .profile-fields {
        width: 100%;
        flex: none;
    }

    .settings-panel h2 {
        font-size: 18px;
        margin-bottom: 16px;
    }

    .input-group {
        margin-bottom: 12px;
    }

    .input-group label {
        font-size: 13px;
    }

    .input-group input,
    .input-group textarea,
    .input-group select {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Voice controls on mobile */
    .voice-controls {
        padding: 16px;
        flex-wrap: wrap;
    }

    .voice-btn {
        width: 56px;
        height: 56px;
    }

    /* User panel */
    .user-panel {
        padding: 8px;
    }

    .user-info {
        flex: 1;
        min-width: 0;
    }

    .user-details .username {
        font-size: 13px;
    }

    /* Hide tooltips on mobile (use touch instead) */
    [data-tooltip]::before,
    [data-tooltip]::after {
        display: none;
    }

    /* Touch-friendly buttons */
    .icon-btn {
        min-width: 44px;
        min-height: 44px;
    }

    /* Channel items */
    .channel-item {
        padding: 12px 16px;
    }

    /* DM items */
    .dm-item {
        padding: 12px;
    }

    /* Context menu positioning - use !important to override inline styles from JS */
    .context-menu {
        position: fixed !important;
        bottom: 70px !important;
        left: 16px !important;
        right: 16px !important;
        top: auto !important;
        border-radius: var(--radius-lg);
        max-height: 60vh;
        overflow-y: auto;
    }

    /* Welcome message */
    .welcome-message {
        padding: 24px 16px;
    }

    .welcome-message h2 {
        font-size: 20px;
    }

    /* Profile editor on mobile */
    .profile-editor {
        flex-direction: column;
        align-items: center;
    }

    .avatar-editor {
        margin-bottom: 16px;
    }

    .profile-fields {
        width: 100%;
    }

    /* Invite code display */
    .invite-code-display {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .invite-code {
        font-size: 20px;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .channel-sidebar {
        width: 100%;
    }

    .main-content.sidebar-open {
        transform: translateX(100%);
    }

    .modal-content {
        margin: 8px;
        border-radius: var(--radius-md);
    }

    .confirm-modal {
        padding: 24px 16px;
    }
}

/* Landscape mode adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .server-sidebar {
        height: 50px;
    }

    .channel-sidebar {
        bottom: 50px;
    }

    .main-content {
        bottom: 50px;
    }

    .server-item {
        width: 36px;
        height: 36px;
    }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .icon-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .btn {
        min-height: 44px;
        padding: 12px 20px;
    }

    .channel-item,
    .dm-item,
    .member-item {
        min-height: 48px;
    }

    /* Disable hover effects that don't work well on touch */
    .server-item:hover {
        border-radius: 16px;
    }

    /* Make scrolling smooth */
    .messages-list,
    .channel-list,
    .members-list {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
}

/* Safe area for notched phones */
@supports (padding: max(0px)) {
    .server-sidebar {
        padding-bottom: max(4px, env(safe-area-inset-bottom));
    }

    .message-input-container {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}

/* Overlay when sidebar is open on mobile */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 60px;
    background: rgba(0, 0, 0, 0.5);
    z-index: 98;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ============================================
   Voice Connection Panel (above user panel)
   ============================================ */
.voice-connection-panel {
    background: linear-gradient(180deg, rgba(16, 185, 129, 0.1) 0%, var(--bg-secondary) 100%);
    border-top: 1px solid rgba(16, 185, 129, 0.2);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.voice-connection-panel.hidden {
    display: none;
}

.voice-connection-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    cursor: pointer;
}

.voice-connection-info:hover {
    opacity: 0.85;
}

.voice-connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.voice-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--status-online);
    box-shadow: 0 0 8px var(--status-online);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(0.9); }
}

.voice-status-text {
    font-size: 11px;
    font-weight: 600;
    color: var(--status-online);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.voice-channel-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.voice-connection-actions {
    display: flex;
    gap: 6px;
}

.voice-panel-btn {
    flex: 1;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    color: var(--text-secondary);
}

.voice-panel-btn:hover {
    background: var(--bg-modifier-active);
    color: var(--text-primary);
}

.voice-panel-btn.active {
    background: var(--status-online);
    color: white;
}

.voice-panel-btn.muted {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.voice-panel-btn.muted:hover {
    background: rgba(239, 68, 68, 0.3);
}

.voice-panel-btn.deafened {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.voice-panel-btn.deafened:hover {
    background: rgba(239, 68, 68, 0.3);
}

.voice-panel-btn.disconnect {
    background: transparent;
    color: var(--text-muted);
    flex: none;
    width: 32px;
}

.voice-panel-btn.disconnect:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

/* ============================================
   Video Grid for Camera/Screensharing
   ============================================ */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    width: 100%;
    max-width: 1400px;
    padding: 20px;
    margin: 0 auto 20px;
}

.video-grid:empty {
    display: none;
}

.video-grid.hidden {
    display: none;
}

.video-container {
    position: relative;
    background: linear-gradient(145deg, var(--bg-primary), var(--bg-secondary));
    border-radius: var(--radius-lg);
    overflow: hidden;
    aspect-ratio: 16/9;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.video-container:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

.video-container.local {
    border: 2px solid var(--brand-primary);
}

.video-container.local video {
    transform: scaleX(-1); /* Mirror local video */
}

.video-container.screen {
    border: 2px solid var(--status-online);
}

.video-container.screen video {
    object-fit: contain;
    background: #000;
}

.video-label {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    gap: 6px;
}

.video-label::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--status-online);
}

/* Video/Screen button active states */
.voice-btn.active {
    background: var(--status-online) !important;
    color: white !important;
}

.voice-btn.active:hover {
    background: #16a34a !important;
}

/* Mobile responsive video grid */
@media (max-width: 768px) {
    .video-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 12px;
    }

    .video-container {
        max-height: 220px;
    }
}

/* ============================================
   INVITE EMBEDS - Compact inline style
   ============================================ */

.invite-embed-placeholder {
    display: block;
    margin: 6px 0;
}

.invite-link {
    display: block;
    color: var(--brand-primary);
    font-size: 14px;
    margin-bottom: 6px;
    text-decoration: none;
}

.invite-link:hover {
    text-decoration: underline;
}

.invite-embed {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.invite-embed.loading,
.invite-embed.invalid {
    opacity: 0.6;
}

.invite-embed-loading {
    color: var(--text-muted);
    font-size: 14px;
}

.invite-embed-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.invite-embed-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.invite-embed-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    line-height: 1.2;
}

.invite-embed-members {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: var(--text-muted);
}

.invite-embed-members .online-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--status-online);
}

.invite-embed-join {
    padding: 8px 18px !important;
    font-size: 14px !important;
    flex-shrink: 0;
}

.invite-embed-error {
    color: var(--text-muted);
    font-size: 14px;
}

/* ============================================
   CAPTCHA Styles
   ============================================ */

.captcha-container {
    display: flex;
    justify-content: center;
    margin: 16px 0;
}

.captcha-container.settings-captcha {
    justify-content: flex-start;
    margin: 16px 0 8px 0;
}

/* Override hCaptcha iframe sizing on smaller screens */
@media (max-width: 400px) {
    .captcha-container {
        transform: scale(0.9);
        transform-origin: center;
    }
}

/* ============================================
   Status Picker Popup
   ============================================ */

.user-panel {
    position: relative;
}

.status-picker {
    position: absolute;
    bottom: 100%;
    left: 8px;
    width: 280px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--bg-tertiary);
    margin-bottom: 8px;
    z-index: 1000;
    overflow: hidden;
    animation: statusPickerIn 0.15s ease;
}

@keyframes statusPickerIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.status-picker.hidden {
    display: none;
}

.status-picker-header {
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--bg-tertiary);
}

.status-picker-options {
    padding: 8px;
}

.status-picker-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: background var(--transition-fast);
    text-align: left;
}

.status-picker-option:hover {
    background: var(--bg-modifier-hover);
}

.status-picker-option.active {
    background: var(--bg-modifier-selected);
}

.status-picker-option .status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-picker-option .status-indicator.online {
    background: var(--status-online);
}

.status-picker-option .status-indicator.away {
    background: var(--status-away);
}

.status-picker-option .status-indicator.busy {
    background: var(--status-busy);
}

.status-picker-option .status-indicator.offline {
    background: var(--status-offline);
}

.status-picker-divider {
    height: 1px;
    background: var(--bg-tertiary);
    margin: 4px 12px;
}

.status-picker-custom {
    padding: 12px;
}

.custom-status-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.custom-status-header svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.status-picker-custom input {
    width: 100%;
    padding: 10px 12px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 10px;
}

.status-picker-custom input:focus {
    outline: none;
    border-color: var(--brand-primary);
}

.status-picker-custom input::placeholder {
    color: var(--text-muted);
}

.custom-status-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

/* Custom Status Display in Member List */
.member-custom-status {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
    line-height: 1.3;
}

/* Custom Status in User Panel */
.user-custom-status {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
    margin-top: 1px;
}
