/* 모바일 전환 수정 CSS - 기존 스타일을 강제로 덮어쓰기 */

/* 모바일 사이즈에서 강제 적용 */
@media (max-width: 768px) {
  
  /* 기존 float 스타일 강제 제거 */
  .im_dialogs_col_wrap,
  .im_history_col_wrap {
    float: none !important;
    width: 100% !important;
    height: 100dvh !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    border-right: none !important;
    background: #fff !important;
    z-index: 1 !important;
  }

  /* 페이지 전체 레이아웃 강제 조정 */
  .im_page_wrap {
    height: 100dvh !important;
    min-height: 100dvh !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  .im_page_split {
    height: 100% !important;
    position: relative !important;
    overflow: hidden !important;
  }

  /* 기본 상태: 채팅리스트만 보이고 채팅방은 숨김 */
  .im_dialogs_col_wrap {
    transform: translateX(0) !important;
    transition: transform 0.3s ease-in-out !important;
    z-index: 2 !important;
  }

  .im_history_col_wrap {
    transform: translateX(100%) !important;
    transition: transform 0.3s ease-in-out !important;
    z-index: 1 !important;
  }

  /* 채팅방 활성화 시: 채팅방만 보이고 채팅리스트 숨김 */
  body.mobile_chat_active .im_dialogs_col_wrap {
    transform: translateX(-100%) !important;
    z-index: 1 !important;
  }

  body.mobile_chat_active .im_history_col_wrap {
    transform: translateX(0) !important;
    z-index: 2 !important;
  }

  /* ============================================ */
  /* 🚨 헤더 관련 스타일 - 수정된 부분 */
  /* ============================================ */
  
  /* 헤더는 모바일에서 항상 보이도록 설정 */
  .tg_head_wrap,
  .tg_page_head,
  body.mobile-optimized .tg_head_wrap,
  body.non_osx.non_msie.is_1x.mobile-optimized .tg_head_wrap {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    overflow: visible !important;
    transition: none !important;
  }

  /* 헤더를 고정 위치로 설정 */
  .tg_head_wrap {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 48px !important;
    z-index: 1000 !important;
    background: #4a90e2 !important;
  }

  /* 헤더 영역 조정 */
  .tg_head_split {
    width: 100% !important;
    min-width: auto !important;
  }
  
  /* 기본 상태에서는 로고 영역만 보임 */
  .tg_head_logo_wrap {
    width: 100% !important;
    display: block !important;
  }

  .tg_head_main_wrap {
    width: 100% !important;
    display: none !important;
  }

  /* ⭐ 중요: 컨텐츠 영역을 헤더 아래로 밀어내기 */
  .im_page_wrap {
    /* padding-top: 48px !important; */
    height: calc(100dvh - 48px) !important;
    box-sizing: border-box !important;
  }

  /* 채팅 리스트 영역도 헤더 높이만큼 조정 */
  .im_dialogs_col_wrap {
    top: 0 !important;
    height: calc(100dvh - 48px) !important;
  }

  .im_history_col_wrap {
    top: 0 !important;
    height: calc(100dvh - 48px) !important;
  }

  /* 채팅방 활성화 시에만 헤더 전환 */
  body.mobile_chat_active .tg_head_main_wrap {
    display: block !important;
  }

  body.mobile_chat_active .tg_head_logo_wrap {
    display: none !important;
  }

  /* 채팅 창 관련 */
  .chat_window_wrap {
    display: flex !important;
  }
  
  .mobile-header-visible {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  .mobile-chat-visible {
    display: block !important;
  }

  /* ============================================ */
  /* 나머지 스타일들 */
  /* ============================================ */

  /* 채팅 영역 높이 강제 조정 */
  .im_dialogs_col{
    height: calc(100dvh - 48px) !important;
    max-height: calc(100dvh - 48px) !important;
  }
  .im_history_wrap {
    height: calc(100dvh - 135px) !important;
    max-height: calc(100dvh - 135px) !important;
  }

  /* 뒤로가기 버튼 */
  .mobile_back_btn {
    display: none !important;
    background: none !important;
    border: none !important;
    color: #fff !important;
    font-size: 18px !important;
    padding: 14px 15px !important;
    cursor: pointer !important;
  }

  body.mobile_chat_active .mobile_back_btn {
    display: inline-block !important;
  }

  /* 기타 모바일 최적화 */
  #search_group_name {
    width: calc(100% - 14px) !important;
    margin: 7px !important;
  }

  #chat_gpt {
    margin: 0 7px !important;
    padding: 10px !important;
  }

  .im_dialogs_scrollable_wrap a.im_dialog {
    padding: 12px 16px !important;
  }

  .composer_rich_textarea,
  .composer_rich_textarea-gpt {
    width: calc(100% - 60px) !important;
    margin-left: 15px !important;
    font-size: 16px !important;
  }

  .im_send_form {
    left: 5px !important;
    right: 5px !important;
    width: calc(100% - 10px) !important;
  }

  /* 모달 크기 조정 */
  .modal-dialog {
    width: 95% !important;
    margin: 10px auto !important;
  }
  
  /* 스크롤 영역 터치 최적화 */
  .im_history_scrollable_wrap,
  .im_dialogs_scrollable_wrap {
    -webkit-overflow-scrolling: touch !important;
  }

  .im_history_wrap,.md_modal_body {
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
  }

  .im_message_wrap {
    margin: 0 auto;
    position: static;
  }
  
  .im_content_message_wrap {
    margin: 8px 10px 8px 0px;
  }

  #search_input_wrap{
    padding:10px 0 10px 20px !important;
  }
}

.composer_rich_textarea,
.composer_textarea {
  overflow: none;
  overflow-y: scroll;
  border-radius: 0;
  border: 0;
  box-shadow: none;
  outline: none;
  box-shadow: 0 1px 0 0 #e8e8e8;
  padding: 1px 10px 1px 0;
  margin: 0;
  line-height: 20px;
  height: auto;
}


/* 디버그용 - 현재 상태 확인 (필요시 주석 해제) */
/*
@media (max-width: 768px) {
  body::before {
    content: "Mobile Mode Active";
    position: fixed;
    top: 0;
    right: 0;
    background: red;
    color: white;
    padding: 2px 5px;
    font-size: 10px;
    z-index: 9999;
    pointer-events: none;
  }
  
  body.mobile_chat_active::before {
    content: "Mobile Chat Active";
    background: green;
  } 
}
*/