/* Chat Interface Styles */

.chat-container {
    display: none;
    height: 100vh;
    background: #1a1a1a;
}

/* Header */
.chat-header {
    background: #2a2a2a;
    border-bottom: 1px solid #404040;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #e4e4e4;
    box-shadow: 0 1px 0 rgba(0,0,0,0.2);
}

.chat-title {
    font-size: 16px;
    font-weight: 700;
    color: #e4e4e4;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.logout-button {
    padding: 6px 14px;
    border: 1px solid #404040;
    border-radius: 4px;
    background: transparent;
    color: #e4e4e4;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.logout-button:hover {
    background: #404040;
    border-color: #555;
}

/* Search */
.search-container {
    flex: 1;
    max-width: 400px;
    margin: 0 20px;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 8px 35px 8px 15px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 14px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.search-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.6);
    pointer-events: none;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    margin-top: 5px;
}

.search-result {
    padding: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    cursor: pointer;
    color: #333;
}

.search-result:hover {
    background: rgba(103, 126, 234, 0.1);
}

.search-result-channel {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.search-result-author {
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 4px;
}

.search-result-content {
    font-size: 14px;
    line-height: 1.3;
}

.search-highlight {
    background: yellow;
    padding: 1px 2px;
    border-radius: 2px;
}

/* Main Chat Area */
.chat-main {
    display: flex;
    height: calc(100vh - 70px);
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: #2a2a2a;
    border-right: 1px solid #404040;
    padding: 16px 12px;
    overflow-y: auto;
}

.sidebar-section {
    margin-bottom: 25px;
}

.sidebar h3 {
    color: #8e8e8e;
    margin-bottom: 8px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 8px;
}

.add-channel-btn {
    background: transparent;
    border: none;
    color: #8e8e8e;
    width: 18px;
    height: 18px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.add-channel-btn:hover {
    background: #404040;
    color: #e4e4e4;
}

.channel-list {
    list-style: none;
}

.channel-item {
    padding: 8px 12px;
    margin: 2px 0;
    border-radius: 4px;
    cursor: pointer;
    color: #b9bbbe;
    transition: all 0.15s;
    background: transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.channel-item:hover {
    background: #3a3a3a;
    color: #e4e4e4;
}

.channel-item.active {
    background: #404040;
    color: #ffffff;
    font-weight: 500;
}

.channel-name {
    flex: 1;
}

.channel-description {
    font-size: 12px;
    opacity: 0.6;
    margin-top: 4px;
}

.channel-type {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.2);
    margin-left: 8px;
}

.private-indicator {
    background: rgba(255, 193, 7, 0.8);
    color: #333;
}

.admin-indicator {
    background: rgba(220, 53, 69, 0.8);
    color: white;
}

/* Admin Controls */
.admin-controls {
    display: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.admin-controls h4 {
    color: white;
    margin-bottom: 10px;
    font-size: 14px;
}

.admin-button {
    background: rgba(220, 53, 69, 0.8);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    margin: 2px;
    transition: background 0.2s;
}

.admin-button:hover {
    background: rgba(220, 53, 69, 1);
}

/* Messages Area */
.messages-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    background: transparent;
    padding: 8px 16px;
    border-radius: 0;
    border: none;
    color: #e4e4e4;
    position: relative;
    transition: background 0.1s;
}

.message:hover {
    background: #2a2a2a;
}

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

.message-author {
    font-weight: 600;
    color: #5865F2;
    font-size: 15px;
}

.message-time {
    font-size: 11px;
    color: #72767d;
    font-weight: 400;
}

.message-content {
    line-height: 1.5;
    font-size: 15px;
    color: #dcddde;
    padding-left: 0;
}

.message-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: none;
    gap: 6px;
}

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

.message-action-btn {
    background: rgba(0, 0, 0, 0.4);
    border: none;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.8;
}

.message-action-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.6);
}

/* Message Input */
.message-input-container {
    padding: 16px 20px;
    background: #1a1a1a;
}

.message-input-form {
    display: flex;
    gap: 8px;
}

.message-input {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    background: #3a3a3a;
    color: #e4e4e4;
    font-size: 15px;
}

.message-input::placeholder {
    color: #72767d;
}

.message-input:focus {
    outline: none;
    background: #404040;
}

.send-button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    background: #5865F2;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.send-button:hover {
    background: #4752C4;
}

.send-button:disabled {
    background: #4752C4;
    opacity: 0.5;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: #e4e4e4;
    font-size: 24px;
    padding: 8px;
    cursor: pointer;
    z-index: 10;
}

.mobile-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* Responsive */
@media (max-width: 768px) {
    /* Show mobile menu toggle */
    .mobile-menu-toggle {
        display: block;
    }

    /* Header - compact horizontal layout, fixed at top */
    .chat-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        flex-direction: row;
        gap: 8px;
        padding: 8px 12px;
        align-items: center;
        z-index: 100;
    }

    .chat-title {
        flex: 1;
        text-align: left;
        font-size: 16px;
    }

    /* Hide search on mobile to save space */
    .search-container {
        display: none;
    }

    .user-info {
        font-size: 12px;
        gap: 6px;
    }

    .logout-button {
        padding: 4px 8px;
        font-size: 12px;
    }

    /* Make container use flexbox properly */
    .chat-container {
        display: flex;
        flex-direction: column;
        height: 100vh;
        padding-top: 50px; /* Space for fixed header */
    }

    /* Main layout */
    .chat-main {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    /* Messages area - make scrollable */
    .messages-area {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .messages-container {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }

    /* Center the loading/placeholder message */
    .messages-container .loading {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 100px;
    }

    .message-input-container {
        flex-shrink: 0;
    }

    /* Sidebar - collapsible overlay */
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        z-index: 1000;
        border-right: 1px solid rgba(255, 255, 255, 0.1);
        transition: left 0.3s ease;
        overflow-y: auto;
        padding: 60px 16px 16px 16px; /* Space for close button */
    }

    .sidebar.mobile-open {
        left: 0;
    }

    /* Overlay backdrop when sidebar is open */
    .sidebar.mobile-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
    }

    /* Keep vertical channel list - easier to use */
    .channel-list {
        display: flex;
        flex-direction: column;
    }

    .channel-item {
        padding: 12px;
        min-height: 44px; /* Better touch target */
    }

    /* Message input - better mobile sizing */
    .message-input-container {
        padding: 12px;
    }

    .message-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .send-button {
        padding: 12px 20px;
        font-size: 15px;
    }

    /* Messages */
    .messages-container {
        padding: 12px;
    }

    .message {
        padding: 10px 12px;
    }
}