/* Custom styles for ChatGPT Clone */

/* CSS переменные для мобильных устройств */
:root {
    --vh: 1vh;
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-inset-top: env(safe-area-inset-top, 0px);
}

/* Basic elements */
html {
    font-size: 16px; /* Base font size */
}

/* Основные контейнеры */
html, body {
    height: 100%;
    margin: 0;
    /* Вертикальный скролл разрешён, горизонтальный ограничен в base.html */
}

body {
    display: flex;
    flex-direction: column;
    touch-action: manipulation; /* Improves touch experience */
}

/* Главный контейнер */
.flex.w-full.h-full {
    height: 100vh;
    overflow: hidden;
}

/* Fix for iOS vh issue */
@supports (-webkit-touch-callout: none) {
    .flex.w-full.h-full {
        height: calc(var(--vh, 1vh) * 100);
    }
}

/* Боковая панель */
/* Стили для управления сайдбаром */
#sidebar {
    transition: transform 0.3s ease-in-out, width 0.3s ease-in-out;
    z-index: 50;
}

#sidebar.hidden {
    transform: translateX(-100%);
    width: 0;
}

#chat-area {
    transition: margin-left 0.3s ease-in-out;
    position: relative;
}

#chat-area.sidebar-hidden {
    margin-left: 0;
}

/* Мобильные стили */
@media (max-width: 768px) {
    html {
        font-size: 14px; /* Slightly reduced font size on mobile */
    }

    body {
        overflow: auto;
    }

    #sidebar {
        position: fixed;
        z-index: 1000;
        height: 100vh !important;
        height: calc(var(--vh, 1vh) * 100) !important; /* Используем динамическую высоту */
        background-color: var(--bg-sidebar); /* Ensure sidebar has proper background */
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    }

    #mobile-header {
        display: flex !important;
        position: sticky;
        top: 0;
        z-index: 10;
        background-color: var(--bg-primary);
    }

    #chat-area {
        width: 100% !important;
        /* Добавляем запас снизу, чтобы ничего не уезжало под системные элементы */
        padding-bottom: clamp(96px, calc(70px + env(safe-area-inset-bottom, 0px)), 240px);
    }

    /* Input stays visible when scrolling */
    #input-container {
        position: fixed;
        bottom: 0;
        width: 100%;
        background-color: var(--bg-primary);
        z-index: 5;
        padding: 10px 10px clamp(28px, calc(10px + env(safe-area-inset-bottom, 0px)), 72px) 10px !important; /* учитываем safe-area, но без излишнего роста */
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    /* Ensure content doesn't get hidden behind fixed elements */
    #messages-container {
        margin-bottom: clamp(96px, calc(70px + env(safe-area-inset-bottom, 0px)), 240px); /* Match input container height + safe-area */
    }

    /* Better tap targets */
    button, .button, .interactive-element {
        min-height: 44px; /* Apple's recommended minimum tap target size */
        min-width: 44px;
    }

    /* Optimize lists for mobile */
    #conversations-list {
        padding: 0 8px;
    }
}

/* Extra small screens (phones) */
@media (max-width: 480px) {
    #sidebar {
        width: 85% !important;
        max-width: 300px;
    }

    /* Input area optimizations */
    #message-input {
        padding: 10px !important;
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
}

/* Исправляем проблему с двойной иконкой */
#mobile-header {
    display: none;
}

#sidebar.hidden ~ #chat-area #mobile-header {
    display: flex;
}

/* Контейнер для чатов в боковой панели */
#conversations-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* Контейнер сообщений */
#messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* Стили для чата */
#chat-area {
    height: 100vh;
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Fix for iOS vh issue */
@supports (-webkit-touch-callout: none) {
    #chat-area {
        height: calc(var(--vh, 1vh) * 100);
    }
}

.sidebar-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 4px;
    transition: background-color 0.2s;
}

.sidebar-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.sidebar-item:hover .delete-conversation {
    opacity: 1 !important;
}

.sidebar-item.active {
    background-color: rgba(255, 255, 255, 0.1);
}

.delete-conversation {
    transition: opacity 0.2s;
}

/* Custom scrollbar styles */
::-webkit-scrollbar {
    width: 6px;
}

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

::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Animation utilities */
.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.delay-150 {
    animation-delay: 150ms;
}

.delay-300 {
    animation-delay: 300ms;
}

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

/* Ensure textarea grows with content but has a max height */
#message-input {
    min-height: 44px;
    max-height: 200px;
    overflow-y: auto;
}

/* Input container should be fixed at bottom */
#input-container {
    flex-shrink: 0;
}

/* Responsive styles */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        z-index: 50;
        height: 100vh !important;
        transform: translateX(0);
        transition: transform 0.3s ease-in-out;
    }

    #sidebar.hidden {
        transform: translateX(-100%);
    }

    .delete-conversation {
        opacity: 1 !important;
    }

    /* Make buttons and links easier to tap on mobile */
    a, button {
        padding: 8px !important;
    }

    /* Improve readability */
    p, li, div {
        line-height: 1.5 !important;
    }
}

/* Стиль для усечения длинных названий чатов в сайдбаре */
.truncate {
    max-width: 165px; /* Или другое подходящее значение */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
}

/* При наведении показывать полное название как подсказку */
.sidebar-item:hover .truncate {
    position: relative;
}

.sidebar-item:hover .truncate:after {
    content: attr(title);
    position: absolute;
    left: 0;
    top: 100%;
    z-index: 10;
    background: rgba(40, 40, 40, 0.9);
    color: white;
    padding: 5px;
    border-radius: 3px;
    white-space: nowrap;
    visibility: hidden;
}

.sidebar-item:hover .truncate:hover:after {
    visibility: visible;
}

/* Mobile tooltip optimization */
@media (max-width: 768px) {
    .sidebar-item:hover .truncate:after {
        display: none; /* Hide tooltips on mobile */
    }
}

/* Стили для уведомления о выборе ассистента */
#assistant-notification {
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.3);
    z-index: 1050;
}

@keyframes slideDown {
    0% {
        transform: translateY(-100%);
    }
    100% {
        transform: translateY(0);
    }
}

.animate-slideDown {
    animation: slideDown 0.3s ease-out forwards;
}

/* Дополнительные стили для мобильной версии уведомления */
@media (max-width: 768px) {
    #assistant-notification {
        font-size: 0.9rem;
    }
    
    #assistant-notification .container {
        padding: 0 12px;
    }
}

/* Стили для информационного баннера ассистента */
.assistant-info-banner {
    background-color: rgba(30, 32, 35, 0.7);
    border: 1px solid rgba(75, 85, 99, 0.5);
    border-radius: 8px;
    margin: 0.5rem 0 1rem;
    transition: all 0.3s ease;
}

.assistant-info-banner:hover {
    background-color: rgba(35, 38, 42, 0.8);
    border-color: rgba(75, 85, 99, 0.7);
}

/* Стили для элементов ассистентов в сайдбаре */
.sidebar-item.assistant-item {
    position: relative;
    transition: all 0.2s ease;
}

.sidebar-item.assistant-item:hover {
    transform: translateX(2px);
}

.sidebar-item.assistant-item.border-l-2 {
    border-left-color: #8e44ad;
}

/* Стили для выпадающего списка ассистентов */
.assistants-dropdown {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
    margin-top: 4px;
    background-color: transparent !important; /* Прозрачный фон как у других элементов */
    border-radius: 8px;
    border: none !important; /* Убираем границу для единого стиля */
    width: 100%; /* Полная ширина */
    margin-left: 0; /* Убираем отступы по бокам */
    margin-right: 0;
    box-shadow: none !important; /* Убираем тень для единого стиля */
}

.assistants-dropdown.expanded {
    max-height: 300px; /* Увеличиваем высоту */
    overflow-y: auto;
    padding: 8px 0;
}

.assistants-dropdown.expanded::-webkit-scrollbar {
    width: 4px;
}

.assistants-dropdown.expanded::-webkit-scrollbar-track {
    background: transparent;
}

.assistants-dropdown.expanded::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.assistants-dropdown.expanded::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Анимация поворота стрелки */
#assistants-toggle-icon.rotated {
    transform: rotate(180deg);
}

/* Стили для заголовка ассистентов */
#assistants-header {
    border-radius: 6px;
    margin-bottom: 0;
    transition: all 0.2s ease;
    background-color: transparent !important; /* Прозрачный фон как у других элементов */
    border: none !important; /* Убираем границу для единого стиля */
}

#assistants-header:hover {
    background-color: rgba(255, 255, 255, 0.1) !important; /* Стандартный hover как у других элементов */
}

/* Стили для заголовка ассистентов когда список открыт */
.assistants-dropdown.expanded + #assistants-header,
#assistants-header.expanded {
    background-color: transparent !important; /* Прозрачный фон как у других элементов */
    border-radius: 6px !important; /* Сохраняем скругленные углы */
    margin: 0 !important; /* Стандартные отступы */
    padding: 12px 16px !important;
    font-size: 14px !important;
    border: none !important; /* Убираем границу */
    width: 100% !important; /* Полная ширина */
}

/* Стили для кнопки переключения ассистентов когда список открыт */
#assistants-header.expanded #assistants-toggle-icon {
    background-color: transparent !important; /* Прозрачный фон */
    border: none !important; /* Убираем границу */
    border-radius: 4px !important;
    padding: 4px !important;
}

#assistants-header.expanded #assistants-toggle-icon:hover {
    background-color: rgba(255, 255, 255, 0.1) !important; /* Стандартный hover */
}

#assistants-header.expanded:hover {
    background-color: rgba(255, 255, 255, 0.1) !important; /* Стандартный hover */
    transform: none !important; /* Убираем трансформацию */
}

/* Стили для элементов в выпадающем списке ассистентов */
.assistants-dropdown .sidebar-item {
    padding: 12px 16px !important; /* Стандартные отступы */
    font-size: 14px !important; /* Стандартный размер шрифта */
    margin: 2px 0 !important; /* Стандартные отступы */
    border-radius: 6px !important; /* Стандартные скругленные углы */
    background-color: transparent !important; /* Прозрачный фон как у других элементов */
    transition: all 0.2s ease !important;
    width: 100% !important; /* Полная ширина */
}

.assistants-dropdown .sidebar-item:hover {
    background-color: rgba(255, 255, 255, 0.1) !important; /* Стандартный hover */
    transform: none !important; /* Убираем трансформацию */
}

/* Светлая тема для выпадающего списка ассистентов */
[data-theme="light"] .assistants-dropdown {
    background-color: transparent !important; /* Прозрачный фон */
    border: none !important; /* Убираем границу */
    box-shadow: none !important; /* Убираем тень */
}

[data-theme="light"] .assistants-dropdown .sidebar-item {
    background-color: transparent !important; /* Прозрачный фон */
}

[data-theme="light"] .assistants-dropdown .sidebar-item:hover {
    background-color: rgba(0, 0, 0, 0.05) !important; /* Стандартный hover для светлой темы */
}

/* Светлая тема для заголовка ассистентов когда список открыт */
[data-theme="light"] #assistants-header.expanded {
    background-color: transparent !important; /* Прозрачный фон */
    border: none !important; /* Убираем границу */
}

[data-theme="light"] #assistants-header.expanded:hover {
    background-color: rgba(0, 0, 0, 0.05) !important; /* Стандартный hover для светлой темы */
}

/* Светлая тема для кнопки переключения ассистентов когда список открыт */
[data-theme="light"] #assistants-header.expanded #assistants-toggle-icon {
    background-color: transparent !important; /* Прозрачный фон */
    border: none !important; /* Убираем границу */
}

[data-theme="light"] #assistants-header.expanded #assistants-toggle-icon:hover {
    background-color: rgba(0, 0, 0, 0.05) !important; /* Стандартный hover для светлой темы */
}

/* Мобильные стили для выпадающего списка ассистентов */
@media (max-width: 768px) {
    .assistants-dropdown.expanded {
        max-height: 250px; /* Увеличиваем высоту на мобильных */
        margin: 4px 0 0 0; /* Стандартные отступы */
        width: 100% !important; /* Полная ширина на мобильных */
    }
    
    #assistants-header {
        padding: 12px 16px; /* Стандартные отступы заголовка */
        margin: 0; /* Стандартные отступы */
    }
    
    .assistants-dropdown .sidebar-item {
        padding: 14px 16px !important; /* Увеличенные отступы на мобильных */
        font-size: 15px !important; /* Увеличенный шрифт на мобильных */
        margin: 3px 0 !important; /* Стандартные отступы */
        width: 100% !important; /* Полная ширина на мобильных */
    }
}

/* Стили для кнопок меню (гамбургер) - возвращаем как было */

#toggle-sidebar:hover,
#mobile-toggle-sidebar:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
}

/* Стили для уведомлений */
#notifications-bell {
    position: relative;
    z-index: 1002; /* Выше чем dropdown */
}

/* Контейнер для колокольчика уведомлений */
#notifications-bell {
    position: relative;
    z-index: 1002;
}

/* Убеждаемся что dropdown уведомлений не обрезается */
#notifications-dropdown {
    position: fixed !important; /* Fixed позиционирование для десктопа (как в мобильной версии) */
    top: auto !important; /* Будет установлено через JavaScript */
    left: auto !important; /* Будет установлено через JavaScript */
    right: auto !important; /* Будет установлено через JavaScript */
    z-index: 1001 !important;
    width: 320px !important; /* Фиксированная ширина для десктопа */
}

#notification-badge {
    font-size: 10px;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    line-height: 1;
    z-index: 1003; /* Выше чем кнопка колокольчика */
}

/* Стили для dropdown уведомлений уже определены выше */

/* Светлая тема для уведомлений */
[data-theme="light"] #notifications-dropdown {
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] #notifications-dropdown .p-3 {
    border-bottom-color: #e5e7eb;
}

[data-theme="light"] #notifications-dropdown h3 {
    color: #374151;
}

[data-theme="light"] .notification-item {
    border-bottom-color: #f3f4f6;
}

[data-theme="light"] .notification-item:hover {
    background-color: #f9fafb;
}

[data-theme="light"] .notification-user-name {
    color: #111827;
}

[data-theme="light"] .notification-message {
    color: #6b7280;
}

[data-theme="light"] .notification-time {
    color: #9ca3af;
}

[data-theme="light"] .notification-unread-badge {
    background-color: #dc2626;
    color: white;
}

[data-theme="light"] .notification-attachment {
    color: #7c3aed;
}

[data-theme="light"] #notifications-bell:hover {
    background-color: #f3f4f6;
}

[data-theme="light"] #notifications-bell i {
    color: #6b7280;
}

[data-theme="light"] #notification-badge {
    background-color: #dc2626;
    color: white;
}

.notification-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.notification-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.notification-item:last-child {
    border-bottom: none;
}

/* Аватарки уведомлений удалены */

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-user-name {
    font-weight: 600;
    color: #f3f4f6;
    font-size: 14px;
    margin-bottom: 2px;
}

.notification-message {
    color: #9ca3af;
    font-size: 13px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.notification-time {
    color: #6b7280;
    font-size: 11px;
    margin-top: 4px;
}

.notification-unread-badge {
    background-color: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 8px;
    flex-shrink: 0;
}

.notification-attachment {
    display: inline-flex;
    align-items: center;
    color: #8b5cf6;
    font-size: 12px;
    margin-top: 2px;
}

.notification-attachment i {
    margin-right: 4px;
}

/* Анимация для появления уведомлений */
@keyframes notificationSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.notification-item.new {
    animation: notificationSlideIn 0.3s ease-out;
}

/* Анимация для светлой темы */
[data-theme="light"] .notification-item.new {
    animation: notificationSlideIn 0.3s ease-out;
}

/* Мобильные стили для уведомлений */
@media (max-width: 768px) {
    #notifications-dropdown {
        width: 100% !important; /* Полная ширина экрана */
        /* Fixed позиционирование для мобильных */
        position: fixed !important;
        top: 60px !important;
        left: 0 !important; /* Прижимаем к левому краю */
        right: 0 !important; /* Прижимаем к правому краю */
        margin: 0 !important; /* Убираем центрирование */
        /* Увеличиваем z-index для мобильных - должен быть выше сайдбара */
        z-index: 1001 !important;
    }
    
    .notification-item {
        padding: 10px 12px;
    }
    
    /* Аватарки уведомлений удалены */
    
    .notification-user-name {
        font-size: 13px;
    }
    
    .notification-message {
        font-size: 12px;
    }
    
    /* Светлая тема для мобильных уведомлений */
    [data-theme="light"] #notifications-dropdown {
        background-color: #ffffff;
        border: 1px solid #e5e7eb;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    }
}

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

.assistant-indicator {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: #8e44ad;
    border-radius: 2px;
    animation: pulse 2s ease-in-out infinite;
}

.assistant-indicator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 6px;
    height: 6px;
    background-color: #8e44ad;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

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

#empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 1rem;
    text-align: center;
    color: #a0aec0;
}

#empty-state h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

/* Address landscape mode for mobile specifically */
@media (max-width: 768px) and (orientation: landscape) {
    #sidebar {
        width: 40% !important;
    }

    #input-container {
        position: sticky;
        bottom: 0;
        max-height: 80px;
    }

    #messages-container {
        max-height: calc(100vh - 110px);
    }
}

/* Стили для длинных сообщений пользователя */
.user-message {
    word-break: break-word;
    overflow-wrap: break-word;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 4px;
}

.user-message::-webkit-scrollbar {
    width: 4px;
}

.user-message::-webkit-scrollbar-track {
    background: transparent;
}

.user-message::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

/* Стили для блоков кода и кнопки копирования */
.code-block-wrapper {
    position: relative;
    margin: 1rem 0;
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background-color: #0d1117;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.45rem 0.75rem;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.code-lang-label {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: #8b949e;
    text-transform: lowercase;
    user-select: none;
}

.code-block-body {
    overflow-x: auto;
}

.code-block-body pre {
    margin: 0;
    padding: 0.875rem 1rem 1rem;
    background: transparent;
    overflow: visible;
}

.code-block-wrapper code,
.code-block-body code {
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 0.8125rem;
    line-height: 1.6;
    white-space: pre;
    background: transparent !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

.code-block-wrapper .hljs {
    background: transparent !important;
    padding: 0;
}

.code-copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    background: #f8fafc !important;
    color: #0f172a !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 0.45rem;
    padding: 0.32rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
}

.code-copy-btn i {
    font-size: 0.85rem;
    color: #475569 !important;
}

.code-copy-btn:hover {
    background: #ffffff !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.1);
}

.code-copy-btn:hover i {
    color: #0f172a !important;
}

.code-copy-btn--success {
    background: #dcfce7 !important;
    color: #166534 !important;
    border-color: #86efac !important;
}

.code-copy-btn--success i {
    color: #166534 !important;
}

.markdown-content.formatted code:not(pre code) {
    background-color: rgba(110, 118, 129, 0.2);
    color: #e6edf3;
    padding: 0.15rem 0.4rem;
    border-radius: 0.35rem;
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 0.84em;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.markdown-content.formatted a {
    color: #58a6ff;
    text-decoration: none;
}

.markdown-content.formatted a:hover {
    text-decoration: underline;
}

.markdown-content.formatted blockquote {
    margin: 0.75rem 0;
    padding: 0.35rem 0 0.35rem 0.9rem;
    border-left: 3px solid rgba(255, 255, 255, 0.18);
    color: #c9d1d9;
}

.markdown-content.formatted hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 1rem 0;
}

/* Стили для отформатированного markdown контента */
.markdown-content.formatted {
    white-space: normal !important;
}

.markdown-content.formatted p {
    margin-bottom: 0.75rem; /* Уменьшено с 1rem */
    margin-top: 0;
    line-height: 1.5; /* Уменьшено с 1.6 */
}

.markdown-content.formatted p:last-child {
    margin-bottom: 0;
}

.markdown-content.formatted h1,
.markdown-content.formatted h2,
.markdown-content.formatted h3,
.markdown-content.formatted h4,
.markdown-content.formatted h5,
.markdown-content.formatted h6 {
    margin-top: 1rem; /* Уменьшено с 1.5rem */
    margin-bottom: 0.25rem; /* Уменьшено с 0.5rem */
    line-height: 1.3; /* Уменьшено с 1.4 */
}

.markdown-content.formatted h1:first-child,
.markdown-content.formatted h2:first-child,
.markdown-content.formatted h3:first-child,
.markdown-content.formatted h4:first-child,
.markdown-content.formatted h5:first-child,
.markdown-content.formatted h6:first-child {
    margin-top: 0;
}

.markdown-content.formatted ul,
.markdown-content.formatted ol {
    margin-bottom: 0.75rem; /* Уменьшено с 1rem */
    margin-top: 0;
    padding-left: 1.25rem; /* Уменьшено с 1.5rem */
}

.markdown-content.formatted li {
    margin-bottom: 0.125rem; /* Уменьшено с 0.25rem */
}

.markdown-content.formatted strong {
    font-weight: 600;
}

.markdown-content.formatted em {
    font-style: italic;
}

.markdown-content.formatted code {
    background-color: rgba(110, 118, 129, 0.2);
    padding: 0.15rem 0.4rem;
    border-radius: 0.35rem;
    font-size: 0.84em;
}

.code-block-wrapper pre {
    margin: 0;
}

.code-block-wrapper code {
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 0.8125rem;
    line-height: 1.6;
    white-space: pre;
}

/* Legacy selectors kept for compatibility */
.code-copy-btn {
    position: static;
    opacity: 1;
    box-shadow: none;
    min-width: auto;
    min-height: auto;
}

.code-block-wrapper:hover .code-copy-btn {
    opacity: 1;
}

.code-copy-btn:active {
    transform: none;
}

/* Стили для языков программирования — подсветка через highlight.js */
.language-python, .language-py,
.language-javascript, .language-js,
.language-html, .language-css {
    color: inherit;
}

/* Дополнительные стили для блоков кода в светлой теме */
[data-theme="light"] .code-block-wrapper {
    background-color: #0d1117;
    border-color: #cbd5e1;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .code-block-header {
    background: #161b22;
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .code-block-wrapper pre,
[data-theme="light"] .code-block-wrapper code {
    color: inherit;
}

[data-theme="light"] .code-copy-btn,
[data-theme="dark"] .code-copy-btn {
    background: #f8fafc !important;
    border-color: #e2e8f0 !important;
    color: #0f172a !important;
}

[data-theme="light"] .code-copy-btn:hover,
[data-theme="dark"] .code-copy-btn:hover {
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
}

[data-theme="light"] .code-copy-btn--success,
[data-theme="dark"] .code-copy-btn--success {
    background: #dcfce7 !important;
    color: #166534 !important;
    border-color: #86efac !important;
}

/* Кнопки действий под сообщениями ассистента */
.chat-message-actions {
    flex-wrap: wrap;
}

.chat-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 2rem;
    padding: 0.4rem 0.65rem;
    border-radius: 0.55rem;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-tertiary);
    font-size: 0.75rem;
    line-height: 1;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
}

.chat-action-btn i {
    font-size: 0.95rem;
    line-height: 1;
}

.chat-action-btn--icon {
    min-width: 2rem;
    padding: 0.4rem;
}

.chat-action-btn:hover {
    background: var(--button-hover);
    color: var(--text-primary);
}

.chat-action-btn:disabled,
.chat-action-btn.opacity-50 {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-rating-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-right: 0.15rem;
}

[data-theme="dark"] .chat-message-actions .chat-action-btn {
    color: #a1a1aa;
}

[data-theme="dark"] .chat-message-actions .chat-action-btn:hover {
    background: #3f3f46;
    color: #ffffff;
}

[data-theme="light"] .chat-message-actions .chat-action-btn {
    background: #ffffff;
    border-color: #e2e8f0;
    color: #64748b;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

[data-theme="light"] .chat-message-actions .chat-action-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
}

[data-theme="light"] .chat-rating-label {
    color: #94a3b8;
}

[data-theme="light"] .markdown-content.formatted code:not(pre code) {
    background-color: #eef2f7 !important;
    color: #0f172a !important;
    border: 1px solid #cbd5e1 !important;
}

[data-theme="light"] .markdown-content.formatted a {
    color: #2563eb;
}

[data-theme="light"] .markdown-content.formatted blockquote {
    border-left-color: #cbd5e1;
    color: #475569;
}

[data-theme="light"] .markdown-content.formatted hr {
    border-top-color: rgba(15, 23, 42, 0.1);
}


/* Переопределяем старые стили для приоритета компактности */
.markdown-content.formatted h1,
.markdown-content.formatted h2,
.markdown-content.formatted h3,
.markdown-content.formatted h4,
.markdown-content.formatted h5,
.markdown-content.formatted h6 {
    margin-top: 0.75rem !important; /* Принудительно компактно */
    margin-bottom: 0.15rem !important; /* Принудительно компактно */
    line-height: 1.25 !important; /* Компактнее */
    padding: 0 !important; /* Убираем padding */
    border: none !important; /* Убираем границы */
}

.markdown-content.formatted p {
    margin-bottom: 0.5rem !important; /* Еще компактнее */
    margin-top: 0 !important;
    line-height: 1.4 !important; 
}

/* Убираем лишние отступы у inline кода */
.markdown-content.formatted code:not(.code-block-wrapper code) {
    background-color: rgba(55, 65, 81, 0.3); /* Еще меньше выделения */
    padding: 0.05rem 0.15rem; /* Минимальные отступы */
    border-radius: 0.15rem;
    font-size: 0.8rem;
    border: none; /* Убираем любые границы */
    box-shadow: none; /* Убираем тени */
}

/* Убираем лишние контуры у всех markdown элементов */
.markdown-content.formatted * {
    outline: none !important;
    box-shadow: none !important;
}

/* Более компактные стили для списков */
.markdown-content.formatted ul,
.markdown-content.formatted ol {
    margin-bottom: 0.5rem; /* Еще меньше */
    margin-top: 0;
    padding-left: 1rem; /* Еще меньше отступ */
}

.markdown-content.formatted li {
    margin-bottom: 0.1rem; /* Минимальные отступы */
    padding: 0;
}

/* ===== Desktop sidebar structure ===== */
@media (min-width: 769px) {
    /* Общая колонка в сайдбаре */
    #sidebar { display: flex; flex-direction: column; }
    .mobile-sidebar-content { display: flex !important; flex-direction: column !important; height: 100vh; overflow: hidden; }

    /* Список чатов — единственный скроллируемый участок в сайдбаре */
    #sidebar-chats-container { flex: 1; overflow-y: auto; }

    /* Нижняя панель ассистентов и профиля — всегда на уровне низа */
    #sidebar-bottom-bar { position: sticky; bottom: 0; z-index: 2; background: var(--bg-sidebar); }
    #sidebar-assistants-container, #sidebar-profile-container { width: 100%; }
}