/**
 * Chat Native View Styles
 * Matches production chat-local layout
 */

.chat-native-wrapper {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --success: #10b981;
    --error: #ef4444;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-dark: #0c1222;
    --surface-light: #334155;
    --border-color: #475569;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    display: flex;
    flex-direction: column;
    height: 100%;  /* Changed from 100vh to respect shell container */
    background: var(--background);
}

.chat-native {
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* Chat Layout */
.chat-layout {
    display: grid;
    grid-template-columns: 72px 240px 1fr 260px;
    height: 100%;
}

/* When inside unified shell - only main chat + members */
.chat-layout.in-shell {
    grid-template-columns: 1fr 260px;
}

/* Server/Home List (Far Left) */
.server-list {
    background: var(--surface-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    gap: 8px;
    border-right: 1px solid rgba(0,0,0,0.3);
}

.server-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text);
}

.server-icon:hover {
    border-radius: 16px;
    background: var(--primary);
}

.server-icon.home {
    background: var(--primary);
    border-radius: 16px;
}

.server-icon svg {
    width: 24px;
    height: 24px;
}

.server-icon.active {
    background: var(--primary);
    border-radius: 16px;
}

.server-icon.dm-icon {
    background: var(--surface);
    position: relative;
    font-size: 1.25rem;
}

.server-icon.dm-icon:hover {
    background: var(--primary);
}

.server-icon.dm-icon.active {
    background: var(--primary);
    border-radius: 16px;
}

/* DM Badge */
.dm-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--surface-dark);
}

.dm-badge.hidden {
    display: none;
}

/* Unread Badge on channel items */
.unread-badge {
    background: #ef4444;
    color: white;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto;
}

.channel-item.has-unread .channel-name {
    font-weight: 600;
    color: var(--text);
}

/* DM item styling */
.channel-item.dm-item .channel-hash {
    color: var(--primary);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 36px 12px 16px;
    min-width: 250px;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
    animation: toast-slide-in 0.3s ease-out;
}

.toast-title {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.toast-message {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.toast-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
}

.toast-close:hover {
    color: var(--text);
}

.toast-info {
    border-left: 3px solid var(--primary);
}

.toast-hiding {
    animation: toast-slide-out 0.3s ease-in forwards;
}

@keyframes toast-slide-in {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toast-slide-out {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Channel Sidebar */
.channel-sidebar {
    background: var(--surface);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    overflow: hidden;
    min-height: 0;
}

.channel-header {
    height: 48px;
    padding: 0 16px;
    border-bottom: 1px solid rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 1px 0 rgba(0,0,0,0.2);
}

.back-btn {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.back-btn:hover {
    background: rgba(255,255,255,0.1);
}

.header-title {
    font-weight: 600;
    color: var(--text);
}

.channel-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.channel-list::-webkit-scrollbar {
    width: 8px;
}

.channel-list::-webkit-scrollbar-track {
    background: transparent;
}

.channel-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.channel-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Category Headers */
.channel-category {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

.channel-category:hover {
    color: var(--text);
}

.category-arrow {
    font-size: 0.625rem;
    width: 12px;
}

.category-name {
    flex: 1;
}

/* Channel Items */
.channel-item {
    display: flex;
    align-items: center;
    padding: 8px 8px 8px 24px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s;
    margin-bottom: 1px;
}

.channel-item:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text);
}

.channel-item.active {
    background: rgba(59,130,246,0.2);
    color: var(--text);
}

.channel-hash {
    margin-right: 6px;
    opacity: 0.5;
}

.channel-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.voice-icon {
    margin-left: auto;
    font-size: 0.875rem;
}

.no-rooms {
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
    font-size: 0.875rem;
}

/* Main Chat Area */
.chat-main {
    display: flex;
    flex-direction: column;
    background: var(--background);
    overflow: hidden;
    min-height: 0;
}

.chat-header {
    height: 48px;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface-dark);
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Mobile menu button - hidden on desktop */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.mobile-menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.mobile-menu-btn:active {
    background: rgba(255, 255, 255, 0.15);
}

.mobile-menu-btn svg {
    display: block;
}

.chat-hash {
    color: var(--text-muted);
    margin-right: 8px;
    font-size: 1.25rem;
}

.chat-room-name {
    font-weight: 600;
    color: var(--text);
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-display {
    color: var(--text);
    font-weight: 500;
}

.user-avatar-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    font-size: 0.875rem;
}

/* Messages Wrapper */
.messages-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

/* Jump to Bottom Button */
.jump-to-bottom {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10;
    transition: transform 0.15s, box-shadow 0.15s;
}

.jump-to-bottom:hover {
    transform: translateX(-50%) scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.jump-to-bottom span {
    font-size: 1rem;
}

.messages-container::-webkit-scrollbar {
    width: 8px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.date-divider {
    display: flex;
    align-items: center;
    margin: 1rem 0;
}

.date-divider::before,
.date-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.date-divider span {
    padding: 0 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Message */
.message {
    display: flex;
    gap: 1rem;
    padding: 0.5rem;
    margin-bottom: 0.25rem;
    border-radius: 4px;
}

.message:hover {
    background: rgba(255,255,255,0.02);
}

.message-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-fallback {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    font-size: 1rem;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.message-author {
    font-weight: 600;
    color: var(--text);
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.message-body {
    color: var(--text);
    line-height: 1.5;
    word-break: break-word;
}

.message-image {
    max-width: 400px;
    max-height: 300px;
    border-radius: 8px;
    margin-top: 0.5rem;
}

.file-attachment {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface-light);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    border: 1px solid var(--border-color);
    transition: background 0.15s, border-color 0.15s;
}

.file-attachment:hover {
    background: var(--surface);
    border-color: var(--primary);
}

.file-attachment .file-icon {
    font-size: 1.25rem;
}

.file-attachment .file-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.file-attachment .file-name {
    font-weight: 500;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-attachment .file-size {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.message-video {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    margin-top: 0.5rem;
    background: #000;
}

.audio-attachment {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface-light);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.audio-attachment .audio-icon {
    font-size: 1.25rem;
}

.audio-attachment .audio-name {
    font-weight: 500;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-audio {
    height: 32px;
    flex: 1;
    min-width: 150px;
}

/* Empty States */
.no-messages,
.no-room-selected,
.chat-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    text-align: center;
}

.no-messages-icon,
.no-room-icon,
.error-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.no-messages h3,
.no-room-selected h3,
.chat-error h3 {
    color: var(--text);
    margin-bottom: 0.5rem;
}

.btn-login {
    margin-top: 1rem;
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

/* Message Input */
.message-input-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--surface-dark);
    border-top: 1px solid var(--border-color);
}

.attach-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    color: var(--text-secondary);
}

.attach-btn:hover {
    background: rgba(255,255,255,0.1);
}

.message-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
}

.message-input:focus {
    outline: none;
    border-color: var(--primary);
}

.message-input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 8px 12px;
    color: var(--text-secondary);
}

.send-btn:hover {
    color: var(--primary);
}

/* Members Panel */
.members-panel {
    background: #0c1222 !important;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.members-header {
    height: 48px;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.member-count {
    color: var(--text-muted);
}

.members-search {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.members-search input {
    width: 100%;
    padding: 8px 12px;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text);
    font-size: 0.875rem;
}

.members-search input:focus {
    outline: none;
    border-color: var(--primary);
}

.members-search input::placeholder {
    color: var(--text-muted);
}

.members-list-inner {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.members-list-inner::-webkit-scrollbar {
    width: 8px;
}

.members-list-inner::-webkit-scrollbar-track {
    background: transparent;
}

.members-list-inner::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.members-list-inner::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.member-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}

.member-item:hover {
    background: rgba(255,255,255,0.05);
}

.member-avatar-wrapper {
    position: relative;
    flex-shrink: 0;
}

.member-avatar-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.member-avatar-wrapper .avatar-fallback {
    width: 32px;
    height: 32px;
    font-size: 0.875rem;
}

.status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--surface-dark);
}

.status-dot.online {
    background: var(--success);
}

.status-dot.away {
    background: #f59e0b;
}

.status-dot.offline {
    background: var(--text-muted);
}

.member-name {
    color: var(--text-secondary);
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.no-members {
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
    font-size: 0.875rem;
}

/* Loading */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .chat-layout {
        grid-template-columns: 60px 200px 1fr;
    }

    .chat-layout.in-shell {
        grid-template-columns: 1fr;
    }

    .chat-layout.in-shell .members-panel {
        display: none;
    }

    .members-panel {
        display: none;
    }
}

@media (max-width: 768px) {
    /* Ensure wrapper fills shell content without overflow */
    .chat-native-wrapper {
        height: 100%;
        max-height: 100%;
        overflow: hidden;
    }

    .chat-native {
        height: 100%;
        max-height: 100%;
    }

    .chat-layout {
        grid-template-columns: 1fr;
        height: 100%;
        max-height: 100%;
    }

    .chat-layout.in-shell {
        grid-template-columns: 1fr;
    }

    .server-list,
    .channel-sidebar,
    .members-panel {
        display: none;
    }

    .chat-layout.in-shell .members-panel {
        display: none;
    }

    .chat-main {
        grid-column: 1;
        height: 100%;
        max-height: 100%;
        overflow: hidden;
    }

    /* Constrain messages area on mobile */
    .messages-container {
        padding: 0.75rem;
    }

    /* Smaller input area on mobile */
    .message-input-container {
        padding: 0.5rem;
    }

    .message-input {
        padding: 0.5rem 0.75rem;
        font-size: 16px; /* Prevent iOS zoom */
    }

    /* Show mobile menu button */
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Hide user dropdown text on mobile, keep avatar */
    .user-dropdown-trigger .user-display,
    .user-dropdown-trigger .dropdown-arrow {
        display: none;
    }
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    padding: 4px 16px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--surface-dark);
}

.typing-indicator .typing-dots {
    animation: typingPulse 1.4s infinite;
    margin-right: 6px;
}

@keyframes typingPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* Markdown Styles */
.message-body code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
}

.message-body pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-body pre code {
    background: none;
    padding: 0;
}

.message-body strong {
    font-weight: 700;
}

.message-body em {
    font-style: italic;
}

.message-body del {
    text-decoration: line-through;
    opacity: 0.7;
}

.message-body a {
    color: var(--primary);
    text-decoration: none;
}

.message-body a:hover {
    text-decoration: underline;
}

/* Media Embeds (YouTube, etc.) */
.media-embed {
    margin: 8px 0;
    border-radius: 8px;
    overflow: hidden;
    max-width: 480px;
}

.youtube-embed {
    background: #000;
}

.media-embed iframe,
.youtube-embed iframe {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: none;
}

/* Compact Messages (grouped from same sender) */
.message-compact {
    padding-top: 0;
    padding-bottom: 0;
    margin-top: -8px;
}

.message-avatar-spacer {
    width: 40px;
    min-width: 40px;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding-right: 8px;
}

.compact-time {
    font-size: 0.65rem;
    color: transparent;
    transition: color 0.15s;
}

.message-compact:hover .compact-time {
    color: var(--text-muted);
}

/* Message Actions (reaction picker trigger) */
.message {
    position: relative;
}

.message-actions {
    position: absolute;
    top: -14px;
    right: 8px;
    opacity: 0;
    transition: opacity 0.15s;
    display: flex;
    flex-direction: row;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 50;
}

.message:hover .message-actions {
    opacity: 1;
}

.action-btn {
    background: transparent;
    border: none;
    width: 32px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background: var(--surface-light);
}

/* Reaction Picker */
.reaction-picker {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px;
    display: flex;
    gap: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.quick-reaction {
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    font-size: 18px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s, transform 0.1s;
}

.quick-reaction:hover {
    background: var(--surface-light);
    transform: scale(1.2);
}

/* Message Reactions */
.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.reaction-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 12px;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.15s, border-color 0.15s;
}

.reaction-btn:hover {
    background: rgba(59, 130, 246, 0.25);
    border-color: rgba(59, 130, 246, 0.5);
}

.reaction-btn.reacted {
    background: rgba(59, 130, 246, 0.3);
    border-color: var(--primary);
}

.reaction-emoji {
    font-size: 1rem;
}

.reaction-count {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* Reply Context in Messages */
.message-reply-context {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
}

.message-reply-context:hover {
    color: var(--text-secondary);
}

.reply-bar {
    width: 2px;
    background: var(--primary);
    border-radius: 1px;
}

.reply-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.reply-author {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.75rem;
}

.reply-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Reply Preview in Input */
.reply-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    border-radius: 8px 8px 0 0;
}

.reply-preview-bar {
    width: 3px;
    height: 32px;
    background: var(--primary);
    border-radius: 2px;
}

.reply-preview-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.reply-preview-author {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.8rem;
}

.reply-preview-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-cancel {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 4px;
}

.reply-cancel:hover {
    background: var(--surface-light);
    color: var(--text);
}

/* Image Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
}

.lightbox-image {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: background 0.2s;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Message images */
.message-image {
    max-width: 400px;
    max-height: 300px;
    border-radius: 8px;
    margin-top: 4px;
    cursor: pointer;
    transition: opacity 0.15s;
}

.message-image:hover {
    opacity: 0.9;
}

/* Edit Message Input */
.edit-input-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.edit-input {
    background: var(--surface-dark);
    border: 1px solid var(--primary);
    border-radius: 4px;
    padding: 8px 12px;
    color: var(--text);
    font-size: 0.95rem;
    width: 100%;
}

.edit-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.edit-actions {
    display: flex;
    gap: 8px;
}

.edit-save-btn,
.edit-cancel-btn {
    padding: 4px 12px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
}

.edit-save-btn {
    background: var(--primary);
    color: white;
}

.edit-save-btn:hover {
    background: var(--primary-dark);
}

.edit-cancel-btn {
    background: var(--surface-light);
    color: var(--text);
}

.edit-cancel-btn:hover {
    background: var(--border-color);
}

/* Edited message indicator - make (edited) subtle */
.message-time {
    color: var(--text-muted);
}

/* Hidden file input */
.hidden-file-input {
    display: none;
}

/* Attach button */
.attach-btn {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.15s;
}

.attach-btn:hover {
    background: var(--surface-light);
}

.attach-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* @Mentions styling in messages */
.mention {
    color: var(--primary);
    background: rgba(203, 166, 247, 0.15);
    padding: 0 4px;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
}

.mention:hover {
    background: rgba(203, 166, 247, 0.25);
}

/* Highlight entire message when current user is mentioned */
.message.mentioned {
    background: rgba(250, 204, 21, 0.1);
    border-left: 3px solid #FACC15;
    padding-left: 13px;
    margin-left: -16px;
}

.message.mentioned:hover {
    background: rgba(250, 204, 21, 0.15);
}

/* @Mention Autocomplete Dropdown */
.mention-autocomplete {
    position: absolute;
    bottom: 100%;
    left: 48px;
    right: 48px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 0;
    margin-bottom: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    max-height: 240px;
    overflow-y: auto;
    z-index: 100;
}

.mention-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.1s;
}

.mention-item:hover,
.mention-item.selected {
    background: var(--surface-light);
}

.mention-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.mention-avatar-fallback {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    font-size: 0.75rem;
}

.mention-name {
    color: var(--text);
    font-size: 0.9rem;
}

/* Member Profile Popup */
.member-profile-popup {
    position: fixed;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    z-index: 2000;
    min-width: 280px;
    max-width: 320px;
    overflow: hidden;
    animation: popupFadeIn 0.15s ease;
}

@keyframes popupFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.member-profile-header {
    padding: 1.25rem;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(139, 92, 246, 0.2) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.member-profile-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

.member-profile-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.member-profile-info {
    flex: 1;
    min-width: 0;
}

.member-profile-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.member-profile-username {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.member-profile-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.member-profile-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
}

.member-profile-status-dot.offline { background: #6b7280; }
.member-profile-status-dot.away { background: #f59e0b; }

.member-profile-body {
    padding: 0.75rem;
}

.member-profile-section {
    margin-bottom: 0.5rem;
}

.member-profile-action {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
}

.member-profile-action:hover {
    background: rgba(255, 255, 255, 0.1);
}

.member-profile-action-icon {
    font-size: 1.125rem;
    width: 24px;
    text-align: center;
}

.member-profile-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0.5rem 0;
}

/* Clickable profile elements */
.clickable-profile {
    cursor: pointer;
    transition: opacity 0.15s;
}

.clickable-profile:hover {
    opacity: 0.8;
}

.message-author.clickable-profile:hover {
    text-decoration: underline;
}

/* Mobile adjustments for member popup */
@media (max-width: 767px) {
    .member-profile-popup {
        position: fixed;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%);
        width: calc(100% - 2rem);
        max-width: 320px;
    }
}

/* User Dropdown Trigger (in chat header) */
.user-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.user-dropdown-trigger:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
}

.user-dropdown-trigger.active {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
}

.trigger-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    overflow: hidden;
}

.user-dropdown-trigger .dropdown-arrow {
    font-size: 0.7rem;
    opacity: 0.7;
    transition: transform 0.2s;
}

.user-dropdown-trigger.active .dropdown-arrow {
    transform: rotate(180deg);
}

/* User Dropdown Menu */
.user-dropdown-menu {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    min-width: 260px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    z-index: 2000;
    animation: dropdownFadeIn 0.15s ease;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Profile Header in Dropdown */
.user-dropdown-menu .profile-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);
    border-bottom: 1px solid var(--border-color);
}

.user-dropdown-menu .profile-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    overflow: hidden;
}

.user-dropdown-menu .profile-info {
    flex: 1;
    min-width: 0;
}

.user-dropdown-menu .profile-display-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-dropdown-menu .profile-username {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.user-dropdown-menu .profile-tier-badge {
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.profile-tier-badge.tier-free { background: rgba(107, 114, 128, 0.2); color: #9ca3af; }
.profile-tier-badge.tier-silver { background: rgba(192, 192, 192, 0.2); color: #c0c0c0; }
.profile-tier-badge.tier-gold { background: rgba(255, 215, 0, 0.2); color: #ffd700; }
.profile-tier-badge.tier-platinum { background: rgba(229, 228, 226, 0.2); color: #e5e4e2; }

/* Dropdown Items */
.user-dropdown-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.625rem 1rem;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
}

.user-dropdown-menu .dropdown-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.user-dropdown-menu .dropdown-item-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

.user-dropdown-menu .dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.375rem 0;
}

.user-dropdown-menu .dropdown-label {
    padding: 0.5rem 1rem 0.25rem;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.user-dropdown-menu .logout-item {
    color: #ef4444;
}

.user-dropdown-menu .logout-item:hover {
    background: rgba(239, 68, 68, 0.15);
}

/* Search Trigger Button */
.search-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.search-trigger:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
    border-color: var(--primary);
}

.search-trigger.active {
    background: rgba(59, 130, 246, 0.2);
    color: var(--primary);
    border-color: var(--primary);
}

/* Search Panel */
.search-panel {
    position: absolute;
    top: 48px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--background);
    z-index: 100;
    display: flex;
    flex-direction: column;
    animation: searchPanelSlideIn 0.2s ease;
}

@keyframes searchPanelSlideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.search-panel-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-dark);
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    transition: border-color 0.2s;
}

.search-input-wrapper:focus-within {
    border-color: var(--primary);
}

.search-input-wrapper .search-icon {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.search-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

.search-stats {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Search Results */
.search-results {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.search-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-secondary);
    text-align: center;
}

.search-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.search-empty p {
    font-size: 0.9rem;
}

/* Search Result Item */
.search-result-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.search-result-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.search-result-avatar {
    flex-shrink: 0;
}

.search-result-avatar img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.search-result-avatar .avatar-fallback {
    width: 36px;
    height: 36px;
    font-size: 0.875rem;
}

.search-result-content {
    flex: 1;
    min-width: 0;
}

.search-result-header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.search-result-author {
    font-weight: 600;
    color: var(--text);
    font-size: 0.875rem;
}

.search-result-time {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.search-result-body {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Search Match Highlight */
.search-match {
    background: rgba(255, 193, 7, 0.3);
    color: #ffc107;
    padding: 0 2px;
    border-radius: 2px;
}

/* Message Highlight (when jumping to message) */
.message.search-highlight {
    background: rgba(59, 130, 246, 0.15) !important;
    animation: messageHighlight 3s ease;
}

@keyframes messageHighlight {
    0% { background: rgba(59, 130, 246, 0.3); }
    100% { background: rgba(59, 130, 246, 0.15); }
}

/* Pinned Messages */
.pinned-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.05));
    border-bottom: 1px solid rgba(245, 158, 11, 0.3);
    cursor: pointer;
    transition: background 0.2s;
}

.pinned-indicator:hover {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(245, 158, 11, 0.1));
}

.pinned-indicator .pin-icon {
    font-size: 1rem;
}

.pinned-indicator .pin-text {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text);
}

.pinned-indicator .pin-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: rgba(245, 158, 11, 0.2);
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
}

.pinned-indicator .pin-expand {
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.pinned-indicator.expanded .pin-expand {
    transform: rotate(180deg);
}

/* Pinned Messages List */
.pinned-list {
    background: var(--surface-dark);
    border-bottom: 1px solid var(--border-color);
    max-height: 300px;
    overflow-y: auto;
}

.pinned-message {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s;
}

.pinned-message:hover {
    background: rgba(255, 255, 255, 0.03);
}

.pinned-message:last-child {
    border-bottom: none;
}

.pinned-message .pin-marker {
    color: #f59e0b;
    font-size: 0.875rem;
    flex-shrink: 0;
    padding-top: 0.125rem;
}

.pinned-message .pin-content {
    flex: 1;
    min-width: 0;
}

.pinned-message .pin-author {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.pinned-message .pin-body {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.pinned-message .unpin-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 0.75rem;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
}

.pinned-message:hover .unpin-btn {
    opacity: 1;
}

.pinned-message .unpin-btn:hover {
    color: var(--error);
}

/* Pin button in message actions */
.action-btn.pin-trigger {
    font-size: 0.875rem;
}

/* Message that is pinned */
.message.is-pinned {
    border-left: 2px solid #f59e0b;
    padding-left: calc(0.75rem - 2px);
}

/* Redacted (deleted) messages */
.redacted-message {
    color: var(--text-muted, #6c7086);
    font-style: italic;
    opacity: 0.7;
}
