/* === ОБНОВЛЕННАЯ ТЕМНАЯ СЕРАЯ ЦВЕТОВАЯ СХЕМА === */
:root {
    /* НОВАЯ СЕРАЯ ЦВЕТОВАЯ ПАЛИТРА */
    --primary-color: #4a5568;
    --primary-dark: #2d3748;
    --primary-light: #718096;
    --secondary-color: #a0aec0;
    --success-color: #38a169;
    --danger-color: #f56565;
    --warning-color: #ed8936;
    --info-color: #4299e1;
    
    /* Градиенты на серых тонах */
    --gradient-primary: linear-gradient(135deg, #4a5568, #2d3748);
    --gradient-success: linear-gradient(135deg, #38a169, #2f855a);
    --gradient-danger: linear-gradient(135deg, #f56565, #c53030);
    --gradient-dark: linear-gradient(135deg, #1a202c, #171923);
    
    /* Фоновые цвета с эффектом стекла */
    --bg-primary: #0f1419;
    --bg-secondary: rgba(45, 55, 72, 0.8);
    --bg-tertiary: rgba(74, 85, 104, 0.6);
    --bg-glass: rgba(255, 255, 255, 0.05);
    --bg-glass-dark: rgba(0, 0, 0, 0.3);
    
    /* Текстовые цвета */
    --text-primary: #e2e8f0;
    --text-secondary: #cbd5e0;
    --text-light: #ffffff;
    --text-muted: #a0aec0;
    
    /* Границы и тени */
    --border-color: rgba(74, 85, 104, 0.3);
    --border-glow: 0 0 20px rgba(74, 85, 104, 0.3);
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;
    
    /* Тени с эффектом глубины */
    --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(74, 85, 104, 0.4);
    
    /* Размеры */
    --header-height: 70px;
    --message-input-height: 80px;
    --tab-height: 60px;
    
    /* Шрифты */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --font-family-mono: 'JetBrains Mono', 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-md: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    
    /* Прочее */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    --backdrop-blur: blur(20px);
    
    /* Новые переменные для файлов */
    --preview-grid-gap: 0.5rem;
    --preview-item-size: 120px;
    --preview-item-size-mobile: 80px;
    --preview-item-size-tablet: 100px;
}

/* === УЛУЧШЕНИЯ: Inter, вертикальный скролл, скрыть полосы прокрутки, SVG-галочка === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap');

:root {
    --check-gray: #9aa0a6;
    --check-blue: #4299e1;
}

/* Применяем шрифт по-умолчанию */
body,
html,
.app,
.container {
    font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === ИСПРАВЛЕНИЕ: Запрет скролла на страницах аутентификации === */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: var(--gradient-dark);
    position: relative;
    overflow: hidden;
}

/* Запрещаем скролл для всей страницы аутентификации */
.auth-body.scroll-locked {
    overflow: hidden;
    height: 100vh;
}

/* Разрешаем скролл только при фокусе на инпуте */
.auth-body.scroll-unlocked {
    overflow-y: auto;
}

/* Контейнер аутентификации - фиксированная высота */
.auth-container {
    width: 100%;
    max-width: 440px;
    animation: slideUpFade 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 2;
}

/* Ограничиваем высоту формы */
.auth-form {
    background: var(--bg-glass);
    backdrop-filter: var(--backdrop-blur);
    padding: 3rem 2.5rem;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    animation: glassSlideUp 0.6s ease;
    position: relative;
    overflow: hidden;
    max-height: 95vh;
    overflow-y: auto;
}

.auth-form::-webkit-scrollbar {
    width: 4px;
}

.auth-form::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 2px;
}

/* При фокусе на любом инпуте в форме разрешаем скролл */
.auth-form:has(input:focus) {
    overflow-y: auto;
}

/* Ограничиваем скролл только вертикальным и скрываем видимые полосы прокрутки */
#messages-container,
.messages-list,
.chat-window {
    overflow-x: hidden !important;
}

/* Скрыть полосы прокрутки в разных браузерах, но оставить возможность скролла */
#messages-container::-webkit-scrollbar {
    width: 0;
    height: 0;
}

#messages-container {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Стили для иконки статуса сообщения (галочка) */
.message-status {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    vertical-align: middle;
    opacity: 0.95;
    font-size: 0;
}

.message-status svg {
    display: block;
    width: 18px;
    height: 18px;
    color: var(--check-gray);
    transition: color .18s ease, transform .18s ease;
    transform-origin: center;
}

/* Когда сообщение помечено как прочитанное — цвет галочки становится синим */
.message.read .message-status svg,
.message.sent.read .message-status svg {
    color: var(--check-blue);
    transform: scale(1.02);
}

/* ИСПРАВЛЕНИЕ: Галочка выровнена по тексту сообщения */
.message.sent .message-status {
    position: relative;
    margin-left: 6px;
    align-self: flex-end;
}

/* Убираем текстовые подписи "прочитано/непрочитано" если они где-то есть */
.read-label,
.unread-label,
.message-read-text,
.read-text {
    display: none !important;
}

/* Добавляем стили для контекстного меню прикрепления файлов */
.file-actions {
    position: relative;
    display: flex;
    gap: 0.5rem;
    order: 1;
    flex-shrink: 0;
}

.attach-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-glass);
    color: var(--secondary-color);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--border-color);
    animation: bounceIn 0.6s ease;
    backdrop-filter: var(--backdrop-blur);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.attach-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: var(--transition-slow);
}

.attach-btn:hover {
    background: var(--primary-color);
    color: var(--text-light);
    transform: scale(1.1) rotate(5deg);
    box-shadow: var(--shadow-glow);
}

.attach-btn:hover::before {
    left: 100%;
}

.attach-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: var(--bg-glass);
    backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    min-width: 160px;
    z-index: 1000;
    display: none;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
    animation: slideDownFade 0.2s ease;
}

.attach-menu.active {
    display: flex;
}

.attach-menu .menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-align: left;
    width: 100%;
}

.attach-menu .menu-item:hover {
    background: var(--bg-tertiary);
    transform: translateX(4px);
}

.attach-menu .menu-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

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

body {
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    color: var(--text-primary);
    line-height: 1.6;
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Стили для скроллбара */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--gradient-primary);
    border-radius: 4px;
    box-shadow: var(--shadow-glow);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

/* Общие стили для аутентификации */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: var(--gradient-dark);
    position: relative;
    overflow: hidden;
}

.auth-body::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 20% 80%, rgba(74, 85, 104, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(56, 161, 105, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(237, 137, 54, 0.05) 0%, transparent 50%);
    animation: float 6s ease-in-out infinite alternate;
}

.auth-container {
    width: 100%;
    max-width: 440px;
    animation: slideUpFade 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 2;
}

.auth-form {
    background: var(--bg-glass);
    backdrop-filter: var(--backdrop-blur);
    padding: 3rem 2.5rem;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    animation: glassSlideUp 0.6s ease;
    position: relative;
    overflow: hidden;
}

.auth-form::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    transition: var(--transition-slow);
}

.auth-form:hover::before {
    left: 100%;
}

.auth-form h1 {
    margin-bottom: 2rem;
    text-align: center;
    color: var(--text-primary);
    font-size: var(--font-size-2xl);
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-link {
    text-align: center;
    margin-top: 2rem;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.auth-link a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 600;
    position: relative;
    transition: var(--transition);
}

.auth-link a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--gradient-primary);
    transition: var(--transition);
}

.auth-link a:hover {
    color: var(--text-light);
}

.auth-link a:hover::after {
    width: 100%;
}

.form-group {
    margin-bottom: 1.5rem;
    animation: fadeInUp 0.6s ease;
}

.form-group label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-md);
    transition: var(--transition);
    background: var(--bg-glass);
    color: var(--text-primary);
    font-family: var(--font-family);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.btn-primary {
    width: 100%;
    padding: 1.125rem;
    background: var(--gradient-primary);
    color: var(--text-light);
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-md);
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    animation: fadeInUp 0.8s ease;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: var(--transition-slow);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-danger {
    padding: 0.75rem 1.5rem;
    background: var(--gradient-danger);
    color: var(--text-light);
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-block;
    position: relative;
    overflow: hidden;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(245, 101, 101, 0.4);
}

.error-message {
    background: rgba(245, 101, 101, 0.1);
    color: var(--danger-color);
    padding: 1rem 1.25rem;
    border-radius: var(--border-radius-sm);
    margin-bottom: 1.5rem;
    border: 1px solid rgba(245, 101, 101, 0.3);
    font-size: var(--font-size-sm);
    animation: shake 0.5s ease;
    backdrop-filter: var(--backdrop-blur);
}

.success-message {
    background: rgba(56, 161, 105, 0.1);
    color: var(--success-color);
    padding: 1rem 1.25rem;
    border-radius: var(--border-radius-sm);
    margin-bottom: 1.5rem;
    border: 1px solid rgba(56, 161, 105, 0.3);
    font-size: var(--font-size-sm);
    animation: slideUpFade 0.5s ease;
    backdrop-filter: var(--backdrop-blur);
}

.text-muted {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

/* Основной макет приложения */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
    position: relative;
    background: var(--gradient-dark);
}

.app-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 80%, rgba(74, 85, 104, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(56, 161, 105, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(237, 137, 54, 0.05) 0%, transparent 50%);
    animation: backgroundShift 10s ease-in-out infinite alternate;
}

/* Боковая панель с эффектом стекла */
.sidebar {
    z-index: 1001;
    width: 280px;
    background: var(--bg-glass);
    backdrop-filter: var(--backdrop-blur);
    display: flex;
    flex-direction: column;
    height: 100%;
    border-right: 1px solid var(--border-color);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-md);
    z-index: 100;
    animation: slideInLeft 0.6s ease;
    position: relative;
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(74, 85, 104, 0.1), transparent 30%);
    pointer-events: none;
}

.sidebar-header {
    z-index: 1002;
    padding: 1.5rem 1.75rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    background: var(--bg-glass);
    position: relative;
}

.sidebar-header h2 {
    font-size: var(--font-size-xl);
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-header p {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.mobile-menu-btn {
    display: none;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    color: var(--text-primary);
    backdrop-filter: var(--backdrop-blur);
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
}

.mobile-menu-btn:hover {
    background: var(--primary-color);
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.mobile-menu-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.sidebar-nav {
    padding: 1rem 0;
    flex: 1;
    z-index: 1003;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 1rem 1.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    border-radius: var(--border-radius-sm);
    margin: 0.5rem 1rem;
    font-weight: 600;
    animation: fadeInLeft 0.6s ease;
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--gradient-primary);
    opacity: 0.1;
    transition: var(--transition);
}
/* Стили для кнопки мобильного меню в настройках */
.settings-container .section-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}

.settings-container .header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.settings-container .header-left h2 {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--text-primary);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

/* Адаптивность для мобильного меню в настройках */
@media (max-width: 768px) {
    .settings-container .section-header {
        padding: 0.75rem 0;
    }
    
    .settings-container .header-left h2 {
        font-size: var(--font-size-lg);
    }
}

@media (max-width: 480px) {
    .settings-container .section-header {
        padding: 0.5rem 0;
    }
    
    .settings-container .header-left h2 {
        font-size: var(--font-size-md);
    }
}
.nav-item svg {
    margin-right: 1rem;
    fill: currentColor;
    transition: var(--transition);
}

.nav-item:hover {
    background: var(--bg-glass);
    color: var(--text-light);
    transform: translateX(8px);
    box-shadow: var(--shadow-sm);
}

.nav-item:hover::before {
    left: 0;
}

.nav-item:hover svg {
    transform: scale(1.1);
}

.nav-item.active {
    background: var(--gradient-primary);
    color: var(--text-light);
    transform: translateX(8px);
    box-shadow: var(--shadow-glow);
}

.nav-item.active::before {
    display: none;
}

/* Мобильная боковая панель */
.sidebar-mobile {
    position: fixed;
    top: 0;
    left: 0;
    width: 320px;
    height: 100%;
    background: var(--bg-glass);
    backdrop-filter: var(--backdrop-blur);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
    border-right: 1px solid var(--border-color);
}

.sidebar-mobile.active {
    transform: translateX(0);
}

.mobile-close-btn {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-close-btn:hover {
    background: var(--danger-color);
    transform: scale(1.05);
}

.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 999;
    display: none;
    animation: fadeIn 0.3s ease;
}

.mobile-overlay.active {
    display: block;
}

/* Основное содержимое */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    background: transparent;
    position: relative;
    z-index: 1;
}

/* Секция чатов */
.chats-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.section-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-glass);
    backdrop-filter: var(--backdrop-blur);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 70px;
    height: auto;
    position: relative;
    gap: 1rem;
    z-index: 100;
}

.section-header::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--gradient-primary);
    opacity: 0.3;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.section-header h1,
.section-header h2 {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--text-primary);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Поиск с эффектом стекла */
.search-container {
    flex: 1;
    max-width: 400px;
    position: relative;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: var(--font-size-sm);
    background: var(--bg-glass);
    transition: var(--transition);
    color: var(--text-primary);
    font-family: var(--font-family);
    backdrop-filter: var(--backdrop-blur);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    transition: var(--transition);
}

.search-input:focus+.search-icon {
    color: var(--primary-color);
}

/* ИСПРАВЛЕННЫЕ РЕЗУЛЬТАТЫ ПОИСКА - теперь поверх всего */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-glass);
    backdrop-filter: var(--backdrop-blur);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    margin-top: 0.5rem;
    display: none;
    animation: slideDownFade 0.3s ease;
    border: 1px solid var(--border-color);
}

.search-results.active {
    display: block;
}

.search-result-item {
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    animation: fadeIn 0.4s ease;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

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

.search-result-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--gradient-primary);
    opacity: 0.1;
    transition: var(--transition);
}

.search-result-item:hover {
    background: var(--bg-glass);
    transform: translateX(8px);
}

.search-result-item:hover::before {
    left: 0;
}

/* Список чатов - ИСПРАВЛЕННЫЙ ДИЗАЙН */
.chats-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: transparent;
    position: relative;
    z-index: 1;
}

.chat-item {
    display: flex;
    align-items: flex-start;
    padding: 1.25rem 1.5rem;
    transition: var(--transition);
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    animation: fadeInUp 0.5s ease;
    background: var(--bg-glass);
    backdrop-filter: var(--backdrop-blur);
    margin: 0.75rem 0;
    border-radius: var(--border-radius);
    border: 1px solid transparent;
    gap: 1rem;
}

.chat-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--gradient-primary);
    opacity: 0.1;
    transition: var(--transition);
}

.chat-item:hover {
    background: var(--bg-tertiary);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-color);
}

.chat-item:hover::before {
    left: 0;
}

.chat-item.active {
    background: var(--gradient-primary);
    color: var(--text-light);
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow);
    border-color: var(--primary-color);
}

.chat-item.active::before {
    display: none;
}

.chat-item.active .chat-last-message {
    color: rgba(255, 255, 255, 0.9);
}

.chat-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-light);
    font-size: var(--font-size-lg);
    flex-shrink: 0;
    animation: bounceIn 0.6s ease;
    box-shadow: var(--shadow-glow);
    position: relative;
    overflow: hidden;
}

.chat-avatar::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transform: rotate(45deg);
    animation: shine 3s infinite;
}

.chat-avatar.small {
    width: 44px;
    height: 44px;
    font-size: var(--font-size-md);
}

.chat-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
}

.chat-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.chat-name {
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
    font-size: var(--font-size-lg);
    flex: 1;
}

.chat-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    flex-shrink: 0;
    position: relative;
}

.chat-time {
    color: var(--text-muted);
    font-size: var(--font-size-xs);
    white-space: nowrap;
    font-weight: 600;
}

/* ИСПРАВЛЕННЫЙ unread-badge - теперь в нижнем правом углу чата */
.unread-badge {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: var(--gradient-danger);
    color: var(--text-light);
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
    animation: pulse 2s infinite;
    box-shadow: var(--shadow-glow);
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
    z-index: 2;
}

.chat-last-message {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
    width: 100%;
}

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
    animation: fadeIn 0.6s ease;
}

.empty-state svg {
    margin-bottom: 1.5rem;
    fill: var(--text-muted);
    opacity: 0.6;
}

.empty-state p {
    margin-bottom: 1.5rem;
    font-size: var(--font-size-lg);
}

/* Контейнер чата */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: transparent;
    position: relative;
}

.chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-glass);
    backdrop-filter: var(--backdrop-blur);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 70px;
    height: auto;
    position: relative;
}

.chat-header::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--gradient-primary);
    opacity: 0.3;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-partner {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-header h2 {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
}

.chat-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    color: var(--text-primary);
    backdrop-filter: var(--backdrop-blur);
    width: 40px;
    height: 40px;
    text-decoration: none;
}

.chat-back-btn:hover {
    background: var(--primary-color);
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.chat-back-btn.desktop-only {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    width: auto;
}

.chat-info-btn {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    color: var(--text-primary);
    backdrop-filter: var(--backdrop-blur);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-info-btn:hover {
    background: var(--primary-color);
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.messages-container {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    background: transparent;
    display: flex;
    flex-direction: column;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    position: relative;
}

.message {
    max-width: 70%;
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    animation: messageSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.message.sent {
    align-self: flex-end;
    margin-left: auto;
    animation: messageSlideInRight 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.message.received {
    align-self: flex-start;
    animation: messageSlideInLeft 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === ТОНКИЕ РАМКИ ДЛЯ СООБЩЕНИЙ === */
.message-bubble {
    padding: 1rem 1.25rem;
    border-radius: var(--border-radius-lg);
    position: relative;
    word-wrap: break-word;
    backdrop-filter: var(--backdrop-blur);
    border-style: solid;
    border-width: 5px 5px 10px 5px;
    border-color: transparent;
}

/* Для отправленных сообщений */
.message.sent .message-bubble {
    background: var(--gradient-primary);
    color: var(--text-light);
    border-bottom-right-radius: 0.5rem;
    box-shadow: var(--shadow-glow);
    border-color: rgba(45, 55, 72, 0.5);
}

/* Для полученных сообщений */
.message.received .message-bubble {
    background: var(--bg-glass);
    color: var(--text-primary);
    border-bottom-left-radius: 0.5rem;
    box-shadow: var(--shadow-sm);
    border-color: var(--border-color);
}

/* УМЕНЬШЕННЫЕ ОТСТУПЫ ДЛЯ МЕДИА-КОНТЕЙНЕРОВ */
.message-media-container,
.message-file-container {
    margin: 1px 1px 4px 1px !important;
    padding: 0 !important;
}

.message-image,
.message-video {
    max-width: 100%;
    border-radius: var(--border-radius-sm);
    margin: 0 !important;
    cursor: pointer;
    max-height: 300px;
    object-fit: cover;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
}

.message-image:hover {
    transform: scale(1.03);
    box-shadow: var(--shadow-lg);
}

.message-video:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-lg);
}

.message-file {
    display: flex;
    align-items: center;
    padding: 0.875rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius-sm);
    margin: 0 !important;
    backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--border-color);
    max-width: 100%;
    overflow: hidden;
}

.message-file a {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
    transition: var(--transition);
    max-width: 100%;
    overflow: hidden;
}

.message-file a:hover {
    text-decoration: underline;
    transform: translateX(4px);
}

.message-file-icon {
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.message-file-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.message-reply {
    background: rgba(255, 255, 255, 0.05);
    border-left: 3px solid var(--primary-color);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    border-radius: var(--border-radius-sm);
    backdrop-filter: var(--backdrop-blur);
}

.message.sent .message-reply {
    background: rgba(255, 255, 255, 0.1);
}

.message-reply-author {
    font-weight: 700;
    font-size: var(--font-size-sm);
    margin-bottom: 0.25rem;
    color: var(--primary-light);
}

.message-reply-text {
    font-size: var(--font-size-sm);
    opacity: 0.9;
    line-height: 1.3;
}

.message-meta {
    font-size: var(--font-size-xs);
    margin-top: 0.5rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    font-weight: 600;
}

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

.message.received .message-meta {
    justify-content: flex-start;
}

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

.message-content {
    word-break: break-word;
    line-height: 1.5;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-secondary);
    padding: 3rem 2rem;
    animation: fadeIn 0.8s ease;
}

.welcome-message h2 {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    font-size: var(--font-size-2xl);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-message p {
    margin-bottom: 2rem;
    max-width: 500px;
    font-size: var(--font-size-lg);
    line-height: 1.6;
}

/* Поле ввода сообщения - ИСПРАВЛЕННЫЙ РАЗМЕР И РАСПОЛОЖЕНИЕ */
.message-input-container {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-glass);
    backdrop-filter: var(--backdrop-blur);
    position: sticky;
    bottom: 0;
    z-index: 100;
}

/* ИСПРАВЛЕНИЕ: Все элементы в одной строке */
.input-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: nowrap;
}

/* Убираем скроллхолдер у инпута ввода сообщения */
#message-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: var(--font-size-sm);
    resize: none;
    min-height: 46px;
    max-height: 120px;
    background: var(--bg-glass);
    transition: var(--transition);
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
    min-width: 0;
    color: var(--text-primary);
    font-family: var(--font-family);
    backdrop-filter: var(--backdrop-blur);
    line-height: 1.4;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#message-input::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

#message-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

/* ИСПРАВЛЕНИЕ: Все кнопки в одном ряду */
.file-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
    order: 1;
}

.template-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-glass);
    color: var(--warning-color);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--border-color);
    animation: bounceIn 0.6s ease;
    backdrop-filter: var(--backdrop-blur);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    order: 2;
}

.template-btn:hover {
    background: var(--warning-color);
    color: var(--text-light);
    transform: scale(1.1) rotate(5deg);
    box-shadow: var(--shadow-glow);
}

.send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: var(--text-light);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    order: 4;
    animation: bounceIn 0.6s ease;
    box-shadow: var(--shadow-glow);
    position: relative;
    overflow: hidden;
}

.send-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: var(--transition-slow);
}

.send-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 8px 32px rgba(74, 85, 104, 0.6);
}

.send-btn:hover::before {
    left: 100%;
}

.send-btn:disabled {
    background: var(--secondary-color);
    cursor: not-allowed;
    opacity: 0.7;
    transform: none;
    box-shadow: none;
}

.send-btn.loading {
    position: relative;
}

.send-btn.loading svg {
    opacity: 0;
}

.send-btn .spinner {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.send-btn svg {
    fill: currentColor;
    width: 20px;
    height: 20px;
}

/* =============================================== */
/* ОБНОВЛЕННЫЕ СТИЛИ ДЛЯ ПРЕВЬЮ ФАЙЛОВ - НОВЫЙ ДИЗАЙН */
/* =============================================== */

.file-previews-container {
    position: relative;
    margin-bottom: 1rem;
    max-height: 300px;
    overflow-y: auto;
    background: var(--bg-glass-dark);
    border-radius: var(--border-radius-sm);
    padding: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) transparent;
}

.file-previews-container::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.file-previews-container::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 3px;
}

.file-previews-container::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

/* Сетка превью файлов */
#file-previews {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--preview-item-size), 1fr));
    gap: var(--preview-grid-gap);
    padding: 0.25rem;
    transition: all 0.3s ease;
}

/* Адаптивные колонки для разных устройств */
@media (min-width: 1024px) {
    #file-previews {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}

@media (max-width: 1023px) and (min-width: 768px) {
    #file-previews {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

@media (max-width: 767px) {
    #file-previews {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}

@media (max-width: 480px) {
    #file-previews {
        grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
    }
}

/* НОВЫЙ ДИЗАЙН КАРТОЧКИ ПРЕВЬЮ */
.file-preview {
    position: relative;
    background: var(--bg-glass);
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
    animation: slideUpFade 0.3s ease;
    transition: all 0.3s ease;
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    backdrop-filter: var(--backdrop-blur);
}

.file-preview:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.file-preview.uploading {
    border-color: var(--info-color);
    animation: pulseGlow 2s infinite;
}

.file-preview.uploaded {
    border-color: var(--success-color);
}

.file-preview.error {
    border-color: var(--danger-color);
    animation: shake 0.5s ease;
}

/* Контейнер для медиа */
.preview-media {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--bg-tertiary);
}

.preview-media img,
.preview-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.file-preview:hover .preview-media img,
.file-preview:hover .preview-media video {
    transform: scale(1.05);
}

/* Иконка типа файла */
.file-type-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--bg-glass-dark);
    backdrop-filter: var(--backdrop-blur);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    border: 1px solid var(--border-color);
}

.file-type-icon svg {
    width: 14px;
    height: 14px;
    color: var(--text-light);
}

/* Информация о файле */
.file-info {
    padding: 0.5rem;
    background: var(--bg-glass-dark);
    backdrop-filter: var(--backdrop-blur);
    border-top: 1px solid var(--border-color);
}

.file-name {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.file-size {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    font-weight: 500;
}

/* Контейнер прогресса загрузки - НОВЫЙ ДИЗАЙН */
.file-progress-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 20, 25, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    backdrop-filter: blur(10px);
    z-index: 10;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.file-preview.uploaded .file-progress-container {
    opacity: 0;
    pointer-events: none;
}

/* Новый прогресс-бар */
.progress-bar {
    width: 100%;
    max-width: 120px;
    height: 6px;
    background: var(--bg-glass);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--info-color), var(--primary-color));
    border-radius: 10px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.progress-fill::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(200%);
    }
}

/* Текст прогресса */
.progress-text {
    color: var(--text-light);
    font-size: var(--font-size-xs);
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    text-align: center;
}

.progress-percentage {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-light);
    margin-bottom: 0.25rem;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}

/* Кнопка отмены загрузки - НОВЫЙ ДИЗАЙН */
.cancel-upload {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--gradient-danger);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
    z-index: 11;
    opacity: 0.9;
}

.cancel-upload:hover {
    background: var(--danger-color);
    transform: scale(1.1) rotate(90deg);
    box-shadow: var(--shadow-glow);
    opacity: 1;
}

/* Иконка завершения загрузки */
.upload-complete {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--success-color);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: bold;
    animation: bounceIn 0.5s ease;
    box-shadow: var(--shadow-sm);
    z-index: 11;
}

/* Панель управления файлами */
.file-controls {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-glass-dark);
    backdrop-filter: var(--backdrop-blur);
    padding: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border-color);
    z-index: 5;
    margin-top: 0.5rem;
}

.file-stats {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    font-weight: 600;
}

.file-count {
    background: var(--primary-color);
    color: var(--text-light);
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-xs);
}

.file-total-size {
    color: var(--text-muted);
    font-size: var(--font-size-xs);
}

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

.clear-all-btn {
    background: var(--gradient-danger);
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    padding: 0.5rem 1rem;
    font-size: var(--font-size-xs);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.clear-all-btn:hover {
    background: var(--danger-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.upload-all-btn {
    background: var(--gradient-success);
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    padding: 0.5rem 1rem;
    font-size: var(--font-size-xs);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.upload-all-btn:hover {
    background: var(--success-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

/* Миниатюры для массовой загрузки */
.file-previews-mini {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    overflow-x: auto;
    background: var(--bg-glass);
    border-radius: var(--border-radius-sm);
    margin-bottom: 0.5rem;
    scrollbar-width: thin;
}

.file-previews-mini::-webkit-scrollbar {
    height: 4px;
}

.file-previews-mini::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 2px;
}

.file-previews-mini::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 2px;
}

.mini-preview {
    position: relative;
    width: 50px;
    height: 50px;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.mini-preview img,
.mini-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mini-preview .mini-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--info-color);
    transition: width 0.3s ease;
}

/* Адаптивные стили для мобильных устройств */
@media (max-width: 768px) {
    .file-previews-container {
        max-height: 200px;
        padding: 0.375rem;
    }
    
    .file-controls {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.5rem;
    }
    
    .file-stats {
        width: 100%;
        justify-content: space-between;
    }
    
    .file-actions-buttons {
        width: 100%;
        justify-content: space-between;
    }
    
    .clear-all-btn,
    .upload-all-btn {
        flex: 1;
        justify-content: center;
        padding: 0.5rem;
    }
    
    .cancel-upload {
        width: 24px;
        height: 24px;
        font-size: 0.9rem;
    }
    
    .upload-complete {
        width: 24px;
        height: 24px;
        font-size: 0.8rem;
    }
    
    .file-type-icon {
        width: 20px;
        height: 20px;
    }
    
    .file-type-icon svg {
        width: 12px;
        height: 12px;
    }
}

@media (max-width: 480px) {
    #file-previews {
        gap: 0.375rem;
    }
    
    .file-previews-container {
        max-height: 180px;
    }
    
    .file-name {
        font-size: 0.65rem;
    }
    
    .file-size {
        font-size: 0.6rem;
    }
    
    .progress-bar {
        max-width: 80px;
        height: 4px;
    }
    
    .progress-percentage {
        font-size: 0.875rem;
    }
    
    .progress-text {
        font-size: 0.6rem;
    }
    
    .file-count {
        font-size: 0.6rem;
        padding: 0.125rem 0.375rem;
    }
    
    .file-total-size {
        font-size: 0.6rem;
    }
}

/* Анимации */
@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(66, 153, 225, 0.5);
    }
    50% {
        box-shadow: 0 0 15px rgba(66, 153, 225, 0.8);
    }
}

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

/* Индикатор ответа */
.reply-indicator {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 0.875rem;
    margin-bottom: 1rem;
    position: relative;
    animation: slideDownFade 0.3s ease;
    backdrop-filter: var(--backdrop-blur);
}

.reply-indicator-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.reply-indicator-text {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-weight: 600;
}

.reply-cancel-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.125rem;
    color: var(--text-muted);
    padding: 0.25rem;
    transition: var(--transition);
}

.reply-cancel-btn:hover {
    color: var(--danger-color);
    transform: scale(1.2);
}

/* Контекстное меню сообщения */
.message-context-menu {
    position: fixed;
    background: var(--bg-glass);
    backdrop-filter: var(--backdrop-blur);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    min-width: 180px;
    z-index: 1000;
    animation: zoomIn 0.2s ease;
    border: 1px solid var(--border-color);
}

.menu-item {
    width: 100%;
    padding: 1rem 1.25rem;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
    font-size: var(--font-size-sm);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
    font-weight: 600;
}

.menu-item:hover {
    background: var(--bg-tertiary);
    transform: translateX(4px);
}

.menu-item.reply-btn {
    color: var(--primary-color);
}

.menu-item.delete-btn {
    color: var(--danger-color);
}

.menu-item.copy-btn {
    color: var(--info-color);
}

.menu-item svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Стили для админ-панели */
.admin-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: var(--gradient-dark);
}

.admin-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    background: transparent;
}

.admin-section {
    margin-bottom: 2rem;
    background: var(--bg-glass);
    backdrop-filter: var(--backdrop-blur);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    animation: fadeInUp 0.5s ease;
    border: 1px solid var(--border-color);
}

.admin-section h2 {
    margin-bottom: 1.5rem;
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--text-primary);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.table-container {
    overflow-x: auto;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    animation: fadeIn 0.6s ease;
    background: var(--bg-glass);
    backdrop-filter: var(--backdrop-blur);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
}

table th,
table td {
    padding: 1.25rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

table th {
    background: var(--gradient-primary);
    font-weight: 700;
    font-size: var(--font-size-sm);
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

table tr:hover {
    background: var(--bg-tertiary);
}

/* ИСПРАВЛЕНИЕ: Модальные окна - пропорциональный размер */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}

/* Улучшенные пропорции модальных окон */
.modal-content {
    background: var(--bg-glass);
    backdrop-filter: var(--backdrop-blur);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    animation: zoomIn 0.3s ease;
    max-width: 500px;
    width: auto;
    min-width: 300px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Контент определяет высоту */
.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: 60vh;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
    animation: bounceIn 0.6s ease;
    backdrop-filter: var(--backdrop-blur);
    z-index: 1001;
}

.modal-close:hover {
    background: var(--danger-color);
    transform: scale(1.1) rotate(90deg);
    box-shadow: var(--shadow-glow);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-glass);
}

.modal-body {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    padding: 1rem 1.5rem 1.5rem;
    gap: 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-glass);
}

/* Выбор нескольких сообщений */
.message.selected .message-bubble {
    background: rgba(74, 85, 104, 0.3);
    border: 2px solid var(--primary-color);
}

.message.sent.selected .message-bubble {
    background: rgba(74, 85, 104, 0.7);
}

.delete-selected-button {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 100;
    padding: 1rem 1.5rem;
    background: var(--gradient-danger);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    animation: bounceIn 0.6s ease;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.delete-selected-button:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 40px rgba(245, 101, 101, 0.6);
}

/* Индикатор новых сообщений */
#new-messages-indicator {
    position: sticky;
    bottom: 1.5rem;
    display: flex;
    justify-content: center;
    z-index: 90;
    margin-top: 1rem;
    animation: slideUpFade 0.3s ease;
}

.new-messages-btn {
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: 1rem 1.5rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.new-messages-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow);
}

/* Анимации */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideUpFade {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideDownFade {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }

    70% {
        transform: scale(0.9);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-8px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(8px);
    }
}

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

    100% {
        transform: rotate(360deg);
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0px) rotate(0deg);
    }

    50% {
        transform: translateY(-20px) rotate(180deg);
    }
}

@keyframes backgroundShift {
    0% {
        transform: scale(1) rotate(0deg);
    }

    100% {
        transform: scale(1.1) rotate(180deg);
    }
}

@keyframes shine {
    0% {
        transform: translateX(-100%) rotate(45deg);
    }

    100% {
        transform: translateX(200%) rotate(45deg);
    }
}

@keyframes glassSlideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
        backdrop-filter: blur(0px);
    }

    to {
        transform: translateY(0);
        opacity: 1;
        backdrop-filter: var(--backdrop-blur);
    }
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes messageSlideInRight {
    from {
        opacity: 0;
        transform: translateX(50px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes messageSlideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* === КОМПАКТНОЕ МОДАЛЬНОЕ ОКНО ШАБЛОНОВ === */

/* КОМПАКТНОЕ МОДАЛЬНОЕ ОКНО ШАБЛОНОВ */
#template-modal .modal-content {
    width: 95%;
    max-width: 1200px;
    height: 90vh;
    max-height: 90vh;
    margin: auto;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    animation: slideUpFade 0.4s ease;
    overflow: hidden;
}

.template-modal-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0;
}

/* Табы шаблонов - компактные */
.template-tabs {
    display: flex;
    background: var(--bg-secondary);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    min-height: 50px;
}

.template-tab {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
    font-size: var(--font-size-sm);
    position: relative;
    margin-right: 0.5rem;
    white-space: nowrap;
}

.template-tab:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.template-tab.active {
    color: var(--text-light);
    background: var(--gradient-primary);
    box-shadow: var(--shadow-sm);
}

/* Основной контейнер шаблонов - вертикальная компактная структура */
.template-main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

/* Компактная панель шаблонов */
.template-list-container {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    max-height: 250px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.template-search-container {
    margin-bottom: 1rem;
}

.template-search-container input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
}

/* Компактный список шаблонов */
#templates-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
}

.template-item {
    background: var(--bg-glass);
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    min-width: 200px;
    flex-shrink: 0;
}

.template-item:hover {
    background: var(--bg-tertiary);
    transform: translateY(-2px);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.template-item.active {
    background: var(--gradient-primary);
    color: var(--text-light);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-glow);
}

.template-item-name {
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-item.active .template-item-name {
    color: var(--text-light);
}

.template-item-preview {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    line-height: 1.3;
    max-height: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.template-item.active .template-item-preview {
    color: rgba(255, 255, 255, 0.8);
}

.template-item-actions {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: var(--transition);
}

.template-item:hover .template-item-actions {
    opacity: 1;
}

.template-action-btn {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    width: 24px;
    height: 24px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
}

.template-action-btn:hover {
    background: var(--primary-color);
    color: var(--text-light);
    transform: scale(1.1);
}

/* Основной редактор - компактный */
.template-editor-main {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

/* Компактный редактор полей */
.template-editor {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Компактные поля шаблона */
#template-fields-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.template-field {
    background: var(--bg-glass);
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    animation: fadeInUp 0.3s ease;
}

.template-field label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
}

.template-field input,
.template-field select,
.template-field textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    transition: var(--transition);
}

.template-field input:focus,
.template-field select:focus,
.template-field textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-glow);
}

.template-field textarea {
    min-height: 80px;
    resize: vertical;
}

/* Компактный редактор создания шаблона */
.template-create-editor {
    background: var(--bg-glass);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.template-form-group {
    margin-bottom: 1.5rem;
}

.template-form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
}

.template-form-group input,
.template-form-group textarea {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
}

.template-form-group textarea {
    min-height: 150px;
    resize: vertical;
}

/* Компактный редактор полей */
.template-fields-editor-container {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: var(--border-radius);
    margin: 1rem 0;
    max-height: 300px;
    overflow-y: auto;
}

#template-fields-editor {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.field-editor-item {
    background: var(--bg-glass);
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    animation: slideInRight 0.3s ease;
}

.field-editor-header {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.field-editor-header input,
.field-editor-header select {
    flex: 1;
    min-width: 150px;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
}

.field-options-container {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.75rem;
    border-radius: var(--border-radius-sm);
    margin-top: 0.5rem;
    border-left: 3px solid var(--primary-color);
}

.remove-field-btn {
    background: var(--gradient-danger);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: var(--transition);
    flex-shrink: 0;
}

.remove-field-btn:hover {
    background: var(--danger-color);
    transform: scale(1.1);
}

#add-field-btn {
    padding: 0.75rem 1.5rem;
    font-size: var(--font-size-sm);
    font-weight: 600;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    margin: 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: fit-content;
}

#add-field-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

/* Компактная панель предпросмотра */
.template-preview-sidebar {
    width: 300px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.template-preview-sidebar h4 {
    font-size: var(--font-size-md);
    color: var(--text-primary);
    margin-bottom: 1rem;
    text-align: center;
}

.template-preview-container {
    flex: 1;
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    overflow-y: auto;
    font-family: var(--font-family-mono);
    font-size: var(--font-size-sm);
    line-height: 1.6;
    white-space: pre-wrap;
    min-height: 200px;
}

.template-preview-container strong {
    color: var(--primary-color);
    background: rgba(74, 85, 104, 0.1);
    padding: 0.1rem 0.25rem;
    border-radius: 3px;
}

/* Компактная секция прикрепления файлов */
.template-attachment-section {
    background: var(--bg-glass);
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    margin-top: 1rem;
}

.template-attachment-section h5 {
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.template-file-input {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.template-file-input input {
    flex: 1;
}

/* Компактные кнопки действий */
.template-actions {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    justify-content: flex-end;
}

#template-send,
#template-save,
#template-cancel {
    padding: 0.75rem 1.5rem;
    font-size: var(--font-size-sm);
    font-weight: 600;
    min-width: 120px;
}

/* Скрываем неактивный контент */
.template-tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
}

.template-tab-content.active {
    display: flex;
    flex-direction: column;
}

/* Адаптивность для шаблонов */
@media (max-width: 1024px) {
    #template-modal .modal-content {
        width: 98%;
        height: 95vh;
    }
    
    .template-editor-main {
        flex-direction: column;
    }
    
    .template-preview-sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border-color);
        max-height: 300px;
    }
    
    #template-fields-container {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    #template-modal .modal-content {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .template-tabs {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.5rem;
    }
    
    .template-tab {
        margin-right: 0;
        text-align: center;
        padding: 0.5rem;
    }
    
    .template-list-container {
        max-height: 200px;
    }
    
    #templates-list {
        flex-direction: column;
    }
    
    .template-item {
        min-width: 100%;
    }
    
    #template-fields-container {
        grid-template-columns: 1fr;
    }
    
    .field-editor-header {
        flex-direction: column;
    }
    
    .field-editor-header input,
    .field-editor-header select {
        min-width: 100%;
    }
    
    .template-actions {
        flex-direction: column;
    }
    
    #template-send,
    #template-save,
    #template-cancel {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .template-btn {
        width: 36px;
        height: 36px;
    }
    
    .template-editor {
        padding: 1rem;
    }
    
    .template-preview-sidebar {
        padding: 1rem;
    }
    
    .template-preview-container {
        padding: 0.75rem;
        font-size: var(--font-size-xs);
    }
    
    #template-send,
    #template-save,
    #template-cancel {
        padding: 0.5rem 1rem;
        min-width: auto;
    }
}

/* Дополнительные стили для хранилища */
.storage-section {
    padding: 0;
}

.storage-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.breadcrumbs {
    padding: 1rem 1.5rem;
    background: var(--bg-glass);
    backdrop-filter: var(--backdrop-blur);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.breadcrumb-link {
    color: var(--primary-color);
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: 600;
    transition: var(--transition);
    position: relative;
}

.breadcrumb-link:hover {
    color: var(--primary-light);
    transform: translateY(-1px);
}

.breadcrumb-current {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 600;
}

.breadcrumb-separator {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

.storage-stats {
    padding: 1rem 1.5rem;
    background: var(--bg-glass);
    backdrop-filter: var(--backdrop-blur);
    border-bottom: 1px solid var(--border-color);
}

.storage-progress {
    max-width: 500px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-glass);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 4px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.progress-fill::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shine 2s infinite;
}

.storage-info {
    display: flex;
    justify-content: space-between;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-weight: 600;
}

.storage-controls {
    padding: 1rem 1.5rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    background: var(--bg-glass);
    backdrop-filter: var(--backdrop-blur);
    border-bottom: 1px solid var(--border-color);
}

.sort-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sort-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: var(--bg-glass);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    backdrop-filter: var(--backdrop-blur);
    transition: var(--transition);
}

.sort-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-glow);
}

.storage-content {
    padding: 1rem;
    min-height: 400px;
    background: transparent;
    overflow-y: auto;
    flex: 1;
}

.folders-list,
.files-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.storage-item {
    background: var(--bg-glass);
    backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
    cursor: pointer;
    animation: fadeInUp 0.5s ease;
    position: relative;
    overflow: hidden;
}

.storage-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--gradient-primary);
    opacity: 0.1;
    transition: var(--transition);
}

.storage-item:hover {
    background: var(--bg-tertiary);
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.storage-item:hover::before {
    left: 0;
}

.item-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--gradient-primary);
    border-radius: var(--border-radius-sm);
    color: var(--text-light);
    font-size: 1.25rem;
}

.item-icon svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

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

.item-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    max-width: 100%;
}

.item-meta {
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    font-weight: 500;
}

.item-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: var(--transition);
}

.storage-item:hover .item-actions {
    opacity: 1;
}

.action-btn {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    cursor: pointer;
    padding: 0.375rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    color: var(--text-secondary);
    backdrop-filter: var(--backdrop-blur);
}

.action-btn:hover {
    background: var(--primary-color);
    color: var(--text-light);
    transform: scale(1.1);
    box-shadow: var(--shadow-glow);
}

.file-info-grid {
    display: grid;
    gap: 1rem;
}

.info-row {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1rem;
    align-items: center;
}

.info-label {
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: var(--font-size-sm);
}

.info-value {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Стили для админ-панели */
.admin-form {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.admin-form .form-group {
    margin-bottom: 0;
}

.form-input {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: var(--bg-glass);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    transition: var(--transition);
    font-family: var(--font-family);
    backdrop-filter: var(--backdrop-blur);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    background: var(--bg-glass);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-block;
    backdrop-filter: var(--backdrop-blur);
    position: relative;
    overflow: hidden;
}

.btn-secondary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    transition: var(--transition-slow);
}

.btn-secondary:hover {
    background: var(--primary-color);
    color: var(--text-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-secondary:hover::before {
    left: 100%;
}

.show-more-container {
    text-align: center;
    margin-top: 2rem;
    padding: 2rem;
}

/* Контекстное меню чатов */
.chat-context-menu {
    position: fixed;
    background: var(--bg-glass);
    backdrop-filter: var(--backdrop-blur);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    min-width: 180px;
    z-index: 1000;
    animation: zoomIn 0.2s ease;
    border: 1px solid var(--border-color);
}

.chat-context-menu .menu-item {
    width: 100%;
    padding: 1rem 1.25rem;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
    font-size: var(--font-size-sm);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
    font-weight: 600;
}

.chat-context-menu .menu-item:hover {
    background: var(--bg-tertiary);
    transform: translateX(4px);
}

.chat-context-menu .delete-chat-btn {
    color: var(--danger-color);
}

/* Стили для информации о чате */
.chat-info-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

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

.chat-info-item strong {
    color: var(--text-primary);
    font-weight: 600;
}

.chat-info-item span {
    color: var(--text-secondary);
}

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

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Адаптивность */
@media (max-width: 1200px) {
    .sidebar {
        width: 250px;
    }

    .search-container {
        width: 300px;
    }

    .message {
        max-width: 80%;
    }
}

@media (max-width: 968px) {
    .sidebar {
        display: none;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .section-header {
        flex-direction: row;
        align-items: center;
        height: auto;
        gap: 1rem;
        padding: 0.75rem 1rem;
        min-height: 60px;
    }

    .section-header h1,
    .section-header h2 {
        display: none;
    }

    .search-container {
        width: 100%;
        max-width: none;
    }

    .chat-header {
        padding: 0.75rem 1rem;
        min-height: 60px;
    }

    .chat-header h2 {
        font-size: var(--font-size-md);
    }

    .message {
        max-width: 90%;
    }

    .chats-list {
        padding: 0.5rem;
    }

    .chat-item {
        padding: 1rem;
        margin: 0.5rem 0;
        gap: 0.75rem;
    }

    .chat-avatar {
        width: 44px;
        height: 44px;
        font-size: var(--font-size-md);
    }

    .chat-name {
        font-size: var(--font-size-md);
    }

    .chat-last-message {
        font-size: var(--font-size-xs);
        max-width: 200px;
    }

    .input-group {
        flex-direction: row;
        align-items: center;
        flex-wrap: nowrap;
        gap: 0.5rem;
    }

    #message-input {
        order: 3;
        flex: 1;
        margin-bottom: 0;
        min-width: 0;
        font-size: var(--font-size-sm);
        padding: 0.75rem;
        min-height: 44px;
    }

    .file-actions {
        order: 1;
    }
    
    .template-btn {
        order: 2;
    }
    
    .send-btn {
        order: 4;
        margin-bottom: 0;
        width: 44px;
        height: 44px;
    }

    .message-input-container {
        padding: 0.75rem 1rem;
    }

    .file-actions {
        gap: 0.25rem;
    }

    .attach-btn {
        width: 44px;
        height: 44px;
    }

    .template-btn {
        width: 44px;
        height: 44px;
    }

    .file-previews-container {
        max-height: 250px;
    }

    .messages-container {
        padding: 1rem;
    }

    /* Адаптивность для рамок сообщений на мобильных устройствах */
    .message-bubble {
        border-width: 4px 4px 8px 4px;
        padding: 0.75rem 1rem;
    }

    /* Адаптивность для хранилища */
    .storage-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .folders-list,
    .files-list {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 0.75rem;
    }

    .storage-item {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
        padding: 0.875rem;
    }

    .item-actions {
        opacity: 1;
        justify-content: center;
    }

    .breadcrumbs {
        padding: 0.875rem 1rem;
    }

    .storage-stats {
        padding: 0.875rem 1rem;
    }

    .storage-controls {
        padding: 0.875rem 1rem;
    }

    .storage-content {
        padding: 0.875rem;
    }
}

@media (max-width: 640px) {
    .auth-form {
        padding: 2rem 1.5rem;
        max-height: 85vh;
    }
    
    /* ИСПРАВЛЕНИЕ: для мобильных устройств разрешаем скролл формы аутентификации */
    .auth-form {
        overflow-y: auto;
    }

    .admin-content {
        padding: 1rem;
    }

    .admin-section {
        padding: 1.5rem;
    }

    .message {
        max-width: 95%;
    }

    .chat-avatar {
        width: 40px;
        height: 40px;
        font-size: var(--font-size-sm);
    }

    .chat-last-message {
        max-width: 180px;
    }

    .file-actions {
        position: static;
        border-bottom: none;
        padding: 0;
        justify-content: space-around;
    }

    .input-group {
        flex-wrap: nowrap;
        gap: 0.5rem;
    }

    .attach-btn {
        width: 40px;
        height: 40px;
    }

    .template-btn {
        width: 40px;
        height: 40px;
    }

    .attach-btn svg {
        width: 18px;
        height: 18px;
    }

    .send-btn {
        width: 40px;
        height: 40px;
    }

    .send-btn svg {
        width: 18px;
        height: 18px;
    }

    .chat-item {
        padding: 0.875rem;
        gap: 0.5rem;
    }

    .message-bubble {
        padding: 0.75rem 1rem;
        border-width: 3px 3px 6px 3px;
    }

    .section-header {
        padding: 0.75rem;
    }

    .chat-header {
        padding: 0.75rem;
    }

    .messages-container {
        padding: 0.75rem;
    }

    .message-input-container {
        padding: 0.75rem;
    }

    .message-file-name {
        max-width: 150px;
    }

    .search-input {
        padding: 0.625rem 0.875rem 0.625rem 2.25rem;
        font-size: var(--font-size-sm);
    }

    .search-icon {
        left: 0.75rem;
    }

    .mobile-menu-btn {
        width: 40px;
        height: 40px;
        padding: 0.5rem;
    }

    .mobile-menu-btn svg {
        width: 18px;
        height: 18px;
    }

    /* Адаптивность для хранилища */
    .folders-list,
    .files-list {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 0.5rem;
    }

    .storage-actions {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }

    .storage-actions .btn-primary {
        width: 100%;
        padding: 0.875rem;
        font-size: var(--font-size-sm);
    }

    .admin-form {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .info-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .storage-item {
        padding: 0.75rem;
    }

    .item-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .item-name {
        font-size: var(--font-size-xs);
    }

    .storage-content {
        padding: 0.5rem;
        overflow-y: auto;
    }

    .item-name {
        max-width: 90px;
        font-size: var(--font-size-xs);
    }
}

@media (max-width: 480px) {
    .message {
        max-width: 98%;
    }

    .chat-avatar {
        width: 36px;
        height: 36px;
        font-size: var(--font-size-sm);
    }

    .chat-avatar.small {
        width: 32px;
        height: 32px;
        font-size: var(--font-size-xs);
    }

    .message-bubble {
        padding: 0.625rem 0.875rem;
        font-size: var(--font-size-sm);
        border-width: 3px 3px 6px 3px;
    }

    .chat-header h2 {
        font-size: var(--font-size-sm);
    }

    .attach-btn {
        width: 36px;
        height: 36px;
    }

    .template-btn {
        width: 36px;
        height: 36px;
    }

    .attach-btn svg {
        width: 16px;
        height: 16px;
    }

    .send-btn {
        width: 36px;
        height: 36px;
    }

    .send-btn svg {
        width: 16px;
        height: 16px;
    }

    #message-input {
        padding: 0.625rem;
        font-size: var(--font-size-sm);
        min-height: 40px;
    }

    .message-file-name {
        max-width: 120px;
        font-size: var(--font-size-xs);
    }

    .message-file-icon {
        margin-right: 0.5rem;
    }

    .chat-item {
        padding: 0.75rem;
        gap: 0.5rem;
    }

    .chat-name {
        font-size: var(--font-size-sm);
    }

    .chat-last-message {
        font-size: var(--font-size-xs);
        max-width: 150px;
    }

    .section-header {
        padding: 0.5rem;
        min-height: 50px;
    }

    .search-input {
        padding: 0.5rem 0.75rem 0.5rem 2rem;
        font-size: var(--font-size-xs);
    }

    .search-icon {
        left: 0.75rem;
    }

    .search-icon svg {
        width: 14px;
        height: 14px;
    }

    /* Адаптивность для хранилища */
    .folders-list,
    .files-list {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 0.5rem;
    }

    .storage-item {
        padding: 0.625rem;
    }

    .item-icon {
        width: 36px;
        height: 36px;
        font-size: 0.875rem;
    }

    .item-name {
        font-size: 0.7rem;
        max-width: 80px;
    }

    .item-meta {
        font-size: 0.65rem;
    }

    .storage-content {
        padding: 0.375rem;
    }
}

@media (max-width: 360px) {
    .message {
        max-width: 100%;
    }

    .chat-avatar {
        width: 32px;
        height: 32px;
        font-size: var(--font-size-xs);
    }

    .chat-avatar.small {
        width: 28px;
        height: 28px;
    }

    .message-bubble {
        padding: 0.5rem 0.75rem;
        font-size: var(--font-size-xs);
        border-width: 2px 2px 5px 2px;
    }

    .attach-btn {
        width: 32px;
        height: 32px;
    }

    .template-btn {
        width: 32px;
        height: 32px;
    }

    .attach-btn svg {
        width: 14px;
        height: 14px;
    }

    .send-btn {
        width: 32px;
        height: 32px;
    }

    .send-btn svg {
        width: 14px;
        height: 14px;
    }

    #message-input {
        padding: 0.5rem;
        font-size: var(--font-size-xs);
        min-height: 36px;
    }

    .message-file-name {
        max-width: 100px;
    }

    .chat-item {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .chat-name {
        font-size: var(--font-size-xs);
    }

    .chat-last-message {
        max-width: 120px;
    }

    .section-header {
        padding: 0.5rem;
        min-height: 45px;
    }

    .search-input {
        padding: 0.5rem 0.625rem 0.5rem 1.75rem;
    }

    .search-icon {
        left: 0.625rem;
    }
    
    /* Адаптивность для хранилища */
    .storage-item {
        padding: 0.5rem;
    }

    .item-icon {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }

    .item-name {
        font-size: var(--font-size-xs);
        max-width: 70px;
    }
}

/* Загрузка файлов */
.upload-file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    margin-bottom: 0.5rem;
    background: var(--bg-glass);
    backdrop-filter: var(--backdrop-blur);
    animation: fadeInUp 0.4s ease;
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.file-size {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-weight: 600;
}

.file-status {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.file-progress {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.progress-bar {
    width: 100px;
    height: 6px;
    background: var(--bg-glass);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 3px;
    transition: width 0.3s ease;
    position: relative;
}

.progress-fill::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shine 2s infinite;
}

.progress-text {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    min-width: 40px;
    font-weight: 600;
    text-align: center;
}

.file-checkmark {
    color: var(--success-color);
    font-weight: bold;
    font-size: 1.25rem;
    animation: bounceIn 0.6s ease;
}

/* Исправления для хранилища */
.storage-content {
    padding: 1rem;
    min-height: 400px;
    overflow-y: auto;
    flex: 1;
}

.folders-list,
.files-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

/* Улучшение отображения при большом количестве файлов */
.storage-item {
    min-height: 100px;
}

/* Стили для переключателя шифрования */
.toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    gap: 1rem;
    font-size: var(--font-size-sm);
    margin-bottom: 1.5rem;
}

.toggle-slider {
    position: relative;
    width: 50px;
    height: 24px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: var(--transition);
    backdrop-filter: var(--backdrop-blur);
}

.toggle-slider:before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-secondary);
    top: 2px;
    left: 2px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

#encrypt-toggle:checked+.toggle-slider {
    background: var(--gradient-primary);
    border-color: var(--primary-color);
}

#encrypt-toggle:checked+.toggle-slider:before {
    transform: translateX(26px);
    background: var(--text-light);
}

#encrypt-toggle {
    display: none;
}

.toggle-text {
    font-weight: 600;
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius-sm);
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    backdrop-filter: var(--backdrop-blur);
    font-size: var(--font-size-sm);
}

.toggle-text:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.upload-options {
    margin-bottom: 1rem;
}

.upload-files-list {
    max-height: 50vh;
    overflow-y: auto;
    margin: 1.5rem 0;
}

/* Улучшение визуального вида переключателя */
.toggle-label:hover .toggle-slider {
    border-color: var(--primary-light);
}

.toggle-label:active .toggle-slider:before {
    transform: scale(0.9);
}

#encrypt-toggle:checked+.toggle-slider+.toggle-text {
    background: var(--gradient-primary);
    color: var(--text-light);
    border-color: var(--primary-color);
}

/* Стили для приветственного сообщения при отсутствии чатов */
.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
    animation: fadeIn 0.8s ease;
    height: 100%;
}

.welcome-icon {
    margin-bottom: 2rem;
    color: var(--primary-color);
    opacity: 0.8;
    animation: bounceIn 1s ease;
}

.welcome-icon svg {
    width: 80px;
    height: 80px;
    filter: drop-shadow(0 0 20px rgba(74, 85, 104, 0.3));
}

.welcome-message h2 {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    font-size: var(--font-size-2xl);
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-message p {
    margin-bottom: 3rem;
    max-width: 400px;
    font-size: var(--font-size-lg);
    line-height: 1.6;
    color: var(--text-secondary);
}

.welcome-features {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 300px;
    margin-top: 2rem;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--bg-glass);
    backdrop-filter: var(--backdrop-blur);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    animation: fadeInUp 0.6s ease;
}

.feature-item:nth-child(1) {
    animation-delay: 0.2s;
}

.feature-item:nth-child(2) {
    animation-delay: 0.4s;
}

.feature-item:nth-child(3) {
    animation-delay: 0.6s;
}

.feature-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.feature-item svg {
    width: 24px;
    height: 24px;
    color: var(--primary-color);
    flex-shrink: 0;
}

.feature-item span {
    font-weight: 600;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
}

/* Адаптивность для приветственного сообщения */
@media (max-width: 768px) {
    .welcome-message {
        padding: 3rem 1.5rem;
    }

    .welcome-icon svg {
        width: 60px;
        height: 60px;
    }

    .welcome-message h2 {
        font-size: var(--font-size-xl);
    }

    .welcome-message p {
        font-size: var(--font-size-md);
        margin-bottom: 2rem;
    }

    .welcome-features {
        max-width: 100%;
    }

    .feature-item {
        padding: 0.875rem 1.25rem;
    }
}

@media (max-width: 480px) {
    .welcome-message {
        padding: 2rem 1rem;
    }

    .welcome-icon svg {
        width: 50px;
        height: 50px;
    }

    .welcome-message h2 {
        font-size: var(--font-size-lg);
    }

    .welcome-message p {
        font-size: var(--font-size-sm);
    }

    .feature-item {
        padding: 0.75rem 1rem;
    }

    .feature-item span {
        font-size: var(--font-size-xs);
    }
}

/* Адаптивность для контекстных меню */
@media (max-width: 768px) {
    .chat-context-menu {
        min-width: 160px;
        font-size: var(--font-size-sm);
    }

    .chat-context-menu .menu-item {
        padding: 0.875rem 1rem;
    }
}

@media (max-width: 480px) {
    .chat-context-menu {
        min-width: 140px;
    }

    .chat-context-menu .menu-item {
        padding: 0.75rem 0.875rem;
        font-size: var(--font-size-xs);
    }
}

/* Дополнительные стили для улучшения интерфейса шаблонов */

.template-field {
    background: var(--bg-glass);
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    animation: fadeInUp 0.3s ease;
    transition: var(--transition);
}

.template-field:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.template-field label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
}

#template-fields-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.field-editor-item {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
    animation: slideInRight 0.3s ease;
}

.field-editor-header {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.field-editor-header input,
.field-editor-header select {
    flex: 1;
    min-width: 120px;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    transition: var(--transition);
}

.field-editor-header input:focus,
.field-editor-header select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-glow);
}

.remove-field-btn {
    background: var(--gradient-danger);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: var(--transition);
    flex-shrink: 0;
}

.remove-field-btn:hover {
    background: var(--danger-color);
    transform: scale(1.1);
}

.field-options-container {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.75rem;
    border-radius: var(--border-radius-sm);
    margin-top: 0.5rem;
    border-left: 3px solid var(--primary-color);
}

.template-preview {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    margin-top: 1rem;
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    line-height: 1.6;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
}

.template-preview strong {
    color: var(--primary-color);
    background: rgba(74, 85, 104, 0.1);
    padding: 0.1rem 0.25rem;
    border-radius: 3px;
}

.template-file-input {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.template-item {
    background: var(--bg-glass);
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 0.5rem;
}

.template-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.template-item.active {
    background: var(--gradient-primary);
    color: var(--text-light);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-glow);
}

.template-item-name {
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
}

.template-item.active .template-item-name {
    color: var(--text-light);
}

.template-item-preview {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    line-height: 1.3;
    max-height: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.template-item.active .template-item-preview {
    color: rgba(255, 255, 255, 0.8);
}

.template-item-actions {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.5rem;
    opacity: 0;
    transition: var(--transition);
}

.template-item:hover .template-item-actions {
    opacity: 1;
}

.template-action-btn {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    width: 24px;
    height: 24px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
}

.template-action-btn:hover {
    background: var(--primary-color);
    color: var(--text-light);
    transform: scale(1.1);
}

/* Адаптивность для шаблонов */
@media (max-width: 768px) {
    #template-fields-container {
        grid-template-columns: 1fr;
    }
    
    .field-editor-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .field-editor-header input,
    .field-editor-header select {
        min-width: 100%;
    }
    
    .template-item-actions {
        opacity: 1;
    }
}

/* Исправление скролла для модального окна шаблонов */
#template-modal .modal-content {
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.template-tab-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.template-tab-content[data-tab="select"] {
    overflow-y: auto;
}

.template-tab-content[data-tab="create"] {
    overflow-y: auto;
}

/* Контейнер для списка шаблонов */
#templates-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

/* Контейнер для полей шаблона */
#template-fields-container {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 5px;
}

/* Контейнер для редактора полей */
#template-fields-editor {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 5px;
}

/* Контейнер для превью */
.template-preview {
    max-height: 200px;
    overflow-y: auto;
}

.template-create-preview {
    max-height: 200px;
    overflow-y: auto;
}

/* Стили для скроллбара в модальном окне */
#template-modal ::-webkit-scrollbar {
    width: 8px;
}

#template-modal ::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

#template-modal ::-webkit-scrollbar-thumb {
    background: var(--gradient-primary);
    border-radius: 4px;
    box-shadow: var(--shadow-glow);
}

#template-modal ::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

/* Улучшение для сообщений в чате */
#messages-container {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Гарантируем, что скроллбар всегда виден */
#messages-container::-webkit-scrollbar {
    width: 8px;
}

#messages-container::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

#messages-container::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

#messages-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

/* Улучшение для контейнера чатов */
.chats-list {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
}

/* Автоматическое прокручивание вниз при новом сообщении */
.scroll-to-bottom {
    animation: scrollDown 0.3s ease;
}

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

/* Кнопка прокрутки вниз */
.scroll-down-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
    z-index: 100;
}

.scroll-down-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow);
}

.scroll-down-btn.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
}

