/* Main CSS: chatplin-like Communication System Styles */

/* CSS Variables */
:root {
    --chatplin-bg-primary: #36393f;
    --chatplin-bg-secondary: #2f3136;
    --chatplin-bg-tertiary: #292b2f;
    --chatplin-text-normal: #dcddde;
    --chatplin-text-muted: #72767d;
    --chatplin-text-link: #00b0f4;
    --chatplin-brand: #5865f2;
    --chatplin-green: #3ba55c;
    --chatplin-yellow: #faa61a;
    --chatplin-red: #ed4245;
    --sidebar-width: 280px;
    --member-list-width: 240px;
    --chatplin-bg-hover: rgba(79, 84, 92, 0.16);
    --chatplin-text-primary: #dcddde;
    --chatplin-blurple: #5865f2;
    /* expose safe-area inset to JS-friendly CSS variable */
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    /* footer/input layout control */
    --comm-footer-height: calc(4rem + var(--safe-area-bottom));
    --comm-input-offset: 0px; /* JS may update this when keyboard opens */
}

/* Global Styles */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--chatplin-bg-primary);
    color: var(--chatplin-text-normal);
    overflow-x: hidden;
}

/* Mobile Navigation Header */
.mobile-nav-header {
    display: none;
    background: var(--chatplin-bg-secondary);
    padding: 12px 16px;
    border-bottom: 1px solid #1e2124;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.mobile-menu-toggle, .mobile-members-toggle {
    background: none;
    border: none;
    color: var(--chatplin-text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
}

.mobile-menu-toggle:hover, .mobile-members-toggle:hover {
    color: var(--chatplin-text-normal);
    background: rgba(79, 84, 92, 0.16);
}

.mobile-menu-toggle:active, .mobile-members-toggle:active {
    background: rgba(79, 84, 92, 0.32);
}

.mobile-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--chatplin-text-normal);
    flex: 1;
    text-align: center;
}

/* Main Container */
.chatplin-container {
    display: flex;
    height: 100vh;
}

/* Left Panel */
#leftPanel {
    display: flex;
    height: 100vh;
}

/* Server List (Left) */
.server-list {
    width: 72px;
    background: var(--chatplin-bg-tertiary);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    overflow-y: auto;
}

.server-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--chatplin-bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-radius 0.2s ease;
    position: relative;
}

.server-icon:hover {
    border-radius: 16px;
    background: var(--chatplin-brand);
}

.server-icon.active {
    border-radius: 16px;
    background: var(--chatplin-brand);
}

.server-icon.active::before {
    content: '';
    position: absolute;
    left: -16px;
    width: 4px;
    height: 40px;
    background: white;
    border-radius: 2px;
}

/* Channels Sidebar */
.channels-sidebar {
    width: var(--sidebar-width);
    background: var(--chatplin-bg-secondary);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
    z-index: 50;
}

.guild-header {
    height: 48px;
    padding: 12px 16px;
    border-bottom: 1px solid #1e2124;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.guild-header:hover {
    background: rgba(79, 84, 92, 0.16);
}

.guild-name {
    font-weight: 600;
    font-size: 16px;
    flex: 1;
}

.channels-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0 70px;
}

.channel-category {
    padding: 0 8px 4px 16px;
    margin-top: 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--chatplin-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    justify-content: between;
    cursor: pointer;
    transition: color 0.2s ease;
    user-select: none;
}

.channel-category .fa-chevron-right,
.channel-category .fa-chevron-down {
    transition: transform 0.2s ease;
}

.channel-category.collapsed .fa-chevron-down {
    transform: rotate(-90deg);
}

.channel-category.collapsed .fa-chevron-right {
    transform: rotate(0deg);
}

/* Hide channel items when category is collapsed */
.channel-category.collapsed + .channel-item,
.channel-category.collapsed ~ .channel-item {
    display: none;
}

/* Show only the first channel items after a collapsed category until the next category */
.channel-category.collapsed ~ .channel-category ~ .channel-item {
    display: flex;
}

.channel-category:hover {
    color: var(--chatplin-text-normal);
}

.channel-category.active {
    font-weight: 700;
    color: var(--chatplin-text-normal);
}

.channel-category:first-child {
    margin-top: 0;
}

.channel-item {
    display: flex;
    align-items: center;
    padding: 4px 8px 4px 16px;
    margin: 1px 8px;
    border-radius: 4px;
    color: var(--chatplin-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    min-height: 32px;
}

.channel-item:hover {
    background: rgba(79, 84, 92, 0.16);
    color: var(--chatplin-text-normal);
}

.channel-item.active {
    background: rgba(79, 84, 92, 0.32);
    color: white;
    font-weight: 700;
}

.channel-icon {
    width: 20px;
    margin-right: 6px;
    font-size: 14px;
    text-align: center;
    flex-shrink: 0;
}

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

.channel-stats {
    font-size: 12px;
    color: var(--chatplin-text-muted);
    margin-left: auto;
}

.unread-indicator {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 8px;
    background: white;
    border-radius: 2px;
}

/* Main Chat Area */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chatplin-bg-primary);
    min-width: 0;
    position: relative;
}

/* Home Content */
.main-chat .home-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
}

/* Channel Wrapper */
.channel-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-header {
    height: 48px;
    padding: 12px 16px;
    border-bottom: 1px solid #1e2124;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 0 rgba(4, 4, 5, 0.2);
}

.channel-info {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.channel-title {
    font-weight: 600;
    font-size: 16px;
    margin-left: 8px;
}

.channel-description {
    color: var(--chatplin-text-muted);
    font-size: 14px;
    margin-left: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-tools {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.tool-button {
    color: var(--chatplin-text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.tool-button:hover {
    color: var(--chatplin-text-normal);
    background: rgba(79, 84, 92, 0.16);
}

/* Messages styles moved to css/chat.css */

/* Input/footer styles moved to css/input.css */

/* Private/DM message bubble styles moved to css/chat.css */

/* Private channel styling in sidebar */
.channel-item.private-channel {
    position: relative;
}

.channel-item.private-channel .channel-icon {
    color: var(--chatplin-green);
}

/* 국가별 채널 스타일 */
.country-section {
    margin: 2px 0;
}

.country-header {
    display: flex;
    align-items: center;
    padding: 4px 8px 4px 16px;
    margin: 1px 8px;
    border-radius: 4px;
    color: var(--chatplin-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.country-header:hover {
    color: var(--chatplin-text-normal);
}

.country-header.collapsed .fa-chevron-down {
    transform: rotate(-90deg);
}

.country-flag {
    margin-right: 6px;
    font-size: 14px;
}

.country-name {
    flex: 1;
}

.channel-count {
    font-size: 11px;
    opacity: 0.7;
}

.country-channels {
    margin-left: 12px;
}

.country-channel {
    border-left: 2px solid rgba(114, 118, 125, 0.3);
    margin-left: 8px;
    padding-left: 12px !important;
}

.country-channel:hover {
    border-left-color: var(--chatplin-brand);
}

.country-channel.active {
    border-left-color: var(--chatplin-brand);
    background: rgba(88, 101, 242, 0.1);
}

.add-dm-button {
    margin-left: auto;
    font-size: 12px;
    padding: 4px;
    border-radius: 3px;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.2s ease;
}

.add-dm-button:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

/* Message row styles moved to css/chat.css */

/* Members List */
.members-list {
    width: var(--member-list-width);
    background: var(--chatplin-bg-secondary);
    padding: 24px 8px;
    overflow-y: auto;
    height: 100vh;
    flex-shrink: 0;
    position: relative;
}

.member-group {
    margin-bottom: 24px;
}

.member-group-title {
    padding: 0 8px;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--chatplin-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
}

.member-count {
    margin-left: auto;
    background: var(--chatplin-bg-secondary);
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 10px;
}

.member-item {
    display: flex;
    align-items: center;
    padding: 1px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin-bottom: 1px;
}

.member-item:hover {
    background: rgba(79, 84, 92, 0.16);
}

.member-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 12px;
    background: var(--chatplin-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    font-size: 14px;
    position: relative;
}

.member-status {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    /* border: 3px solid var(--chatplin-bg-secondary); */
}

.status-online { background: var(--chatplin-green); }
.status-idle { background: var(--chatplin-yellow); }
.status-dnd { background: var(--chatplin-red); }
.status-offline { background: var(--chatplin-text-muted); }

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

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

.member-activity {
    font-size: 12px;
    color: var(--chatplin-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Input area and toolbar styles moved to css/input.css */

/* Stats Cards */
.stats-card {
    background: rgba(79, 84, 92, 0.16);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.stats-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--chatplin-text-normal);
    margin-bottom: 12px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    color: var(--chatplin-text-muted);
    font-size: 14px;
}

.stat-value {
    color: var(--chatplin-text-normal);
    font-weight: 500;
}

/* Enhanced UI Features */
.typing-indicator {
    animation: fadeIn 0.3s ease-in;
}

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

/* Message hover actions moved to css/chat.css */

/* Connection Indicator */
.connection-indicator {
    position: fixed;
    top: 16px;
    right: 16px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    z-index: 1000;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

/* Mention Styles */
.mention {
    background: rgba(88, 101, 242, 0.3);
    color: var(--chatplin-brand);
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
}

/* Emoji Reactions moved to css/chat.css */

/* Status Indicators */
.status-indicator {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 8px;
}

.status-online {
    background: rgba(59, 165, 92, 0.2);
    color: var(--chatplin-green);
}

.status-away {
    background: rgba(250, 166, 26, 0.2);
    color: var(--chatplin-yellow);
}

.status-busy {
    background: rgba(237, 66, 69, 0.2);
    color: var(--chatplin-red);
}

/* Member Role */
.member-role {
    font-size: 10px;
    color: var(--chatplin-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* Mention Dropdown */
.mention-dropdown {
    position: fixed !important;
    z-index: 2000 !important;
    bottom: 60px;
    background: var(--chatplin-bg-primary);
    border: 1px solid #1e2124;
    border-radius: 6px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    min-width: 200px;
    max-height: 300px;
    overflow-y: auto;
}

.mention-dropdown .mention-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.mention-dropdown .mention-item:hover,
.mention-dropdown .mention-item.selected {
    background: var(--chatplin-bg-hover);
}

.mention-dropdown .mention-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--chatplin-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    margin-right: 10px;
    flex-shrink: 0;
}

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

.mention-dropdown .mention-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--chatplin-text-normal);
    line-height: 18px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mention-dropdown .mention-status {
    font-size: 12px;
    color: var(--chatplin-text-muted);
    line-height: 14px;
}

.mention-dropdown .mention-status.online {
    color: #43b581;
}

.mention-dropdown .mention-status.away {
    color: #faa61a;
}

.mention-dropdown .mention-status.offline {
    color: #747f8d;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-corner {
    background-color: var(--chatplin-bg-secondary);
}

::-webkit-scrollbar-thumb {
    background-color: #202225;
    border: 2px solid var(--chatplin-bg-secondary);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: #2e3338;
}

::-webkit-scrollbar-track {
    background-color: var(--chatplin-bg-secondary);
}

/* Loading States */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--chatplin-text-muted);
    border-radius: 50%;
    border-top-color: var(--chatplin-brand);
    animation: spin 1s ease-in-out infinite;
}

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

/* Avatar Circle */
.avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    background: var(--chatplin-brand);
}

.avatar-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--chatplin-text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    font-size: 14px;
}

.btn-icon:hover {
    color: var(--chatplin-text-normal);
    background: rgba(79, 84, 92, 0.16);
}

/* Message edited/deleted states moved to css/chat.css */

/* AI Related Styles - Removed for general styling */

.add-ai-button {
    opacity: 0.7;
    cursor: pointer;
    transition: opacity 0.3s;
}

.add-ai-button:hover {
    opacity: 1;
}

.ai-channel {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-left: 3px solid #667eea;
    margin: 4px 0;
}

.ai-channel:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
    transform: translateX(2px);
}






.ai-typing {
    display: flex;
    align-items: center;
    padding: 8px;
    font-style: italic;
    color: #667eea;
}

.ai-typing .typing-dots {
    display: inline-block;
    margin-left: 8px;
}

.ai-typing .typing-dots::after {
    content: '';
    animation: typing 1.4s infinite;
}

@keyframes typing {
    0%, 60%, 100% { content: ''; }
    20% { content: '.'; }
    40% { content: '..'; }
    60% { content: '...'; }
}

/* AI message styles moved to css/chat.css */

/* Responsive Media Queries */
/* Mobile Breakpoint: 0-768px */
@media (max-width: 768px) {
    /* Prevent any scrolling on mobile */
    html, body {
        overflow: hidden;
        height: 100dvh; /* dynamic viewport for iOS */
        position: fixed;
        width: 100%;
        overscroll-behavior-x: contain;
        touch-action: pan-y; /* prevent accidental horizontal pans */
    }

    /* Note: keyboard-open class handling was removed; visualViewport is used instead */
    
    /* Show mobile navigation header */
    .mobile-nav-header {
        display: flex;
    }
    
    /* Hide chat header on mobile by default (JS will set display:flex when a channel is active) */
    .chat-header {
        display: none;
    }
    
    /* Hide chat tools and show mobile more button */
    .chat-tools {
        display: none;
    }
    
    .mobile-tools-button {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: var(--chatplin-bg-tertiary);
        color: var(--chatplin-text-muted);
        cursor: pointer;
        transition: all 0.2s ease;
        font-size: 16px;
        margin-left: auto;
        border: none;
    }
    
    .mobile-tools-button:hover {
        background: rgba(79, 84, 92, 0.32);
        color: var(--chatplin-text-normal);
    }
    
    /* Mobile tools popup */
    .mobile-tools-popup {
        position: fixed;
        top: 60px;
        right: 16px;
        background: var(--chatplin-bg-primary);
        border-radius: 8px;
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.24);
        padding: 8px 0;
        min-width: 200px;
        z-index: 1000;
        display: none; /* hidden by default */
        flex-direction: column;
    }
    
    .mobile-tools-popup.active {
        display: flex;
    }
    
    .mobile-tool-item {
        display: flex;
        align-items: center;
        padding: 12px 16px;
        color: var(--chatplin-text-normal);
        cursor: pointer;
        transition: background-color 0.2s ease;
        text-decoration: none;
    }
    
    .mobile-tool-item:hover {
        background: var(--chatplin-brand);
        color: white;
    }
    
    .mobile-tool-item i {
        margin-right: 12px;
        width: 20px;
        text-align: center;
    }
    
    /* Left Panel (server list + channels wrapper) - ensure controllable on mobile */
    #leftPanel {
        /* Keep original desktop flow hidden on narrow view; explicit control via classes */
        display: none;
    }
    /* When any of the mobile-open triggers are active, show container so its children can slide */
    #leftPanel.mobile-active { display:flex; }
    /* Unified mobile slide control */
    #leftPanel {
        position: fixed;
        top:0;left:0;bottom:0;
        z-index: 1000;
        flex-direction: row;
        /* Start fully hidden to left */
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        will-change: transform;
    }
    #leftPanel.mobile-open { transform: translateX(0); }
    /* Inside it, keep server-list fixed width, channels-sidebar normal (no own transform needed) */
    #leftPanel .server-list { position: relative; transform:none; box-shadow:none; }
    #leftPanel .channels-sidebar { position: relative; transform:none; box-shadow:none; pointer-events:auto; }
    /* Remove legacy transforms when parent unified mode used */
    #leftPanel.mobile-open .channels-sidebar,
    #leftPanel.mobile-open .server-list { transform:none !important; }
    
    .server-list.mobile-open {
        transform: translateX(0);
        pointer-events: auto;
    }
    
    /* Channels sidebar - slide in/out */
    .channels-sidebar {
        display: flex;
        position: fixed;
        left: 0; /* 기본 위치는 왼쪽 끝 */
        top: 0;
        z-index: 1000;
        height: 100vh;
        width: var(--sidebar-width);
        transform: translateX(-100%); /* 숨김 상태에서는 완전히 왼쪽으로 */
        transition: transform 0.25s ease;
        will-change: transform;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
        pointer-events: none;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    /* Prefer dynamic value set by JS: --mobile-input-bottom. Cap to a reasonable maximum fallback. */
    padding-bottom: min(var(--mobile-input-bottom, calc(108px + env(safe-area-inset-bottom))), calc(108px + env(safe-area-inset-bottom)));
        box-sizing: border-box;
    }
    
    .channels-sidebar.mobile-open {
        transform: translateX(72px); /* 보임 상태에서는 server-list(72px) 오른쪽에 위치 */
        pointer-events: auto;
    }
    
    /* Main chat takes full width and height */
    .main-chat {
        width: 100%;
        height: 100dvh;
        position: relative;
        flex: none;
        overflow: hidden;
    }
    
    /* Members list - slide in/out */
    .members-list {
        display: block;
        position: fixed;
        right: 0;
        top: 0;
        z-index: 999;
        height: 100vh;
        width: var(--member-list-width);
        transform: translateX(100%);
        transition: transform 0.25s ease;
        will-change: transform;
        box-shadow: -2px 0 8px rgba(0, 0, 0, 0.3);
        pointer-events: none;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    /* Prefer dynamic value set by JS: --mobile-input-bottom. Cap to a reasonable maximum fallback. */
    padding-bottom: min(var(--mobile-input-bottom, calc(108px + env(safe-area-inset-bottom))), calc(108px + env(safe-area-inset-bottom)));
        box-sizing: border-box;
    }
    
    .members-list.mobile-open {
        transform: translateX(0);
        pointer-events: auto;
    }
    
    /* Messages container adjustments moved to css/chat.css */
    
    /* Message input adjustments for mobile */
    /* Input container stays fixed but uses a JS-driven bottom offset to account for keyboard height
       and avoid jumping. Fallback to safe-area inset. */
    /* Message input container mobile adjustments moved to css/input.css */
    
    /* Message input mobile adjustments moved to css/input.css */
    
    /* Hide input toolbar on mobile for more space */
    .input-toolbar {
        display: none !important;
    }
    
    /* Mobile input toolbar button */
    .mobile-input-button {
        position: absolute;
        left: 23px;
        bottom: 29px;
        width: 24px;
        height: 24px;
        background: var(--chatplin-text-muted);
        border: none;
        border-radius: 50%;
        color: white;
        cursor: pointer;
        font-size: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 15;
        transition: all 0.2s ease;
    }
    
    .mobile-input-button:hover {
        background: var(--chatplin-text-normal);
        transform: scale(1.1);
    }
    
    /* Mobile input toolbar popup */
    .mobile-input-popup {
        position: fixed;
        bottom: 80px;
        left: 16px;
        background: var(--chatplin-bg-primary);
        border-radius: 8px;
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.24);
        padding: 8px 0;
        min-width: 180px;
        z-index: 1000;
        display: none; /* hidden by default */
        flex-direction: column;
    }

/* Hide mobile-only popups on desktop, show only on <= 768px */
@media (min-width: 769px) {
    .mobile-tools-popup,
    .mobile-input-popup,
    .mobile-input-button,
    .mobile-tools-button {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .mobile-tools-popup.active,
    .mobile-input-popup.active {
        display: flex !important;
    }
}
    
    .mobile-input-popup.active {
        display: flex;
    }
    
    .mobile-input-item {
        display: flex;
        align-items: center;
        padding: 12px 16px;
        color: var(--chatplin-text-normal);
        cursor: pointer;
        transition: background-color 0.2s ease;
        text-decoration: none;
    }
    
    .mobile-input-item:hover {
        background: var(--chatplin-brand);
        color: white;
    }
    
    .mobile-input-item i {
        margin-right: 12px;
        width: 16px;
        text-align: center;
    }
    
    .input-send-button {
        right: 12px;
        bottom: 12px;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        color: var(--chatplin-brand);
    }
    
    /* Touch-friendly message actions */
    .message-actions {
        position: relative;
        right: auto;
        top: auto;
        background: transparent;
        opacity: 1;
        box-shadow: none;
        margin-top: 8px;
        justify-content: flex-end;
    }
    
    .action-button {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Touch-friendly tool buttons */
    .chat-tools {
        gap: 8px;
    }
    
    .tool-button {
        min-width: 44px;
        min-height: 44px;
        font-size: 16px;
    }
    
    /* Member items touch-friendly */
    .member-item {
        padding: 12px 8px;
        min-height: 56px;
    }
    
    .member-avatar {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    /* Channel items touch-friendly */
    .channel-item {
        padding: 12px 8px 12px 16px;
        min-height: 48px;
    }
    
    .channel-name {
        font-size: 16px;
    }
    
    
    /* Stats cards responsive */
    .stats-card {
        margin: 8px 0;
        padding: 12px;
    }
    
    /* Remove hover effects on touch devices */
    /* Message bubble responsiveness and hover tweaks are managed in css/chat.css */
    
    /* Active states for touch */
    .channel-item:active,
    .member-item:active {
        background: rgba(79, 84, 92, 0.32);
    }
}

/* Tablet Breakpoint: 768px-1024px */
@media (min-width: 768px) and (max-width: 1024px) {
    /* Hide mobile navigation header */
    .mobile-nav-header {
        display: none;
    }
    
    /* Reduce sidebar widths for more chat space */
    :root {
        --sidebar-width: 240px;
        --member-list-width: 200px;
    }
    
    /* Channel description might be too long, allow hiding */
    .channel-description {
        display: none;
    }
    
    /* Member list can be toggled */
    .members-list {
        position: relative;
        transition: width 0.3s ease;
    }
    
    .members-list.collapsed {
        width: 0;
        overflow: hidden;
    }
    
    /* Touch-friendly buttons on tablet */
    .tool-button, .action-button {
        min-width: 36px;
        min-height: 36px;
    }
    
    /* Slightly larger touch targets */
    .channel-item, .member-item {
        min-height: 40px;
        padding: 8px;
    }
}

/* Desktop Breakpoint: 1024px+ */
@media (min-width: 1024px) {
    /* Hide mobile navigation header */
    .mobile-nav-header {
        display: none;
    }
    
    /* Ensure full layout is visible */
    .server-list,
    .channels-sidebar,
    .members-list {
        position: relative;
        left: auto;
        right: auto;
        transform: none;
    }
    
    /* Restore hover effects for desktop */
    .message:hover {
        background: rgba(4, 4, 5, 0.07);
    }
    
    .channel-item:hover {
        background: rgba(79, 84, 92, 0.16);
        color: var(--chatplin-text-normal);
    }
    
    .member-item:hover {
        background: rgba(79, 84, 92, 0.16);
    }
    
    .tool-button:hover {
        color: var(--chatplin-text-normal);
        background: rgba(79, 84, 92, 0.16);
    }
}

/* Mobile overlay for preventing background scroll */
.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 500;
    display: none;
}

.mobile-overlay.active {
    display: block;
}

/* Accessibility improvements for mobile */
@media (max-width: 768px) {
    /* Focus styles for keyboard navigation */
    .mobile-menu-toggle:focus,
    .mobile-members-toggle:focus,
    .channel-item:focus,
    .member-item:focus,
    .tool-button:focus,
    .action-button:focus {
        outline: 2px solid var(--chatplin-brand);
        outline-offset: 2px;
    }
    
    /* Better contrast for important elements */
    .message-input {
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .message-input:focus {
        border-color: var(--chatplin-brand);
        outline: none;
    }
}

/* Performance optimizations for mobile */
@media (max-width: 768px) {
    /* Reduce expensive animations */
    * {
        animation-duration: 0.2s !important;
        transition-duration: 0.2s !important;
    }
    
    /* Simplify shadows for performance */
    .channels-sidebar,
    .server-list,
    .members-list {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }

    /* Ensure scrollbar doesn't overlap content and panels reserve space for bottom
       In addition to padding-bottom, prefer using a spacer element inside panels */
    .channels-sidebar,
    .server-list,
    .members-list {
        scrollbar-gutter: stable both-edges;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Reduce motion for users who prefer it */
    @media (prefers-reduced-motion: reduce) {
        * {
            animation: none !important;
            transition: none !important;
        }
    }
    
    /* Optimize rendering performance */
    .messages-container {
        will-change: scroll-position;
        -webkit-overflow-scrolling: touch;
    }
    
    .channels-sidebar,
    .members-list {
        will-change: transform;
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
    }
    
    /* Better text rendering on mobile */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;
    }
    
    /* Prevent zoom on input focus */
    input, textarea, select {
        font-size: 16px !important;
    }
    
    /* Safe area handling for notched devices */
    .mobile-nav-header {
        padding-top: calc(12px + env(safe-area-inset-top));
    }
    
    .message-input-container {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
}

/* Loading states */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--discord-text-muted);
    border-radius: 50%;
    border-top-color: var(--discord-brand);
    animation: spin 1s ease-in-out infinite;
}

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

/* Message Search Modal */
.search-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}

.search-modal.active {
    display: flex;
}

.search-container {
    background: var(--discord-bg-primary);
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Prevent overflow on small screens */
@media (max-width: 480px) {
    .search-container {
        width: 100%;
        max-width: calc(100% - 24px); /* avoid 100vw overflow on mobile */
        margin: 0 12px;
    }

    /* Alternative search modal variant */
    .search-modal {
        padding: 12px; /* provide breathing room */
        box-sizing: border-box;
    }

    .search-modal-content {
        width: 100%;
        max-width: calc(100% - 24px);
        margin: 0 auto;
        box-sizing: border-box;
    }

    /* Ensure inputs don't exceed container due to padding */
    .search-input {
        box-sizing: border-box;
    }

    /* Stack header and filters vertically on mobile */
    .search-header,
    .search-modal-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .search-filters {
        flex-direction: column;
        width: 100%;
    }

    .search-filter,
    .search-input,
    .search-pagination,
    .search-pagination-buttons,
    .search-results {
        width: 100%;
        min-width: 0; /* allow flex children to shrink within container */
        box-sizing: border-box;
    }

    /* Avoid icon or date pushing layout */
    .search-result-header {
        flex-wrap: wrap;
    }
}

/* Wrap long content to avoid horizontal scroll */
.search-result-content {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Use dynamic viewport units where supported (iOS Safari quirks safe) */
@supports (width: 100dvw) {
    @media (max-width: 480px) {
        .search-container,
        .search-modal-content {
            max-width: calc(100dvw - 24px);
        }
    }
}

.search-header {
    padding: 16px 20px;
    border-bottom: 1px solid #1e2124;
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-input {
    background: var(--discord-bg-secondary);
    border: 1px solid #1e2124;
    border-radius: 4px;
    padding: 8px 12px;
    color: var(--discord-text-normal);
    font-size: 14px;
    flex: 1;
    outline: none;
}

.search-input:focus {
    border-color: var(--discord-brand);
}

.search-filters {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.search-filter {
    background: var(--discord-bg-secondary);
    border: 1px solid #1e2124;
    border-radius: 4px;
    padding: 4px 8px;
    color: var(--discord-text-normal);
    font-size: 12px;
    outline: none;
}

.search-results {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* A small spacer that can be appended to the end of panel lists as a last-resort guarantee
   that the last content isn't obscured by fixed inputs. JS can append <div class="panel-bottom-spacer"></div>
   into panel containers if necessary. */
.panel-bottom-spacer {
    height: var(--mobile-input-bottom, calc(108px + env(safe-area-inset-bottom)));
    pointer-events: none;
}

.search-result-item {
    background: var(--discord-bg-secondary);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border: 1px solid transparent;
}

.search-result-item:hover {
    background: rgba(79, 84, 92, 0.32);
    border-color: var(--discord-brand);
}

.search-result-header {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--discord-text-muted);
}

.search-result-channel {
    color: var(--discord-brand);
    margin-right: 8px;
}

.search-result-author {
    font-weight: 500;
    margin-right: 8px;
}

.search-result-date {
    margin-left: auto;
}

.search-result-content {
    color: var(--discord-text-normal);
    font-size: 14px;
    line-height: 1.4;
}

.search-highlight {
    background: rgba(250, 166, 26, 0.3);
    color: var(--discord-yellow);
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: 500;
}

.search-no-results {
    text-align: center;
    color: var(--discord-text-muted);
    padding: 40px;
    font-size: 14px;
}

.search-loading {
    text-align: center;
    padding: 40px;
    color: var(--discord-text-muted);
}

.search-close {
    background: none;
    border: none;
    color: var(--discord-text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.search-close:hover {
    color: var(--discord-text-normal);
    background: rgba(79, 84, 92, 0.16);
}

.search-pagination {
    padding: 12px 20px;
    border-top: 1px solid #1e2124;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--discord-text-muted);
}

.search-pagination-buttons {
    display: flex;
    gap: 8px;
}

.search-pagination-btn {
    background: var(--discord-bg-secondary);
    border: 1px solid #1e2124;
    color: var(--discord-text-normal);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.search-pagination-btn:hover:not(:disabled) {
    background: var(--discord-brand);
}

.search-pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Emoji Reaction System moved to css/chat.css */

/* Search Modal */
.search-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
}

.search-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-modal-content {
    background: var(--chatplin-bg-primary);
    border-radius: 8px;
    padding: 24px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.search-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.search-modal-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--chatplin-text-normal);
}

.search-modal-close {
    background: none;
    border: none;
    color: var(--chatplin-text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.search-modal-close:hover {
    color: var(--chatplin-text-normal);
    background: rgba(79, 84, 92, 0.16);
}

.search-input-container {
    position: relative;
    margin-bottom: 20px;
}

.search-input {
    width: 100%;
    background: #40444b;
    border: none;
    border-radius: 6px;
    padding: 12px 16px;
    padding-right: 40px;
    color: var(--chatplin-text-normal);
    font-size: 15px;
}

.search-input::placeholder {
    color: var(--chatplin-text-muted);
}

.search-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--chatplin-brand);
}

.search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--chatplin-text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.search-clear:hover {
    color: var(--chatplin-text-normal);
    background: rgba(79, 84, 92, 0.16);
}

.search-results {
    flex: 1;
    overflow-y: auto;
    max-height: 400px;
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin-bottom: 4px;
}

.search-result-item:hover {
    background: rgba(79, 84, 92, 0.16);
}

.search-result-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--chatplin-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    color: white;
    font-size: 14px;
    flex-shrink: 0;
}

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

.search-result-name {
    font-weight: 500;
    color: var(--chatplin-text-normal);
    margin-bottom: 2px;
}

.search-result-details {
    font-size: 12px;
    color: var(--chatplin-text-muted);
}

.no-results {
    text-align: center;
    color: var(--chatplin-text-muted);
    padding: 40px 20px;
    font-size: 14px;
}

/* Profile Modal */
.profile-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.profile-modal.active {
    display: flex;
}

.profile-card {
    background: var(--chatplin-bg-primary);
    border-radius: 12px;
    overflow: hidden;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
}

.profile-header {
    background: var(--chatplin-brand);
    padding: 20px;
    text-align: center;
    position: relative;
}

.profile-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.profile-close:hover {
    background: rgba(0, 0, 0, 0.5);
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--chatplin-bg-secondary);
    color: white;
    font-size: 32px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    position: relative;
}

.profile-status-indicator {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 3px solid var(--chatplin-brand);
}

.profile-name {
    font-size: 24px;
    font-weight: 600;
    color: white;
    margin-bottom: 4px;
}

.profile-username {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 8px;
}

.profile-country {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
}

.profile-body {
    padding: 20px;
}

.profile-section {
    margin-bottom: 24px;
}

.profile-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--chatplin-text-normal);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-bottom: 12px;
}

.profile-info-item {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.profile-info-icon {
    width: 20px;
    margin-right: 12px;
    color: var(--chatplin-text-muted);
    text-align: center;
}

.profile-info-content {
    flex: 1;
}

.profile-info-label {
    font-size: 12px;
    color: var(--chatplin-text-muted);
    margin-bottom: 2px;
}

.profile-actions {
    display: flex;
    gap: 12px;
    padding: 20px;
    border-top: 1px solid rgba(79, 84, 92, 0.32);
}

.profile-action-btn {
    flex: 1;
    background: var(--chatplin-brand);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.profile-action-btn:hover {
    background: #677bc4;
}

.profile-action-btn.secondary {
    background: var(--chatplin-bg-tertiary);
    color: var(--chatplin-text-normal);
}

.profile-action-btn.secondary:hover {
    background: rgba(79, 84, 92, 0.32);
}

/* Home Content Styles */
.home-content {
    padding: 40px;
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
    color: var(--chatplin-text-normal);
}

/* Make main home screen scroll like chat */
#homeContent {
    height: 100vh;
    overflow-y: auto;
    background: var(--chatplin-bg-primary);
    -webkit-overflow-scrolling: touch; /* smooth iOS */
    overscroll-behavior: contain;
}

/* Match chat scrollbar styling specifically for #homeContent (in addition to global) */
#homeContent::-webkit-scrollbar {
    width: 12px;
}
#homeContent::-webkit-scrollbar-corner {
    background-color: var(--chatplin-bg-secondary);
}
#homeContent::-webkit-scrollbar-thumb {
    background-color: #202225;
    border: 2px solid var(--chatplin-bg-secondary);
    border-radius: 6px;
}
#homeContent::-webkit-scrollbar-thumb:hover {
    background-color: #2e3338;
}
#homeContent::-webkit-scrollbar-track {
    background-color: var(--chatplin-bg-secondary);
}

.welcome-section {
    margin-bottom: 50px;
}

.welcome-header {
    margin-bottom: 20px;
}

.welcome-icon {
    font-size: 48px;
    color: var(--chatplin-brand);
    margin-bottom: 20px;
    display: block;
}

.welcome-title {
    font-size: 32px;
    font-weight: 600;
    color: var(--chatplin-text-normal);
    margin: 0 0 20px 0;
    line-height: 1.2;
}

.welcome-description {
    font-size: 18px;
    color: var(--chatplin-text-muted);
    line-height: 1.6;
    margin: 0;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-bottom: 50px;
}

.feature-card {
    background: rgba(79, 84, 92, 0.16);
    padding: 30px 20px;
    border-radius: 12px;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.feature-card:hover {
    background: rgba(79, 84, 92, 0.24);
    transform: translateY(-5px);
}

.feature-icon {
    font-size: 36px;
    color: var(--chatplin-brand);
    margin-bottom: 15px;
    display: block;
}

.feature-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--chatplin-text-normal);
    margin: 0 0 10px 0;
}

.feature-description {
    font-size: 14px;
    color: var(--chatplin-text-muted);
    line-height: 1.5;
    margin: 0;
}

.quick-actions {
    background: rgba(88, 101, 242, 0.1);
    padding: 30px;
    border-radius: 12px;
    border: 2px solid rgba(88, 101, 242, 0.2);
}

.quick-actions-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--chatplin-text-normal);
    margin: 0 0 20px 0;
}

.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 150px;
    justify-content: center;
}

.action-btn.primary {
    background: var(--chatplin-brand);
    color: white;
}

.action-btn.primary:hover {
    background: #677bc4;
    transform: translateY(-2px);
}

.action-btn.secondary {
    background: transparent;
    color: var(--chatplin-text-normal);
    border: 2px solid var(--chatplin-text-muted);
}

.action-btn.secondary:hover {
    background: rgba(79, 84, 92, 0.32);
    border-color: var(--chatplin-text-normal);
    transform: translateY(-2px);
}


/* Message Editing styles moved to css/chat.css */

.message-edited-indicator {
    color: var(--discord-text-muted);
    font-size: 10px;
    margin-left: 6px;
    font-style: italic;
}

.message-deleted {
    opacity: 0.6;
    font-style: italic;
}

.message-deleted .message-text {
    color: var(--discord-text-muted);
}

/* Enhanced message actions for edit/delete */
.message-actions .action-button.edit {
    color: var(--discord-yellow);
}

.message-actions .action-button.delete {
    color: var(--discord-red);
}

.message-actions .action-button.edit:hover {
    background: rgba(250, 166, 26, 0.2);
}

.message-actions .action-button.delete:hover {
    background: rgba(237, 66, 69, 0.2);
}



/* Mobile responsive for home content */
@media (max-width: 768px) {
    .home-content {
        padding: 20px;
    }
    
    .welcome-title {
        font-size: 24px;
    }
    
    .welcome-description {
        font-size: 16px;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .feature-card {
        padding: 20px 15px;
    }
    
    .quick-actions {
        padding: 20px;
    }
    
    .action-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .action-btn {
        width: 100%;
        max-width: 250px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --chatplin-bg-primary: #000000;
        --chatplin-bg-secondary: #1a1a1a;
        --chatplin-bg-tertiary: #0d0d0d;
        --chatplin-text-normal: #ffffff;
        --chatplin-text-muted: #cccccc;
    }
    
    .channel-item:hover,
    .member-item:hover,
    .message:hover {
        background: rgba(255, 255, 255, 0.2);
    }
    
    .message-input {
        border: 2px solid #ffffff;
    }
}

/* Dark theme improvements for OLED displays */
@media (prefers-color-scheme: dark) {
    :root {
        --chatplin-bg-primary: #000000;
        --chatplin-bg-secondary: #0f0f0f;
        --chatplin-bg-tertiary: #1a1a1a;
    }
}

/* Message Edit Modal visibility moved to css/chat.css; Emoji picker is in css/components.css */

.emoji-item {
    background: transparent;
    border: none;
    padding: 8px;
    font-size: 20px;
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 4px;
    text-align: center;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.emoji-item:active {
    transform: scale(0.95);
}

/* Message Reactions Display */
.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.reaction-emoji {
    display: inline-flex;
    align-items: center;
    background: var(--discord-bg-modifier-accent);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

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

.reaction-count {
    margin-left: 4px;
    font-size: 12px;
    font-weight: 500;
    opacity: 0.8;
}

/* My message alignment moved to css/chat.css */

/* Defensive: ensure mobile-only popups are always hidden on desktop even if .active is toggled */
@media (min-width: 769px) {
    .mobile-tools-popup,
    .mobile-tools-popup.active,
    .mobile-input-popup,
    .mobile-input-popup.active,
    .mobile-input-button,
    .mobile-tools-button {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }
}

/* Hide all chat-tools icons except search */
.chat-tools .tool-button {
    display: none;
}

.chat-tools .fa-search {
    display: inline-block;
}

/* Unified Search (dynamic) */
.unified-search-wrapper { /* container fills messages area */ width:100%; }
.unified-search-wrapper .unified-search-header input:focus { outline: none; box-shadow:0 0 0 2px var(--chatplin-brand); }