/* === КРИТИЧЕСКИЕ ИСПРАВЛЕНИЯ ДЛЯ МОБИЛЬНОЙ ВЕРСИИ === */

/* Сброс всех базовых стилей для мобильных устройств */
@media (max-width: 768px) {
  /* Полный сброс для корневых элементов */
  html, body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow-x: hidden !important;
    position: relative !important;
    box-sizing: border-box !important;
  }
  
  /* Основной контейнер */
  .tw-main-layout {
    flex-direction: column !important;
    height: 100vh !important;
    width: 100vw !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    position: relative !important;
  }
  
  /* Сайдбар (список) */
  .tw-sidebar {
    width: 100vw !important;
    height: 100vh !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #fff !important;
    border: none !important;
    box-shadow: none !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  /* Чат секция - скрыта по умолчанию */
  .tw-chat-section {
    display: none !important;
  }
  
  /* Активный чат - на весь экран */
  .tw-chat-section.active {
    display: flex !important;
    flex-direction: column !important;
    position: static !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #f8f9fb !important;
    z-index: 1001 !important;
    overflow: hidden !important;
    
    /* Убираем все псевдоэлементы */
    &::before, &::after {
      display: none !important;
      content: none !important;
    }
  }
  
  /* Заголовок чата */
  .tw-chat-header {
    padding: 80px 16px 16px 16px !important;
    text-align: center !important;
    background: #f8f9fb !important;
    flex-shrink: 0 !important;
    font-size: 1.2rem !important;
    font-weight: 700 !important;
    position: static !important;
    top: auto !important;
    z-index: auto !important;
  }
  .tw-chat-section.active::before,
  .tw-chat-section.active::after {
    display: none !important;
    content: none !important;
  }
  
  /* Область сообщений */
  .tw-chat-messages {
    flex: 1 !important;
    padding: 16px !important;
    margin: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    max-height: calc(100vh - 120px) !important;
  }
  
  /* Кнопка меню */
  #mobile-menu-btn {
    display: none !important;
    position: static !important;
    top: auto !important;
    left: auto !important;
    z-index: 1300 !important;
    background: #0071e3 !important;
    color: #fff !important;
    border: none !important;
    border-radius: 12px !important;
    padding: 10px 20px !important;
    font-size: 1rem !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    box-shadow: 0 4px 12px rgba(0,113,227,0.3) !important;
  }
  
  /* Показываем кнопку только в активном чате */
  .tw-chat-section.active #mobile-menu-btn {
    display: block !important;
  }
  
  /* Аккаунт бокс */
  .tw-account-box {
    margin: 0 !important;
    padding: 8px 16px !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
    border-bottom: 1px solid #e5e7eb !important;
  }
  
  /* Список вебинаров */
  #webinar-list {
    padding: 8px !important;
    gap: 8px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  /* Элементы вебинаров */
  .tw-webinar-item {
    padding: 16px !important;
    margin: 0 !important;
    border-radius: 12px !important;
    font-size: 1.1rem !important;
  }
  
  /* Сообщения */
  .tw-message-bubble {
    padding: 18px !important;
    font-size: 1.1rem !important;
    line-height: 1.5 !important;
    margin-bottom: 12px !important;
  }
  
  /* Кнопки */
  .tw-next-btn {
    margin: 16px auto !important;
    padding: 12px 24px !important;
    font-size: 1.1rem !important;
  }
  
  /* Убираем все скроллбары */
  * {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }
  
  *::-webkit-scrollbar {
    display: none !important;
  }
  
  /* Убираем футер */
  .tw-footer {
    display: none !important;
  }
}

/* Специальные исправления для iPhone с safe-area */
@media (max-width: 768px) and (min-height: 800px) {
  .tw-chat-section.active {
    height: calc(100vh - env(safe-area-inset-bottom, 0px)) !important;
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
  }
  
  .tw-chat-header {
    padding-top: calc(60px + env(safe-area-inset-top, 0px)) !important;
  }
  
  #mobile-menu-btn {
    top: calc(16px + env(safe-area-inset-top, 0px)) !important;
  }
  
  .tw-chat-messages {
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
    max-height: calc(100vh - 140px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) !important;
  }
}