/* Chat Container */
.chat-container {
    display: flex;
    height: calc(100vh - 80px);
    margin: 20px;
    margin-top: 70px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* Sidebar */
.chat-sidebar {
    width: 280px;
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* User Card */
.user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    margin-bottom: 10px;
}

.user-avatar {
    width: 48px;
    height: 48px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.user-info h4 {
    color: white;
    font-size: 16px;
    margin-bottom: 4px;
}

.user-badge {
    font-size: 11px;
    color: rgba(255,255,255,0.8);
}

/* Sidebar Sections */
.sidebar-section {
    padding: 15px;
    border-bottom: 1px solid #e9ecef;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.section-title .badge {
    background: #4ade80;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    margin-left: auto;
}

/* Room Search */
.room-search {
    position: relative;
    margin-bottom: 12px;
}

.room-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #adb5bd;
    font-size: 12px;
}

.room-search input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    font-size: 13px;
    outline: none;
}

.room-search input:focus {
    border-color: #667eea;
}

/* Rooms & Users Lists */
.rooms-list, .users-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.room-item, .user-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.room-item:hover, .user-item:hover {
    background: #e9ecef;
}

.room-item.active {
    background: rgba(102, 126, 234, 0.1);
    border-left: 3px solid #667eea;
}

.room-item i, .user-item i {
    width: 20px;
    color: #667eea;
    font-size: 14px;
}

.room-item span {
    flex: 1;
    font-size: 14px;
    color: #495057;
}

.room-badge {
    background: #667eea;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
}

.user-item .online-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    margin-left: auto;
}

/* Chat Main */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

/* Chat Header */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #e9ecef;
}

.room-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.room-header i {
    font-size: 24px;
    color: #667eea;
}

.room-header h2 {
    font-size: 18px;
    color: #212529;
    margin: 0;
}

.room-header p {
    font-size: 12px;
    color: #6c757d;
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* Search Bar */
.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.search-bar i {
    color: #adb5bd;
}

.search-bar input {
    flex: 1;
    border: none;
    background: none;
    padding: 8px 0;
    outline: none;
}

.close-search {
    background: none;
    border: none;
    cursor: pointer;
    color: #adb5bd;
}

/* Messages Area */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Message */
.message {
    display: flex;
    gap: 12px;
    animation: fadeIn 0.2s ease;
}

.message-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
    flex-shrink: 0;
}

.message-content {
    flex: 1;
    max-width: 70%;
}

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

.message-sender {
    font-weight: 600;
    font-size: 14px;
    color: #212529;
}

.message-time {
    font-size: 10px;
    color: #adb5bd;
}

.message-text {
    font-size: 14px;
    color: #495057;
    line-height: 1.4;
    word-wrap: break-word;
}

.message-text a {
    color: #667eea;
    text-decoration: none;
}

.message-text code {
    background: #f1f3f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.message-text .mention {
    background: rgba(102,126,234,0.1);
    padding: 2px 6px;
    border-radius: 12px;
    color: #667eea;
    cursor: pointer;
}

/* Own Message */
.message-own {
    flex-direction: row-reverse;
}

.message-own .message-content {
    text-align: right;
}

.message-own .message-header {
    justify-content: flex-end;
}

.message-own .message-avatar {
    background: linear-gradient(135deg, #10b981, #059669);
}

/* Message Actions */
.message-actions {
    display: none;
    gap: 8px;
    margin-top: 6px;
}

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

.message-actions button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 4px;
    color: #6c757d;
}

.message-actions button:hover {
    background: #f1f3f5;
}

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

.reaction-badge {
    background: #f1f3f5;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    cursor: pointer;
}

/* Date Separator */
.date-separator {
    text-align: center;
    margin: 20px 0;
}

.date-separator span {
    background: #f1f3f5;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    color: #6c757d;
}

/* Code Block */
.code-block {
    background: #1e1e1e;
    border-radius: 8px;
    padding: 12px;
    overflow-x: auto;
    margin: 8px 0;
}

.code-block pre {
    margin: 0;
    color: #d4d4d4;
    font-family: monospace;
    font-size: 12px;
}

/* Message Image */
.message-image {
    max-width: 250px;
    border-radius: 10px;
    cursor: pointer;
}

/* Typing Area */
.typing-area {
    padding: 8px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #6c757d;
}

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

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #667eea;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Input Area */
.input-area {
    padding: 15px 20px;
    border-top: 1px solid #e9ecef;
    background: white;
}

.input-tools {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.tool-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #adb5bd;
    padding: 6px;
    border-radius: 8px;
    font-size: 16px;
}

.tool-btn:hover {
    background: #f1f3f5;
    color: #667eea;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.input-wrapper textarea {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    max-height: 100px;
}

.input-wrapper textarea:focus {
    border-color: #667eea;
}

.send-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: transform 0.2s;
}

.send-btn:hover {
    transform: scale(1.05);
}

/* Loading */
.loading {
    text-align: center;
    padding: 50px;
    color: #adb5bd;
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #e9ecef;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 10px;
}

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

/* Emoji Picker */
.emoji-picker {
    position: fixed;
    bottom: 100px;
    left: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    width: 280px;
    z-index: 1000;
}

.emoji-header {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    border-bottom: 1px solid #e9ecef;
}

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

.emoji-item {
    font-size: 24px;
    text-align: center;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
}

.emoji-item:hover {
    background: #f1f3f5;
}

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

.modal-box {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 450px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #e9ecef;
}

.modal-head button {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #adb5bd;
}

/* Form */
.form-field {
    padding: 15px 20px;
}

.form-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #495057;
}

.form-field input, .form-field select, .form-field textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
    border-color: #667eea;
}

/* Avatar Grid */
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.avatar-option {
    font-size: 28px;
    text-align: center;
    padding: 8px;
    cursor: pointer;
    border-radius: 10px;
    background: #f8f9fa;
}

.avatar-option:hover, .avatar-option.selected {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

/* Commands List */
.commands-list {
    padding: 15px;
}

.command-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid #e9ecef;
}

.command-item code {
    background: #f1f3f5;
    padding: 4px 8px;
    border-radius: 6px;
    color: #667eea;
}

/* Buttons */
.btn-primary, .btn-secondary {
    padding: 8px 20px;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    font-weight: 500;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-secondary {
    background: #e9ecef;
    color: #495057;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid #e9ecef;
}

.icon-btn, .icon-btn-sm {
    background: none;
    border: none;
    cursor: pointer;
    color: #6c757d;
    padding: 6px;
    border-radius: 8px;
}

.icon-btn:hover, .icon-btn-sm:hover {
    background: #f1f3f5;
    color: #667eea;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #1f2937;
    color: white;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 13px;
    z-index: 3000;
    animation: slideIn 0.3s ease;
}

.toast-success { background: #10b981; }
.toast-error { background: #ef4444; }
.toast-warning { background: #f59e0b; }
.toast-info { background: #3b82f6; }

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

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

/* Responsive */
@media (max-width: 768px) {
    .chat-container {
        margin: 10px;
        margin-top: 60px;
        flex-direction: column;
    }
    
    .chat-sidebar {
        width: 100%;
        max-height: 200px;
        flex-direction: row;
        overflow-x: auto;
    }
    
    .sidebar-section {
        min-width: 200px;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .emoji-picker {
        width: 260px;
    }
}