/* Подключение шрифтов */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');
/* Общие настройки */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #8b5cf6;
    --background-light: #f4f4f4;
    --background-white: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-light: #e2e8f0;
    --border-focus: #c7d2fe;
    --success-color: #10b981;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --font-primary: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    /* font-family: 'Tinos', serif; */
    font-family: var(--font-primary);
    background-color: var(--background-light);
    min-height: 100vh;
    color: var(--text-primary);
}

/* Компактная навигация встроенная в чат */
.chat-nav {
    background: var(--background-white);
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: relative;
    z-index: 100;
}

.chat-nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.chat-nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 18px;
    color: var(--text-primary);
    text-decoration: none;
}

.chat-nav-logo img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

.chat-nav-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-nav-search {
    position: relative;
}

.chat-nav-search input {
    padding: 8px 12px 8px 35px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 14px;
    width: 200px;
    transition: all 0.3s ease;
    background: var(--background-light);
    font-family: 'Tinos', serif;
}

.chat-nav-search input:focus {
    width: 250px;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    outline: none;
}

.chat-nav-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
}

.chat-nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-nav-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--background-white);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.3s ease;
    font-family: 'Tinos', serif;
    cursor: pointer;
}

.chat-nav-btn:hover {
    background: var(--background-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.chat-nav-btn.primary {
    background: var(--gradient-primary);
    color: white;
    border: none;
}

.chat-nav-btn.primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.chat-nav-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.chat-nav-user:hover {
    background: var(--background-light);
}

.chat-nav-user img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-nav-user-info {
    display: flex;
    flex-direction: column;
}

.chat-nav-user-name {
    font-weight: 600;
    font-size: 14px;
}

.chat-nav-user-status {
    font-size: 12px;
    color: var(--success-color);
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--background-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    padding: 8px;
    display: none;
    z-index: 1000;
}

.chat-nav-user:hover .user-dropdown {
    display: block;
}

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    text-decoration: none;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
    font-size: 14px;
}

.user-dropdown a:hover {
    background: var(--background-light);
    color: var(--primary-color);
}

.user-dropdown a i {
    width: 16px;
    text-align: center;
}

/* Основной контейнер чата */
main {
    height: calc(100vh - 60px);
    display: flex;
    background: var(--background-white);
    position: relative;
}

/* Левая панель - список чатов */
.sidebar {
    width: 380px;
    background: var(--background-white);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    position: relative;
}

.sidebar-header {
    padding: 20px 24px;
    font-size: 20px;
    font-weight: 700;
    background: var(--background-white);
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.sidebar-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--background-white);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.sidebar-btn:hover {
    background: var(--background-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.chats {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-item {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 4px;
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
}

.chat-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.1), transparent);
    transition: left 0.6s;
}

.chat-item:hover::before {
    left: 100%;
}

.chat-item:hover {
    background: var(--background-light);
    border-color: var(--border-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.chat-item.active {
    background: linear-gradient(135deg, #f0f4ff 0%, #e0e7ff 100%);
    border-color: var(--border-focus);
    box-shadow: var(--shadow-md);
}

.chat-item.pinned {
    border-left: 4px solid var(--primary-color);
    background: linear-gradient(135deg, #f8faff 0%, #f0f4ff 100%);
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 16px;
    margin-right: 12px;
}

.chat-item-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.chat-name {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-item.pinned .chat-name::before {
    content: '📌';
    font-size: 12px;
}

.chat-time {
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.chat-last-message {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-unread {
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    margin-left: auto;
}

/* Правая панель - переписка */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--background-light);
    position: relative;
}

.chat-header {
    padding: 16px 32px;
    background: var(--background-white);
    border-bottom: 1px solid var(--border-light);
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 10;
}

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

.chat-header-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: normal;
}

.chat-header-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--success-color);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-messages {
    flex: 1;
    padding: 24px 32px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--background-light);
}

.message {
    max-width: 65%;
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    line-height: 1.5;
    font-size: 15px;
    word-wrap: break-word;
    position: relative;
    animation: messageAppear 0.3s ease-out;
    box-shadow: var(--shadow-sm);
}

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

.message.user {
    align-self: flex-end;
    background: var(--gradient-primary);
    color: white;
    border-bottom-right-radius: var(--radius-sm);
}

.message.other {
    align-self: flex-start;
    background: var(--background-white);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-bottom-left-radius: var(--radius-sm);
}

/* Поле ввода */
.chat-input {
    display: flex;
    padding: 16px 32px;
    background: var(--background-white);
    border-top: 1px solid var(--border-light);
    gap: 12px;
    position: relative;
}

.chat-input-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-input-tool {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--background-white);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    color: var(--text-secondary);
}

.chat-input-tool:hover {
    background: var(--background-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.chat-input input {
    flex: 1;
    padding: 14px 18px;
    font-size: 15px;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    outline: none;
    font-family: 'Tinos', serif;
    background: var(--background-white);
    transition: all 0.3s ease;
}

.chat-input input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.chat-input button {
    padding: 14px 24px;
    font-size: 14px;
    background: var(--gradient-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Tinos', serif;
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-input button:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.chat-input button:active {
    transform: translateY(0);
}

/* Кастомный скроллбар */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Индикатор печати */
.typing-indicator {
    display: none;
    padding: 10px 18px;
    background: var(--background-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    font-family: var(--font-mono);
    align-self: flex-start;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 8px;
    align-items: center;
    gap: 8px;
}

.typing-indicator.visible {
    display: flex;
    animation: typingPulse 1.5s infinite;
}

@keyframes typingPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

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

.typing-dot {
    width: 4px;
    height: 4px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingDot {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Время сообщения */
.message-time {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 4px;
    text-align: right;
    font-family: var(--font-mono);
}

.message.other .message-time {
    color: var(--text-muted);
    text-align: left;
}

/* Адаптивность */
@media (max-width: 1024px) {
    .sidebar {
        width: 320px;
    }
    
    .message {
        max-width: 75%;
    }
    
    .chat-nav-search input {
        width: 150px;
    }
    
    .chat-nav-search input:focus {
        width: 200px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: absolute;
        z-index: 50;
        height: 100%;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .chat-area {
        width: 100%;
    }
    
    .chat-nav-search {
        display: none;
    }
    
    .chat-messages {
        padding: 16px 20px;
    }
    
    .chat-input {
        padding: 12px 20px;
    }
    
    .chat-header {
        padding: 12px 20px;
    }
    
    .message {
        max-width: 85%;
    }
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }
}