/* ===== ダイレクトメッセージ モーダル ===== */

/* モーダル本体（書斎・買い物リストと同じ枠に合わせる） */
#group_message_modal .modal_contents.gm_modal_contents {
    width: 95%;
    max-width: 1100px;
    max-height: 90vh;
}

/* グループメッセージ全体のコンテナ（左右2ペイン） */
.gm_container {
    display: flex;
    height: calc(75vh - 80px);
    min-height: 400px;
    margin-top: 8px;
    border: 1px solid #444;
    border-radius: 4px;
    overflow: hidden;
}

/* ===== 左ペイン：スレッドリスト ===== */
.gm_thread_list_panel {
    width: 280px;
    min-width: 220px;
    border-right: 1px solid #444;
    display: flex;
    flex-direction: column;
    background: #1a1a1a;
    flex-shrink: 0;
}
.gm_thread_search {
    display: flex;
    gap: 4px;
    padding: 8px;
    border-bottom: 1px solid #333;
}
.gm_recipient_search_input {
    flex: 1;
    padding: 6px 8px;
    background: #2a2a2a;
    border: 1px solid #555;
    border-radius: 4px;
    color: whitesmoke;
    font-size: 12px;
}
.gm_recipient_search_btn {
    padding: 6px 10px;
    font-size: 12px;
    background: #333;
    border: 1px solid #555;
    border-radius: 4px;
    color: whitesmoke;
    cursor: pointer;
    white-space: nowrap;
}
.gm_recipient_search_btn:hover {background: #444;}

/* 選択済みメンバーエリア */
.gm_selected_area {
    padding: 6px 8px;
    border-bottom: 1px solid #333;
    background: #1e2a3a;
}
.gm_selected_area.is-hidden {display: none;}
.gm_selected_label {font-size: 10px; color: #888; margin-bottom: 4px;}
.gm_selected_list {display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px;}
.gm_selected_member_item {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    background: #2a4a8a;
    border-radius: 10px;
    font-size: 11px;
    color: whitesmoke;
}
.gm_selected_member_remove {
    cursor: pointer;
    font-size: 12px;
    color: #aaa;
    line-height: 1;
}
.gm_selected_member_remove:hover {color: #e55;}
.gm_create_thread_btn {
    width: 100%;
    padding: 5px 8px;
    font-size: 12px;
    background: #2a5aaa;
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    transition: background 0.15s;
}
.gm_create_thread_btn:hover {background: #3a6acc;}

/* 検索結果ドロップダウン */
.gm_recipient_search_result {
    position: absolute;
    z-index: 200;
    width: 268px;
    background: #222;
    border: 1px solid #555;
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 44px;
    margin-left: 8px;
}
.gm_recipient_item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-bottom: 1px solid #333;
    cursor: pointer;
}
.gm_recipient_item:hover {background: #2a2a2a;}
.gm_recipient_icon {border-radius: 50%; object-fit: cover;}
.gm_recipient_info {flex: 1; overflow: hidden;}
.gm_recipient_name {font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.gm_recipient_account_name {font-size: 11px; color: #888;}
.gm_add_btn {
    padding: 4px 8px;
    font-size: 11px;
    background: #2a4a8a;
    border: 1px solid #3a5aaa;
    border-radius: 4px;
    color: whitesmoke;
    cursor: pointer;
    white-space: nowrap;
}
.gm_add_btn:hover:not(:disabled) {background: #3a5aaa;}
.gm_add_btn:disabled {background: #333; color: #666; cursor: not-allowed; border-color: #444;}
.gm_no_results {padding: 12px 8px; font-size: 12px; color: #888;}

.gm_thread_list_title {
    padding: 6px 10px;
    font-size: 12px;
    color: #888;
    border-bottom: 1px solid #333;
}
.gm_thread_list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
}
.gm_thread_item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 10px;
    border-bottom: 1px solid #2a2a2a;
    cursor: pointer;
    transition: background 0.15s;
}
.gm_thread_item:hover, .gm_thread_item.active {background: #2a3a5a;}
.gm_thread_icon {border-radius: 50%; object-fit: cover; flex-shrink: 0;}
.gm_thread_info {flex: 1; overflow: hidden;}
.gm_thread_name {font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.gm_thread_account_name {font-size: 11px; color: #888;}
.gm_thread_last_message {font-size: 11px; color: #999; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px;}
.gm_thread_date {font-size: 10px; color: #666; flex-shrink: 0; align-self: flex-start; padding-top: 2px;}
.gm_no_threads {padding: 16px 10px; font-size: 12px; color: #888;}
.gm_loading {padding: 16px 10px; font-size: 12px; color: #888;}

/* ===== 右ペイン：メッセージビュー ===== */
.gm_message_panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #111;
}
.gm_message_panel_header {
    padding: 10px 14px;
    border-bottom: 1px solid #333;
    font-size: 15px;
    font-weight: bold;
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.gm_message_partner_name {flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;}
.gm_partner_account_name {font-size: 12px; color: #888; font-weight: normal;}
.gm_left_tag {font-size: 11px; color: #888; font-weight: normal;}
.gm_leave_btn {
    padding: 4px 12px;
    font-size: 12px;
    background: transparent;
    border: 1px solid #666;
    border-radius: 4px;
    color: #aaa;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: color 0.15s, border-color 0.15s;
}
.gm_leave_btn:hover {color: #e55; border-color: #e55;}
.gm_leave_btn.is-hidden {display: none;}

/* メッセージ表示エリア */
.gm_messages_area {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
}
.gm_no_messages {font-size: 12px; color: #888; text-align: center; padding-top: 40px;}
.gm_no_threads {font-size: 12px; color: #888; text-align: center; padding-top: 40px;}

/* システムメッセージ（退室通知など） */
.gm_system_message {
    text-align: center;
    font-size: 11px;
    color: #666;
    padding: 4px 0;
    margin: 4px 0;
}

/* 送信者名（グループメッセージ）*/
.gm_message_sender_name {
    font-size: 10px;
    color: #888;
    margin-bottom: 2px;
    padding: 0 4px;
}
.gm_message_sender_name.is-hidden {display: none;}

/* メッセージバブル */
.gm_message_bubble {
    max-width: 72%;
    display: flex;
    flex-direction: column;
}
.gm_message_mine {align-self: flex-end; align-items: flex-end;}
.gm_message_other {align-self: flex-start; align-items: flex-start;}
.gm_message_content {
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}
.gm_message_content a {
    color: #7ab4ff;
    text-decoration: underline;
    word-break: break-all;
}
.gm_message_mine .gm_message_content {
    background: #2a5aaa;
    color: white;
    border-bottom-right-radius: 4px;
}
.gm_message_other .gm_message_content {
    background: #2a2a2a;
    color: whitesmoke;
    border-bottom-left-radius: 4px;
}
.gm_message_meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: #666;
    margin-top: 3px;
    padding: 0 4px;
}
.gm_read_mark {color: #4a8aff; font-size: 10px;}
.gm_message_delete {
    font-size: 10px;
    padding: 1px 6px;
    background: transparent;
    border: 1px solid #444;
    border-radius: 3px;
    color: #888;
    cursor: pointer;
    margin-left: 4px;
}
.gm_message_delete:hover {color: #e55; border-color: #e55;}
.gm_message_deleted {text-decoration: line-through; opacity: 0.5;}

/* 入力エリア */
.gm_input_area {
    padding: 10px 14px;
    border-top: 1px solid #333;
    background: #1a1a1a;
}
.gm_message_input {
    width: 100%;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 6px;
    color: whitesmoke;
    padding: 8px 10px;
    font-size: 14px;
    resize: none;
    min-height: 58px;
    max-height: 200px;
    overflow-y: auto;
    box-sizing: border-box;
    font-family: inherit;
}
.gm_message_input:focus {outline: none; border-color: #3a5aaa;}
.gm_input_actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}
.gm_char_count {font-size: 11px; color: #666;}
.gm_input_notice {font-size: 10px; color: #666; margin-top: 4px;}
.gm_char_warn {color: #e55 !important;}
.gm_send_btn {
    padding: 6px 18px;
    background: #2a5aaa;
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
}
.gm_send_btn:hover:not(:disabled) {background: #3a6acc;}
.gm_send_btn:disabled {background: #333; color: #666; cursor: not-allowed;}

/* プロフィールモーダルのメッセージボタン */
.gm_open_from_profile {
    padding: 6px 16px;
    background: #2a5aaa;
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}
.gm_open_from_profile:hover {background: #3a6acc;}

/* トップページ メッセージアイコンラッパー */
.gm_icon_wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    top: 4px;
}
#gm_unread_badge {
    position: absolute;
    top: -4px;
    right: -8px;
    min-width: 12px;
    height: 12px;
    font-size: 9px;
    padding: 0 3px;
    line-height: 12px;
    border-radius: 6px;
}

/* 未読バッジ */
.gm_unread_badge {
    display: inline-block;
    background: #e55;
    color: white;
    border-radius: 10px;
    font-size: 12px;
    padding: 1px 7px;
    vertical-align: middle;
    min-width: 20px;
    text-align: center;
}
.gm_unread_badge.is-hidden {
    display: none;
}
.gm_thread_unread_badge {
    display: inline-block;
    background: #e55;
    border-radius: 50%;
    width: 8px;
    height: 8px;
    vertical-align: middle;
    margin-left: 4px;
}
.gm_thread_unread_badge.is-hidden {
    display: none;
}

/* グループ名編集ボタン */
.gm_edit_name_btn {
    padding: 4px 8px;
    font-size: 13px;
    background: transparent;
    border: 1px solid #555;
    border-radius: 4px;
    color: #888;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.15s, border-color 0.15s;
}
.gm_edit_name_btn:hover {color: #fa0; border-color: #fa0;}
.gm_edit_name_btn.is-hidden {display: none;}

/* グループ名編集エリア */
.gm_edit_name_area {
    padding: 8px 14px;
    border-bottom: 1px solid #333;
    background: #161e2e;
}
.gm_edit_name_area.is-hidden {display: none;}
.gm_edit_name_row {
    display: flex;
    gap: 6px;
}
.gm_edit_name_input {
    flex: 1;
    padding: 5px 8px;
    background: #2a2a2a;
    border: 1px solid #555;
    border-radius: 4px;
    color: whitesmoke;
    font-size: 13px;
}
.gm_edit_name_save_btn {
    padding: 5px 12px;
    font-size: 12px;
    background: #2a5aaa;
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    white-space: nowrap;
}
.gm_edit_name_save_btn:hover:not(:disabled) {background: #3a6acc;}
.gm_edit_name_save_btn:disabled {background: #333; color: #666; cursor: not-allowed;}
.gm_edit_name_close_btn {
    padding: 5px 8px;
    font-size: 13px;
    background: transparent;
    border: 1px solid #555;
    border-radius: 4px;
    color: #888;
    cursor: pointer;
}
.gm_edit_name_close_btn:hover {color: #e55; border-color: #e55;}

/* メンバー追加ボタン */
.gm_add_member_btn {
    padding: 4px 10px;
    font-size: 12px;
    background: transparent;
    border: 1px solid #555;
    border-radius: 4px;
    color: #aaa;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: color 0.15s, border-color 0.15s;
}
.gm_add_member_btn:hover {color: #4af; border-color: #4af;}
.gm_add_member_btn.is-hidden {display: none;}

/* メンバー追加エリア */
.gm_add_member_area {
    padding: 8px 14px;
    border-bottom: 1px solid #333;
    background: #161e2e;
}
.gm_add_member_area.is-hidden {display: none;}
.gm_add_member_search_row {
    display: flex;
    gap: 6px;
}
.gm_add_member_input {
    flex: 1;
    padding: 5px 8px;
    background: #2a2a2a;
    border: 1px solid #555;
    border-radius: 4px;
    color: whitesmoke;
    font-size: 12px;
}
.gm_add_member_search_btn {
    padding: 5px 10px;
    font-size: 12px;
    background: #2a4a8a;
    border: 1px solid #3a5aaa;
    border-radius: 4px;
    color: white;
    cursor: pointer;
}
.gm_add_member_search_btn:hover {background: #3a5aaa;}
.gm_add_member_close_btn {
    padding: 5px 8px;
    font-size: 13px;
    background: transparent;
    border: 1px solid #555;
    border-radius: 4px;
    color: #888;
    cursor: pointer;
}
.gm_add_member_close_btn:hover {color: #e55; border-color: #e55;}
.gm_add_member_result {
    margin-top: 6px;
    background: #222;
    border: 1px solid #444;
    border-radius: 4px;
    max-height: 180px;
    overflow-y: auto;
}
.gm_add_member_result.is-hidden {display: none;}

/* レスポンシブ：スマホ・狭い画面 */
@media (max-width: 680px) {
    .gm_container {flex-direction: column; height: auto; min-height: 500px;}
    .gm_thread_list_panel {width: 100%; border-right: none; border-bottom: 1px solid #444; max-height: 200px;}
    .gm_message_panel {min-height: 300px;}
    .gm_recipient_search_result {width: calc(100% - 16px); margin-left: 8px;}
}
