:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2d2d2d;
    --card-background: var(--bg-secondary);
    --modal-bg: var(--bg-secondary);
    --bg-hover: rgba(255, 255, 255, 0.08);
    --bg-active: rgba(255, 255, 255, 0.12);
    
    --text-primary: #ffffff;
    --text-secondary: #8e8e93;
    --text-muted: #6c6c70;
    
    --primary-buble-message: #1a4d0f;
    --primary-color: #239508;
    --primary-hover: #239508;
    --success-color: #34c759;
    --warning-color: #ff9500;
    --danger-color: #ff3b30;
    --error-500: var(--danger-color);
    --info-color: #5ac8fa;
    
    --border-color: rgba(255, 255, 255, 0.12);
    --border-light: rgba(255, 255, 255, 0.06);
    
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-circle: 50%;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
    
    --font-primary: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    min-height: 100vh;
    position: relative;
    background: var(--bg-primary);
}

.floating-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.particle {
    position: absolute;
    background: linear-gradient(45deg, var(--primary-color), transparent);
    border-radius: 50%;
    animation: float 20s infinite ease-in-out;
}

.particle:nth-child(1) { top: 10%; left: 5%; width: 300px; height: 300px; animation-delay: 0s; }
.particle:nth-child(2) { top: 20%; right: 10%; width: 200px; height: 200px; animation-delay: -5s; }
.particle:nth-child(3) { bottom: 15%; left: 15%; width: 150px; height: 150px; animation-delay: -10s; }
.particle:nth-child(4) { bottom: 25%; right: 20%; width: 250px; height: 250px; animation-delay: -15s; }
.particle:nth-child(5) { top: 60%; left: 40%; width: 100px; height: 100px; animation-delay: -2s; }
.particle:nth-child(6) { top: 30%; left: 70%; width: 180px; height: 180px; animation-delay: -8s; }

.gradient-accent {
    position: fixed;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.15;
    pointer-events: none;
    z-index: -1;
}

.gradient-accent-1 {
    top: -100px;
    right: -100px;
    width: 400px;
    height: 400px;
    background: linear-gradient(45deg, var(--primary-color), var(--info-color));
}

.gradient-accent-2 {
    bottom: -150px;
    left: -150px;
    width: 500px;
    height: 500px;
    background: linear-gradient(135deg, var(--success-color), var(--warning-color));
}

.gradient-accent-3 {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    background: linear-gradient(225deg, var(--danger-color), var(--primary-color));
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(30px, -50px) rotate(120deg); }
    66% { transform: translate(-20px, 40px) rotate(240deg); }
}

.sidebar {
    width: var(--sidebar-width);
    height: 100vh; 
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    z-index: 100;
    position: fixed;
    top: 0;
    left: 0;
    transition: width var(--transition-normal);
    overflow: visible;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    margin-left: var(--sidebar-width); 
    transition: margin-left var(--transition-normal);
}

.main-content.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed);
}

.sidebar-toggle-btn {
    position: absolute;
    top: 50%;
    right: -12px;
    transform: translateY(-50%);
    width: 24px;
    height: 40px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-left: none;
    border-radius: 0 8px 8px 0;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    z-index: 10;
    opacity: 0;
}

.sidebar:hover .sidebar-toggle-btn {
    opacity: 1;
}

.sidebar-toggle-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.sidebar-toggle-btn i {
    font-size: 12px;
    transition: transform var(--transition-fast);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar.collapsed .logo h1,
.sidebar.collapsed .nav-item span:not(.badge),
.sidebar.collapsed .user-info,
.sidebar.collapsed .logout-btn {
    display: none;
}

.sidebar.collapsed .logo {
    justify-content: center;
    padding: 20px 0;
}

.sidebar.collapsed .logo-image {
    width: 32px;
    height: 32px;
    margin: 0;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
}

.sidebar.collapsed .nav-item i {
    font-size: 20px;
    width: auto;
}

.sidebar.collapsed .badge {
    position: absolute;
    top: 8px;
    right: 8px;
    min-width: 16px;
    height: 16px;
    font-size: 10px;
}

.sidebar.collapsed .user-profile {
    justify-content: center;
    padding: 16px 0;
}

.sidebar.collapsed .user-avatar {
    width: 32px;
    height: 32px;
    margin: 0;
}

.sidebar.collapsed .sidebar-toggle-btn i {
    display: block;
    transform: rotate(180deg);
}

.sidebar.collapsed .sidebar-toggle-btn {
    right: -12px;
}

.swipe-indicator {
    position: absolute;
    right: -12px;
    top: 50%;
    transform: translateY(-50%) translateX(100%);
    background: linear-gradient(135deg, var(--primary-color), var(--info-color));
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 101;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    pointer-events: none;
}

.swipe-indicator:hover {
    transform: translateY(-50%) translateX(110%) scale(1.1);
    box-shadow: 0 4px 16px rgba(42, 171, 238, 0.4);
}

.swipe-indicator i {
    font-size: 14px;
    transition: transform 0.2s ease;
}

.swipe-indicator:hover i {
    transform: scale(1.2);
}

.logo {
    flex-shrink: 0; 
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
}

.logo-image {
    width: 86px;
    height: 86px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

@keyframes logo-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.logo h1 {
    font-size: 16px;
    font-weight: 700;
    background: linear-gradient(105deg, #e5b609, #36c706);
    -webkit-background-clip: text;
    -webkit-text-fill-color: #ad741f5c;
    background-clip: text;
}

/* НАВИГАЦИОННОЕ МЕНЮ - ПРОКРУЧИВАЕМАЯ СРЕДНЯЯ ЧАСТЬ */
.nav-menu {
    flex: 1 1 auto; /* ЗАНИМАЕТ ВСЁ ДОСТУПНОЕ ПРОСТРАНСТВО */
    overflow-y: auto; /* ВКЛЮЧАЕМ ПРОКРУТКУ */
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* КАСТОМНЫЙ СКРОЛЛБАР ДЛЯ КРАСОТЫ */
.nav-menu::-webkit-scrollbar {
    width: 4px;
}

.nav-menu::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.nav-menu::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.nav-menu::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

.nav-item {
    flex-shrink: 0; /* ОТДЕЛЬНЫЕ ПУНКТЫ НЕ СЖИМАЮТСЯ */
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
    position: relative;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--bg-active);
    color: var(--primary-color);
    font-weight: 500;
}

.nav-item.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 24px;
    background: var(--primary-color);
    border-radius: 0 2px 2px 0;
}

.nav-item i {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.nav-item span:not(.badge) {
    flex: 1;
    font-size: 15px;
}

.badge {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--primary-color);
    color: white;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}

/* ПРОФИЛЬ ПОЛЬЗОВАТЕЛЯ - ПРИЛИПАЕТ К НИЗУ */
.user-profile {
    flex-shrink: 0; /* НЕ СЖИМАЕТСЯ */
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    background: var(--bg-secondary);
    margin-top: auto; /* КЛЮЧЕВОЕ СВОЙСТВО - ПРИЖИМАЕТ К НИЗУ */
}

.user-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-circle);
    object-fit: cover;
    border: 2px solid var(--primary-color);
    transition: transform var(--transition-fast);
}

.user-avatar:hover img {
    transform: scale(1.05);
}

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

.user-name {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-circle);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.logout-form {
    display: flex;
    margin: 0;
}

.logout-btn:hover {
    background: var(--danger-color);
    color: white;
    transform: rotate(90deg);
}

.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-circle);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mobile-menu-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    max-width: 400px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    transition: all var(--transition-fast);
}

.search-bar:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(42, 171, 238, 0.2);
}

.search-bar i {
    color: var(--text-muted);
    font-size: 16px;
}

.search-bar input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
}

.search-bar input::placeholder {
    color: var(--text-muted);
}

.quick-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.quick-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-circle);
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.quick-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

.quick-btn:active {
    transform: translateY(0);
}

.notifications-indicator {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-circle);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.notifications-indicator:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.notifications-indicator.has-notifications {
    color: var(--primary-color);
}

.indicator {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    background: var(--danger-color);
    color: white;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-profile-mini {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.user-profile-mini:hover {
    background: var(--bg-hover);
}

.content-area {
    flex: 1;
    overflow: auto;
    position: relative;
}

.panel-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--border-color);
}

.panel-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.chat-container {
    display: flex;
    height: calc(100vh - 65px);
    position: relative;
}

.chat-list-container {
    width: 340px;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

.chat-list-header {
    padding: 20px 20px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-list-header h3 {
    font-size: 20px;
    font-weight: 700;
    flex: 1;
}

.chat-search {
    padding: 16px 20px;
}

.search-input {
    width: 100%;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: all var(--transition-fast);
}

.search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(42, 171, 238, 0.2);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.chat-list-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.chat-item:hover {
    background: var(--bg-hover);
}

.chat-item.active {
    background: var(--bg-active);
}

.chat-item-avatar {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.chat-item-avatar img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-circle);
    object-fit: cover;
    border: 2px solid var(--primary-color);
}

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

.chat-item-name {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-item-name i {
    color: var(--text-muted);
    font-size: 12px;
}

.chat-item-last-message {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

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

.chat-item-unread {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--primary-color);
    color: white;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-area-full {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 80;
}

.chat-info {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.chat-avatar-container {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.chat-avatar {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-circle);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    overflow: hidden;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-edit-btn:hover {
    transform: scale(1.1);
}

.chat-details {
    flex: 1;
    min-width: 0;
}

.chat-details h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-status {
    font-size: 14px;
    color: var(--text-muted);
}

.chat-status.online {
    color: var(--success-color);
}

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

.chat-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-circle);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.chat-messages-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: auto;
}

.message {
    display: flex;
    gap: 12px;
    animation: messageAppear 0.3s ease;
    position: relative;
}

.message.has-reactions {
    margin-bottom: 20px;
}

.message.grouped.has-reactions {
    margin-bottom: 18px;
}

.message.grouped {
    margin-top: -4px;
}

.message.grouped.other {
    padding-left: 0;
}

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

.message.own {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    align-self: flex-start;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-circle);
    object-fit: cover;
    border: 2px solid var(--primary-color);
}

.message-content {
    max-width: 65%;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    position: relative;
}

.message.own .message-content {
    align-items: flex-end;
}

.message-sender {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.message.own .message-sender {
    display: none;
}

.message-text {
    background: var(--bg-tertiary);
    padding: 9px 86px 20px 14px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.4;
    word-wrap: break-word;
    word-break: normal;
    hyphens: manual;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    max-width: 100%;
    position: relative;
    border: 1px solid var(--border-light);
}


.message.own .message-text {
    background: var(--primary-buble-message);
    color: white;
    border-color: var(--primary-color);
}

.message-text:has(> code),
.message-text:has(> pre) {
    font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
    font-size: 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
}

.message-text.very-long {
    width: 100%;
    max-width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.collapsed-message-text {
    max-height: 13.2em;
    overflow: hidden;
}

.collapsed-message-text:not(.expanded)::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 58px;
    border-radius: 0 0 18px 18px;
    background: linear-gradient(to bottom, transparent, var(--bg-tertiary));
    pointer-events: none;
}

.message.own .collapsed-message-text:not(.expanded)::after {
    background: linear-gradient(to bottom, transparent, var(--primary-buble-message));
}

.collapsed-message-text.expanded {
    max-height: none;
}

.message-expand-btn {
    position: absolute;
    left: 50%;
    bottom: -13px;
    transform: translateX(-50%);
    z-index: 4;
    border: 0;
    border-radius: 999px;
    padding: 6px 13px;
    background: rgba(255, 255, 255, 0.76);
    backdrop-filter: blur(10px);
    color: var(--primary-color);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    white-space: nowrap;
    line-height: 1;
}

.message.own .message-expand-btn {
    background: rgba(255, 255, 255, 0.72);
    color: var(--primary-color);
}

.message-text a {
    color: #000000;
    text-decoration: none;
    word-break: break-all;
}

.message-text a:hover {
    text-decoration: underline;
}

.message-time {
    font-size: 10.5px;
    color: var(--text-muted);
    padding: 0;
    text-align: right;
    margin-top: 0;
    white-space: nowrap;
    max-width: calc(100% - 24px);
    overflow: hidden;
    text-overflow: ellipsis;
    position: absolute;
    right: 12px;
    bottom: 6px;
    pointer-events: none;
    line-height: 1;
}

.message.own .message-time {
    color: rgba(255, 255, 255, 0.78);
}

@keyframes highlightMessage {
    0% {
        background-color: rgba(42, 171, 238, 0.1);
    }
    100% {
        background-color: transparent;
    }
}

.message.new .message-text {
    animation: highlightMessage 2s ease;
}

.message-text blockquote {
    border-left: 3px solid var(--primary-color);
    margin: 8px 0;
    padding-left: 12px;
    font-style: italic;
    color: var(--text-secondary);
}

.message-text ul,
.message-text ol {
    margin: 8px 0;
    padding-left: 20px;
}

.message-text li {
    margin-bottom: 4px;
}

.message-text {
    font-family: var(--font-primary), "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    line-height: 1.5;
}

.message-text:only-child:has(:global(🎉🎊🎈)) {
    font-size: 24px;
    line-height: 1.2;
    padding: 12px;
}

.message-file, .message-image {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.message-file {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 64px 18px 16px;
}

.message-file i {
    font-size: 24px;
    color: var(--primary-color);
}

.file-info {
    flex: 1;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.file-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
}

.download-btn {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.download-btn:hover {
    text-decoration: underline;
}

.message-image {
    position: relative;
    max-width: 400px;
}

.image-container {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-md);
}

.chat-image {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
    transition: transform var(--transition-slow);
}

.chat-image:hover {
    transform: scale(1.02);
}

.image-overlay {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.image-container:hover .image-overlay {
    opacity: 1;
}

.image-download-btn, .image-fullscreen-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-circle);
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.image-download-btn:hover, .image-fullscreen-btn:hover {
    background: var(--primary-color);
    transform: scale(1.1);
}

.image-info {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-tertiary);
}

.image-name, .image-size {
    font-size: 12px;
    color: var(--text-muted);
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    width: fit-content;
    max-width: calc(100% - 48px);
    margin: 0 24px 8px;
    padding: 9px 13px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
}

.typing-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-circle);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.typing-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.typing-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 0;
}

.typing-text strong {
    color: var(--text-primary);
}

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

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-circle);
    background: var(--primary-color);
    animation: typingDot 1.4s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

.chat-input-container {
    padding: 0px 0px;
    background: var(--bg-secondary);
    position: sticky;
    bottom: 0;
    z-index: 80;
}

.chat-input {
    display: flex;
    align-items: flex-end;
    gap: 0px;
    border-radius: var(--radius-xl);
    padding: 0px 0px;
    border: 2px solid var(--border-light);
    transition: all var(--transition-fast);
}

.chat-input:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(42, 171, 238, 0.2);
}

.input-actions {
    display: flex;
    align-self: flex-start;
    padding-top: 6px;
}

.input-action-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-circle);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

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

.message-input {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    outline: none;
    font-family: var(--font-primary);
    padding: 8px 0;
}

.message-input::placeholder {
    color: var(--text-muted);
}

.send-button {
    width: 43px;
    height: 43px;
    border-radius: var(--radius-circle);
    background: var(--primary-color);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    align-self: flex-end;
}

.send-button:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.send-button:active {
    transform: scale(0.95);
}


.filter-btn {
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-btn.active {
    background: var(--primary-color);
    color: white;
}

.filter-btn:hover:not(.active) {
    background: var(--bg-hover);
    color: var(--text-primary);
}


@keyframes urgentPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(255, 59, 48, 0); }
}


.meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.meta-item i {
    width: 16px;
    color: var(--text-muted);
}


.friends-container {
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.friends-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.friends-header-actions {
    display: flex;
    gap: 12px;
}

.friends-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    overflow-x: auto;
}

.friends-tab {
    flex: 1;
    min-width: fit-content;
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

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

.friends-tab.active {
    background: var(--primary-color);
    color: white;
}

.tab-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--danger-color);
    color: white;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}

.friends-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.friends-tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

.friends-tab-content.active {
    display: block;
}

.friends-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.friend-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    transition: all var(--transition-fast);
}

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

.friend-avatar {
    position: relative;
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    cursor: pointer;
}

.friend-avatar img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-circle);
    object-fit: cover;
    border: 3px solid var(--primary-color);
}

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

.friend-name {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.friend-username {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.friend-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.friend-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

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

.friend-action-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-circle);
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.chat-btn:hover { background: var(--primary-color); color: white; }
.group-btn:hover { background: var(--info-color); color: white; }
.remove-btn:hover { background: var(--danger-color); color: white; }

.friend-request-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    margin-bottom: 12px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.friend-request-avatar {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    cursor: pointer;
}

.friend-request-avatar img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-circle);
    object-fit: cover;
    border: 3px solid var(--primary-color);
}

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

.friend-request-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.friend-request-message {
    font-size: 14px;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 8px;
    padding-left: 8px;
    border-left: 2px solid var(--primary-color);
}

.friend-request-time {
    font-size: 13px;
    color: var(--text-muted);
}

.friend-request-actions {
    display: flex;
    gap: 12px;
}

.search-users-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.search-users-input {
    display: flex;
    gap: 12px;
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    transition: all var(--transition-fast);
}

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

.search-result-avatar {
    position: relative;
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    cursor: pointer;
}

.search-result-avatar img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-circle);
    object-fit: cover;
    border: 3px solid var(--primary-color);
}

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

.search-result-name {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.friend-status-badge {
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
}

.friend-status-badge.friend { background: rgba(52, 199, 89, 0.2); color: var(--success-color); }
.friend-status-badge.pending { background: rgba(255, 149, 0, 0.2); color: var(--warning-color); }
.friend-status-badge.received { background: rgba(42, 171, 238, 0.2); color: var(--primary-color); }

.search-result-username {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.search-result-status {
    display: flex;
    gap: 8px;
    font-size: 13px;
}

.online-status { color: var(--success-color); }
.offline-status { color: var(--text-muted); }

.search-result-actions {
    display: flex;
    gap: 12px;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

.modal-header h3 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
}

.modal-header .close {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-circle);
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.modal-header .close:hover {
    background: var(--danger-color);
    color: white;
    transform: rotate(90deg);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
}

.modal-footer {
    padding: 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 15px;
    font-family: var(--font-primary);
    transition: all var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(42, 171, 238, 0.2);
}

.form-control::placeholder {
    color: var(--text-muted);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='https://www.w3.org/2000/svg' width='16' height='16' fill='%238e8e93' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.form-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 32px;
}

@keyframes swipeHint {
    0%, 100% { 
        transform: translateY(-50%) translateX(100%);
        background: linear-gradient(135deg, var(--primary-color), var(--info-color));
    }
    50% { 
        transform: translateY(-50%) translateX(120%);
        background: linear-gradient(135deg, var(--info-color), var(--primary-color));
    }
}

.sidebar.mobile-open .swipe-indicator {
    display: none;
}

@media (max-width: 1024px) {
    .sidebar:not(.mobile-open) .swipe-indicator {
        display: flex;
        opacity: 1;
        pointer-events: auto;
        animation: swipeHint 2s infinite;
    }
    
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: var(--sidebar-width);
        transform: translateX(-100%);
        transition: transform var(--transition-normal) cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2);
        z-index: 200;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 199;
        backdrop-filter: blur(4px);
        transition: opacity var(--transition-normal) ease;
        opacity: 0;
    }
    
    .sidebar.mobile-open + .sidebar-overlay {
        display: block;
        opacity: 1;
    }
    
    .mobile-menu-btn {
        display: flex;
    }
    
    .sidebar-toggle-btn {
        display: none;
    }
    
    /* НА МОБИЛЬНОМ УБИРАЕМ ОТСТУП */
    .main-content,
    .main-content.sidebar-collapsed {
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    .message-content {
        max-width: 85%;
    }
    
    .message-text {
        font-size: 14px;
        padding: 8px 76px 19px 12px;
    }
    
    .message-text:has(> code),
    .message-text:has(> pre) {
        font-size: 13px;
        padding: 10px;
    }
    
    .swipe-indicator {
        width: 28px;
        height: 28px;
        right: -14px;
    }
    
    .swipe-indicator i {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .message-content {
        max-width: 90%;
    }
    
    .message-text {
        font-size: 14px;
        padding: 8px 72px 19px 11px;
    }
    
    .message-text.very-long {
        font-size: 13px;
        padding: 7px 72px 28px 11px;
        border-radius: 14px;
    }

    .message-expand-btn {
        bottom: -12px;
        padding: 6px 11px;
        font-size: 11px;
    }
}

@keyframes showSwipeIndicator {
    0%, 80% {
        opacity: 1;
        pointer-events: auto;
    }
    100% {
        opacity: 0;
        pointer-events: none;
    }
}

@media (max-width: 1024px) {
    .sidebar:not(.mobile-open) .swipe-indicator {
        display: flex;
        opacity: 1;
        pointer-events: auto;
        animation: showSwipeIndicator 3s ease forwards, swipeHint 2s infinite 0.5s;
    }
}

.theme-toggle-btn {
    position: relative;
    overflow: hidden;
}

.theme-toggle-btn i {
    transition: transform 0.3s ease, color 0.2s ease;
}

.theme-toggle-btn:hover i {
    transform: rotate(15deg) scale(1.1);
}

.theme-toggle-btn:active i {
    transform: rotate(0deg) scale(0.95);
}

.sidebar .theme-indicator {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sidebar .theme-indicator:hover {
    transform: scale(1.1);
}

/* ====================== РЕАКЦИИ НА СООБЩЕНИЯ ====================== */

.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 0;
    position: absolute;
    left: 12px;
    bottom: -10px;
    z-index: 3;
    max-width: calc(100% - 20px);
    pointer-events: auto;
}

.message.own .message-reactions {
    left: auto;
    right: 12px;
    justify-content: flex-end;
}

.reaction-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--bg-secondary);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
    position: relative;
    line-height: 1;
}

.message.own .reaction-badge {
    background: rgba(255, 255, 255, 0.95);
}

.reaction-badge:hover {
    background: var(--bg-hover);
    transform: scale(1.05);
}

.reaction-badge.user-reacted {
    background: rgba(35, 149, 8, 0.15);
    border-color: var(--primary-color);
}

.message.own .reaction-badge.user-reacted {
    background: rgba(52, 199, 89, 0.18);
}

.reaction-emoji {
    font-size: 14px;
}

.reaction-count {
    font-size: 11px;
    color: var(--text-secondary);
}

.reaction-menu {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    animation: fadeInUp 0.2s ease;
    max-width: 260px;
    width: auto;
    min-width: 200px;
}

.reaction-menu.mobile {
    width: 90%;
    max-width: 260px;
}

.reaction-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.reaction-menu-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-muted);
}

.reaction-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    max-width: 100%;
}

.reaction-option {
    width: 44px;
    height: 44px;
    font-size: 24px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.reaction-option:hover {
    background: var(--bg-hover);
    transform: scale(1.1);
}

.reaction-option.active {
    background: rgba(35, 149, 8, 0.2);
    box-shadow: 0 0 0 2px var(--primary-color);
}

.reaction-menu-footer {
    padding: 8px 12px;
    border-top: 1px solid var(--border-color);
}

.remove-reaction-btn {
    width: 100%;
    padding: 6px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 12px;
}

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

/* Подсказка при наведении на реакцию */
.reaction-badge[data-users]:hover::after {
    content: attr(data-users);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    z-index: 100;
    pointer-events: none;
}

.message-bubble {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 100%;
    position: relative;
}

.message-bubble > .message-expand-btn {
    position: absolute;
}

.message.own .message-text.very-long {
    background: var(--primary-buble-message);
    border-color: var(--primary-color);
    color: #fff;
}

/* В ваш основной CSS файл */
.upload-progress-container {
    position: relative;
    width: 200px;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.upload-progress-bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
    border-radius: 2px;
}

.upload-progress-text {
    position: absolute;
    right: 0;
    top: -18px;
    font-size: 10px;
    color: var(--text-secondary);
}

.message.uploading {
    opacity: 0.7;
}

.message.uploading .message-file {
    background: var(--bg-tertiary);
}

.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* ====================== МОДАЛЬНОЕ ОКНО ДЛЯ ИЗОБРАЖЕНИЙ (КАК В TELEGRAM) ====================== */

.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: imageModalFadeIn 0.2s ease;
}

.image-modal.closing {
    animation: imageModalFadeOut 0.2s ease forwards;
}

@keyframes imageModalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes imageModalFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.image-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(8px);
}

.image-modal-container {
    position: relative;
    z-index: 1;
    background: transparent;
    border-radius: 28px;
    overflow: hidden;
    animation: imageModalZoom 0.25s cubic-bezier(0.2, 0.9, 0.4, 1.1);
}

@keyframes imageModalZoom {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.image-modal-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), transparent);
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-modal-container:hover .image-modal-header,
.image-modal-header:focus-within {
    opacity: 1;
}

.image-modal-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.image-modal-name {
    color: white;
    font-size: 15px;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.image-modal-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.image-modal-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.image-modal-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.image-modal-btn:active {
    transform: scale(0.95);
}

.image-modal-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 200px;
    min-height: 200px;
    background: transparent;
}

.image-modal-img {
    display: block;
    border-radius: 8px;
    object-fit: contain;
    cursor: pointer;
    transition: transform 0.2s ease;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.image-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 200px;
    min-height: 200px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-error {
    color: white;
    text-align: center;
    font-size: 14px;
}

.loading-error i {
    font-size: 32px;
    margin-bottom: 12px;
    display: block;
}

.image-modal-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 20px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.5), transparent);
    text-align: center;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-modal-container:hover .image-modal-footer {
    opacity: 1;
}

.image-modal-size {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
}

/* Мобильная версия */
@media (max-width: 768px) {
    .image-modal-header {
        padding: 12px 16px;
    }
    
    .image-modal-name {
        font-size: 13px;
        max-width: 180px;
    }
    
    .image-modal-btn {
        width: 32px;
        height: 32px;
    }
    
    .image-modal-footer {
        padding: 10px 16px;
    }
    
    .image-modal-size {
        font-size: 11px;
    }
}

/* Для очень маленьких экранов */
@media (max-width: 480px) {
    .image-modal-name {
        max-width: 120px;
    }
}
/* Поддержка свайпа для закрытия на мобильных */
@media (max-width: 768px) {
    .image-modal-img {
        cursor: default;
        touch-action: pan-y pinch-zoom;
    }
}
.message-menu {
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    overflow: hidden;
    min-width: 180px;
    max-width: 260px;
    width: auto;
    z-index: 10001;
}

.message-menu.mobile {
    width: 90%;
    max-width: 180px;
}

.message-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-secondary);
}

.message-menu-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-muted);
}

.message-menu-actions {
    display: flex;
    flex-direction: column;
}

.message-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    transition: background 0.2s;
    text-align: left;
}

.message-menu-item:hover {
    background: var(--bg-hover);
}

.message-menu-item i {
    width: 20px;
    color: var(--text-secondary);
}

.message-menu-item.delete-btn i {
    color: var(--danger-color);
}
/* ====================== ПЕРЕСЛАННЫЕ СООБЩЕНИЯ ====================== */

.message-forward-badge {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding-bottom: 4px;
    border-bottom: 1px dashed var(--border-color);
}

.message-forward-badge i {
    font-size: 10px;
}

.message-forward-preview {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    margin-bottom: 8px;
    border: 1px solid var(--border-light);
}

.forward-preview-header {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.forward-preview-header i {
    font-size: 10px;
}

.forward-preview-content {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ====================== АНИМАЦИЯ УДАЛЕНИЯ СООБЩЕНИЯ ====================== */

.message.removing {
    animation: messageFadeOut 0.3s ease forwards;
}

@keyframes messageFadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.8);
        display: none;
    }
}

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

/* ====================== ПРЕДПРОСМОТР ПЕРЕСЫЛКИ В МОДАЛЬНОМ ОКНЕ ====================== */

.forward-preview {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
}

.forward-preview-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px dashed var(--border-color);
}

.forward-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    overflow: hidden;
}

.forward-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.forward-message {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    word-break: break-word;
    padding: 4px 0;
}

/* ====================== ИНДИКАТОР РЕДАКТИРОВАНИЯ ====================== */

.message-edited {
    font-size: 10px;
    color: var(--text-muted);
    margin-left: 6px;
}

.message.own .message-edited {
    color: rgba(255, 255, 255, 0.6);
}

/* ====================== SCROLL TO BOTTOM БОТТОН ====================== */

.scroll-to-bottom-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
    z-index: 90;
}

.scroll-to-bottom-btn.visible {
    opacity: 1;
    transform: translateY(0);
}

.scroll-to-bottom-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

/* ====================== EMOJI И ТЕКСТ ====================== */

.message-text a {
    color: var(--text-primary);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    opacity: 0.9;
}

.message-text a:hover {
    opacity: 1;
}

.message.own .message-text a {
    color: white;
}
/* ====================== СТИЛИ ДЛЯ ОТВЕТОВ И ПЕРЕСЫЛОК ====================== */

/* Панель ответа (reply bar) */
.reply-bar {
    background: var(--bg-tertiary);
    border-radius: 12px;
    margin-bottom: 8px;
    padding: 8px 12px;
    border-left: 3px solid var(--primary-color);
    animation: slideDown 0.2s ease;
}

.reply-bar-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.reply-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.reply-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

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

.reply-label {
    font-size: 12px;
    color: var(--primary-color);
    margin-bottom: 2px;
}

.reply-label i {
    margin-right: 4px;
}

.reply-preview {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-cancel-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 0 4px;
    transition: color 0.2s;
}

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

/* Предпросмотр цитаты в сообщении */
.message-reply-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-md);
    margin-bottom: 2px;
    border-left: 3px solid var(--primary-color);
    cursor: pointer;
    transition: all 0.2s ease;
    width: fit-content;
    max-width: min(420px, 100%);
    align-self: flex-start;
}

.message.own .message-reply-preview {
    background: rgba(255, 255, 255, 0.1);
    align-self: flex-end;
}

.message-reply-preview:hover {
    background: var(--bg-hover);
    transform: translateX(2px);
}

.reply-preview-avatar {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.reply-preview-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.reply-preview-content {
    flex: 1;
    min-width: 0;
    max-width: 320px;
}

.reply-preview-sender {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 2px;
}

.reply-preview-text {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-reply-preview i {
    color: var(--text-muted);
    font-size: 12px;
    opacity: 0.5;
}

/* Пересланные сообщения */
.message-forward-badge {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding-bottom: 4px;
    border-bottom: 1px dashed var(--border-color);
}

.message-forward-badge i {
    font-size: 10px;
}

.message-forward-preview {
    background: rgba(0, 0, 0, 0.03);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
}

.message.own .message-forward-preview {
    background: rgba(255, 255, 255, 0.08);
}

.message-forward-preview i {
    margin-right: 6px;
    font-size: 11px;
    opacity: 0.5;
}

/* Анимации */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Подсветка цитируемого сообщения */
.message.highlight .message-bubble {
    animation: highlightMessage 2s ease;
}

@keyframes highlightMessage {
    0% {
        background-color: rgba(35, 149, 8, 0.2);
    }
    100% {
        background-color: transparent;
    }
}

/* Модальное окно пересылки */
.forward-sender-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
}

.forward-sender-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.forward-sender-name {
    font-weight: 600;
    color: var(--primary-color);
}

.forward-message {
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--text-secondary);
    max-height: 150px;
    overflow-y: auto;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label i {
    color: var(--text-muted);
}
/* Аватар в пересланном сообщении */
.forward-preview-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

/* Аватар в панели ответа */
.reply-bar-content .reply-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.reply-bar-content .reply-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
/* Панель редактирования сообщения */
.edit-bar {
    background: var(--bg-tertiary);
    border-radius: 12px;
    margin-bottom: 8px;
    padding: 8px 12px;
    border-left: 3px solid var(--warning-color);
    animation: slideDown 0.2s ease;
}

.edit-bar-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.edit-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--warning-color);
}

.edit-info i {
    font-size: 14px;
}

.edit-cancel-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 0 4px;
}

.edit-cancel-btn:hover {
    color: var(--danger-color);
}

/* Индикатор активного звонка в чате */
.call-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: rgba(35, 149, 8, 0.15);
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 6px;
}

.call-indicator:hover {
    background: rgba(35, 149, 8, 0.25);
}

.call-indicator i {
    font-size: 12px;
    color: var(--primary-color);
}

.call-indicator span {
    color: var(--text-secondary);
}

.call-indicator-join-btn {
    background: var(--primary-color);
    border: none;
    border-radius: 16px;
    padding: 4px 10px;
    color: white;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.call-indicator-join-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.02);
}

.call-indicator-leave-btn {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    padding: 0;
    color: var(--danger-color, #ff4d5e);
    border: 1px solid color-mix(in srgb, var(--danger-color, #ff4d5e) 35%, transparent);
    border-radius: 50%;
    background: color-mix(in srgb, var(--danger-color, #ff4d5e) 9%, transparent);
    cursor: pointer;
    transition: transform .16s ease, background .16s ease;
}

.call-indicator-leave-btn i {
    color: inherit;
}

.call-indicator-leave-btn:hover {
    background: color-mix(in srgb, var(--danger-color, #ff4d5e) 18%, transparent);
    transform: scale(1.05);
}

/* Мини-индикатор в списке чатов */
.chat-item-call-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    background: var(--primary-color);
    border-radius: 12px;
    font-size: 10px;
    color: white;
    margin-left: 8px;
}

.chat-item-call-badge i {
    font-size: 10px;
}

/* Анимация для удаления сообщения */
.message.removing {
    animation: messageFadeOut 0.3s ease forwards;
}

@keyframes messageFadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.8);
        display: none;
    }
}

/* Стили для блока пересланного сообщения */
.forward-preview {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 8px;
    border: 1px solid var(--border-light);
}

.forward-preview-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px dashed var(--border-color);
}

.forward-avatar {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    overflow: hidden;
}

.forward-message {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    word-break: break-word;
}

/* Стили для кнопок звонка в хедере чата */
.chat-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-circle);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

#group-video-call-btn:hover {
    color: var(--primary-color);
}

#group-audio-call-btn:hover {
    color: var(--success-color);
}

/* Анимация появления */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
/* ====================== АДМИН-ПАНЕЛЬ ====================== */

.admin-panel {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.admin-header h2 {
    font-size: 24px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.admin-stats .stat-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.admin-stats .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
}

.admin-stats .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.admin-users-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 12px;
}

.section-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.search-box {
    position: relative;
    width: 250px;
}

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

.search-box input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    color: var(--text-primary);
}

.users-list {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    transition: all 0.2s;
}

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

.user-avatar {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.user-status {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--bg-tertiary);
}

.user-status.online {
    background: #34c759;
}

.user-status.offline {
    background: #8e8e93;
}

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

.user-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.user-username {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.user-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--primary-color);
    color: white;
}

.delete-btn:hover {
    background: var(--danger-color);
}

.chat-role-badge {
    width: 14px;
    height: 14px;
    margin-left: 6px;
    vertical-align: middle;
    display: inline-block;
}

.chat-item-name {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.chat-item-name .chat-role-badge {
    margin-left: 4px;
    flex: 0 0 auto;
}

.ai-verify-badge {
    width: 15px;
    height: 15px;
    display: inline-block;
    vertical-align: -2px;
    margin-left: 5px;
    object-fit: contain;
    flex: 0 0 auto;
}

.ai-header-verify-badge {
    width: 18px;
    height: 18px;
    vertical-align: -3px;
}

.chat-item-name .ai-verify-badge {
    margin-left: 4px;
}

/* ====================== МОБИЛЬНАЯ АДАПТАЦИЯ ====================== */

@media (max-width: 768px) {
    .admin-panel {
        padding: 12px;
    }
    
    .admin-header h2 {
        font-size: 20px;
        margin-bottom: 16px;
    }
    
    .admin-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 16px;
    }
    
    .admin-stats .stat-card {
        padding: 12px;
    }
    
    .admin-stats .stat-value {
        font-size: 22px;
    }
    
    .admin-stats .stat-label {
        font-size: 11px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 16px;
    }
    
    .search-box {
        width: 100%;
    }
    
    .users-list {
        padding: 8px;
    }
    
    .user-item {
        padding: 10px;
        gap: 12px;
    }
    
    .user-avatar {
        width: 44px;
        height: 44px;
    }
    
    .user-name {
        font-size: 14px;
    }
    
    .user-username {
        font-size: 11px;
    }
    
    .action-btn {
        width: 32px;
        height: 32px;
    }
}

@media (max-width: 480px) {
    .admin-stats {
        gap: 8px;
    }
    
    .admin-stats .stat-card {
        padding: 10px;
    }
    
    .admin-stats .stat-value {
        font-size: 18px;
    }
    
    .user-item {
        flex-wrap: wrap;
    }
    
    .user-actions {
        width: 100%;
        justify-content: flex-end;
        padding-top: 8px;
        border-top: 1px solid var(--border-light);
    }
}
/* ====================== МОДАЛЬНОЕ ОКНО ДЛЯ ВЫБОРА РОЛИ ====================== */

#change-role-modal .modal-content {
    max-width: 400px;
}

#change-role-modal {
    align-items: center;
    justify-content: center;
}

#change-role-modal[style*="display: block"],
#change-role-modal[style*="display: flex"] {
    display: flex;
}

.role-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.role-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border-light);
}

.role-option:hover {
    background: var(--bg-hover);
    border-color: var(--primary-color);
}

.role-option.selected {
    border-color: var(--primary-color);
    background: rgba(35, 149, 8, 0.1);
}

.role-option input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.role-option-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.role-option-content i {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 50%;
    font-size: 16px;
    color: var(--primary-color);
}

.role-option-info {
    flex: 1;
}

.role-option-info strong {
    display: block;
    font-size: 15px;
    margin-bottom: 4px;
}

.role-option-info small {
    font-size: 11px;
    color: var(--text-muted);
}


.ggdep-switch {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    cursor: pointer;
}

.ggdep-switch input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.ggdep-switch > span {
    position: relative;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: var(--border-color, #cbd5e1);
    box-shadow: inset 0 0 0 1px rgb(15 23 42 / 8%);
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.ggdep-switch > span::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 5px rgb(15 23 42 / 25%);
    transition: transform 0.2s ease;
}

.ggdep-switch input:checked + span {
    background: var(--primary-color);
}

.ggdep-switch input:checked + span::after {
    transform: translateX(18px);
}

.ggdep-switch input:focus-visible + span {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 24%, transparent);
}

/* Мобильная версия модального окна */
@media (max-width: 480px) {
    #change-role-modal .modal-content {
        width: 95%;
        margin: 10px;
        border-radius: 16px;
    }
    
    .role-option {
        padding: 10px;
    }
    
    .role-option-content i {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    .role-option-info strong {
        font-size: 14px;
    }
    
    .role-option-info small {
        font-size: 10px;
    }
    
    .modal-footer {
        flex-direction: column;
        gap: 8px;
    }
    
    .modal-footer button {
        width: 100%;
    }
}
/* ====================== МОДАЛЬНОЕ ОКНО ПРОФИЛЯ ПОЛЬЗОВАТЕЛЯ ====================== */

#user-profile-modal .modal-content {
    max-width: 480px;
    padding: 0;
    overflow: hidden;
    border-radius: 24px;
}

.user-profile-modal {
    position: relative;
}

.profile-cover {
    padding: 40px 20px 60px;
    text-align: center;
    position: relative;
}

.profile-avatar-large {
    position: relative;
    display: inline-block;
}

.profile-avatar-large img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid white;
    box-shadow: var(--shadow-md);
}

.profile-status-badge {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

.profile-status-badge i {
    font-size: 8px;
}

.profile-status-badge.online {
    color: var(--success-color);
}

.profile-status-badge.offline {
    color: var(--text-muted);
}

.profile-info-section {
    padding: 20px 24px 24px;
    background: var(--bg-secondary);
}

.profile-name {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    margin: 0 0 4px;
}

.profile-username {
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
    margin: 0 0 20px;
}

.profile-stats {
    display: flex;
    justify-content: space-around;
    padding: 16px 0;
    margin-bottom: 20px;
    background: var(--bg-tertiary);
    border-radius: 16px;
}

.profile-stat {
    text-align: center;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.profile-details {
    margin-bottom: 24px;
}

.detail-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

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

.detail-icon {
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.detail-icon i {
    font-size: 16px;
    color: var(--primary-color);
}

.detail-content {
    flex: 1;
}

.detail-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 2px;
}

.detail-value {
    font-size: 15px;
    font-weight: 500;
    word-break: break-word;
}

.profile-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.profile-action-group {
    display: flex;
    gap: 12px;
    width: 100%;
    flex-wrap: wrap;
    flex-direction: column;
 }
    
.role-icon {
    width: 12px;
    height: 12px;
    vertical-align: middle;
    margin-right: 2px;
}

.profile-action-btn {
    flex: 1;
    padding: 12px 16px;
    border-radius: 40px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.profile-action-btn.primary {
    background: var(--primary-color);
    color: white;
}

.profile-action-btn.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.profile-action-btn.success {
    background: var(--success-color);
    color: white;
}

.profile-action-btn.success:hover {
    background: #2db84c;
}

.profile-action-btn.danger {
    background: var(--danger-color);
    color: white;
}

.profile-action-btn.danger:hover {
    background: #e33c32;
}

.profile-action-btn.pending {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
}

.profile-action-btn:active {
    transform: translateY(1px);
}

/* Мобильная адаптация */
@media (max-width: 480px) {
    #user-profile-modal .modal-content {
        width: 95%;
        margin: 10px;
        border-radius: 20px;
    }
    
    .profile-cover {
        padding: 30px 16px 50px;
    }
    
    .profile-avatar-large img {
        width: 80px;
        height: 80px;
    }
    
    .profile-info-section {
        padding: 16px 20px 20px;
    }
    
    .profile-name {
        font-size: 20px;
    }
    
    .profile-stats {
        padding: 12px 0;
    }
    
    .stat-value {
        font-size: 18px;
    }
    
    .profile-actions {
        flex-direction: column;
    }
    
    .profile-action-group {
        flex-direction: column;
    }
    
    .profile-action-btn {
        padding: 10px 14px;
    }
}
/* Бейдж роли в карточке друга */
.friend-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.chat-details {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.chat-details h3 {
    margin: 0;
    display: inline-flex;
    align-items: center;
}

.chat-header-role-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 0;
}

.chat-header-role-badge .role-icon {
    width: 14px;
    height: 14px;
    vertical-align: middle;
}
.message-image,
.message-file,
.message-text {
    cursor: pointer;
    position: relative;
}

.message-image:hover,
.message-file:hover,
.message-text:hover {
    filter: brightness(0.98);
}

.message-image .image-container {
    position: relative;
}

@media (max-width: 768px) {
    .message-image,
    .message-file {
        min-height: 44px;
    }
}
/* Карточка задачи в чате */


/* Модальное окно задачи из чата */


.participant-info {
    display: flex;
    flex-direction: column;
}

.participant-name {
    font-weight: 500;
}

.participant-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}


.tab-count {
    background: var(--bg-tertiary);
    padding: 0px 6px;
    border-radius: 20px;
    font-size: 0.7rem;
}


.history-item {
    display: flex;
    gap: 10px;
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
}

.history-item-icon {
    width: 28px;
    height: 28px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 0.8rem;
}

.history-item-content {
    flex: 1;
}

.history-item-action {
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.history-item-user {
    display: flex;
    gap: 8px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.history-item-change {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
}


/* В style1.css, добавьте */
.message.highlight .message-bubble {
    animation: highlightMessage 2s ease;
}

@keyframes highlightMessage {
    0% {
        background-color: rgba(35, 149, 8, 0.2);
        box-shadow: 0 0 0 2px rgba(35, 149, 8, 0.3);
    }
    100% {
        background-color: transparent;
        box-shadow: none;
    }
}
.toast-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10001;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 12px 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.3s ease;
}

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

/* Voice messages */
.voice-record-btn.is-recording {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
    min-width: 64px;
    width: auto;
    padding: 0 10px;
    gap: 6px;
}

.voice-record-time {
    font-size: 12px;
    font-weight: 700;
}

.voice-message {
    min-width: 230px;
    max-width: 340px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 82px 26px 12px;
    border-radius: 18px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    position: relative;
}

.message.own .voice-message {
    background: var(--primary-buble-message);
    border-color: var(--primary-color);
    color: #fff;
}

.voice-play-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: #fff;
    cursor: pointer;
    flex: 0 0 auto;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.14);
}

.message.own .voice-play-btn {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}

.voice-message-main {
    min-width: 0;
    flex: 1;
}

.voice-wave {
    height: 22px;
    display: flex;
    align-items: center;
    gap: 3px;
    opacity: 0.8;
}

.voice-wave span {
    width: 3px;
    border-radius: 999px;
    background: currentColor;
    opacity: 0.65;
}

.voice-wave span:nth-child(1) { height: 8px; }
.voice-wave span:nth-child(2) { height: 16px; }
.voice-wave span:nth-child(3) { height: 12px; }
.voice-wave span:nth-child(4) { height: 20px; }
.voice-wave span:nth-child(5) { height: 10px; }
.voice-wave span:nth-child(6) { height: 18px; }
.voice-wave span:nth-child(7) { height: 9px; }

.voice-meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
    font-size: 12px;
}

.voice-duration {
    color: var(--text-muted);
    font-weight: 700;
}

.message.own .voice-duration {
    color: rgba(255, 255, 255, 0.8);
}

.voice-transcript-toggle {
    border: 0;
    background: transparent;
    color: var(--primary-color);
    font-size: 12px;
    font-weight: 700;
    padding: 0;
    cursor: pointer;
}

.message.own .voice-transcript-toggle {
    color: rgba(255, 255, 255, 0.9);
}

.voice-transcript {
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.62);
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.35;
    white-space: pre-wrap;
}

.message.own .voice-transcript {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.voice-transcript.is-hidden {
    display: none;
}

@media (max-width: 768px) {
    .voice-message {
        min-width: 210px;
        max-width: min(330px, calc(100vw - 82px));
        padding-right: 76px;
    }
}

/* Chat polish: compact bubbles, swipe reply, voice preview */
.message-content {
    width: fit-content;
    max-width: min(72%, 680px);
}

.message.own .message-content {
    margin-left: auto;
}

.message-bubble {
    width: fit-content;
    max-width: 100%;
}

.message-text {
    padding: 9px 14px 21px 14px;
    min-width: 78px;
}

.message-text.very-long {
    width: auto;
}



.message-time {
    right: 10px;
    bottom: 6px;
    max-width: none;
    overflow: visible;
}

.message.reply-swipe-active::after {
    content: "";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    background: rgba(108, 99, 255, 0.12);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
    pointer-events: none;
    z-index: 2;
}

.message .message-bubble {
    transition: transform 0.16s ease;
}

.voice-send-preview {
    padding: 0 14px 8px;
}

.voice-send-preview-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 18px;
    background: rgba(108, 99, 255, 0.08);
    border: 1px solid rgba(108, 99, 255, 0.18);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
}

.voice-preview-info {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.voice-preview-info strong {
    font-size: 13px;
    color: var(--text-primary);
}

.voice-preview-info span {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.voice-preview-play,
.voice-preview-cancel,
.voice-preview-send {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: 0 0 auto;
}

.voice-preview-play {
    background: var(--bg-secondary);
    color: var(--primary-color);
}

.voice-preview-cancel {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

.voice-preview-send {
    background: var(--primary-color);
    color: #fff;
}

.voice-preview-send:disabled {
    opacity: 0.7;
    cursor: wait;
}

@media (max-width: 768px) {
    .message-content {
        max-width: min(82%, 620px);
    }

    .message-text {
        padding-right: 13px;
    }

    .voice-send-preview {
        padding: 0 10px 8px;
    }
}

/* Chat message layout fixes: media time, compact voice transcripts, mobile reply bar */
.media-message-bubble {
    position: relative;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    overflow: visible;
}

.media-message-bubble > .message-attachments,
.media-message-bubble > .message-file,
.media-message-bubble > .message-image,
.media-message-bubble > .message-image-group {
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

.media-message-bubble .message-time {
    position: absolute;
    right: 8px;
    bottom: 8px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    max-width: calc(100% - 16px);
    padding: 4px 7px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.46);
    color: #fff !important;
    line-height: 1;
    font-size: 10.5px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.media-message-bubble.has-reactions .message-time,
.message.has-reactions .media-message-bubble .message-time {
    bottom: 18px;
}

.media-message-bubble .message-reactions {
    bottom: -8px;
}

.voice-message-bubble {
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}

.voice-message-bubble .voice-message {
    box-sizing: border-box;
    min-width: 244px;
    width: fit-content;
    max-width: min(360px, calc(100vw - 92px));
    align-items: center;
    gap: 12px;
    padding: 10px 62px 24px 11px;
}

.voice-message-bubble .voice-transcript {
    margin-top: 8px;
    padding: 1px 2px;
    border-radius: 12px;
    font-size: 12.5px;
    line-height: 1.42;
    max-height: 140px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.54);
}

.voice-message-bubble .voice-transcript.is-hidden {
    display: none !important;
}

.message.own .voice-message-bubble .voice-transcript {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.18);
}

.voice-message-bubble .voice-transcript-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 24px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(108, 99, 255, 0.11);
    color: var(--primary-color);
    font-size: 11.5px;
    opacity: 0.96;
    white-space: nowrap;
}

.voice-message-bubble .voice-transcript-toggle:disabled {
    cursor: default;
    opacity: 0.62;
}

.message.own .voice-message-bubble .voice-transcript-toggle {
    background: rgba(255, 255, 255, 0.16);
    color: rgba(255, 255, 255, 0.94);
}

.voice-message-bubble .voice-transcript-toggle i {
    font-size: 10px;
}

.voice-message-bubble .voice-wave {
    height: 22px;
}

.voice-message-bubble .message-time {
    right: 10px;
    bottom: 6px;
}

.reply-bar {
    padding: 0;
    margin: 0 0 8px;
    background: transparent;
    border: 0;
}

.reply-bar-content {
    position: relative;
    display: grid;
    grid-template-columns: 26px 1fr 28px;
    grid-template-rows: auto auto;
    column-gap: 8px;
    row-gap: 1px;
    align-items: center;
    padding: 8px 9px;
    border-radius: 14px;
    background: rgba(108, 99, 255, 0.08);
    border: 1px solid rgba(108, 99, 255, 0.16);
    border-left: 3px solid var(--primary-color);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.reply-bar-content .reply-avatar {
    grid-row: 1 / span 2;
    width: 24px;
    height: 24px;
}

.reply-bar-content .reply-info {
    grid-column: 2;
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 5px;
    font-size: 12px;
    line-height: 1.1;
    color: var(--primary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-bar-content .reply-info i {
    font-size: 10px;
    flex: 0 0 auto;
}

.reply-bar-content .reply-preview {
    grid-column: 2;
    font-size: 11.5px;
    line-height: 1.2;
    color: var(--text-muted);
    min-width: 0;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-bar-content .reply-cancel-btn {
    grid-column: 3;
    grid-row: 1 / span 2;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
}

@media (max-width: 768px) {
    .reply-bar-content {
        grid-template-columns: 22px 1fr 26px;
        padding: 7px 8px;
        border-radius: 13px;
    }

    .reply-bar-content .reply-avatar {
        width: 22px;
        height: 22px;
    }

    .reply-bar-content .reply-info {
        font-size: 11.5px;
    }

    .reply-bar-content .reply-preview {
        font-size: 11px;
    }

    .voice-message-bubble .voice-message {
        min-width: 200px;
        max-width: min(320px, calc(100vw - 84px));
        padding: 8px 68px 21px 10px;
    }

    .voice-message-bubble .voice-transcript {
        max-height: 82px;
        font-size: 12px;
    }
}

/* Final chat polish: notification auto-clear, readable voice transcript, stable time badges */
.chat-area-full,
.chat-messages-container,
.chat-messages,
.message,
.message-content,
.message-bubble {
    min-width: 0;
    max-width: 100%;
}

.chat-area-full,
.chat-messages-container {
    overflow-x: hidden;
}

.chat-messages {
    display: flex;
    overflow-x: hidden;
    gap: 6px;
    overscroll-behavior-x: contain;
}

.message {
    width: 100%;
}

.message-content {
    width: auto;
    max-width: min(68%, 660px);
}

.message-bubble:not(.media-message-bubble):not(.voice-message-bubble) {
    display: inline-block;
    width: auto;
    max-width: 100%;
    position: relative;
}

.message-bubble:not(.media-message-bubble):not(.voice-message-bubble) .message-text {
    box-sizing: border-box;
    width: auto;
    min-width: 112px;
    max-width: 100%;
    padding: 7px 11px 18px;
    border: 0;
    border-radius: 18px 18px 18px 7px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.055));
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.14);
}

.message-bubble:not(.media-message-bubble):not(.voice-message-bubble) .message-text::after {
    content: "";
    display: inline-block;
    width: 62px;
    height: 1px;
}

.message.own .message-bubble:not(.media-message-bubble):not(.voice-message-bubble) .message-text {
    box-sizing: border-box;
    width: auto;
    min-width: 112px;
    max-width: 100%;
    padding: 7px 11px 18px;
    border-radius: 18px 18px 7px 18px;
    background: linear-gradient(180deg, #278d16 0%, var(--primary-buble-message) 100%);
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.16);
}

.message.own .message-bubble:not(.media-message-bubble):not(.voice-message-bubble) .message-text::after {
    width: 70px;
}

.message-bubble.long-time-bubble:not(.media-message-bubble):not(.voice-message-bubble) {
    min-width: 126px;
}

.message.own .message-bubble.long-time-bubble:not(.media-message-bubble):not(.voice-message-bubble) {
    min-width: 132px;
}

.message-bubble.long-time-bubble:not(.media-message-bubble):not(.voice-message-bubble) .message-text {
    min-width: 126px;
}

.message-bubble.long-time-bubble:not(.media-message-bubble):not(.voice-message-bubble) .message-text::after {
    width: 82px;
}

.message.own .message-bubble.long-time-bubble:not(.media-message-bubble):not(.voice-message-bubble) .message-text {
    min-width: 132px;
}

.message.own .message-bubble.long-time-bubble:not(.media-message-bubble):not(.voice-message-bubble) .message-text::after {
    width: 90px;
}

.message-bubble:not(.media-message-bubble):not(.voice-message-bubble) .message-time {
    right: 10px;
    bottom: 6px;
    max-width: calc(100% - 20px);
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 10.5px;
    letter-spacing: 0;
    opacity: 0.72;
}

.message-bubble:not(.media-message-bubble):not(.voice-message-bubble) .message-text a,
.message-bubble:not(.media-message-bubble):not(.voice-message-bubble) .message-text code,
.message-bubble:not(.media-message-bubble):not(.voice-message-bubble) .message-text pre {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.media-message-bubble {
    position: relative !important;
    padding: 0 !important;
    overflow: visible !important;
}

.media-message-bubble .message-time {
    position: absolute !important;
    right: 8px !important;
    bottom: 8px !important;
    z-index: 7 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: auto !important;
    max-width: calc(100% - 18px) !important;
    padding: 4px 7px !important;
    border-radius: 999px !important;
    background: rgba(0, 0, 0, 0.48) !important;
    color: #fff !important;
    font-size: 10.5px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.message.has-reactions .media-message-bubble .message-time {
    bottom: 30px !important;
}

.voice-message-bubble .voice-message-main {
    min-width: 0;
    max-width: 100%;
}

.voice-message-bubble .voice-message {
background: linear-gradient(85deg, #86e475 0%, #fafafa 100%) !important;
    border: 0 !important;
    border-radius: 18px 18px 18px 8px !important;
    color: #2f3a45;
    box-shadow: 0 6px 18px rgba(20, 31, 46, 0.08) !important;
}

.message.own .voice-message-bubble .voice-message {
    background: var(--primary-buble-message) !important;
    border-radius: 18px 18px 8px 18px !important;
    color: #fff;
}

.voice-message-bubble .voice-play-btn {
    width: 38px;
    height: 38px;
    margin-top: 0;
    background: var(--primary-color);
    box-shadow: 0 8px 18px rgba(108, 99, 255, 0.22);
}

.message.own .voice-message-bubble .voice-play-btn {
    background: rgba(255, 255, 255, 0.24);
    box-shadow: none;
}

.voice-message-bubble .voice-wave {
    height: 22px;
    gap: 3px;
    opacity: 0.76;
}

.voice-message-bubble .voice-wave span {
    width: 2px;
}

.voice-message-bubble .voice-meta-row {
    margin-top: 4px;
    gap: 8px;
    line-height: 1.1;
    flex-wrap: wrap;
}

.voice-message-bubble .voice-duration {
    font-size: 11.5px;
    font-weight: 600;
}

.voice-message-bubble .voice-transcript-toggle {
    font-size: 11.5px !important;
    font-weight: 600;
    opacity: 0.96;
}

.voice-message-bubble .voice-transcript {
    box-sizing: border-box;
    display: block;
    width: auto;
    max-width: min(264px, 100%);
    margin: 8px 0 0 !important;
    padding: 1px 2px !important;
    border-radius: 12px !important;
    background: rgba(255, 255, 255, 0.72) !important;
    color: #28323c !important;
    font-size: 12px !important;
    line-height: 1.42 !important;
    max-height: none !important;
    overflow-y: visible;
    overflow-x: hidden;
    border: 1px solid rgba(255, 255, 255, 0.54);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45) !important;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: normal;
}

.voice-message-bubble .voice-transcript.is-hidden {
    display: none !important;
}

.message.own .voice-message-bubble .voice-transcript {
    background: rgba(255, 255, 255, 0.18) !important;
    color: rgba(255, 255, 255, 0.92) !important;
    border-color: rgba(255, 255, 255, 0.18);
}

.voice-message-bubble .voice-transcript:not(.is-hidden)::before {
    content: none;
}

@media (max-width: 768px) {
    .chat-messages {
        padding: 12px 10px 14px;
        gap: 5px;
    }

    .message-content {
        max-width: min(84%, 520px);
    }

    .message-bubble:not(.media-message-bubble):not(.voice-message-bubble) .message-text {
        min-width: 106px;
        padding: 6px 10px 17px;
    }

    .message-bubble:not(.media-message-bubble):not(.voice-message-bubble) .message-text::after {
        width: 58px;
    }

    .message.own .message-bubble:not(.media-message-bubble):not(.voice-message-bubble) .message-text {
        min-width: 106px;
    }

    .message.own .message-bubble:not(.media-message-bubble):not(.voice-message-bubble) .message-text::after {
        width: 64px;
    }

    .message-bubble.long-time-bubble:not(.media-message-bubble):not(.voice-message-bubble) {
        min-width: 122px;
    }

    .message.own .message-bubble.long-time-bubble:not(.media-message-bubble):not(.voice-message-bubble) {
        min-width: 128px;
    }

    .message-bubble.long-time-bubble:not(.media-message-bubble):not(.voice-message-bubble) .message-text {
        min-width: 122px;
    }

    .message-bubble.long-time-bubble:not(.media-message-bubble):not(.voice-message-bubble) .message-text::after {
        width: 76px;
    }

    .message.own .message-bubble.long-time-bubble:not(.media-message-bubble):not(.voice-message-bubble) .message-text {
        min-width: 128px;
    }

    .message.own .message-bubble.long-time-bubble:not(.media-message-bubble):not(.voice-message-bubble) .message-text::after {
        width: 82px;
    }

    .message-bubble:not(.media-message-bubble):not(.voice-message-bubble) .message-time {
        right: 9px;
        bottom: 5px;
        font-size: 10px;
    }

    .voice-message-bubble .voice-message {
        min-width: 208px;
        max-width: min(300px, calc(100vw - 72px));
        padding: 10px 58px 23px 10px;
    }

    .voice-message-bubble .voice-transcript {
        max-width: min(226px, 100%);
        margin-top: 7px !important;
        padding: 1px 2px !important;
        max-height: none !important;
        font-size: 11.5px !important;
    }
}
