/* ============================================
   МОБИЛЬНАЯ АДАПТАЦИЯ — ПОЛНАЯ ВЕРСИЯ
   ============================================ */

.mobile-back-btn {
    display: none;
}

/* Основные мобильные стили */
@media (max-width: 768px) {
    
    /* Базовые */
    body {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }
    .main-interface {
        position: relative;
        overflow: hidden;
        width: 100%;
        height: 100%;
    }

    /* Навигация */
    .glass-sidebar {
        position: absolute;
        top: 0;
        left: 0;
        width: 100% !important;
        height: 100% !important;
        transform: translateX(0);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 10;
        background: rgba(3, 8, 26, 0.98) !important;
        backdrop-filter: blur(20px);
        border-right: none;
    }
    .glass-sidebar.chat-open {
        transform: translateX(-100%);
    }

    .glass-chat-area {
        position: absolute;
        top: 0;
        right: 0;
        width: 100%;
        height: 100%;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 20;
        background: rgba(3, 8, 26, 0.98);
        backdrop-filter: blur(20px);
    }
    .glass-chat-area.chat-open {
        transform: translateX(0);
    }

    /* Кнопка назад */
    .mobile-back-btn {
        display: flex !important;
        background: rgba(255, 255, 255, 0.08);
        border: none;
        color: white;
        cursor: pointer;
        width: 36px;
        height: 36px;
        min-width: 36px;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        transition: background 0.15s, transform 0.1s;
    }
    .mobile-back-btn:active {
        background: rgba(255, 255, 255, 0.18);
        transform: scale(0.93);
    }

    /* Поле ввода */
    .input-zone {
        display: none !important;
    }
    .glass-chat-area.chat-open .input-zone {
        display: block !important;
    }

    /* Хедер чата */
    .chat-header {
        padding: 10px 14px;
        background: rgba(0, 0, 0, 0.35);
        border-bottom: 1px solid var(--glass-border);
        flex-shrink: 0;
    }
    .chat-info {
        display: flex;
        align-items: center;
        gap: 10px;
        flex-wrap: nowrap;
        overflow: hidden;
    }
    .chat-info h3 {
        font-size: 15px;
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
    }
    .chat-status {
        font-size: 11px;
        white-space: nowrap;
    }
    .current-user-badge {
        font-size: 10px;
        padding: 3px 8px;
        flex-shrink: 0;
    }

    /* Список диалогов */
    .dialogs-header {
        padding: 14px 12px;
        flex-shrink: 0;
    }
    .search-input {
        font-size: 14px;
        padding: 10px 12px 10px 38px;
        border-radius: 20px;
    }
    .dialogs-list {
        flex: 1;
        overflow-y: auto;
        padding: 6px 0;
        -webkit-overflow-scrolling: touch;
    }
    .dialog-item {
        padding: 11px 14px;
        gap: 11px;
        cursor: pointer;
        transition: background 0.12s;
        border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    }
    .dialog-item:active {
        background: rgba(255, 255, 255, 0.09);
    }
    .dialog-avatar {
        width: 46px;
        height: 46px;
        font-size: 16px;
        flex-shrink: 0;
    }
    .dialog-name {
        font-size: 14px;
        font-weight: 600;
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 4px;
    }
    .dialog-preview {
        font-size: 12px;
    }

    /* Групповой бейдж на мобильных */
    .group-badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 20px;
        height: 20px;
        background: #4a5568;
        border-radius: 10px;
        margin-right: 6px;
    }
    .group-badge svg {
        width: 12px;
        height: 12px;
    }

    /* Сообщения */
    .messages-container {
        padding: 10px;
        gap: 8px;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .message {
        gap: 8px;
    }
    .msg-avatar {
        width: 30px;
        height: 30px;
        font-size: 11px;
        flex-shrink: 0;
    }
    .msg-bubble {
        max-width: 86%;
        padding: 8px 11px;
    }
    .text {
        font-size: 14px;
        line-height: 1.45;
        word-break: break-word;
    }
    .msg-time {
        font-size: 9px;
        margin-top: 3px;
    }

    /* Поле ввода */
    .input-zone {
        padding: 8px 12px;
        background: rgba(0, 0, 0, 0.45);
        backdrop-filter: blur(10px);
        flex-shrink: 0;
    }
    .glass-input-wrapper {
        padding: 5px 10px;
        border-radius: 24px;
    }
    .glass-input-wrapper input {
        font-size: 16px;
        padding: 8px 0;
    }

    /* Эмодзи */
    .emoji-picker {
        position: fixed;
        bottom: 66px;
        left: 10px;
        right: 10px;
        max-width: none;
        width: auto;
        padding: 10px;
        z-index: 1000;
    }
    .emoji-list {
        display: grid;
        grid-template-columns: repeat(6, 1fr);
        gap: 6px;
        max-height: 220px;
        overflow-y: auto;
    }
    .emoji-item {
        font-size: 26px;
        padding: 7px;
        cursor: pointer;
        text-align: center;
        border-radius: 10px;
    }
    .emoji-item:active {
        background: rgba(255, 255, 255, 0.15);
        transform: scale(0.92);
    }

    /* Нижняя панель профиля */
    .profile-footer {
        padding: 8px 12px;
        min-height: 58px;
        flex-shrink: 0;
    }
    .profile-footer-avatar {
        width: 38px;
        height: 38px;
        font-size: 15px;
    }
    .profile-footer-name {
        font-size: 13px;
    }
    .profile-footer-username {
        font-size: 11px;
    }
    .profile-footer-btn {
        width: 34px;
        height: 34px;
    }
    .profile-footer-btn:active {
        transform: scale(0.93);
    }

    /* Кнопки отправки */
    .send-btn, .emoji-btn {
        padding: 8px;
        min-width: 38px;
        min-height: 38px;
    }
    .send-btn:active, .emoji-btn:active {
        transform: scale(0.92);
    }

    /* Разделитель дат */
    .date-divider {
        margin: 12px 0;
    }
    .date-divider-text {
        font-size: 10px;
        padding: 3px 10px;
    }

    /* Кнопка создания группы */
    .create-group-btn {
        width: 38px !important;
        height: 38px !important;
        flex-shrink: 0;
    }

    /* Модальные окна (единый стиль) */
    .profile-modal-card,
    .custom-modal-container {
        margin: 12px;
        width: calc(100% - 24px);
        max-width: none;
        border-radius: 24px;
        max-height: calc(var(--dvh, 100vh) - 40px);
        display: flex;
        flex-direction: column;
    }
    .profile-modal-body,
    .custom-modal-body {
        padding: 14px 18px 18px;
        overflow-y: auto;
        flex: 1;
    }
    .profile-avatar-big {
        width: 72px;
        height: 72px;
        font-size: 28px;
    }
    .glass-input {
        padding: 11px;
        font-size: 14px;
    }

    /* Контекстное меню (скрыто на мобильных, используем bottom sheet) */
    #message-menu {
        display: none !important;
    }
    
    /* Мобильное контекстное меню для участников группы */
    #member-context-menu {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        border-radius: 20px 20px 0 0;
        max-width: none;
        width: 100%;
    }
    #member-context-menu.menu-visible {
        transform: translateY(0);
    }

    /* Заглушка */
    .msg-stub {
        padding: 40px 20px;
    }
    .msg-stub p {
        font-size: 13px;
    }

    /* Участники группы */
    .member-actions {
        flex-wrap: wrap;
        gap: 4px;
    }
    .promote-btn, .danger-btn {
        padding: 5px 10px;
        font-size: 12px;
    }
    .group-members-list {
        max-height: 320px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .member-item {
        padding: 8px 10px;
        cursor: pointer;
    }
    .member-item:active {
        background: rgba(255, 255, 255, 0.05);
    }
    .member-name {
        font-size: 13px;
    }
    .member-avatar {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    .member-role {
        font-size: 9px;
        padding: 2px 6px;
    }
    .member-role.admin {
        background: rgba(102, 126, 234, 0.3);
        color: #a78bfa;
    }

    /* Групповая статистика */
    .group-stats {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    /* Результаты поиска */
    .members-results {
        max-height: 150px;
    }
    .search-result-item {
        padding: 8px 10px;
    }
    .result-avatar {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    .result-name {
        font-size: 13px;
    }
    .selected-member-tag {
        font-size: 11px;
        padding: 3px 6px 3px 10px;
    }

    /* Футер модальных окон */
    .custom-modal-footer {
        padding: 12px 16px;
        flex-shrink: 0;
    }
    .custom-modal-footer .glass-button {
        padding: 10px;
        font-size: 13px;
    }

    /* Предотвращаем зумирование */
    input, textarea {
        font-size: 16px !important;
    }
}

/* Очень маленькие экраны */
@media (max-width: 480px) {
    .dialog-avatar {
        width: 42px;
        height: 42px;
    }
    .dialog-item {
        padding: 9px 12px;
    }
    .msg-bubble {
        max-width: 90%;
        padding: 7px 10px;
    }
    .emoji-item {
        font-size: 22px;
        padding: 5px;
    }
    .chat-info h3 {
        font-size: 14px;
    }
    .mobile-back-btn {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }
}

/* Анимации навигации */
@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}
@keyframes slideOutLeft {
    from { transform: translateX(0); }
    to { transform: translateX(-100%); }
}

/* Запрет растягивания модальных окон */
.profile-modal-card,
.custom-modal-container {
    resize: none;
    user-select: none;
    max-width: 440px;
    width: 100%;
}

.profile-modal-body,
.custom-modal-body {
    overflow-y: auto;
    overflow-x: hidden;
}
/* Добавьте в конец файла mobile.css */

/* Стили для мобильного контекстного меню диалогов */
@media (max-width: 768px) {
    #dialog-menu {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        transform: translateY(100%);
        border-radius: 20px 20px 0 0;
        max-width: none;
        width: 100%;
        transition: transform 0.3s ease;
        background: rgba(20, 30, 50, 0.98);
        backdrop-filter: blur(20px);
        z-index: 10001;
    }
    
    #dialog-menu.menu-visible {
        transform: translateY(0);
    }
    
    #dialog-menu .menu-item {
        padding: 14px 20px;
        font-size: 16px;
    }
    
    #dialog-menu .menu-item:active {
        background: rgba(255, 255, 255, 0.1);
    }
    
    /* Стили для иконок в меню */
    #dialog-menu .menu-item svg {
        width: 20px;
        height: 20px;
    }
}

/* Анимация для новых сообщений */
@keyframes newMessagePulse {
    0% { background: rgba(0, 114, 255, 0); }
    50% { background: rgba(0, 114, 255, 0.3); }
    100% { background: rgba(0, 114, 255, 0); }
}

.dialog-item.new-message {
    animation: newMessagePulse 1s ease-in-out 2;
}
/* Стили для оверлея мобильного меню */
#mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: none;
    backdrop-filter: blur(4px);
}

/* Улучшенные стили для мобильного контекстного меню */
@media (max-width: 768px) {
    #dialog-menu {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        transform: translateY(100%);
        border-radius: 20px 20px 0 0;
        max-width: none;
        width: 100%;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        background: rgba(20, 30, 50, 0.98);
        backdrop-filter: blur(20px);
        z-index: 10000;
        padding-bottom: env(safe-area-inset-bottom, 16px);
    }
    
    #dialog-menu.menu-visible {
        transform: translateY(0);
    }
    
    #dialog-menu .menu-item {
        padding: 16px 20px;
        font-size: 16px;
        min-height: 54px;
    }
    
    #dialog-menu .menu-item:active {
        background: rgba(255, 255, 255, 0.1);
    }
    
    #dialog-menu .menu-item svg {
        width: 22px;
        height: 22px;
    }
    
    /* Ручка сверху для индикации свайпа */
    #dialog-menu::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.3);
        border-radius: 2px;
    }
}
