/* Пульс - Минималистичный дизайн */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #ffffff;
    color: #333333;
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
}

/* Заголовок */
.header {
    text-align: center;
    margin-bottom: 20px;
}

.header h1 {
    font-size: 2.2rem;
    font-weight: 300;
    color: #333333;
    letter-spacing: -0.02em;
    margin: 0 0 4px 0;
}

.tagline {
    font-size: 0.95rem;
    color: #666666;
    margin: 0;
    text-align: center;
    font-weight: 400;
    letter-spacing: 0.5px;
}

/* Основной контент */
.main-content {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.room-section {
    width: 100%;
}

.hidden {
    display: none !important;
}

/* Стили для встреч */

.meeting-link-container {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.meeting-link-container label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333333;
}

.link-input-container {
    display: flex;
    gap: 8px;
}

.link-input-container input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    background: #ffffff;
    color: #666666;
}

.copy-btn {
    padding: 10px 15px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 0.9rem;
}

.copy-btn:hover {
    background: #0056b3;
}

.copy-btn.copied {
    background: #28a745;
}

.copy-btn.copied:hover {
    background: #1e7e34;
}

/* Стили для страницы ошибки убраны - используем обычные стили форм */


/* Стили для аватаров */
.participant-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #333;
    font-weight: bold;
}

.participant-video-placeholder {
    width: 100%;
    height: 100%;
    background: #f0f0f0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #999;
}

/* Карточка */
.card {
    background: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 40px 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* Формы */
.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #666666;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-size: 16px;
    color: #333333;
    background: #ffffff;
    transition: border-color 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #333333;
}

.form-group input::placeholder {
    color: #999999;
}

/* Кнопки */
.btn {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: #333333;
    color: #ffffff;
}

.btn-primary:hover {
    background: #222222;
}

.btn-secondary {
    background: #f8f8f8;
    color: #666666;
    border: 1px solid #e5e5e5;
}

.btn-secondary:hover {
    background: #f0f0f0;
}

/* Интерфейс звонка */
.call-header {
    background: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.room-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: nowrap;
}

.room-id-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.call-header h2 {
    font-size: 1.1rem;
    font-weight: 500;
    color: #333333;
    margin: 0;
}

.status-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.copy-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    background: #ffffff;
    color: #666666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 14px;
    flex-shrink: 0;
    margin-left: 4px;
}

.copy-btn:hover {
    background: #f8f8f8;
    border-color: #333333;
    color: #333333;
}

.copy-btn.copied {
    background: #2ed573;
    color: #ffffff;
    border-color: #2ed573;
}

.participants-count {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #666666;
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* Индикатор состояния соединения */
.connection-status {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.connection-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s ease;
    min-width: 40px;
    justify-content: center;
    background: #dc3545;
    color: #ffffff;
    border: 1px solid #dc3545;
}

.connection-indicator:empty {
    padding: 8px;
    min-width: 32px;
}

.connection-indicator i {
    font-size: 1rem;
}

/* Состояния соединения */
.connection-indicator.connected {
    background: #28a745;
    color: #ffffff;
    border: 1px solid #28a745;
}

.connection-indicator.reconnecting {
    background: #ffc107;
    color: #000000;
    border: 1px solid #ffc107;
}

/* Анимации */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

@keyframes pulse-red {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.02); }
    100% { opacity: 1; transform: scale(1); }
}

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


/* Участники - ДИНАМИЧЕСКИЙ HORIZONTAL LAYOUT */
.participants-container {
    background: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 15px;
    margin: 0 auto 15px auto;
    min-height: 100px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    transition: all 0.3s ease;
}

.participants-container.updating {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Стили для разного количества участников - убираем фиксированные ширины */

.participants-list {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 15px !important;
    justify-content: center !important;
    align-items: flex-start !important;
    width: 100% !important;
    padding: 0;
    margin: 0;
    transition: all 0.3s ease;
}

.participant {
    background: #f8f8f8;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    padding: 12px;
    text-align: center;
    transition: all 0.2s ease;
    width: 200px !important;
    min-width: 180px !important;
    max-width: 250px !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    box-sizing: border-box;
}

.participant.speaking {
    border-color: #333333;
    background: #f0f0f0;
}

.participant.self {
    border: 2px solid #333333;
}

.participant-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: #666666;
}

.participant-video {
    width: 100%;
    height: 160px;
    background: #f0f0f0;
    border-radius: 8px;
    margin-bottom: 12px;
    object-fit: cover;
    cursor: pointer;
    transition: all 0.3s ease;
}

.participant-video:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.participant-video-placeholder {
    width: 100%;
    height: 160px;
    /* Убрали белый фон чтобы показывались аватары */
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    border: 2px solid #e5e5e5;
    border-radius: 8px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.participant-video-placeholder:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #333333;
}

/* Убрали градиент - теперь показываем аватары животных */
.participant-video-placeholder::before {
    display: none;
}

/* Убрали дефолтную иконку - теперь показываем аватары животных */
.participant-video-placeholder::after {
    content: '';
    display: none;
}

/* Модальное окно для увеличенного видео */
.video-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: pointer;
}

.video-modal.active {
    display: flex;
}

.video-modal-content {
    position: relative;
    max-width: 80vw;
    max-height: 80vh;
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: row;
}

.video-modal-video {
    width: 60%;
    height: auto;
    max-height: 80vh;
    object-fit: cover;
    border-radius: 12px 0 0 12px;
}

.video-modal-video.avatar-mode {
    background: linear-gradient(135deg, #ffffff 0%, #f8f8f8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 3px solid #e5e5e5;
}

/* Большая иконка пользователя в модальном окне без кружка */
.video-modal-video.avatar-mode::before {
    content: '👤';
    font-size: 120px;
    color: #333333;
    filter: grayscale(100%) brightness(0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.video-modal-info {
    padding: 20px;
    text-align: center;
    width: 40%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.video-modal-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333333;
    margin-bottom: 8px;
}

.video-modal-status {
    color: #666666;
    font-size: 0.9rem;
}

.video-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.8);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 1001;
}

.video-modal-close:hover {
    background: rgba(0, 0, 0, 1);
    transform: scale(1.1);
}

/* Чат */
.chat-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: #ffffff;
    border-left: 1px solid #e5e5e5;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.chat-panel.active {
    right: 0;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e5e5;
    background: #f8f8f8;
}

.chat-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #333333;
}

.close-chat-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: #e5e5e5;
    border-radius: 6px;
    color: #666666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-chat-btn:hover {
    background: #d5d5d5;
    color: #333333;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    background: #f0f0f0;
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 80%;
    word-wrap: break-word;
}

.chat-message.own {
    background: #333333;
    color: #ffffff;
    align-self: flex-end;
}

.chat-message.other {
    background: #f0f0f0;
    color: #333333;
    align-self: flex-start;
}

.message-author {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 4px;
    opacity: 0.8;
}

.message-text {
    font-size: 0.9rem;
    line-height: 1.4;
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.6;
    margin-top: 4px;
}

.chat-input-container {
    display: flex;
    padding: 20px;
    border-top: 1px solid #e5e5e5;
    background: #f8f8f8;
    gap: 12px;
}

#chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s ease;
}

#chat-input:focus {
    border-color: #333333;
}

.send-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: #333333;
    color: #ffffff;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.send-btn:hover {
    background: #555555;
}

.send-btn:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

.participant-name {
    font-weight: 500;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.participant-status {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* Элементы управления */
.call-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.control-group.separated {
    margin-left: 20px;
    padding-left: 20px;
    border-left: 2px solid #e5e5e5;
}

.leave-control {
    display: none; /* Скрываем отдельную секцию */
}

.control-btn {
    width: 48px;
    height: 48px;
    border: 1px solid #e5e5e5;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative; /* Для позиционирования бейджа уведомлений */
    background: #ffffff;
    color: #666666;
}

.control-btn:hover {
    background: #f8f8f8;
    transform: scale(1.05);
}

.control-btn.muted {
    background: #ff4757;
    color: #ffffff;
    border-color: #ff4757;
}

.control-btn.muted:hover {
    background: #ff3742;
}

.control-btn.camera-off {
    background: #ff4757;
    color: #ffffff;
    border-color: #ff4757;
}

.control-btn.camera-off:hover {
    background: #ff3742;
}

/* Кнопка демонстрации экрана по умолчанию - КРАСНАЯ */
#screen-share-btn {
    background: #ff4757;
    color: #ffffff;
    border-color: #ff4757;
}

#screen-share-btn:hover {
    background: #ff3742;
}

/* Кнопка демонстрации экрана при включении - БЕЛАЯ */
.control-btn.screen-sharing {
    background: #ffffff !important;
    color: #666666 !important;
    border-color: #e5e5e5 !important;
}

.control-btn.screen-sharing:hover {
    background: #f8f8f8 !important;
}

.control-btn.leave-btn {
    background: #ff4757;
    color: #ffffff;
    border-color: #ff4757;
}

.control-btn.leave-btn:hover {
    background: #ff3742;
}

/* Информация о звонке */

/* Уведомления */
.notifications {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.notification {
    background: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.3s ease;
    max-width: 300px;
    font-size: 0.9rem;
}

.notification.success {
    border-left: 3px solid #2ed573;
}

.notification.error {
    border-left: 3px solid #ff4757;
}

.notification.warning {
    border-left: 3px solid #ffa502;
}

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

/* Адаптивность для планшетов */
@media (max-width: 1024px) and (min-width: 769px) {
    .participant {
        width: 180px !important;
        min-width: 160px !important;
        max-width: 200px !important;
    }
    
    .participants-container {
        max-width: 90%;
    }
}

/* Стили для десктопа - восстанавливаем нормальные размеры */
@media (min-width: 769px) {
    .participants-container {
        padding: 20px;
        margin: 0 auto 20px auto;
    }
    
    .call-header {
        padding: 16px 20px;
        margin-bottom: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .container {
        padding: 20px;
    }
    
    .header {
        margin-bottom: 24px;
    }
    
    .header h1 {
        font-size: 2.2rem;
        margin-bottom: 4px;
    }
    
    .tagline {
        font-size: 0.95rem;
    }
    
    .participant {
        aspect-ratio: 4/3;
        max-height: none;
    }
    
    .participant-video {
        height: 200px;
    }
    
    .participant-video-placeholder {
        height: 200px;
    }
    
    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 16px;
    }
    
    .call-controls {
        gap: 12px;
        padding: 0 20px;
        margin-bottom: 20px;
    }
    
    /* ОПТИМИЗИРОВАННОЕ ВЫРАВНИВАНИЕ В ЗАГОЛОВКЕ ДЛЯ ПК */
    .room-info {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-wrap: nowrap;
        gap: 20px;
        width: 100%;
        max-width: 900px;
        margin: 0 auto;
    }
    
    .room-id-container {
        display: flex;
        align-items: center;
        gap: 10px;
        flex-shrink: 0;
    }
    
    .room-id-container h2 {
        margin: 0;
        font-size: 1.1rem;
        font-weight: 500;
        white-space: nowrap;
    }
    
    .status-row {
        display: flex;
        align-items: center;
        gap: 16px;
        flex-shrink: 0;
    }
    
    .connection-indicator {
        padding: 6px 14px;
        font-size: 0.85rem;
        border-radius: 20px;
        min-width: 40px;
        display: flex;
        align-items: center;
        gap: 6px;
        white-space: nowrap;
    }
    
    .participants-count {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 0.9rem;
        font-weight: 500;
        white-space: nowrap;
    }
    
    .copy-btn {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .container {
        padding: 10px 8px !important;
    }
    
    .header {
        margin-bottom: 8px !important;
    }
    
    .header h1 {
        font-size: 1.6rem !important;
        margin-bottom: 2px;
    }
    
    .tagline {
        font-size: 0.8rem !important;
        margin: 2px 0 0 0;
    }
    
    .card {
        padding: 24px 16px;
    }
    
    /* КОМПАКТНЫЙ ЗАГОЛОВОК КОМНАТЫ ДЛЯ МОБИЛЬНЫХ */
    .call-header {
        padding: 10px 12px !important;
        margin-bottom: 8px !important;
        flex-direction: column;
        gap: 8px;
    }
    
    .room-info {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 8px;
        flex-wrap: nowrap;
    }
    
    .room-id-container {
        display: inline-flex;
        align-items: center;
        justify-content: flex-start;
        gap: 4px;
        width: auto;
        max-width: 100%;
    }
    
    .room-id-container h2 {
        font-size: 0.85rem !important;
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex-shrink: 1;
        min-width: 0;
    }
    
    .room-id-container .copy-btn {
        flex-shrink: 0;
    }
    
    .status-row {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
    }
    
    .connection-indicator {
        padding: 4px 10px !important;
        font-size: 0.75rem !important;
        border-radius: 12px !important;
        min-width: 32px !important;
        max-width: none !important;
        white-space: nowrap !important;
        gap: 4px;
    }
    
    .connection-indicator i {
        font-size: 0.85rem !important;
    }
    
    .participants-count {
        font-size: 0.75rem !important;
        gap: 4px;
        flex-shrink: 0;
    }
    
    .copy-btn {
        width: 26px !important;
        height: 26px !important;
        font-size: 11px !important;
        flex-shrink: 0;
    }
    
    /* ФИКСИРОВАННЫЙ КОНТЕЙНЕР УЧАСТНИКОВ */
    .participants-container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 auto 8px auto !important;
        padding: 8px !important;
        height: 62vh !important;
        max-height: 62vh !important;
        overflow: hidden !important;
        display: flex !important;
        align-items: flex-start !important;
    }
    
    /* КОМПАКТНЫЕ КНОПКИ УПРАВЛЕНИЯ */
    .call-controls {
        display: flex;
        gap: 8px;
        justify-content: center;
        align-items: center;
        padding: 0;
        margin-bottom: 8px;
        flex-wrap: nowrap;
    }
    
    .control-group {
        display: flex;
        gap: 8px;
        align-items: center;
    }
    
    .control-group.separated {
        margin-left: 12px;
        padding-left: 12px;
        border-left: 2px solid #e5e5e5;
    }
    
    .control-btn {
        width: 42px !important;
        height: 42px !important;
        font-size: 14px;
    }
    
    .control-btn.leave-btn {
        width: 42px !important;
        height: 42px !important;
        font-size: 14px;
    }
    
    .participants-list {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
        width: 100% !important;
        align-items: start !important;
    }
    
    /* ДИНАМИЧЕСКИЕ РАЗМЕРЫ В ЗАВИСИМОСТИ ОТ КОЛИЧЕСТВА УЧАСТНИКОВ */
    
    /* 1-2 участника - большие */
    .participants-list .participant {
        width: 100% !important;
        max-width: 100% !important;
        min-width: auto !important;
        padding: 6px;
    }
    
    .participants-list .participant-video,
    .participants-list .participant-video-placeholder {
        height: 260px !important;
        border-radius: 8px !important;
        object-fit: cover !important;
        margin-bottom: 6px;
    }
    
    /* 3-4 участника - средние */
    .participants-list:has(.participant:nth-child(3)) .participant {
        padding: 5px;
    }
    
    .participants-list:has(.participant:nth-child(3)) .participant-video,
    .participants-list:has(.participant:nth-child(3)) .participant-video-placeholder {
        height: 140px !important;
        margin-bottom: 4px;
    }
    
    /* 5-6 участников - маленькие */
    .participants-list:has(.participant:nth-child(5)) .participant {
        padding: 4px;
    }
    
    .participants-list:has(.participant:nth-child(5)) .participant-video,
    .participants-list:has(.participant:nth-child(5)) .participant-video-placeholder {
        height: 105px !important;
        margin-bottom: 3px;
    }
    
    /* 7-8 участников - очень маленькие */
    .participants-list:has(.participant:nth-child(7)) .participant {
        padding: 3px;
    }
    
    .participants-list:has(.participant:nth-child(7)) .participant-video,
    .participants-list:has(.participant:nth-child(7)) .participant-video-placeholder {
        height: 85px !important;
        margin-bottom: 3px;
    }
    
    .participant-name {
        font-size: 0.75rem !important;
        font-weight: 600 !important;
        margin-bottom: 2px;
    }
    
    .participant-status {
        font-size: 0.65rem !important;
    }
    
    .chat-panel {
        width: 100% !important;
        right: -100%;
        height: 100vh !important;
        top: 0 !important;
        z-index: 2000 !important;
    }
    
    .chat-panel.active {
        right: 0 !important;
    }
    
    .chat-header {
        padding: 15px;
        position: sticky;
        top: 0;
        z-index: 2001;
        background: #f8f8f8;
    }
    
    .chat-messages {
        padding: 15px;
        flex: 1;
        overflow-y: auto;
        padding-bottom: 80px; /* Место для фиксированного ввода */
    }
    
    .chat-input-container {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        padding: 15px !important;
        background: #ffffff !important;
        border-top: 1px solid #e5e5e5 !important;
        z-index: 2002 !important;
        display: none !important; /* Скрыто по умолчанию */
        gap: 10px !important;
    }
    
    /* Показываем поле ввода только когда чат активен */
    .chat-panel.active ~ .chat-input-container,
    .chat-panel.active .chat-input-container {
        display: flex !important;
    }
    
    #chat-input {
        flex: 1 !important;
        padding: 12px 16px !important;
        font-size: 16px !important; /* Предотвращает зум на iOS */
        border: 1px solid #e5e5e5 !important;
        border-radius: 6px !important;
    }
    
    .send-btn {
        width: 50px !important;
        height: 50px !important;
        border-radius: 6px !important;
        flex-shrink: 0 !important;
    }
    
    /* Дополнительные стили для мобильного чата */
    .chat-message {
        max-width: 85% !important;
        margin-bottom: 8px !important;
    }
    
    .message-text {
        font-size: 14px !important;
        line-height: 1.4 !important;
    }
    
    .message-author {
        font-size: 12px !important;
    }
    
    .message-time {
        font-size: 11px !important;
    }
    
    .participant-video {
        height: 150px;
    }
    
    .participant-video-placeholder {
        height: 150px;
        font-size: 2rem;
    }
    
    .video-modal-content {
        max-width: 95vw;
        max-height: 95vh;
        flex-direction: column;
    }
    
    .video-modal-video {
        width: 100%;
        max-height: 60vh;
        border-radius: 12px 12px 0 0;
    }
    
    .video-modal-info {
        width: 100%;
        padding: 15px;
    }
    
    .notifications {
        left: 16px;
        right: 16px;
        top: 16px;
    }
    
    .notification {
        max-width: none;
    }
    
}

/* Дополнительная адаптивность для очень маленьких экранов */
@media (max-width: 480px) {
    /* УЛЬТРА-КОМПАКТНЫЙ РЕЖИМ */
    .container {
        padding: 8px 6px !important;
    }
    
    .header {
        margin-bottom: 6px !important;
    }
    
    .header h1 {
        font-size: 1.4rem !important;
    }
    
    .header p {
        font-size: 0.75rem !important;
    }
    
    /* ЗАГОЛОВОК КОМНАТЫ */
    .call-header {
        padding: 6px 8px !important;
        margin-bottom: 6px !important;
    }
    
    .room-id-container h2 {
        font-size: 0.8rem !important;
        flex: 1;
        min-width: 0;
    }
    
    .connection-indicator {
        padding: 3px 8px !important;
        font-size: 0.7rem !important;
        border-radius: 10px !important;
        min-width: 28px !important;
    }
    
    .connection-indicator i {
        font-size: 0.8rem !important;
    }
    
    .participants-count {
        font-size: 0.7rem !important;
    }
    
    .copy-btn {
        width: 24px !important;
        height: 24px !important;
        font-size: 10px !important;
    }
    
    /* УЧАСТНИКИ */
    .participants-container {
        padding: 6px !important;
        margin: 0 auto 6px auto !important;
        height: 58vh !important;
        max-height: 58vh !important;
        overflow: hidden !important;
    }
    
    .participants-list {
        grid-template-columns: 1fr !important;
        gap: 5px !important;
    }
    
    .participant {
        padding: 5px;
    }
    
    /* 1-2 участника */
    .participant-video,
    .participant-video-placeholder {
        height: 240px !important;
        margin-bottom: 4px;
    }
    
    /* 3-4 участника */
    .participants-list:has(.participant:nth-child(3)) .participant {
        padding: 4px;
    }
    
    .participants-list:has(.participant:nth-child(3)) .participant-video,
    .participants-list:has(.participant:nth-child(3)) .participant-video-placeholder {
        height: 130px !important;
        margin-bottom: 3px;
    }
    
    /* 5-6 участников */
    .participants-list:has(.participant:nth-child(5)) .participant {
        padding: 3px;
    }
    
    .participants-list:has(.participant:nth-child(5)) .participant-video,
    .participants-list:has(.participant:nth-child(5)) .participant-video-placeholder {
        height: 100px !important;
        margin-bottom: 3px;
    }
    
    /* 7-8 участников */
    .participants-list:has(.participant:nth-child(7)) .participant {
        padding: 3px;
    }
    
    .participants-list:has(.participant:nth-child(7)) .participant-video,
    .participants-list:has(.participant:nth-child(7)) .participant-video-placeholder {
        height: 80px !important;
        margin-bottom: 2px;
    }
    
    /* Для 3+ участников показываем в 2 колонки */
    .participants-list:has(.participant:nth-child(3)) {
        grid-template-columns: 1fr 1fr !important;
    }
    
    .participant-name {
        font-size: 0.7rem !important;
    }
    
    .participant-status {
        font-size: 0.6rem !important;
    }
    
    /* Специальный стиль для 2+ участников - показываем в 2 колонки */
    .participants-list:has(.participant:nth-child(2)) {
        grid-template-columns: 1fr 1fr !important;
    }
    
    /* КНОПКИ УПРАВЛЕНИЯ */
    .call-controls {
        gap: 6px;
        padding: 0;
        margin-bottom: 6px;
    }
    
    .control-group {
        gap: 6px;
    }
    
    .control-group.separated {
        margin-left: 10px;
        padding-left: 10px;
    }
    
    .control-btn {
        width: 38px !important;
        height: 38px !important;
        font-size: 12px !important;
    }
    
    .control-btn.leave-btn {
        width: 38px !important;
        height: 38px !important;
        font-size: 12px !important;
    }
    
    /* ЧАТ */
    .chat-header {
        padding: 10px !important;
    }
    
    .chat-header h3 {
        font-size: 1rem !important;
    }
    
    .chat-messages {
        padding: 10px !important;
        padding-bottom: 65px !important;
    }
    
    .chat-input-container {
        padding: 10px !important;
        gap: 6px !important;
    }
    
    #chat-input {
        padding: 10px 12px !important;
        font-size: 16px !important;
    }
    
    .send-btn {
        width: 42px !important;
        height: 42px !important;
    }
    
    .chat-message {
        max-width: 88% !important;
        padding: 8px 12px !important;
    }
    
    .message-text {
        font-size: 0.85rem !important;
    }
    
    .message-author {
        font-size: 0.7rem !important;
    }
    
    .message-time {
        font-size: 0.65rem !important;
    }
    
    /* ФОРМА */
    .card {
        padding: 20px 14px;
    }
    
    .form-group {
        margin-bottom: 14px !important;
    }
    
    .form-group label {
        font-size: 0.85rem !important;
        margin-bottom: 6px !important;
    }
    
    .form-group input {
        padding: 10px 14px !important;
        font-size: 16px !important;
        border-radius: 6px !important;
    }
    
    .btn {
        padding: 11px 20px !important;
        font-size: 0.95rem !important;
        border-radius: 6px !important;
        width: 100% !important;
        margin-bottom: 8px !important;
    }
    
    .btn:last-child {
        margin-bottom: 0 !important;
    }
}

/* Оптимизация для мобильных с малой высотой экрана */
@media (max-width: 768px) and (max-height: 700px) {
    .header {
        margin-bottom: 6px !important;
    }
    
    .header h1 {
        font-size: 1.4rem !important;
    }
    
    .header p {
        font-size: 0.75rem !important;
    }
    
    .call-header {
        padding: 8px 10px !important;
        margin-bottom: 6px !important;
    }
    
    .participants-container {
        padding: 6px !important;
        margin-bottom: 6px !important;
        height: 55vh !important;
        max-height: 55vh !important;
        overflow: hidden !important;
    }
    
    .participant {
        max-height: none !important;
    }
    
    /* 1-2 участника */
    .participant-video,
    .participant-video-placeholder {
        height: 220px !important;
    }
    
    /* 3-4 участника */
    .participants-list:has(.participant:nth-child(3)) .participant {
        padding: 4px;
    }
    
    .participants-list:has(.participant:nth-child(3)) .participant-video,
    .participants-list:has(.participant:nth-child(3)) .participant-video-placeholder {
        height: 120px !important;
    }
    
    /* 5-6 участников */
    .participants-list:has(.participant:nth-child(5)) .participant {
        padding: 3px;
    }
    
    .participants-list:has(.participant:nth-child(5)) .participant-video,
    .participants-list:has(.participant:nth-child(5)) .participant-video-placeholder {
        height: 95px !important;
    }
    
    /* 7-8 участников */
    .participants-list:has(.participant:nth-child(7)) .participant {
        padding: 3px;
    }
    
    .participants-list:has(.participant:nth-child(7)) .participant-video,
    .participants-list:has(.participant:nth-child(7)) .participant-video-placeholder {
        height: 75px !important;
    }
    
    .call-controls {
        margin-bottom: 6px;
    }
    
    .control-btn,
    .control-btn.leave-btn {
        width: 38px !important;
        height: 38px !important;
        font-size: 12px !important;
    }
}

/* Очень малая высота экрана */
@media (max-width: 768px) and (max-height: 600px) {
    .container {
        padding: 6px 4px !important;
    }
    
    .header {
        margin-bottom: 4px !important;
    }
    
    .header h1 {
        font-size: 1.3rem !important;
    }
    
    .header p {
        font-size: 0.7rem !important;
    }
    
    .call-header {
        padding: 4px 6px !important;
        margin-bottom: 4px !important;
    }
    
    .participants-container {
        padding: 4px !important;
        margin-bottom: 4px !important;
        height: 52vh !important;
        max-height: 52vh !important;
        overflow: hidden !important;
    }
    
    .participant {
        max-height: none !important;
        padding: 3px;
    }
    
    /* 1-2 участника */
    .participant-video,
    .participant-video-placeholder {
        height: 200px !important;
        margin-bottom: 3px;
    }
    
    /* 3-4 участника */
    .participants-list:has(.participant:nth-child(3)) .participant {
        padding: 3px;
    }
    
    .participants-list:has(.participant:nth-child(3)) .participant-video,
    .participants-list:has(.participant:nth-child(3)) .participant-video-placeholder {
        height: 110px !important;
        margin-bottom: 2px;
    }
    
    /* 5-6 участников */
    .participants-list:has(.participant:nth-child(5)) .participant {
        padding: 2px;
    }
    
    .participants-list:has(.participant:nth-child(5)) .participant-video,
    .participants-list:has(.participant:nth-child(5)) .participant-video-placeholder {
        height: 85px !important;
        margin-bottom: 2px;
    }
    
    /* 7-8 участников */
    .participants-list:has(.participant:nth-child(7)) .participant {
        padding: 2px;
    }
    
    .participants-list:has(.participant:nth-child(7)) .participant-video,
    .participants-list:has(.participant:nth-child(7)) .participant-video-placeholder {
        height: 68px !important;
        margin-bottom: 2px;
    }
    
    .participant-name {
        font-size: 0.65rem !important;
    }
    
    .participant-status {
        font-size: 0.6rem !important;
    }
    
    .call-controls {
        margin-bottom: 4px;
        gap: 4px;
    }
    
    .control-group {
        gap: 4px;
    }
    
    .control-btn,
    .control-btn.leave-btn {
        width: 36px !important;
        height: 36px !important;
        font-size: 11px !important;
    }
}

/* Анимации загрузки */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #e5e5e5;
    border-top: 2px solid #333333;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* === Уведомления чата === */

/* Бейдж с количеством непрочитанных сообщений на кнопке чата */
.chat-notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ff4444;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: badge-pulse 2s infinite;
    z-index: 10;
}

@keyframes badge-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Всплывающее уведомление о новом сообщении */
.chat-toast-notification {
    position: fixed;
    top: 80px;
    right: 20px;
    background: white;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    min-width: 300px;
    max-width: 400px;
    z-index: 10000;
    cursor: pointer;
    transform: translateX(450px);
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

.chat-toast-notification.show {
    transform: translateX(0);
    opacity: 1;
}

.chat-toast-notification:hover {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.toast-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e5e5;
    color: #333;
}

.toast-header i {
    color: #4CAF50;
    font-size: 16px;
}

.toast-header strong {
    font-size: 14px;
    font-weight: 600;
}

.toast-body {
    padding: 12px 16px;
    color: #666;
    font-size: 13px;
    line-height: 1.4;
}

/* Адаптив для мобильных */
@media (max-width: 768px) {
    .chat-toast-notification {
        top: 60px;
        right: 10px;
        left: 10px;
        min-width: auto;
        max-width: none;
    }
    
    .chat-notification-badge {
        top: -2px;
        right: -2px;
        font-size: 10px;
        padding: 1px 5px;
        min-width: 16px;
        height: 16px;
    }
}

/* === Скрытие кнопок в зависимости от устройства === */

/* Скрываем кнопку демонстрации экрана на мобильных */
@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
}

/* Скрываем кнопку переворота камеры на десктопе */
@media (min-width: 769px) {
    .mobile-only {
        display: none !important;
    }
}

/* === Режим демонстрации экрана === */
.screen-share-view {
    display: flex;
    gap: 20px;
    width: 100%;
    height: calc(100vh - 320px); /* Еще больше отступ для кнопок */
    padding: 10px;
    box-sizing: border-box;
    margin-bottom: 15px;
}

.screen-share-main {
    flex: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
    border: 3px solid #000000;
    border-radius: 20px;
    position: relative;
    overflow: hidden;
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    transition: all 0.3s ease;
}

.screen-share-video-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#screen-share-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.screen-share-label {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 400;
    z-index: 10;
}

.screen-share-label i {
    color: #2ecc71;
    font-size: 12px;
}

.screen-share-sidebar {
    flex: 1;
    background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
    border: 3px solid #000000;
    border-radius: 20px;
    padding: 20px;
    overflow-y: auto;
    min-width: 250px;
    max-width: 300px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.screen-share-sidebar h3 {
    color: #000000;
    font-size: 18px;
    margin: 0 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #000000;
}

.screen-share-participants {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.screen-share-participant-card {
    background: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.screen-share-participant-card.self {
    border: 2px solid #667eea;
    background: linear-gradient(135deg, #f0f4ff 0%, #e8eeff 100%);
    box-shadow: 
        0 4px 12px rgba(102, 126, 234, 0.2),
        0 1px 3px rgba(0, 0, 0, 0.1);
}

.screen-share-participant-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.participant-mini-video {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
    background: #1a1a1a;
}

.participant-mini-avatar {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.participant-mini-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.participant-mini-name {
    color: #000000;
    font-size: 14px;
    font-weight: 500;
}

.participant-mini-info i {
    font-size: 16px;
}

/* Адаптив для демонстрации экрана */
@media (max-width: 1024px) {
    .screen-share-view {
        flex-direction: column;
        height: auto;
    }
    
    .screen-share-main {
        height: 60vh;
    }
    
    .screen-share-sidebar {
        max-width: none;
        min-width: auto;
        max-height: 200px;
    }
    
    .screen-share-participants {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .screen-share-participant-card {
        flex: 0 0 calc(50% - 6px);
    }
}

@media (max-width: 768px) {
    .screen-share-main {
        height: 50vh;
    }
    
    .screen-share-label {
        top: 10px;
        left: 10px;
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .participant-mini-video,
    .participant-mini-avatar {
        width: 45px;
        height: 45px;
    }
    
    .participant-mini-name {
        font-size: 12px;
    }
}

/* Мобильные устройства - скрытие контейнеров при демонстрации экрана */
.mobile-device .screen-share-view .call-header,
.mobile-device .screen-share-view .room-info,
.mobile-device .screen-share-view .participants-container {
    display: none !important;
}

/* Принудительное скрытие на мобильных при демонстрации */
.mobile-device .hidden-on-mobile {
    display: none !important;
}

/* Скрытие основных карточек участников на мобильных при демонстрации */
.mobile-device .screen-share-view .participant {
    display: none !important;
}

.mobile-device .screen-share-view .participants-list {
    display: none !important;
}

/* Улучшенное определение мобильных устройств */
@media (max-width: 768px), (pointer: coarse) {
    .mobile-device .screen-share-view .call-header,
    .mobile-device .screen-share-view .room-info,
    .mobile-device .screen-share-view .participants-container,
    .mobile-device .screen-share-view .participant,
    .mobile-device .screen-share-view .participants-list {
        display: none !important;
    }
}

/* Дополнительное скрытие для мобильных устройств */
@media (max-width: 768px), (pointer: coarse) {
    .mobile-device .screen-share-view ~ .participants-container,
    .mobile-device .screen-share-view ~ .call-header,
    .mobile-device .screen-share-view ~ .room-info {
        display: none !important;
    }
    
    /* Скрываем все элементы участников внутри call-room при демонстрации */
    .mobile-device #call-room:has(.screen-share-view) .participants-container,
    .mobile-device #call-room:has(.screen-share-view) .call-header,
    .mobile-device #call-room:has(.screen-share-view) .participant {
        display: none !important;
    }
}

/* АГРЕССИВНОЕ скрытие для мобильных при демонстрации экрана */
.mobile-device #call-room:has(.screen-share-view) .call-header,
.mobile-device #call-room:has(.screen-share-view) .room-info,
.mobile-device #call-room:has(.screen-share-view) .participants-container,
.mobile-device #call-room:has(.screen-share-view) .participant {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Альтернативный способ - скрываем все элементы кроме демонстрации и кнопок */
.mobile-device #call-room:has(.screen-share-view) > *:not(.screen-share-view):not(.call-controls) {
    display: none !important;
}