* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-green: #25D366;
    --primary-green-dark: #128C7E;
    --primary-green-light: #DCF8C6;
    --gradient-start: #25D366;
    --gradient-end: #128C7E;
    --bg-color: #f0f2f5;
    --white: #ffffff;
    --text-primary: #111b21;
    --text-secondary: #667781;
    --border-color: #e9edef;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* Custom Scrollbar Styles - Applied to all scrollable elements */

/* Webkit browsers (Chrome, Safari, Edge) */
*::-webkit-scrollbar {
    width: 6px !important;
    height: 6px !important;
}

*::-webkit-scrollbar-track {
    background: var(--bg-color) !important;
    border-radius: 10px !important;
}

*::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%) !important;
    border-radius: 10px !important;
    border: none !important;
}

*::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--gradient-end) 0%, var(--gradient-start) 100%) !important;
}

/* For horizontal scrollbars */
*::-webkit-scrollbar:horizontal {
    height: 6px !important;
}

/* For specific elements that need scrollbar */
body,
html,
.sidebar,
.chats-list,
.messages-container,
.profile-screen,
.search-results {
    scrollbar-width: thin !important;
    scrollbar-color: var(--gradient-start) var(--bg-color) !important;
}

body::-webkit-scrollbar,
html::-webkit-scrollbar,
.sidebar::-webkit-scrollbar,
.chats-list::-webkit-scrollbar,
.messages-container::-webkit-scrollbar,
.profile-screen::-webkit-scrollbar,
.search-results::-webkit-scrollbar {
    width: 6px !important;
    height: 6px !important;
}

body::-webkit-scrollbar-track,
html::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track,
.chats-list::-webkit-scrollbar-track,
.messages-container::-webkit-scrollbar-track,
.profile-screen::-webkit-scrollbar-track,
.search-results::-webkit-scrollbar-track {
    background: var(--bg-color) !important;
    border-radius: 10px !important;
}

body::-webkit-scrollbar-thumb,
html::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb,
.chats-list::-webkit-scrollbar-thumb,
.messages-container::-webkit-scrollbar-thumb,
.profile-screen::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%) !important;
    border-radius: 10px !important;
    border: none !important;
}

body::-webkit-scrollbar-thumb:hover,
html::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover,
.chats-list::-webkit-scrollbar-thumb:hover,
.messages-container::-webkit-scrollbar-thumb:hover,
.profile-screen::-webkit-scrollbar-thumb:hover,
.search-results::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--gradient-end) 0%, var(--gradient-start) 100%) !important;
}

html {
    /* Предотвращаем масштабирование на мобильных */
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    touch-action: manipulation;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    min-height: 100vh;
    color: var(--text-primary);
    /* Предотвращаем масштабирование */
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    /* Разрешаем выделение текста в инпутах */
}

input, textarea, [contenteditable] {
    -webkit-user-select: text;
    user-select: text;
    touch-action: auto;
}

.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: flex;
}

/* Auth Screen */
#auth-screen {
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* Hide bottom nav only when auth screen is active */
#auth-screen.active ~ .bottom-nav,
body:has(#auth-screen.active) .bottom-nav {
    display: none !important;
}

.auth-container {
    background: var(--white);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.logo {
    text-align: center;
    margin-bottom: 30px;
}

.logo h1 {
    font-size: 36px;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.logo p {
    color: var(--text-secondary);
    font-size: 14px;
}

.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.3s;
}

.tab-btn.active {
    color: var(--primary-green-dark);
    border-bottom-color: var(--primary-green-dark);
    font-weight: 600;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form input {
    width: 100%;
    padding: 14px;
    margin-bottom: 15px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 15px;
    transition: border-color 0.3s;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary-green);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    color: var(--white);
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active {
    transform: translateY(0);
}

.error-message {
    margin-top: 15px;
    padding: 12px;
    background: #fee;
    color: #c33;
    border-radius: 8px;
    font-size: 14px;
    display: none;
}

.error-message.show {
    display: block;
}

/* Main App */
.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
    background: var(--white);
    padding-bottom: 60px;
}

@media (min-width: 769px) {
    .app-container {
        max-width: 1400px;
        margin: 0 auto;
        box-shadow: var(--shadow-lg);
        padding-bottom: 0;
    }
    
    .sidebar {
        width: 350px;
        flex: 0 0 350px;
        position: relative;
        display: flex !important;
    }
    
    .sidebar.hidden {
        display: none !important;
        width: 0 !important;
        flex: 0 0 0 !important;
    }
    
    .chat-area {
        flex: 1;
        position: relative;
        display: flex !important;
    }
    
    .chat-area.hidden {
        display: none !important;
    }
}

/* Copy toast animations */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Sidebar */
.sidebar {
    width: 100%;
    flex: 1;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: var(--white);
    min-width: 0;
}

.sidebar-header {
    padding: 20px 20px 15px 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-title {
    font-size: 24px;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

/* Chat Filters - iOS Style */
.chat-filters {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
}

.chat-filter-btn {
    flex: 1;
    padding: 8px 16px;
    background: rgba(142, 142, 147, 0.12);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.chat-filter-btn:hover {
    background: rgba(142, 142, 147, 0.18);
}

.chat-filter-btn.active {
    background: rgba(142, 142, 147, 0.25);
    color: var(--text-primary);
    font-weight: 600;
}

.chat-filter-btn:active {
    transform: scale(0.98);
    background: rgba(142, 142, 147, 0.3);
}

.search-container {
    padding: 15px;
    position: relative;
    border-bottom: 1px solid var(--border-color);
}

.btn-icon {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-color);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: background 0.2s;
}

.btn-icon:hover {
    background: var(--border-color);
}

.btn-icon.loading,
.chat-user-info.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.btn-icon.loading::after,
.chat-user-info.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid var(--primary-green);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.user-avatar, .chat-user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 600;
    font-size: 18px;
}

#search-input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 25px;
    font-size: 14px;
    background: var(--bg-color);
}

#search-input:focus {
    outline: none;
    border-color: var(--primary-green);
    background: var(--white);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 15px;
    right: 15px;
    background: var(--white);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    margin-top: 5px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.search-results.show {
    display: block;
}

.search-result-item {
    padding: 12px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s;
}

.search-result-item:hover {
    background: var(--bg-color);
}

.chats-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-item:hover {
    background: var(--bg-color);
}

.chat-item.active {
    background: var(--primary-green-light);
}

/* Chat item actions menu */
.chat-item-actions-menu {
    position: fixed;
    z-index: 10000;
    animation: slideInMenu 0.2s ease;
}

@keyframes slideInMenu {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.chat-item-actions-menu-content {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 8px;
    min-width: 200px;
}

.chat-item-action-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 15px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
    text-align: left;
}

.chat-item-action-btn:hover {
    background: var(--bg-secondary);
}

.chat-item-action-btn svg {
    flex-shrink: 0;
    color: var(--text-secondary);
}

.chat-item-action-delete {
    color: #e74c3c;
}

.chat-item-action-delete svg {
    color: #e74c3c;
}

.chat-item-action-delete:hover {
    background: rgba(231, 76, 60, 0.1);
}

.chat-item-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 600;
    flex-shrink: 0;
}

.chat-item-info {
    flex: 1;
    min-width: 0;
}

.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.chat-item-name {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-time {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.chat-item-last-message {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-unread {
    background: var(--primary-green);
    color: var(--white);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

/* Group chat item styles */
.chat-item-group {
    background: linear-gradient(135deg, rgba(37, 211, 102, 0.05) 0%, rgba(18, 140, 126, 0.05) 100%);
    border-left: 3px solid var(--primary-green);
}

.chat-item-group:hover {
    background: linear-gradient(135deg, rgba(37, 211, 102, 0.1) 0%, rgba(18, 140, 126, 0.1) 100%);
}

.chat-item-group.active {
    background: linear-gradient(135deg, rgba(37, 211, 102, 0.15) 0%, rgba(18, 140, 126, 0.15) 100%);
    border-left: 3px solid var(--primary-green-dark);
}

.chat-item-group .chat-item-avatar {
    border: 2px solid var(--primary-green);
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.2);
}

.chat-item-group .chat-item-name::before {
    content: "👥 ";
    margin-right: 4px;
    font-size: 14px;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-color);
}

.empty-chat {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-chat-content {
    text-align: center;
    color: var(--text-secondary);
}

.empty-chat-content svg {
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-chat-content h2 {
    margin-bottom: 10px;
    color: var(--text-primary);
}

.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.chat-header {
    padding: 15px 20px;
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-user-name {
    font-weight: 600;
    font-size: 16px;
}

.chat-user-status {
    font-size: 13px;
    color: var(--text-secondary);
    transition: color 0.3s;
}

.chat-user-status.online {
    color: var(--primary-green);
    font-weight: 500;
}

.chat-user-status.activity {
    color: var(--primary-green);
    font-style: italic;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    /* Оптимизация для плавной прокрутки */
    will-change: scroll-position;
    transform: translateZ(0);
    -webkit-overflow-scrolling: touch;
    /* Улучшаем производительность рендеринга */
    contain: layout style paint;
    position: relative;
}

/* Кнопка прокрутки вниз */
.scroll-to-bottom-btn {
    position: fixed;
    right: 20px;
    bottom: 100px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
    z-index: 1000;
    transition: all 0.3s ease;
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.scroll-to-bottom-btn.show {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.scroll-to-bottom-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(37, 211, 102, 0.5);
}

.scroll-to-bottom-btn:active {
    transform: scale(0.95);
}

.scroll-to-bottom-btn svg {
    width: 20px;
    height: 20px;
}

.message {
    display: flex;
    gap: 8px;
    max-width: 70%;
    animation: slideIn 0.3s ease;
    /* Оптимизация для плавного рендеринга */
    will-change: transform, opacity;
    transform: translateZ(0);
    /* Улучшаем производительность */
    contain: layout style paint;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translate3d(0, 10px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

.message.own {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 0;
}

.message-content {
    background: var(--white);
    padding: 10px 14px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    max-width: 100%;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
    box-sizing: border-box;
    overflow: hidden;
}

/* Имя автора сообщения в групповых чатах */
.message-author-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-green);
    margin-bottom: 4px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.message-author-name:hover {
    opacity: 0.8;
}

.message.own .message-author-name {
    color: rgba(255, 255, 255, 0.9);
}

.message.own .message-content {
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    color: var(--white);
    align-items: flex-end;
}

.message.own .voice-message-player {
    background: rgba(255, 255, 255, 0.15);
}

.message.deleted .message-text {
    color: var(--text-secondary);
    font-style: italic;
}

.message-text {
    font-size: 15px;
    line-height: 1.4;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    max-width: 100%;
    overflow: hidden;
}

/* System Messages */
.message.system-message {
    max-width: 100%;
    justify-content: center;
    margin: 16px 0;
    width: 100%;
}

.message.system-message .message-content {
    background: transparent;
    box-shadow: none;
    padding: 0;
    width: 100%;
    display: flex;
    justify-content: center;
}

.message.system-message .system-message-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    max-width: 80%;
}

.message.system-message .system-message-text {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    text-align: center;
    padding: 10px 24px;
    background: linear-gradient(135deg, rgba(37, 211, 102, 0.15) 0%, rgba(18, 140, 126, 0.15) 100%);
    border-radius: 18px;
    border: 1px solid rgba(37, 211, 102, 0.3);
    position: relative;
    display: inline-block;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-width: 100%;
    word-wrap: break-word;
    backdrop-filter: blur(5px);
}

.message.system-message .system-message-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 2px;
}

.message.system-message .message-time {
    font-size: 11px;
    color: var(--text-secondary) !important; /* Используем серый цвет для видимости на белом фоне */
    opacity: 0.8;
    margin: 0;
}

.message.system-message .system-message-action-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s, background 0.2s;
}

.message.system-message .system-message-action-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.1);
}

.message.system-message .system-message-action-btn svg {
    width: 14px;
    height: 14px;
    color: var(--text-secondary);
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
}

.message-read-status {
    display: inline-flex;
    align-items: center;
    margin-left: 4px;
    position: relative;
}

.message-read-status svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.message-read-status.sent {
    opacity: 0.6;
}

.message-read-status.read {
    opacity: 1;
}

.message-read-status.read svg:first-child {
    color: var(--primary-green);
}

.message.own .message-read-status.read svg:first-child {
    color: var(--white);
}

.message-read-status.read svg:last-child {
    color: var(--primary-green);
    margin-left: -12px;
}

.message.own .message-read-status.read svg:last-child {
    color: var(--white);
}

/* Failed message styles */
.message.failed {
    opacity: 0.8;
}

.message.failed .message-content {
    border-left: 3px solid #e74c3c;
}

.message-error-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e74c3c;
    color: white;
    font-size: 12px;
    font-weight: bold;
    margin-left: 4px;
    cursor: help;
    position: relative;
}

.message-error-icon:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    margin-bottom: 5px;
    z-index: 1000;
    pointer-events: none;
}

.message-error-icon:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    margin-bottom: -5px;
    z-index: 1000;
    pointer-events: none;
}

.message-error-text {
    color: #e74c3c;
    font-size: 12px;
    font-style: italic;
    margin-left: 4px;
}

.failed-message {
    color: #e74c3c;
}

.message-wrapper {
    position: relative;
    flex: 1;
    min-width: 0;
    max-width: 100%;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    overflow: hidden;
}

/* Разделитель между старыми и новыми сообщениями */
.messages-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    margin: 20px 0;
    padding: 0 20px;
}

.messages-separator-line {
    flex: 1;
    height: 1px;
    background: var(--border-color);
    max-width: 200px;
}

.messages-separator-text {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
    padding: 0 8px;
}

.message:hover .message-actions {
    opacity: 1;
}

.message-actions {
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s;
    background: var(--white);
    padding: 4px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    flex-shrink: 0;
    z-index: 10;
    pointer-events: auto;
}

.message.own .message-wrapper {
    flex-direction: row-reverse;
}

.message-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--bg-color);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: background 0.2s;
    position: relative;
    z-index: 10;
    pointer-events: auto;
}

.message-action-btn:hover {
    background: var(--border-color);
}

.message-action-btn:active {
    transform: scale(0.95);
}

.message-reply {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    border-left: 3px solid var(--primary-green);
}

.message.own .message-reply {
    background: rgba(255, 255, 255, 0.2);
    border-left-color: var(--white);
}

.message-reply-line {
    width: 2px;
    background: var(--primary-green);
    border-radius: 2px;
}

.message.own .message-reply-line {
    background: var(--white);
}

.message-reply-content {
    flex: 1;
}

.message-reply-author {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 2px;
    opacity: 0.8;
}

.message-reply-text {
    font-size: 13px;
    opacity: 0.7;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    word-break: break-word;
}

@media (max-width: 768px) {
    .message-reply {
        max-width: 90%;
    }
    
    .message-reply-text {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

.message-reply {
    cursor: pointer;
    transition: all 0.2s ease;
}

.message-reply:hover {
    opacity: 0.8;
    background: rgba(37, 211, 102, 0.1) !important;
    border-radius: 4px;
}

.reply-preview-content {
    cursor: pointer;
    transition: all 0.2s ease;
}

.reply-preview-content:hover {
    opacity: 0.8;
    background: rgba(37, 211, 102, 0.1);
    border-radius: 4px;
}

/* Эффект подсветки сообщения при прокрутке к нему */
.message-highlight {
    animation: messageHighlight 2s ease-in-out;
    background: rgba(37, 211, 102, 0.15) !important;
    border-left: 3px solid var(--primary-green) !important;
    padding-left: 12px !important;
    transition: all 0.3s ease;
}

@keyframes messageHighlight {
    0% {
        background: rgba(37, 211, 102, 0.3);
        transform: scale(1.02);
        box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
    }
    50% {
        background: rgba(37, 211, 102, 0.2);
        transform: scale(1.01);
        box-shadow: 0 2px 8px rgba(37, 211, 102, 0.2);
    }
    100% {
        background: rgba(37, 211, 102, 0.15);
        transform: scale(1);
        box-shadow: none;
    }
}

.message-forward {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    font-size: 12px;
    opacity: 0.8;
}

.message-forward > span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.message-forward-text {
    font-size: 13px;
    color: var(--text-primary);
    margin-top: 4px;
    padding-left: 22px;
    opacity: 0.9;
}

.message.own .message-forward {
    background: rgba(255, 255, 255, 0.2);
}

.message-forward svg {
    flex-shrink: 0;
}

.reply-preview,
.forward-preview {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
    border-left: 3px solid var(--primary-green);
    border-radius: 0;
    margin: 0;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
}

.reply-preview-content {
    display: flex;
    gap: 10px;
    flex: 1;
}

.reply-preview-line {
    width: 2px;
    background: var(--primary-green);
    border-radius: 2px;
}

.reply-preview-info {
    flex: 1;
}

.reply-preview-author {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--text-primary);
}

.reply-preview-text {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reply-preview-close,
.forward-preview-close {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.reply-preview-close:hover,
.forward-preview-close:hover {
    background: var(--border-color);
}

.forward-preview-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
}

.delete-menu {
    background: var(--white);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    padding: 5px;
    z-index: 1000;
    min-width: 150px;
}

.delete-menu-item {
    width: 100%;
    padding: 10px 15px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    font-size: 14px;
    color: var(--text-primary);
    transition: background 0.2s;
}

.delete-menu-item:hover {
    background: var(--bg-color);
}

.delete-menu-item[data-action="delete-all"] {
    color: #c33;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    z-index: 1000;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}


.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
    position: relative;
}

.bottom-nav-item.active {
    color: var(--primary-green);
}

.bottom-nav-item svg {
    width: 24px;
    height: 24px;
}

.bottom-nav-label {
    font-size: 12px;
    font-weight: 500;
}

.bottom-nav-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 600;
    font-size: 11px;
}

.bottom-nav-badge {
    position: absolute;
    top: 4px;
    right: 20%;
    background: var(--primary-green);
    color: var(--white);
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

/* Profile Screen */
#profile-screen {
    display: none;
    background: var(--bg-color);
    min-height: 100vh;
}

#profile-screen.active {
    display: flex;
    flex-direction: column;
}

.profile-container {
    flex: 1;
    overflow-y: auto;
    background: var(--white);
    padding-bottom: 60px;
}

.profile-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--white);
}

.profile-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.profile-content {
    padding: 30px 20px;
    text-align: center;
}

.profile-avatar-large {
    margin-bottom: 20px;
}

.profile-avatar-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 600;
    font-size: 48px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

.profile-avatar-large {
    position: relative;
    display: inline-block;
}

.btn-avatar-upload {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-green);
    border: 3px solid var(--white);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn-avatar-upload:hover {
    background: var(--primary-green-dark);
    transform: scale(1.1);
}

.btn-avatar-upload:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

#avatar-upload-progress {
    pointer-events: none;
}

.profile-info {
    margin-top: 20px;
}

.profile-name {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.profile-short-name {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.profile-email {
    font-size: 14px;
    color: var(--text-secondary);
}

.message-input-container {
    padding: 15px 20px;
    background: var(--white);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
    z-index: 10;
    position: relative;
}

.btn-attach {
    width: 45px;
    height: 45px;
    border: none;
    background: none;
    color: var(--text-secondary);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.btn-attach:hover {
    background: var(--border-color);
}

#message-input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 25px;
    font-size: 15px;
}

#message-input:focus {
    outline: none;
    border-color: var(--primary-green);
}

/* Voice recording UI */
.voice-recording-ui {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-color);
    border-radius: 25px;
}

.voice-recording-timer {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-green);
    min-width: 50px;
    text-align: center;
}

.btn-voice-action {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-color);
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-voice-action:hover {
    background: var(--border-color);
}

.btn-voice-send {
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    color: var(--white);
}

.btn-voice-send:hover {
    background: linear-gradient(135deg, var(--gradient-end) 0%, var(--gradient-start) 100%);
}

.btn-voice-record {
    width: 45px;
    height: 45px;
    border: none;
    background: var(--bg-color);
    border-radius: 50%;
    color: var(--primary-green);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-voice-record:hover {
    background: var(--border-color);
}

.voice-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-color);
    border-radius: 25px;
    flex: 1;
    gap: 10px;
}

.voice-preview-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.voice-preview-duration {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 50px;
}

.btn-voice-preview {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--primary-green);
    border-radius: 50%;
    color: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-voice-preview:hover {
    background: var(--primary-green-dark);
}

.btn-voice-preview-cancel {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-voice-preview-cancel:hover {
    color: var(--text-primary);
}

/* Video message player */
.video-message-player {
    width: 100%;
    max-width: 100%;
    background: var(--white);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.video-player-preview {
    position: relative;
    width: 100%;
    background: #000;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

.video-player-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.video-player-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

.video-player-play-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--primary-green);
    transition: all 0.2s;
}

.video-player-play-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

.video-player-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--white);
}

.video-player-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--primary-green);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.video-player-btn:hover {
    background: var(--primary-green-dark);
    transform: scale(1.05);
}

.video-player-progress-container {
    flex: 1;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
}

.video-player-progress-bar {
    height: 100%;
    background: var(--primary-green);
    border-radius: 2px;
    transition: width 0.1s;
}

.video-player-progress-handle {
    position: absolute;
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary-green);
    cursor: grab;
    opacity: 1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.1s;
}

.video-player-progress-handle:active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.2);
}

.video-player-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--white);
    border-top: 1px solid var(--border-color);
}

.video-player-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.video-player-actions {
    display: flex;
    gap: 8px;
}

.video-player-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.video-player-action-btn:hover {
    background: var(--bg-color);
    color: var(--primary-green);
}

/* Audio file player */
.audio-file-player {
    width: 100%;
    max-width: 100%;
    background: var(--white);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    overflow: hidden;
}

.audio-file-player-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.audio-file-player-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--primary-green);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.audio-file-player-btn:hover {
    background: var(--primary-green-dark);
    transform: scale(1.05);
}

.audio-file-player-progress-container {
    flex: 1;
    min-width: 0;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
}

.audio-file-player-progress-bar {
    height: 100%;
    background: var(--primary-green);
    border-radius: 2px;
    transition: width 0.1s;
}

.audio-file-player-progress-handle {
    position: absolute;
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary-green);
    cursor: grab;
    opacity: 1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.1s;
}

.audio-file-player-progress-handle:active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.2);
}

/* Message Reactions */
.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
    align-items: center;
}

.message-reaction {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--bg-color);
    border-radius: 12px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.message-reaction:hover {
    background: var(--border-color);
    transform: scale(1.05);
}

.message-reaction.user-reacted {
    background: rgba(37, 211, 102, 0.15);
    border-color: var(--primary-green);
}

.message.own .message-reaction {
    background: rgba(255, 255, 255, 0.2);
}

.message.own .message-reaction:hover {
    background: rgba(255, 255, 255, 0.3);
}

.message.own .message-reaction.user-reacted {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.reaction-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-left: 2px;
}

.message.own .reaction-count {
    color: rgba(255, 255, 255, 0.9);
}

.message-reaction-add-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s;
    padding: 0;
}

.message-reaction-add-btn:hover {
    background: var(--bg-color);
    color: var(--primary-green);
    transform: scale(1.1);
}

.message.own .message-reaction-add-btn {
    color: rgba(255, 255, 255, 0.7);
}

.message.own .message-reaction-add-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
}

.message-reaction-add-btn svg {
    width: 16px;
    height: 16px;
}

/* Reaction Picker */
.reaction-picker {
    position: fixed;
    background: var(--white);
    border-radius: 24px;
    padding: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    gap: 4px;
    z-index: 10000;
    animation: slideUp 0.2s ease;
    max-width: calc(100vw - 16px);
    flex-wrap: wrap;
    justify-content: center;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.reaction-picker-item {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.2s;
    padding: 0;
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Адаптивные стили для мобильных устройств */
@media (max-width: 768px) {
    .reaction-picker {
        padding: 6px;
        gap: 3px;
        border-radius: 20px;
        max-width: calc(100vw - 12px);
    }
    
    .reaction-picker-item {
        width: 40px;
        height: 40px;
        font-size: 26px;
    }
}

@media (max-width: 480px) {
    .reaction-picker {
        padding: 4px;
        gap: 2px;
        border-radius: 18px;
        max-width: calc(100vw - 8px);
    }
    
    .reaction-picker-item {
        width: 38px;
        height: 38px;
        font-size: 24px;
    }
}

.reaction-picker-item:hover {
    background: var(--bg-color);
    transform: scale(1.2);
}

.reaction-picker-item:active {
    transform: scale(1.1);
}

.audio-file-player-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.audio-file-player-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.audio-file-player-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
}

.audio-file-player-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.audio-file-player-speed {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.audio-file-player-speed-btn {
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    background: var(--white);
    color: var(--text-secondary);
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.audio-file-player-speed-btn:hover {
    background: var(--bg-color);
}

.audio-file-player-speed-btn.active {
    background: var(--primary-green);
    color: white;
    border-color: var(--primary-green);
}

/* Voice message player */
.voice-message-player {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: var(--bg-color);
    border-radius: 12px;
    min-width: 250px;
    max-width: 400px;
    width: 100%;
    box-sizing: border-box;
}

.voice-player-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.voice-player-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--primary-green);
    border-radius: 50%;
    color: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.voice-player-btn:hover {
    background: var(--primary-green-dark);
}

.voice-player-btn.pause {
    background: var(--primary-green);
}

.voice-player-progress-container {
    flex: 1;
    position: relative;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    cursor: pointer;
}

.voice-player-progress-bar {
    height: 100%;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    border-radius: 2px;
    transition: width 0.1s linear;
}

.voice-player-progress-handle {
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    background: var(--primary-green);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: grab;
    opacity: 1;
    transition: opacity 0.2s, transform 0.1s;
    box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.3);
    z-index: 10;
}

.voice-player-progress-container:hover .voice-player-progress-handle {
    transform: translate(-50%, -50%) scale(1.2);
}

.voice-player-progress-handle:active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.3);
}

.voice-player-progress-container {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.voice-player-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

.voice-player-speed {
    display: flex;
    align-items: center;
    gap: 5px;
}

.voice-player-speed-btn {
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    background: var(--white);
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.voice-player-speed-btn:hover {
    background: var(--bg-color);
}

.voice-player-speed-btn.active {
    background: var(--primary-green);
    color: var(--white);
    border-color: var(--primary-green);
}

.btn-send {
    width: 45px;
    height: 45px;
    border: none;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    color: var(--white);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.btn-send:hover {
    transform: scale(1.05);
}

.btn-send:active {
    transform: scale(0.95);
}

/* Attach Menu */
.attach-menu {
    position: absolute;
    bottom: 70px;
    left: 20px;
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 8px;
    min-width: 200px;
    z-index: 1000;
    display: none;
}

.attach-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
    color: var(--text-primary);
}

.attach-menu-item:hover {
    background: var(--border-color);
}

.attach-menu-item svg {
    flex-shrink: 0;
    color: var(--text-secondary);
}

.attach-menu-item span {
    font-size: 15px;
}

/* File Message Styles */
.file-message {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--bg-color);
    border-radius: 12px;
    max-width: 400px;
    position: relative;
}

.file-message-image {
    padding: 0;
    background: transparent;
    max-width: 100%;
}

.file-message-image-preview {
    max-width: 100%;
    max-height: 400px;
    border-radius: 12px;
    cursor: pointer;
    object-fit: contain;
}

.file-message-video {
    padding: 0;
    background: transparent;
    max-width: 100%;
}

.file-message-video-preview {
    max-width: 100%;
    max-height: 400px;
    border-radius: 12px;
}

.file-message-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}

.file-message-image:hover .file-message-overlay,
.file-message-video:hover .file-message-overlay {
    opacity: 1;
}

.file-message-action-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.file-message-action-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.file-message-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
}

.file-message-info {
    flex: 1;
    min-width: 0;
}

.file-message-name {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    word-break: break-word;
}

.file-message-size {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.file-message-download-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--primary-green);
    color: var(--white);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.file-message-download-btn:hover {
    background: var(--primary-green-dark);
}

/* File Upload Progress */
.file-upload-progress-container {
    position: relative;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.file-upload-progress-bar {
    height: 100%;
    background: var(--primary-green);
    border-radius: 2px;
    transition: width 0.3s;
    width: 0%;
}

.file-upload-progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    color: var(--text-primary);
    font-weight: 600;
}

.file-upload-cancel-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.file-upload-cancel-btn:hover {
    background: rgba(255, 255, 255, 1);
    color: #e74c3c;
    transform: scale(1.1);
}

.file-message-info {
    position: relative;
}

.file-upload-error {
    color: #e74c3c;
    font-size: 12px;
    margin-top: 4px;
    display: none;
}

/* Fullscreen Modal */
.fullscreen-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fullscreen-modal-content {
    position: relative;
    max-width: 95%;
    max-height: 95%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.fullscreen-modal-close {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255, 255, 255, 0.25);
    color: var(--white);
    border-radius: 50%;
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 10001;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
    .fullscreen-modal-close {
        top: 100px;
        right: 15px;
        width: 48px;
        height: 48px;
        font-size: 32px;
        background: rgba(255, 255, 255, 0.3);
    }
}

.fullscreen-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.fullscreen-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
}

.fullscreen-video-content {
    width: 100%;
    max-width: 95vw;
    max-height: 95vh;
}

.fullscreen-video-player {
    width: 100%;
    max-width: 100%;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.fullscreen-video-preview {
    position: relative;
    width: 100%;
    flex: 1;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    max-height: 85vh;
}

.fullscreen-video-element {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.fullscreen-video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

.fullscreen-video-play-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--primary-green);
    transition: all 0.2s;
}

.fullscreen-video-play-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

.fullscreen-video-controls,
.fullscreen-video-info {
    transition: opacity 0.3s ease;
    pointer-events: auto;
}

.fullscreen-video-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.8);
}

.fullscreen-video-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--primary-green);
    color: white;
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
    opacity: 1 !important;
    pointer-events: auto !important;
    visibility: visible !important;
}

.fullscreen-video-btn:hover {
    background: var(--primary-green-dark);
    transform: scale(1.05);
}

.fullscreen-video-progress-container {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    position: relative;
    cursor: pointer;
}

.fullscreen-video-progress-bar {
    height: 100%;
    background: var(--primary-green);
    border-radius: 3px;
    transition: width 0.1s;
}

.fullscreen-video-progress-handle {
    position: absolute;
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-green);
    cursor: grab;
    opacity: 1;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.1s;
}

.fullscreen-video-progress-handle:active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.2);
}

.fullscreen-video-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.8);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.fullscreen-video-time {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

.fullscreen-video-actions {
    display: flex;
    gap: 12px;
}

.fullscreen-video .fullscreen-action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.fullscreen-video .fullscreen-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.fullscreen-modal-actions {
    margin-top: 20px;
    display: flex;
    gap: 12px;
}

.fullscreen-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.fullscreen-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.incoming-call-modal {
    z-index: 99999;
}

#user-profile-modal {
    z-index: 1001;
}

.modal.show,
.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 22px;
}

.btn-close {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    position: relative;
    pointer-events: auto;
}

.btn-close:hover {
    color: var(--text-primary);
    background: var(--bg-color);
    border-radius: 50%;
}

.btn-close:active {
    transform: scale(0.9);
}

.modal-body {
    padding: 20px;
}

.settings-section {
    margin-bottom: 25px;
}

.settings-section h3 {
    margin-bottom: 15px;
    font-size: 18px;
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input[type="text"],
.form-group input[type="email"] {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-green);
}

.form-group small {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: var(--text-secondary);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.btn-secondary {
    width: 100%;
    padding: 12px;
    background: var(--bg-color);
    color: var(--text-primary);
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: var(--border-color);
}

/* Mobile navigation */
.mobile-only {
    display: flex !important;
}

@media (min-width: 769px) {
    #back-from-chat-btn {
        display: flex !important;
    }
}

@media (max-width: 768px) {
    .mobile-only {
        display: flex !important;
    }
    
    .app-container {
        position: relative;
        overflow: hidden;
        width: 100%;
        max-width: 100%;
    }
    
    .sidebar {
        width: 100%;
        height: 100vh;
        position: absolute;
        left: 0;
        top: 0;
        z-index: 10;
        transition: transform 0.3s ease;
        flex: none;
    }
    
    .sidebar.hidden {
        transform: translateX(-100%);
    }
    
    .chat-area {
        width: 100%;
        height: 100vh;
        position: absolute;
        right: 0;
        top: 0;
        z-index: 5;
        transition: transform 0.3s ease;
    }
    
    .chat-area.hidden {
        transform: translateX(100%);
    }
    
    .auth-container {
        padding: 30px 20px;
    }
    
    .logo h1 {
        font-size: 28px;
    }
    
    .message {
        max-width: 90%;
        width: auto;
    }
    
    .message-reply {
        max-width: 100%;
    }
    
    .message.own {
        margin-left: auto;
        margin-right: 0;
    }
    
    .message:not(.own) {
        margin-left: 0;
        margin-right: auto;
    }
    
    .message-content {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0;
        padding: 8px 12px;
    }
    
    /* Карточка приглашения внутри message-content должна занимать всю ширину */
    .message-content .invitation-card {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        align-self: stretch !important;
    }
    
    .message.own .message-content .invitation-card {
        align-self: stretch !important;
        margin-left: 0 !important;
    }
    
    .message-wrapper {
        flex: 1;
        min-width: 0;
        max-width: 100%;
        width: 100%;
    }
    
    .voice-message-player {
        min-width: 200px;
        max-width: 100%;
        width: 100%;
        padding: 10px;
        gap: 6px;
    }
    
    .voice-player-controls {
        gap: 8px;
    }
    
    .voice-player-btn {
        width: 32px;
        height: 32px;
        flex-shrink: 0;
    }
    
    .invitation-card {
        max-width: 100% !important;
        width: 100% !important;
        padding: 12px;
        align-self: stretch !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    .message.own .invitation-card {
        align-self: stretch !important;
        margin-left: 0 !important;
    }
    
    .invitation-card-content {
        width: 100%;
    }
    
    .invitation-card-info {
        max-width: none !important;
        flex: 1;
    }
    
    .invitation-card-avatar,
    .invitation-card-icon {
        width: 48px;
        height: 48px;
    }
    
    .invitation-card-title {
        font-size: 14px;
    }
    
    .invitation-card-subtitle {
        font-size: 12px;
    }
    
    .voice-player-info {
        font-size: 11px;
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .voice-player-speed {
        gap: 3px;
    }
    
    .voice-player-speed-btn {
        padding: 3px 6px;
        font-size: 10px;
    }
    
    .message-content {
        padding: 8px 12px;
    }
    
    .chat-header {
        padding: 12px 15px;
    }
    
    .app-container {
        padding-bottom: 60px;
    }
    
    .bottom-nav {
        display: flex;
    }
}

@media (min-width: 769px) {
    .bottom-nav {
        display: flex;
    }
    
    .app-container {
        padding-bottom: 0;
    }
}

@media (max-width: 480px) {
    .sidebar-header {
        padding: 15px;
    }
    
    .chat-item {
        padding: 12px 15px;
    }
    
    .messages-container {
        padding: 15px 10px;
    }
    
    .message-input-container {
        padding: 12px 15px;
    }
    
    .voice-message-player {
        min-width: 180px;
        padding: 8px;
        gap: 6px;
    }
    
    .voice-player-btn {
        width: 28px;
        height: 28px;
    }
    
    .voice-player-info {
        font-size: 10px;
    }
    
    .voice-player-speed-btn {
        padding: 2px 4px;
        font-size: 9px;
    }
    
    .message {
        max-width: calc(100% - 16px);
        width: auto;
    }
    
    .message.own {
        margin-left: auto;
        margin-right: 0;
    }
    
    .message:not(.own) {
        margin-left: 0;
        margin-right: auto;
    }
    
    .message-content {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    
    .message-wrapper {
        flex: 1;
        min-width: 0;
        max-width: 100%;
        width: 100%;
    }
    
    .video-message-player,
    .audio-file-player {
        max-width: 100%;
    }
    
    .video-player-preview {
        aspect-ratio: 16 / 9;
    }
    
    .video-player-controls,
    .audio-file-player-controls {
        padding: 6px 8px;
    }
    
    .video-player-btn,
    .audio-file-player-btn {
        width: 32px;
        height: 32px;
    }
    
    .video-player-info,
    .audio-file-player-info {
        padding: 6px 8px;
    }
    
    .video-player-time,
    .audio-file-player-time {
        font-size: 11px;
    }
    
    .audio-file-player-title {
        font-size: 13px;
    }
    
    .audio-file-player-bottom {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .audio-file-player-time {
        width: 100%;
        margin-bottom: 4px;
    }
    
    .audio-file-player-speed {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .audio-file-player-speed-btn {
        padding: 6px 10px;
        font-size: 12px;
        min-width: 44px;
    }
    
    .audio-file-player-controls {
        gap: 6px;
    }
    
    .audio-file-player-progress-container {
        min-width: 0;
    }
    
    .audio-file-player {
        padding: 10px;
        box-sizing: border-box;
    }
    
    .audio-file-player-info {
        gap: 6px;
    }
}

/* ========== CALL UI STYLES ========== */

/* Incoming Call Modal */
.incoming-call-modal-content {
    max-width: 400px;
    width: 90%;
    text-align: center;
    padding: 40px 30px;
    background: var(--white);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
}

.incoming-call-avatar {
    margin-bottom: 30px;
}

.incoming-call-avatar-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 48px;
    font-weight: 600;
    margin: 0 auto;
    animation: pulse-ring 2s ease-in-out infinite;
}

@keyframes pulse-ring {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7);
    }
    50% {
        box-shadow: 0 0 0 20px rgba(37, 211, 102, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
    }
}

.incoming-call-info {
    margin-bottom: 40px;
}

.incoming-call-name {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.incoming-call-status {
    font-size: 16px;
    color: var(--text-secondary);
}

.incoming-call-actions {
    display: flex;
    justify-content: center;
    gap: 30px;
}

.call-action-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow);
}

.call-action-btn:active {
    transform: scale(0.95);
}

.call-accept-btn {
    background: var(--primary-green);
    color: var(--white);
}

.call-accept-btn:hover {
    background: var(--primary-green-dark);
    box-shadow: var(--shadow-lg);
}

.call-reject-btn {
    background: #f44336;
    color: var(--white);
}

.call-reject-btn:hover {
    background: #d32f2f;
    box-shadow: var(--shadow-lg);
}

/* Active Call Overlay */
.active-call-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
}

.active-call-content {
    text-align: center;
    padding: 40px;
    width: 100%;
    max-width: 500px;
}

.active-call-header {
    margin-bottom: 60px;
    position: relative;
    width: 100%;
}

/* Видео контейнер */
.call-video-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto 30px;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
    aspect-ratio: 16 / 9;
}

.call-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remote-video {
    width: 100%;
    height: 100%;
    /* Зеркальное отображение применяется через JS только для камеры, не для демонстрации экрана */
}

.local-video {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 200px;
    height: 150px;
    border-radius: 12px;
    border: 3px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10;
    object-fit: cover;
    /* Зеркальное отображение применяется через JS только для камеры, не для экрана */
}

/* Кнопка полноэкранного режима */
.call-fullscreen-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    z-index: 25;
    opacity: 0.8;
}

.call-fullscreen-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
    opacity: 1;
}

.call-fullscreen-btn:active {
    transform: scale(0.95);
}

.call-fullscreen-btn.active {
    background: rgba(37, 211, 102, 0.5);
}

/* Контейнер участников группового звонка */
.group-call-participants {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    margin-top: 30px;
    margin-bottom: 20px;
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
}

/* Карточка участника */
.group-call-participant-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 80px;
    max-width: 100px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
}

.group-call-participant-card:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.group-call-participant-card:active {
    transform: translateY(0);
}

/* Аватар участника */
.group-call-participant-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.1) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 600;
    color: var(--white);
    border: 2px solid rgba(255, 255, 255, 0.3);
    position: relative;
}

/* Имя участника */
.group-call-participant-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--white);
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Индикатор активности */
.group-call-participant-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    margin-top: 4px;
    transition: background 0.3s;
}

.group-call-participant-indicator.active {
    background: #25d366;
    box-shadow: 0 0 8px rgba(37, 211, 102, 0.6);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

.call-fullscreen-btn .fullscreen-icon,
.call-fullscreen-btn .fullscreen-exit-icon {
    transition: opacity 0.2s;
}

/* Полноэкранный режим */
.call-video-container:fullscreen {
    max-width: 100%;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    margin: 0;
    aspect-ratio: unset;
}

.call-video-container:-webkit-full-screen {
    max-width: 100%;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    margin: 0;
    aspect-ratio: unset;
}

.call-video-container:-moz-full-screen {
    max-width: 100%;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    margin: 0;
    aspect-ratio: unset;
}

.call-video-container:-ms-fullscreen {
    max-width: 100%;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    margin: 0;
    aspect-ratio: unset;
}

.call-video-container:fullscreen .local-video {
    width: 300px;
    height: 225px;
    bottom: 30px;
    right: 30px;
}

.call-video-container:-webkit-full-screen .local-video {
    width: 300px;
    height: 225px;
    bottom: 30px;
    right: 30px;
}

.call-video-container:-moz-full-screen .local-video {
    width: 300px;
    height: 225px;
    bottom: 30px;
    right: 30px;
}

.call-video-container:-ms-fullscreen .local-video {
    width: 300px;
    height: 225px;
    bottom: 30px;
    right: 30px;
}

.active-call-avatar {
    margin-bottom: 30px;
}

.active-call-avatar-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 60px;
    font-weight: 600;
    margin: 0 auto;
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.active-call-info {
    margin-bottom: 20px;
}

.active-call-name {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--white);
}

.active-call-status {
    font-size: 18px;
    opacity: 0.9;
    margin-bottom: 10px;
}

.active-call-timer {
    font-size: 32px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 2px;
}

.active-call-controls {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 30px;
    margin-top: 60px;
}

.call-controls-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
}

.call-controls-row-end {
    margin-top: 10px;
}

.call-control-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.call-control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.call-control-btn:active {
    transform: scale(0.95);
}

.call-control-btn.muted {
    background: rgba(244, 67, 54, 0.3);
    border: 2px solid rgba(244, 67, 54, 0.5);
}

.call-control-btn.muted:hover {
    background: rgba(244, 67, 54, 0.4);
}

.call-control-btn.active {
    background: rgba(37, 211, 102, 0.3);
    border: 2px solid rgba(37, 211, 102, 0.5);
}

.call-control-btn.active:hover {
    background: rgba(37, 211, 102, 0.4);
}

.call-control-btn .mute-icon,
.call-control-btn .unmute-icon,
.call-control-btn .speaker-icon,
.call-control-btn .speaker-off-icon {
    transition: opacity 0.2s;
}

.call-control-btn.muted .mute-icon {
    display: none !important;
}

.call-control-btn.muted .unmute-icon {
    display: block !important;
}

.call-control-btn.active .speaker-icon {
    display: none !important;
}

.call-control-btn.active .speaker-off-icon {
    display: block !important;
}

.call-control-btn.disabled {
    opacity: 0.5;
    background: rgba(255, 255, 255, 0.1);
}

.call-control-btn.disabled:hover {
    background: rgba(255, 255, 255, 0.15);
}

.call-control-btn .video-icon,
.call-control-btn .video-off-icon {
    transition: opacity 0.2s;
}

.call-control-btn.disabled .video-icon {
    display: none !important;
}

.call-control-btn.disabled .video-off-icon {
    display: block !important;
}

.call-control-btn.active .screen-icon {
    color: var(--primary-green);
}

.call-end-btn {
    width: 64px;
    height: 64px;
    background: #f44336;
    box-shadow: 0 6px 16px rgba(244, 67, 54, 0.4);
}

.call-end-btn:hover {
    background: #d32f2f;
    transform: scale(1.1);
}

.call-minimize-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 30;
}

.call-minimize-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Minimized Call Card */
.minimized-call-card {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 99999;
    min-width: 280px;
    max-width: 320px;
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    animation: slideUp 0.3s ease-out;
    cursor: move;
    user-select: none;
    touch-action: none;
    transform-origin: center;
}

.minimized-call-card:active {
    cursor: grabbing;
}

.minimized-call-card button {
    cursor: pointer;
    touch-action: auto;
}

@keyframes slideUp {
    from {
        transform: translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.minimized-call-content {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.minimized-call-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
}

.minimized-call-info {
    flex: 1;
    min-width: 0;
}

.minimized-call-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.minimized-call-timer {
    font-size: 12px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.minimized-call-restore-btn,
.minimized-call-end-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    flex-shrink: 0;
}

.minimized-call-restore-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: scale(1.1);
}

.minimized-call-end-btn {
    background: rgba(244, 67, 54, 0.1);
    color: #f44336;
}

.minimized-call-end-btn:hover {
    background: rgba(244, 67, 54, 0.2);
    transform: scale(1.1);
}

/* Mobile styles for minimized call card */
@media (max-width: 768px) {
    .minimized-call-card {
        bottom: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        min-width: auto;
    }
}

/* Mobile styles for call UI */
@media (max-width: 768px) {
    .incoming-call-modal-content {
        padding: 30px 20px;
    }
    
    .incoming-call-avatar-circle {
        width: 100px;
        height: 100px;
        font-size: 40px;
    }
    
    .incoming-call-name {
        font-size: 20px;
    }
    
    .incoming-call-actions {
        gap: 40px;
    }
    
    .call-action-btn {
        width: 72px;
        height: 72px;
    }
    
    .active-call-content {
        padding: 30px 20px;
    }
    
    .active-call-avatar-circle {
        width: 120px;
        height: 120px;
        font-size: 48px;
    }
    
    .active-call-name {
        font-size: 24px;
    }
    
    .active-call-timer {
        font-size: 28px;
    }
    
    .active-call-controls {
        gap: 30px;
        margin-top: 80px;
    }
    
    .call-controls-row {
        gap: 50px;
    }
    
    .call-control-btn {
        width: 64px;
        height: 64px;
    }
    
    .call-end-btn {
        width: 80px;
        height: 80px;
    }
    
    .call-video-container {
        max-width: 100%;
        margin-bottom: 20px;
    }
    
    .local-video {
        width: 120px;
        height: 90px;
        bottom: 10px;
        right: 10px;
    }
    
    .call-minimize-btn {
        width: 40px;
        height: 40px;
        top: 10px;
        left: 10px;
    }
    
    .call-fullscreen-btn {
        width: 40px;
        height: 40px;
        top: 10px;
        right: 10px;
    }
    
    .call-video-container:fullscreen .local-video,
    .call-video-container:-webkit-full-screen .local-video,
    .call-video-container:-moz-full-screen .local-video,
    .call-video-container:-ms-fullscreen .local-video {
        width: 150px;
        height: 112px;
        bottom: 15px;
        right: 15px;
    }
}

@media (max-width: 480px) {
    .incoming-call-modal-content {
        padding: 25px 15px;
    }
    
    .incoming-call-avatar-circle {
        width: 80px;
        height: 80px;
        font-size: 32px;
    }
    
    .incoming-call-name {
        font-size: 18px;
    }
    
    .incoming-call-status {
        font-size: 14px;
    }
    
    .call-action-btn {
        width: 64px;
        height: 64px;
    }
    
    .active-call-avatar-circle {
        width: 100px;
        height: 100px;
        font-size: 40px;
    }
    
    .active-call-name {
        font-size: 20px;
    }
    
    .active-call-timer {
        font-size: 24px;
    }
    
    .active-call-controls {
        gap: 25px;
        margin-top: 60px;
    }
    
    .call-controls-row {
        gap: 40px;
    }
}

/* Settings Screen */
#settings-screen {
    display: none;
    background: var(--bg-color);
    min-height: 100vh;
}

#settings-screen.active {
    display: flex;
    flex-direction: column;
}

.settings-container {
    flex: 1;
    overflow-y: auto;
    background: var(--white);
    padding-bottom: 60px;
}

.settings-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--white);
    position: sticky;
    top: 0;
    z-index: 10;
}

.settings-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.settings-content {
    padding: 20px;
}

.settings-category {
    margin-bottom: 30px;
    background: var(--white);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.settings-category-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

.settings-item {
    margin-bottom: 20px;
}

.settings-item:last-child {
    margin-bottom: 0;
}

.settings-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

/* Error states for settings fields */
.settings-item input.error,
.settings-item textarea.error {
    border-color: #e53e3e !important;
    background-color: #fff5f5 !important;
    box-shadow: 0 0 0 2px rgba(229, 62, 62, 0.1) !important;
}

.settings-item input.error:focus,
.settings-item textarea.error:focus {
    border-color: #e53e3e !important;
    box-shadow: 0 0 0 2px rgba(229, 62, 62, 0.2) !important;
}

.settings-error-message {
    color: #e53e3e;
    font-size: 12px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.settings-error-message::before {
    content: "⚠";
    font-size: 14px;
}

/* Session items */
.session-item {
    transition: transform 0.2s, box-shadow 0.2s;
}

.session-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-settings-action {
    width: 100%;
    padding: 12px;
    background: var(--white);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s;
}

.btn-settings-action:hover {
    background: var(--bg-color);
    border-color: var(--primary-green);
}

.settings-item input[type="text"],
.settings-item input[type="time"],
.settings-item input[type="password"],
.settings-item input[type="date"],
.settings-item textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s;
}

.settings-item input:focus {
    outline: none;
    border-color: var(--primary-green);
}

.settings-item small {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Switch Toggle */
.switch-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.switch-input {
    position: relative;
    width: 48px;
    height: 26px;
    appearance: none;
    background: var(--border-color);
    border-radius: 13px;
    cursor: pointer;
    transition: background 0.3s;
    flex-shrink: 0;
}

.switch-input:checked {
    background: var(--primary-green);
}

.switch-input::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--white);
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.switch-input:checked::before {
    transform: translateX(22px);
}

.switch-text {
    flex: 1;
    font-size: 15px;
    color: var(--text-primary);
}

/* Settings Action Button */
.btn-settings-action {
    width: 100%;
    padding: 14px 16px;
    background: var(--white);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 15px;
    color: var(--text-primary);
}

.btn-settings-action:hover {
    border-color: var(--primary-green);
    background: var(--bg-color);
}

.btn-settings-action svg {
    color: var(--text-secondary);
}

/* Settings Save Notification */
#settings-save-notification {
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Avatar images in chat items and messages */
.chat-item-avatar img,
.message-avatar img,
.chat-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Invitation Card Styles */
.invitation-card {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin: 8px 0;
    max-width: 280px;
    width: fit-content;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
    cursor: pointer;
    align-self: flex-start;
}

.message.own .invitation-card {
    align-self: flex-end;
    margin-left: auto;
}

/* На мобильных устройствах карточка занимает всю ширину */
@media (max-width: 768px) {
    .invitation-card {
        max-width: 100% !important;
        width: 100% !important;
        align-self: stretch !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    .message.own .invitation-card {
        align-self: stretch !important;
        margin-left: 0 !important;
    }
    
    .invitation-card-content {
        width: 100%;
    }
    
    .invitation-card-info {
        max-width: none !important;
        flex: 1;
    }
}

.invitation-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.invitation-card-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.invitation-card-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.invitation-card-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.invitation-card-avatar-text {
    color: white;
    font-weight: 600;
    font-size: 20px;
}

.invitation-card-icon {
    font-size: 32px;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.invitation-card-info {
    flex: 1;
    min-width: 0;
    max-width: 180px;
}

.invitation-card-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.3;
    max-height: 2.6em;
}

.invitation-card-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.invitation-card-join-btn {
    margin-top: 12px;
    width: 100%;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.invitation-card-join-btn:hover {
    opacity: 0.9;
    transform: scale(1.02);
}

.invitation-card-join-btn:active {
    transform: scale(0.98);
}

.invitation-card-link {
    color: var(--primary-green);
    text-decoration: none;
    font-size: 12px;
    word-break: break-all;
}

.invitation-card-link:hover {
    text-decoration: underline;
}

/* Chat List Invitation Card */
.chat-list-invitation-card {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: rgba(37, 211, 102, 0.1);
    border-radius: 6px;
    font-size: 13px;
    color: var(--primary-green);
}

.chat-list-invitation-icon {
    font-size: 14px;
}

.chat-list-invitation-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* Profile details */
.profile-details {
    margin-top: 20px;
    text-align: left;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 20px;
}

.profile-details div {
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.5;
}

.profile-details strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Avatar fullscreen modal close button - mobile fix */
@media (max-width: 768px) {
    #close-avatar-fullscreen {
        top: 100px !important;
        right: 15px !important;
        width: 48px !important;
        height: 48px !important;
        font-size: 32px !important;
        background: rgba(255, 255, 255, 0.3) !important;
    }
}

/* Group Call Invitation Card Styles */
.group-call-invitation-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 15px;
    margin-top: 10px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 300px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.group-call-invitation-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.group-call-invitation-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 12px;
}

.group-call-invitation-icon {
    font-size: 48px;
    margin-bottom: 5px;
}

.group-call-invitation-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    flex: 1;
}

.group-call-invitation-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.group-call-invitation-status {
    font-size: 14px;
    color: var(--text-secondary);
}

.group-call-invitation-join-btn {
    background: var(--primary-green);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    width: 100%;
    max-width: 200px;
}

.group-call-invitation-join-btn:hover:not(:disabled) {
    background: var(--primary-green-dark);
}

.group-call-invitation-join-btn:disabled {
    background: var(--border-color);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.message.own .group-call-invitation-card {
    align-self: flex-end;
    margin-left: auto;
}

.message:not(.own) .group-call-invitation-card {
    align-self: flex-start;
    margin-right: auto;
}

/* Mobile responsive styles for group call invitation cards */
@media (max-width: 768px) {
    .group-call-invitation-card {
        max-width: 100% !important;
        width: 100% !important;
        align-self: stretch !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    .message.own .group-call-invitation-card {
        align-self: stretch !important;
        margin-left: 0 !important;
    }
    
    .group-call-invitation-content {
        width: 100%;
    }
    
    .group-call-invitation-info {
        max-width: none !important;
        flex: 1;
    }
}

/* Group Call Card Styles (for messages) */
.group-call-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 15px;
    margin-top: 10px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 300px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.group-call-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.group-call-card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 12px;
}

.group-call-card-icon {
    font-size: 48px;
    margin-bottom: 5px;
}

.group-call-card-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    flex: 1;
}

.group-call-card-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.group-call-card-members {
    font-size: 14px;
    color: var(--text-secondary);
}

.group-call-card-join-btn {
    background: var(--primary-green);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    width: 100%;
    max-width: 200px;
    margin-top: 5px;
}

.group-call-card-join-btn:hover:not(:disabled) {
    background: var(--primary-green-dark);
}

.group-call-card-join-btn:disabled {
    background: var(--border-color);
    color: var(--text-secondary);
    cursor: not-allowed;
}

/* Карточка звонка всегда по центру */
.message.own .group-call-card,
.message:not(.own) .group-call-card {
    align-self: center;
    margin-left: auto;
    margin-right: auto;
}

/* Mobile responsive styles for group call cards */
@media (max-width: 768px) {
    .group-call-card {
        max-width: 100% !important;
        width: 100% !important;
        align-self: stretch !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    .message.own .group-call-card {
        align-self: stretch !important;
        margin-left: 0 !important;
    }
}
