/**
 * ReconCom Modern Chat Interface
 * Clean, responsive, WhatsApp-style design
 */

/* Reset and base styles */
.reconcom-chat {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.4;
    color: #333;
    background: #f5f5f5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Chat layout */
.chat-container {
    display: flex;
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

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

.sidebar-header {
    padding: 20px;
    background: #007bff;
    color: white;
    font-weight: 600;
    font-size: 18px;
}

.channels-list {
    flex: 1;
    overflow-y: auto;
}

.channel-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #e9ecef;
    color: #333;
    text-decoration: none;
    transition: background-color 0.2s ease;
    position: relative;
}

.channel-item:hover {
    background: #e9ecef;
    text-decoration: none;
    color: #333;
}

.channel-item.active {
    background: #007bff;
    color: white;
}

.channel-icon {
    font-size: 20px;
    margin-right: 12px;
    width: 24px;
    text-align: center;
}

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

.channel-name {
    font-weight: 800;
    font-size: 16px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-preview {
    font-size: 14px;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background: #dc3545;
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
    margin-left: 8px;
}

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

.chat-header {
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
    font-size: 18px;
}

.messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
    scroll-behavior: smooth;
}

/* Messages */
.message-item {
    margin-bottom: 20px;
    animation: slideInUp 0.3s ease;
}

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

.message-content {
    max-width: 70%;
    background: #f1f3f4;
    border-radius: 18px;
    padding: 12px 16px;
    position: relative;
}

.message-content.current-user {
    background: #007bff;
    color: white;
    margin-left: auto;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 12px;
}

.user-name {
    font-weight: 600;
    opacity: 0.8;
}

.message-time {
    opacity: 0.6;
    font-size: 11px;
}

.message-body {
    font-size: 15px;
    line-height: 1.4;
    word-wrap: break-word;
}

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

.reaction-btn {
    background: rgba(0,0,0,0.05);
    border: none;
    border-radius: 12px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reaction-btn:hover {
    background: rgba(0,0,0,0.1);
    transform: scale(1.05);
}

.reaction-btn.user-reacted {
    background: #007bff;
    color: white;
}

/* Message input area */
.message-input-area {
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.message-form {
    display: flex;
    gap: 12px;
    align-items: end;
}

.message-input {
    flex: 1;
    width: 100%;
    border: 1px solid #e9ecef;
    border-radius: 24px;
    padding: 12px 16px;
    font-size: 15px;
    outline: none;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    transition: border-color 0.2s ease;
    font-family: inherit;
}

.message-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
}

.send-button {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
}

.send-button:hover {
    background: #0056b3;
    transform: scale(1.05);
}

.send-button:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

.message-form.sending {
    opacity: 0.7;
    pointer-events: none;
}

/* File attachments */
.file-attachment {
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 12px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 400px;
}

.file-icon {
    font-size: 20px;
    opacity: 0.8;
}

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

.file-name {
    font-weight: 500;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 12px;
    opacity: 0.7;
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    animation: slideInRight 0.3s ease;
}

.notification-error {
    background: #dc3545;
}

.notification-warning {
    background: #ffc107;
    color: #212529;
}

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

/* Loading states */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #6c757d;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e9ecef;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile responsive */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
        height: 100vh;
        border-radius: 0;
    }
    
    .chat-sidebar {
        width: 100%;
        height: auto;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid #e9ecef;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .messages-container {
        max-height: none;
        flex: 1;
    }
}

@media (max-width: 480px) {
    .chat-sidebar {
        max-height: 30vh;
    }
    
    .message-content {
        max-width: 90%;
    }
    
    .chat-header,
    .sidebar-header,
    .message-input-area {
        padding: 15px;
    }
    
    .messages-container {
        padding: 15px;
    }
    
    .channel-item {
        padding: 12px 15px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .reconcom-chat {
        background: #1a1a1a;
        color: #fff;
    }
    
    .chat-container {
        background: #2d2d2d;
    }
    
    .chat-sidebar {
        background: #252525;
        border-right-color: #404040;
    }
    
    .channel-item {
        color: #fff;
        border-bottom-color: #404040;
    }
    
    .channel-item:hover {
        background: #404040;
        color: #fff;
    }
    
    .chat-header,
    .message-input-area {
        background: #252525;
        border-color: #404040;
    }
    
    .message-content {
        background: #404040;
        color: #fff;
    }
    
    .message-input {
        background: #2d2d2d;
        color: #fff;
        border-color: #404040;
    }
    
    .message-input:focus {
        border-color: #007bff;
    }
}

/* Smooth transitions for all interactive elements */
* {
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}