:root {
    --primary-color: #4e73df;
    --secondary-color: #858796;
    --success-color: #1cc88a;
    --danger-color: #e74a3b;
    --warning-color: #f6c23e;
    --info-color: #36b9cc;
    --light-color: #f8f9fc;
    --dark-color: #5a5c69;
    --gray-100: #f8f9fc;
    --gray-200: #eaecf4;
    --gray-300: #dddfeb;
    --gray-400: #b7b9cc;
    --gray-500: #858796;
    --gray-600: #6e707e;
    --gray-700: #5a5c69;
    --gray-800: #3a3b45;
    --gray-900: #2e2f38;
    --white: #fff;
    --black: #000;
    --border-radius: 0.35rem;
    --box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
    --transition: all 0.2s ease-in-out;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f8f9fc;
    color: #5a5c69;
    overflow-x: hidden;
}

.chat-app {
    display: flex;
    min-height: 100vh;
    background-color: #f8f9fc;
}

/* Левая панель - контакты */
.chat-sidebar {
    width: 320px;
    background-color: #fff;
    border-right: 1px solid #dddfeb;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    box-shadow: var(--box-shadow);
}

.sidebar-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #dddfeb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #fff;
}

.sidebar-search {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #dddfeb;
    background-color: #f8f9fc;
}

.contacts-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.contact-item {
    display: block;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    color: #5a5c69;
    border-bottom: 1px solid #eaecf4;
    transition: var(--transition);
}

.contact-item:hover {
    background-color: #f8f9fc;
    color: var(--primary-color);
}

.contact-item.active {
    background-color: #e9ecef;
    border-left: 3px solid var(--primary-color);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    display: inline-block;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #dddfeb;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar.online::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--success-color);
    border: 2px solid #fff;
}

.avatar-xl {
    width: 120px;
    height: 120px;
}

/* Центральная панель - чат */
.chat-main {
    flex-grow: 1;
    margin-left: 320px;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #dddfeb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.chat-messages {
    flex-grow: 1;
    padding: 1.5rem;
    overflow-y: auto;
    background-color: #f8f9fc;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-empty {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8f9fc;
}

.message {
    display: flex;
    gap: 0.75rem;
    max-width: 80%;
}

.message-left {
    justify-content: flex-start;
}

.message-right {
    justify-content: flex-end;
    flex-direction: row-reverse;
}

.message-content {
    flex-grow: 1;
}

.message-bubble {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    position: relative;
    max-width: 100%;
    word-wrap: break-word;
}

.message-left .message-bubble {
    border-radius: 0.5rem 0.5rem 0.5rem 0;
    background-color: #fff;
    border: 1px solid #dddfeb;
}

.message-right .message-bubble {
    border-radius: 0.5rem 0.5rem 0 0.5rem;
}

.message-time {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: #858796;
}

.chat-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #dddfeb;
    background-color: #fff;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.05);
}

/* Правая панель - информация о контакте */
.chat-sidebar-right {
    width: 300px;
    background-color: #fff;
    border-left: 1px solid #dddfeb;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    right: -300px;
    top: 0;
    z-index: 999;
    transition: var(--transition);
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
}

.chat-sidebar-right.show {
    right: 0;
}

.contact-profile {
    padding: 1.5rem;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.5rem;
}

/* Адаптивность */
@media (max-width: 992px) {
    .chat-sidebar {
        width: 280px;
    }
    .chat-main {
        margin-left: 280px;
    }
}

@media (max-width: 768px) {
    .chat-sidebar {
        width: 100%;
        height: auto;
        position: relative;
        box-shadow: none;
        border-bottom: 1px solid #dddfeb;
    }
    .chat-main {
        margin-left: 0;
    }
    .chat-sidebar-right {
        width: 100%;
        height: auto;
        position: relative;
        right: 0;
        box-shadow: none;
        border-top: 1px solid #dddfeb;
        display: none;
    }
    .chat-sidebar-right.show {
        display: flex;
    }
}

/* Дополнительные стили */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.25);
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #3a5ecf;
    border-color: #3a5ecf;
}

.text-success {
    color: var(--success-color) !important;
}

.text-danger {
    color: var(--danger-color) !important;
}

.bg-primary {
    background-color: var(--primary-color) !important;
}

.bg-light {
    background-color: var(--gray-100) !important;
}

.border-bottom {
    border-bottom: 1px solid #dddfeb !important;
}

.shadow-sm {
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075) !important;
}

/* Всплывающие уведомления */
.toast {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    max-width: 350px;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-body {
    padding: 1rem;
}

/* Анимации */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.3s ease forwards;
}

/* Кастомные скроллбары */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c5c6c8;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a9ab;
}