/* ===================================================================
   Dialogs.css
   モーダル、ダイアログ全般
   ================================================================ */

/* ------------------------------------------------------------------
   汎用モーダル
   ------------------------------------------------------------------ */

.clsModal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.clsModal[hidden] {
    display: none !important;
}

.clsModalContent {
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    /* iOS Safari対策: スムーズスクロール */
    -webkit-overflow-scrolling: touch;
}

.clsModalHeader {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    padding: 24px;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.clsModalHeader h3 {
    margin: 0;
    font-size: 19px;
}

.clsModalClose {
    font-size: 24px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.2);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: none;
    color: white;
}

.clsModalClose:hover {
    background: rgba(255, 255, 255, 0.3);
}

.clsModalBody {
    padding: 32px;
}

.clsModalFooter {
    padding: 16px 32px 32px;
    display: flex;
    justify-content: flex-end;
    gap: 16px;
}

/* ------------------------------------------------------------------
   医師選択ダイアログ
   ------------------------------------------------------------------ */

.clsDoctorSelectOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    /* iOS Safari対策: タッチスクロール無効化 */
    -webkit-overflow-scrolling: auto;
    overflow: hidden;
}

.clsDoctorSelectDialog {
    background: #fff;
    border-radius: 12px;
    width: min(900px, 95vw);
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 32px rgba(14, 30, 37, 0.18);
    overflow: hidden;
}

.clsDoctorSelectHeader {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    padding: 24px;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.clsDoctorSelectHeader h3 {
    margin: 0;
    font-size: 19px;
    font-weight: 600;
}

.clsDoctorSelectClose {
    font-size: 16px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.2);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s ease;
    border: none;
    color: white;
    font-weight: bold;
}

.clsDoctorSelectClose:hover {
    background: rgba(255, 255, 255, 0.3);
}

.clsDoctorSelectBody {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px 32px 24px 32px;
    gap: 12px;
    overflow: hidden;
}

.clsDoctorSelectLoading,
.clsDoctorSelectError {
    text-align: center;
    padding: 40px 0;
    color: #64748b;
    font-size: 15px;
}

.clsDoctorSelectError {
    color: #d94848;
}

.clsDoctorSelectContent {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    flex: 1;
    min-height: 320px;
}

.clsDoctorSelectPanel {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fff;
}

.clsDoctorSelectPanelDoctors {
    background: #fff;
}

.clsDoctorSelectPanelHeader {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.clsDoctorSelectHeading {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: #007bff;
}

.clsDoctorSelectListContainer {
    flex: 1;
    overflow-y: auto;
    min-height: 200px;
    max-height: 400px;
    /* iOS Safari対策: スムーズスクロール */
    -webkit-overflow-scrolling: touch;
}

.clsDoctorSelectPagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.clsDoctorSelectPageInfo {
    font-size: 14px;
    color: #64748b;
    min-width: 60px;
    text-align: center;
}

.clsDoctorSelectToolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.clsDoctorSelectSearch {
    flex: 1;
    border: 1px solid #d0d7e2;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 16px; /* iOS Safariの自動ズーム防止のため16px以上 */
}

.clsDoctorSelectSearch:focus {
    outline: none;
    border-color: #007bff;
}

.clsDoctorSelectSearch:focus-visible {
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

.clsDoctorSelectFacilities {
    list-style: none;
    padding: 0;
    margin: 0;
}

.clsDoctorSelectFacilityItem {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    border-bottom: 1px solid #f1f3f5;
    cursor: pointer;
    transition: background-color 0.2s ease;
    gap: 0 8px;
}

.clsDoctorSelectFacilityItem:hover {
    background-color: #f8f9fa;
}

.clsDoctorSelectFacilityItem.clsIsActive {
    background-color: rgba(0, 123, 255, 0.08);
}

.clsDoctorSelectFacilityItem:last-child {
    border-bottom: none;
}

.clsDoctorSelectFacilityName {
    flex: 1;
    font-size: 15px;
    color: #333;
}

.clsDoctorSelectFacilityActions {
    display: flex;
    gap: 4px;
}

.clsDoctorSelectDoctors {
    list-style: none;
    padding: 0;
    margin: 0;
}

.clsDoctorSelectDoctorItem {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    border-bottom: 1px solid #f1f3f5;
    cursor: pointer;
    transition: background-color 0.2s ease;
    gap: 0 8px;
}

.clsDoctorSelectDoctorItem:hover {
    background-color: #f8f9fa;
}

.clsDoctorSelectDoctorItem.clsIsSelected {
    background-color: rgba(0, 123, 255, 0.08);
}

.clsDoctorSelectDoctorItem:last-child {
    border-bottom: none;
}

.clsDoctorSelectDoctorInfo {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.clsDoctorSelectDoctorName {
    font-weight: 500;
    color: #333;
    font-size: 15px;
}

.clsDoctorSelectDoctorFacility {
    font-size: 14px;
    color: #6c757d;
}

.clsDoctorSelectDoctorActions {
    display: flex;
    gap: 4px;
}

.clsDoctorSelectEmpty {
    padding: 32px 16px;
    text-align: center;
    color: #6b7a90;
}

@media (max-width: 720px) {
    .clsDoctorSelectDialog {
        width: 96vw;
        max-height: 96vh;
        height: auto;
    }

    .clsDoctorSelectHeader {
        padding: 16px;
    }

    .clsDoctorSelectBody {
        padding: 12px 16px 16px 16px;
        /* ダイアログ本体ではなく各リストコンテナでスクロール */
        overflow: visible;
    }

    .clsDoctorSelectContent {
        grid-template-columns: 1fr;
        min-height: auto;
        gap: 12px;
        /* コンテンツ領域全体のmax-heightを設定してパネルが収まるように */
        max-height: calc(96vh - (120px + 12px));
        /* コンテンツ領域自体はスクロールしない */
        overflow: visible;
    }

    .clsDoctorSelectPanel {
        height: calc((96vh - 120px) / 2 - 12px);
        overflow: hidden;
    }

    .clsDoctorSelectPanelHeader{
        flex-direction: row;
        align-items: center;
    }

    .clsDoctorSelectHeading{
        margin: 0;
    }

    .clsDoctorSelectListContainer {
        /* リストコンテナのみでスクロール */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        max-height: 100%;
    }

    .clsDoctorSelectFacilities {
        grid-template-columns: 1fr;
    }
}

/* ------------------------------------------------------------------
   医師検索ダイアログ
   ------------------------------------------------------------------ */

.clsDoctorSearchOverlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    /* iOS Safari対策: タッチスクロール無効化 */
    -webkit-overflow-scrolling: auto;
    overflow: hidden;
}

.clsDoctorSearchModalContent {
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    /* iOS Safari対策: スムーズスクロール */
    -webkit-overflow-scrolling: touch;
}

.clsDoctorSearchHeader {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    padding: 24px;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.clsDoctorSearchHeader h3 {
    margin: 0;
    font-size: 19px;
    font-weight: 600;
}

.clsDoctorSearchClose {
    font-size: 16px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.2);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s ease;
    border: none;
    color: white;
    font-weight: bold;
}

.clsDoctorSearchClose:hover {
    background: rgba(255, 255, 255, 0.3);
}

.clsDoctorSearchBody {
    padding: 32px 32px 0 32px;
    flex: 1;
    overflow-y: auto;
}

.clsDoctorSearchFooter {
    padding: 16px 32px 32px;
    display: flex;
    justify-content: flex-end;
    gap: 16px;
}

.clsDoctorSearchPagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 16px 0;
    margin-top: 16px;
    border-top: 1px solid #e9ecef;
}

.clsDoctorSearchPageInfo {
    font-size: 14px;
    color: #64748b;
    min-width: 60px;
    text-align: center;
}

/* ------------------------------------------------------------------
   医師リスト（共通）
   ------------------------------------------------------------------ */

.clsDoctorList {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
}

.clsDoctorListItem {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    gap: 16px;
    flex-wrap: wrap;
}

.clsDoctorListItem:hover {
    background: #f8f9fa;
}

.clsDoctorListItem:focus {
    outline: none;
}

.clsDoctorListItem:focus-visible {
    background: #f8f9fa;
    outline: 2px solid #007bff;
    outline-offset: -2px;
}

.clsDoctorListItem:last-child {
    border-bottom: none;
}

.clsDoctorListItem.clsIsSelected {
    background-color: #e7f1ff;
}

.clsDoctorListName {
    font-weight: 500;
    color: #212529;
}

.clsDoctorListFacility {
    font-size: 14px;
    color: #6c757d;
}

.clsDoctorListEmpty {
    padding: 16px;
    text-align: center;
    color: #6c757d;
    list-style: none;
}

/* 医師検索結果リスト専用スタイル */
.clsDoctorSearchResultList {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.clsDoctorSearchResultList .clsDoctorListItem {
    padding: 12px;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0 16px;
}

.clsDoctorSearchResultList .clsDoctorListItem:hover {
    background-color: #f8f9fa;
}

.clsDoctorSearchResultList .clsDoctorListItem:focus-visible {
    background-color: #f8f9fa;
    outline: 2px solid #007bff;
    outline-offset: -2px;
}

.clsDoctorSearchResultList .clsDoctorListItem:last-child {
    border-bottom: none;
}

.clsDoctorSearchResultList .clsDoctorListItem.clsIsSelected {
    background-color: #e7f1ff;
}

.clsDoctorSearchResultList .clsDoctorListName {
    font-weight: 500;
    color: #212529;
}

.clsDoctorSearchResultList .clsDoctorListFacility {
    color: #6c757d;
    font-size: 14px;
}

.clsDoctorSearchResultList .clsDoctorListEmpty {
    padding: 16px;
    text-align: center;
    color: #6c757d;
    list-style: none;
}

/* ------------------------------------------------------------------
   レスポンシブ対応
   ------------------------------------------------------------------ */

@media (max-width: 768px) {
    .clsDoctorSearchModalContent {
        width: 96vw;
        max-height: 96vh;
    }

    .clsDoctorSearchHeader {
        padding: 16px;
    }

    .clsDoctorSearchBody {
        padding: 24px;
    }

    .clsDoctorSearchFooter {
        padding: 12px 24px 24px;
    }

    .clsDoctorSearchPagination {
        padding: 12px 0;
    }
}
