/* Общие стили */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f5f5f5;
    margin: 0;
    padding: 0;
}

.container-fluid {
    padding: 0;
}

/* Заголовок */
.header {
    background: #2c3e50;
    color: white;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #3498db;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

/* Основной контейнер */
.main-container {
    height: calc(100vh - 80px);
    overflow: hidden;
}

/* Боковая панель */
.sidebar {
    background: white;
    border-right: 1px solid #e0e0e0;
    height: 100%;
    overflow-y: auto;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

/* Список чатов */
.chat-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.chat-item {
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-item:hover {
    background-color: #f8f9fa;
}

.chat-item.active {
    background-color: #e3f2fd;
    border-right: 3px solid #2196f3;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #2196f3;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

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

.chat-name {
    font-weight: 500;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-last-message {
    font-size: 0.875rem;
    color: #666;
    margin: 0.25rem 0 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-time {
    font-size: 0.75rem;
    color: #999;
}

.unread-badge {
    background: #2196f3;
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.75rem;
    min-width: 20px;
    text-align: center;
}

/* Область чата */
.chat-container {
    height: 100%;
    background: white;
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-title {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.online-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
}

.chat-actions {
    display: flex;
    gap: 0.5rem;
}

/* Область сообщений */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #fafafa;
}

.message {
    margin-bottom: 1rem;
    display: flex;
    gap: 0.75rem;
}

.message.own {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    flex-shrink: 0;
}

.message.own .message-avatar {
    background: #2196f3;
}

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

.message-bubble {
    background: white;
    padding: 0.75rem 1rem;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    position: relative;
}

.message.own .message-bubble {
    background: #2196f3;
    color: white;
}

.message-text {
    margin: 0;
    word-wrap: break-word;
}

.message-meta {
    font-size: 0.75rem;
    color: #999;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.message.own .message-meta {
    color: rgba(255,255,255,0.7);
    justify-content: flex-end;
}

.message-time {
    white-space: nowrap;
}

.message-status {
    font-size: 0.75rem;
}

.message-file {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0.75rem;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.message-file i {
    font-size: 1.25rem;
    color: #666;
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 500;
    margin: 0;
}

.file-size {
    font-size: 0.875rem;
    color: #666;
    margin: 0;
}

.message-image {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 0.5rem;
}

/* Форма отправки сообщений */
.message-form {
    padding: 1rem;
    border-top: 1px solid #e0e0e0;
    background: white;
}

.input-group {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.message-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 0.75rem 1rem;
    resize: none;
    font-family: inherit;
    max-height: 120px;
}

.message-input:focus {
    outline: none;
    border-color: #2196f3;
}

.file-upload-btn, .send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.file-upload-btn {
    background: #f5f5f5;
    color: #666;
}

.file-upload-btn:hover {
    background: #e0e0e0;
}

.send-btn {
    background: #2196f3;
    color: white;
}

.send-btn:hover {
    background: #1976d2;
}

.send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Пустое состояние */
.empty-chat {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #666;
}

.empty-chat i {
    font-size: 4rem;
    margin-bottom: 1rem;
    color: #ddd;
}

/* Уведомления */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.notification.show {
    transform: translateX(0);
}

.notification.success {
    background: #4caf50;
}

.notification.error {
    background: #f44336;
}

.notification.info {
    background: #2196f3;
}

/* Модальные окна */
.modal-backdrop {
    background-color: rgba(0,0,0,0.5);
}

/* Адаптивность */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: -100%;
        width: 100%;
        z-index: 1000;
        transition: left 0.3s ease;
    }
    
    .sidebar.show {
        left: 0;
    }
    
    .chat-container {
        width: 100%;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .header {
        position: relative;
    }
    
    .menu-toggle {
        display: block;
        background: none;
        border: none;
        color: white;
        font-size: 1.25rem;
        cursor: pointer;
    }
}

@media (min-width: 769px) {
    .menu-toggle {
        display: none;
    }
}

/* Скроллбары */
.messages-container::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.messages-container::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Анимации */
.message {
    animation: slideUp 0.3s ease;
}

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

.chat-item {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Состояние загрузки */
.loading {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2196f3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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