.chat-list-main-body {
    width: 100%;
    background: #fff;
    border-radius: 0 0 10px 10px;
    padding: 5px 10px;
    margin: 0 auto;
    height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
}

.sort-buttons {
    display: flex;
    justify-content: flex-start;
    gap: 10px;
    margin-bottom: 5px;
}

.sort-buttons button {
    color: #333333 !important;
    padding: 10px;
    border: none;
    cursor: pointer;
    background-color: #d9d8d8;
    color: white;
    border-radius: 10px;
}
.sort-buttons button:hover {
    color: #fff !important;
    background-color: #0AA273;
}
.sort-buttons button:active {
    color: #fff;
    background-color: #0AA273;
}
#new-chat-button {
    margin-left: auto; /* ボタンを右端に配置 */
}

/* ヘッダーアクション領域のスタイル */
.header-actions {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 10;
}

/* テーブルを包むコンテナ */
.table-container {
    flex: 1;
    overflow: auto;
    position: relative;
}

.chat-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.chat-table thead {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #333333;
}

.chat-table th {
    background-color: #333333;
    color: white;
    cursor: default;
    position: sticky;
    top: 0;
    z-index: 5;
}

.chat-table th, .chat-table td {
    padding: 10px;
    border-bottom: 1px solid #ddd;
    text-align: left;
    overflow: hidden;  /* はみ出た部分を隠す */
    vertical-align: middle;
    box-sizing: border-box;
    line-height: 1.2; /* 行の高さを統一 */
}

/* 全てのテーブルセルに一貫した境界線表示を適用 */
.chat-table td {
    padding: 10px;
    border-bottom: 1px solid #ddd;
    text-align: left;
    vertical-align: middle; /* 全てのセルで中央揃えにする */
    line-height: 1.2; /* 行の高さを統一 */
    box-sizing: border-box; /* ボーダーとパディングをセルのサイズに含める */
    white-space: nowrap;
}

@media screen and (max-width: 1000px)
{
    .sort-buttons button,
    .chat-table th,
    .chat-table td,
    .pagination {
        font-size: 14px;
    }
}
@media screen and (max-width: 739px)
{
    .sort-buttons button,
    .chat-table th,
    .chat-table td,
    .pagination {
        font-size: 12px;
    }
}

.chat-table th:nth-child(1) { 
    width: 60px; /* 未読カラムの幅を固定値に設定 */
    min-width: 60px; /* 最小幅も設定 */
    white-space: nowrap; /* テキストの折り返しを防ぐ */
}
.chat-table th:nth-child(2) { width: 30%; } /* ユーザー名 */
.chat-table th:nth-child(3) { width: 37%; } /* 最終メッセージ */
.chat-table th:nth-child(4) { width: 18%; } /* 最終対応者 */
.chat-table th:nth-child(5) { width: 10%; } /* 日時 */

.chat-table tr {
    transition: background-color 0.2s ease;
}

.chat-table tr:hover {
    background-color: #f1f1f1;
    cursor: pointer;
}

.unread-cell {
    text-align: center;
    padding: 10px 5px; /* 左右のパディングを調整 */
    vertical-align: middle;
}

.username-cell {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0; /* パディングを削除 - 親のtdのパディングを使用 */
    height: 100%; /* 親要素の高さいっぱいに */
    box-sizing: border-box; /* ボーダーとパディングをセルの高さに含める */
}

.unread-count {
    background-color: red;
    color: white;
    font-size: 12px;
    font-weight: bold;
    border-radius: 12px; /* 丸から楕円形に変更 */
    text-align: center;
    min-width: 24px; /* 最小幅を設定 */
    height: 24px;
    line-height: 24px;
    padding: 0 6px; /* 横方向にパディングを追加 */
    margin: 0 auto;
    display: inline-block;
}
@media screen and (max-width: 739px)
{
    .unread-count {
        font-size: 9px;
        min-width: 18px; /* スマホ用の最小幅 */
        height: 18px;
        line-height: 18px;
        padding: 0 4px; /* スマホ用のパディング */
    }
}

.pagination {
    margin-top: 10px;
    text-align: center;
}

.pagination button {
    padding: 5px 10px;
    margin: 0 5px;
    font-size: 14px;
    cursor: pointer;
    border-radius: 5px;
}
.pagination button:hover {
    color: #fff;
    background-color: #0AA273;
}
.pagination button:active {
    color: #fff;
    background-color: #0AA273;
}
.pagination button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.user-icon {
    width: 32px;
    background: #F1EDE7;
    margin-right: 5px;
    border-radius: 50%;
    vertical-align: middle;
}

/* チャットメニューアイテムの位置調整 */
.chat-menu-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    z-index: 1;
}

.chat-icon-wrapper {
    position: relative;
    display: inline-block;
    margin-right: 5px;
    z-index: 1;
}

/* チャットアイコンとバッジの配置 */
.fa-solid.fa-comment {
    position: relative;
    display: inline-block;
}

/* メニューテキストの位置調整 */
.menu-text {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* 未読バッジのスタイル */
.unread-badge-corner {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: red;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    padding: 0;
    font-size: 12px;
    font-weight: bold;
    margin-left: 5px;
    line-height: 1;
    padding-top: 5px;
}

/* 未読バッジの中の数字を中央に配置 */
.unread-badge-corner:not(:empty) {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* レスポンシブ対応 */
@media screen and (max-width: 1000px) {
    .sort-buttons button,
    .chat-table th,
    .chat-table td,
    .pagination {
        font-size: 14px;
    }
}

@media screen and (max-width: 768px) {
    .chat-table th,
    .chat-table td {
        font-size: 13px;
        padding: 6px;
    }
    
    /* 特定のカラムのみ表示 */
    .chat-table th:nth-child(3),
    .chat-table td:nth-child(3) {
        display: none;
    }
    
    /* カラム幅の再調整 */
    .chat-table th:nth-child(1) { 
        width: 60px;
        min-width: 60px;
    }
    .chat-table th:nth-child(2) { width: 43%; } /* ユーザー名 */
    .chat-table th:nth-child(4) { width: 25%; } /* 最終対応者 */
    .chat-table th:nth-child(5) { width: 22%; } /* 日時 */
    
    /* 全てのセルを2行表示に対応 */
    .chat-table td {
        height: auto;
        white-space: normal;
        line-height: 1.4;
        min-height: 48px; /* 2行分の最小の高さを確保 */
        overflow: visible;
    }
    
    /* テキストを折り返す */
    .chat-table td:nth-child(2),  /* ユーザー名 */
    .chat-table td:nth-child(4) { /* 最終対応者 */
        word-break: break-word;
        white-space: normal;
    }
    
    /* ユーザー名セルのフレックスレイアウトを調整 */
    .username-cell {
        flex-wrap: wrap;
        min-height: 40px; /* 高さを調整 */
        align-items: flex-start;
        padding: 0; /* 親のtdのパディングを使用 */
    }
    
    /* ユーザーアイコンを調整 */
    .user-icon {
        margin-right: 8px;
        margin-bottom: 4px;
    }
    
    /* テーブルのレイアウト調整 */
    .chat-table {
        width: 100%;
        table-layout: fixed;
        border-collapse: collapse; /* 境界線を結合 */
    }
    
    /* 検索フォームのレイアウト調整 */
    .header-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .search-forms-container {
        width: 100%;
        flex-direction: column;
        gap: 8px;
    }
    
    .search-form {
        width: 100%;
        margin-right: 0;
        margin-bottom: 5px;
    }
    
    #username-search, #staff-filter {
        width: 100%;
    }

    .date-range {
        width: 100%;
        justify-content: space-between;
    }
    
    .mobile-search-container, 
    .mobile-filter-container {
        display: flex;
        width: 100%;
        margin-bottom: 5px;
    }
    
    .mobile-search-container .search-form,
    .mobile-filter-container .search-form {
        flex: 1;
        margin-bottom: 0;
    }
    
    .new-chat-button {
        width: 100%;
        justify-content: center;
        margin-left: 0;
        margin-top: 5px;
    }
    
    /* 最終対応者とクリアボタンを横並びにする */
    .staff-container {
        display: flex;
        width: 100%;
        align-items: center;
        gap: 5px;
        margin-bottom: 8px;
    }
    
    .staff-container .search-form {
        flex: 1;
        margin-bottom: 0;
    }
    
    .staff-container .clear-button {
        flex-shrink: 0;
        margin: 0;
        white-space: nowrap;
    }
    
    /* クリアボタンのマージン調整 */
    .clear-button {
        margin-left: 5px;
        margin-right: 0;
    }
    
    /* モバイル表示時の調整 */
    .mobile-layout {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    .mobile-layout .search-form,
    .mobile-layout .staff-container {
        margin-bottom: 0;
    }
    
    /* フォーム内の要素が横幅いっぱいになるように */
    .mobile-layout .search-form input,
    .mobile-layout .search-form select {
        width: 100%;
    }
    
    /* 日付入力フィールドの横幅調整 */
    .mobile-layout .date-range {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 5px;
    }
    
    .mobile-layout .date-range input {
        flex: 1;
    }
    
    .date-range-label {
        min-width: 45px;
    }
}

@media screen and (max-width: 739px)
{
    .sort-buttons button,
    .chat-table th,
    .chat-table td,
    .pagination {
        font-size: 12px;
    }
    
    .unread-count {
        font-size: 9px;
        min-width: 18px; /* スマホ用の最小幅 */
        height: 18px;
        line-height: 18px;
        padding: 0 4px; /* スマホ用のパディング */
    }
}

/* 画面幅480px以下の場合の調整 */
@media screen and (max-width: 480px) {
    /* ソートアイコンを非表示 */
    .chat-table th.sortable .sort-icon {
        display: none;
    }
    
    /* ソートアイコンを非表示にした際のパディング調整 */
    .chat-table th.sortable {
        padding-right: 8px;
    }
    
    /* 文字サイズをさらに小さく */
    .sort-buttons button,
    .chat-table th,
    .chat-table td,
    .pagination {
        font-size: 11px;
    }
    
    /* セルのパディングを減らして表示スペースを確保 */
    .chat-table th,
    .chat-table td {
        padding: 5px 3px;
    }
    
    .chat-table th:nth-child(1) { 
        width: 50px; /* より小さい画面では少し幅を縮める */
        min-width: 50px;
    }
}

/* ソート可能なテーブルヘッダを指定するスタイル */
.chat-table th.sortable {
    cursor: pointer;
    position: relative;
    padding-right: 20px; /* アイコン用のスペース */
}

/* ホバー時のスタイル */
.chat-table th.sortable:hover {
    background-color: #444;
}

/* ソートアイコンのスタイル */
.sort-icon {
    color: #999;
    position: absolute;
    right: 5px;
    font-size: 14px;
}

/* ヘッダーアクション領域のスタイル */
.header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    justify-content: space-between;
    margin: 5px 0 0 0 !important;
}

/* 左側のフォーム要素をまとめるコンテナ */
.search-forms-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    flex: 1;
}

.search-form {
    position: relative;
    margin-right: 10px;
}

#username-search {
    width: 180px; /* 幅を調整 */
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

#staff-filter {
    width: 150px; /* 幅を調整 */
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.date-range {
    display: flex;
    align-items: center;
    gap: 5px;
}

.date-range input[type="date"] {
    width: 110px; /* 日付入力の幅をさらに狭く */
    padding: 8px 6px; /* 左右のパディングを減らす */
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.date-range-label {
    min-width: 45px; /* 「日時：」の3文字分の幅を確保 */
    display: inline-block;
    text-align: right;
    margin-right: 5px;
    white-space: nowrap; /* 改行を防ぐ */
}

.clear-button {
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    margin-right: 10px;
    white-space: nowrap;
    min-width: 90px; /* ボタンの最小幅を設定 */
}

.clear-button i {
    margin-right: 5px; /* アイコンの右側に余白を追加 */
}

.clear-button:hover {
    background-color: #e0e0e0;
}

.new-chat-button {
    background-color: #0AA273;
    color: white !important;
    border: none;
    border-radius: 4px;
    padding: 8px 15px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
}

.new-chat-button:hover {
    background-color: #3e8e41;
    color: white;
}

.new-chat-button i {
    margin-right: 5px;
}

/* レスポンシブデザイン */
@media (min-width: 769px) {
    .search-forms-container {
        max-width: calc(100% - 150px);
    }
    
    .search-form {
        margin-bottom: 0;
    }
}

/* チャット一覧ページのJavaScript用クラス */
.chat-search-container {
    display: flex;
    width: 100%;
    gap: 5px;
    margin-bottom: 10px;
}

.chat-search-container .search-form {
    flex: 1;
    min-width: 0;
}

.chat-search-container .clear-button {
    flex-shrink: 0;
    white-space: nowrap;
}

/* 特に大きい画面向けの調整 */
@media screen and (min-width: 1001px) and (max-width: 1300px) {
    #username-search {
        width: 160px; /* 幅をさらに調整 */
    }
    
    #staff-filter {
        width: 140px; /* 幅をさらに調整 */
    }
    
    .date-range input[type="date"] {
        width: 115px; /* 日付入力の幅をさらに調整 */
    }
    
    .date-range span {
        font-size: 13px; /* 「期間:」と「～」のテキストサイズを小さく */
    }
}

/* 非常に大きい画面向けの調整 */
@media screen and (min-width: 1301px) {
    #username-search {
        width: 200px; /* 大きい画面では幅を広げる */
    }
    
    #staff-filter {
        width: 160px; /* 大きい画面では幅を広げる */
    }
    
    .date-range input[type="date"] {
        width: 140px; /* 大きい画面では幅を広げる */
    }
}

/* すべてのPC向けデスクトップ表示で「期間：」の検索フォームを2行目に表示 */
@media screen and (min-width: 769px) {
    .search-forms-container {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important; /* 左寄せに変更 */
        width: auto !important; /* 必要な幅だけ取るように */
        max-width: 100% !important;
    }
    
    .search-first-row {
        display: flex;
        align-items: center;
        margin-bottom: 5px; /* 行間を狭く */
    }
    
    .search-second-row {
        display: flex;
        align-items: center;
        width: auto; /* 必要な幅だけに */
    }
    
    .search-form.date-range {
        width: auto; /* 必要な幅だけに */
        margin-top: 0; /* 余分なマージンを削除 */
    }

    /* ヘッダーアクションの調整 */
    .header-actions {
        justify-content: space-between !important;
        flex-wrap: nowrap !important;
    }
    
    /* 新規チャットボタンの位置調整 */
    .new-chat-button {
        margin-left: auto !important;
    }
}

/* ===== ユーザーメニューモーダル（共通コンポーネント） ===== */
.user-menu-container {
    position: relative;
    display: inline-block;
}

.user-img {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.user-img:hover {
    opacity: 0.8;
}

.user-img img {
    border-radius: 50%;
    width: 40px;
    height: 40px;
    object-fit: cover;
}

/* ドロップダウンモーダル（共通コンポーネント） */
.dropdown-modal {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    min-width: 150px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    margin-top: 5px;
}

.dropdown-modal.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-modal-content {
    padding: 8px 0;
}

.dropdown-menu-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: background-color 0.2s ease;
    gap: 8px;
}

.dropdown-menu-item:hover {
    background-color: #f5f5f5;
}

.dropdown-menu-item:active {
    background-color: #e0e0e0;
}

.dropdown-menu-item i {
    width: 16px;
    text-align: center;
    color: #666;
}

/* レスポンシブ対応 */
@media screen and (max-width: 768px) {
    .dropdown-modal {
        min-width: 130px;
        right: -10px; /* スマホでは少し左にずらす */
    }
    
    .dropdown-menu-item {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .user-img img {
        width: 35px;
        height: 35px;
    }
}