/* Messages Section */
.messages-section {
    padding: 3rem 5%;
    background: white;
    border-top: 1px solid #eee;
}

.messages-container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.messages-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
    padding: 1.5rem 2rem;
    background: var(--primary);
    color: white;
}

.messages-header .section-title {
    color: white;
    margin-bottom: 0;
}

.chat-container {
    display: flex;
    height: 600px;
}

.dialogs-sidebar {
    width: 350px;
    border-right: 1px solid #eee;
    background: #fafafa;
    display: flex;
    flex-direction: column;
}

.dialogs-search {
    padding: 1rem;
    border-bottom: 1px solid #eee;
}

.search-input {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 0.9rem;
}

.dialogs-list {
    flex: 1;
    overflow-y: auto;
}

.dialog-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.3s;
    position: relative;
}

.dialog-item:hover {
    background: #f0f0f0;
}

.dialog-item.active {
    background: var(--secondary);
    color: white;
}

.dialog-item.active .dialog-preview,
.dialog-item.active .dialog-time {
    color: rgba(255,255,255,0.8);
}

.dialog-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    margin-right: 1rem;
    flex-shrink: 0;
}

.dialog-content {
    flex: 1;
    min-width: 0;
}

.dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
}

.dialog-name {
    font-weight: bold;
    font-size: 0.95rem;
}

.dialog-time {
    font-size: 0.8rem;
    color: #999;
}

.dialog-preview {
    font-size: 0.85rem;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background: var(--accent);
    color: white;
    border-radius: 10px;
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
    margin-left: auto;
}

.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

.chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.chat-user-info {
    flex: 1;
}

.chat-user-name {
    font-weight: bold;
    margin-bottom: 0.2rem;
}

.chat-user-status {
    font-size: 0.8rem;
    color: var(--success);
}

.chat-actions {
    display: flex;
    gap: 1rem;
}

.chat-action-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 1.1rem;
}

.messages-area {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    max-width: 70%;
    padding: 0.8rem 1rem;
    border-radius: 15px;
    position: relative;
    animation: messageAppear 0.3s ease;
}

@keyframes messageAppear {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.incoming {
    align-self: flex-start;
    background: white;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 5px;
}

.message.outgoing {
    align-self: flex-end;
    background: var(--secondary);
    color: white;
    border-bottom-right-radius: 5px;
}

.message-text {
    margin-bottom: 0.5rem;
}

.message-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.message-image {
    width: 100px;
    height: 100px;
    border-radius: 8px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.3s;
}

.message-image:hover {
    transform: scale(1.05);
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.7;
    text-align: right;
}

.message.incoming .message-time {
    text-align: left;
}

.message-input-area {
    padding: 1rem 1.5rem;
    border-top: 1px solid #eee;
    background: white;
}

.attachments-preview {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.attachment-preview {
    position: relative;
    width: 60px;
    height: 60px;
}

.attachment-image {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    object-fit: cover;
}

.remove-attachment {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
    cursor: pointer;
}

.input-container {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.file-input-wrapper {
    position: relative;
}

.file-input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.attach-btn {
    background: none;
    border: none;
    color: #666;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
}

.message-input {
    flex: 1;
    padding: 0.8rem 1rem;
    border: 1px solid #ddd;
    border-radius: 20px;
    resize: none;
    font-family: inherit;
    font-size: 0.9rem;
    max-height: 120px;
}

.send-btn {
    background: var(--secondary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Чат сообщения стили */
.message.incoming .message-time {
    text-align: left;
}