/* ===================================================================
   Components.css
   汎用コンポーネント：ボタン、カード、フォーム、テーブル等
   
   【命名規則移行完了 - 2025-10-22】
   - クラス名: cls + PascalCase (例: clsBtn, clsCard, clsFormControl)
   - 旧クラス名（ケバブケース）はすべて削除済み
   - ファイルサイズ約40%削減
   ================================================================ */

/* ------------------------------------------------------------------
   ボタン
   ------------------------------------------------------------------ */

.clsBtn {
    display: inline-block;
    padding: 10px 19px;
    border: none;
    border-radius: 5px;
    text-decoration: none;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 15px;
}

/* ボタンのフォーカス状態（キーボード操作時のみ） */
.clsBtn:focus {
    outline: none;
}

.clsBtn:focus-visible {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.clsBtnPrimary {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
}

.clsBtnPrimary:hover {
    background: linear-gradient(135deg, #0056b3 0%, #004085 100%);
    transform: translateY(-1px);
}

.clsBtnSecondary {
    background: #6c757d;
    color: white;
}

.clsBtnSecondary:hover {
    background: #545b62;
}

.clsBtnSuccess {
    background: #28a745;
    color: white;
}

.clsBtnSuccess:hover {
    background: #1e7e34;
    transform: translateY(-1px);
}

.clsBtnDanger {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.clsBtnDanger:hover {
    background: #c82333;
    border-color: #bd2130;
    transform: translateY(-1px);
}

.clsBtnOutline {
    background: white;
    border: 2px solid #007bff;
    color: #007bff;
}

.clsBtnOutline:hover {
    background: #007bff;
    color: white;
}

.clsBtn:disabled,
.clsBtn[disabled],
.clsBtn[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(35%);
}

/* ------------------------------------------------------------------
   カード
   ------------------------------------------------------------------ */

.clsCard {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
    padding: 20px;
    margin-bottom: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.clsCard:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.15);
}

.clsCardHeader {
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.clsCardTitle {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
}

.clsCardTitle::before {
    content: attr(data-icon);
    margin-right: 8px;
    font-size: 24px;
}

/* ------------------------------------------------------------------
   フォーム
   ------------------------------------------------------------------ */

.clsFormRow {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
    /* グリッドアイテムの幅を制限 */
    width: 100%;
}

.clsFormRow > * {
    /* すべての子要素の最小幅を0に設定（グリッドの収縮を許可） */
    min-width: 0;
    max-width: 100%;
    /* グリッドセルの幅を明示的に制御 */
    width: 100%;
}

.clsFormRow.clsSingle,
.clsFormRow.single {
    grid-template-columns: 1fr;
}

.clsFormLabel {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #333;
}

.clsFormHint {
    font-size: 14px;
    color: #6c757d;
    margin-top: 8px;
}

.clsFormControl,
.clsFormSelect,
.clsRadioGroup,
.clsRadioItem,
.clsCheckboxGroup,
.clsCheckboxItem {
    text-align: left;
}

.clsFormControl,
.clsFormSelect {
    width: 100%;
    border: 1px solid #ced4da;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 16px; /* iOS Safariの自動ズーム防止のため16px以上 */
    text-align: left;
}

.clsFormControl {
    transition: border-color 0.3s ease;
}

/* セレクトボックスのカスタム矢印 */
select,
.clsFormSelect {
    /* ブラウザ標準の矢印を非表示 */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    
    /* 右側にスペースを確保 */
    padding-right: 36px;
    
    /* カスタム矢印（下向き三角形） */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23495057' d='M1.41 0L6 4.59L10.59 0L12 1.41l-6 6l-6-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    background-color: white;
}

.clsFormControl:focus,
.clsFormSelect:focus {
    outline: none;
    border-color: #007bff;
}

/* フォーカス時に矢印の色を青に変更 */
select:focus,
.clsFormSelect:focus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23007bff' d='M1.41 0L6 4.59L10.59 0L12 1.41l-6 6l-6-6z'/%3E%3C/svg%3E");
}

.clsFormControl:focus-visible,
.clsFormSelect:focus-visible {
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

select, input, textarea, button {
    font-family: 'Noto Sans JP', sans-serif;
    background-color: #fff;
    color: #000;
}

/* 入力要素の左寄せ */
input[type="text"],
input[type="number"],
input[type="date"],
textarea,
select,
.clsFormControl,
.clsFormSelect {
    text-align: left !important;
}

select,
.clsFormSelect {
    text-align-last: left !important;
}

/* iOS Safari: 日付ピッカーのスタイル調整 */
input[type="date"].clsFormControl {
    /* 見た目を完全にリセット */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    /* 他のフォームコントロールと同じ高さを確保 */
    /* font-size(16px) × line-height(1.6) + padding-top(10px) + padding-bottom(10px) + border(2px) */
    line-height: 1.6;
    min-height: 46px;
    height: auto;
}

/* 日付フィールドの内部コンテンツの配置 */
input[type="date"]::-webkit-date-and-time-value {
    text-align: left;
    line-height: 1.6;
}

/* iOS Safari: カレンダーアイコン */
input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
}

/* 読み取り専用フィールド */
.clsFormControl:disabled,
.clsFormControl[readonly],
.clsFormSelect:disabled,
textarea.clsFormControl:disabled,
textarea.clsFormControl[readonly] {
    background-color: #f1f3f5;
    color: #495057;
    opacity: 1;
    cursor: not-allowed;
}

/* 無効化時に矢印の色をグレーに変更 */
select:disabled,
.clsFormSelect:disabled {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23adb5bd' d='M1.41 0L6 4.59L10.59 0L12 1.41l-6 6l-6-6z'/%3E%3C/svg%3E");
    background-color: #f1f3f5;
}

/* ラジオボタン・チェックボックス */
.clsRadioGroup,
.clsCheckboxGroup {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.clsRadioGroupInline {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.clsBtnHistoryEdit {
    /* 履歴編集ボタン用のスタイル */
}

.clsRadioItem,
.clsCheckboxItem {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.25s ease;
}

.clsRadioItem:hover,
.clsCheckboxItem:hover {
    background: #e9ecef;
}

.clsRadioItem.clsIsChecked,
.clsCheckboxItem.clsIsChecked {
    background: #e7f3ff;
    border-color: #007bff;
}

.clsRadioItem input[disabled] + label,
.clsRadioItem input[readonly] + label {
    color: #6c757d;
    cursor: not-allowed;
}

.clsRadioItem:has(input[disabled]),
.clsRadioItem:has(input[readonly]) {
    background: #f1f3f5;
    border-color: #dee2e6;
    cursor: not-allowed;
}

.clsRadioItem input[disabled],
.clsRadioItem input[readonly] {
    cursor: not-allowed;
}

.clsRadioItem input[disabled] ~ span,
.clsRadioItem input[readonly] ~ span {
    color: #6c757d;
}

/* フォームセクション */
.clsFormSection {
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 24px;
    margin-bottom: 24px;
}

.clsFormSection:last-child {
    border-bottom: none;
}

/* フォームセクション内の最初と最後の子要素の余分なマージンを削除 */
.clsFormSection > :first-child {
    margin-top: 0;
}

.clsFormSection > :last-child {
    margin-bottom: 0;
}

/* フォームグループ（追加） */
.clsFormGroup {
    margin-bottom: 16px;
    /* グリッド内で最大幅を制限 */
    max-width: 100%;
    min-width: 0;
    width: 100%;
    /* 子要素（input）がはみ出さないように */
    display: flex;
    flex-direction: column;
}

.clsFormGroup-readonly {
    margin-bottom: 16px;
}

.clsFormGroup-readonly .clsFormControl,
.clsFormGroup-readonly .clsFormSelect,
.clsFormGroup-readonly textarea {
    background-color: #f8f9fa;
    border-color: #e9ecef;
}

/* ------------------------------------------------------------------
   テーブル
   ------------------------------------------------------------------ */

.clsTable {
    width: 100%;
    border-collapse: collapse;
}

.clsTable th,
.clsTable td,
.table th {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.clsTable th:nth-child(4),
.clsTable th:nth-child(5),
.clsTable th:nth-child(6),
.clsTable td:nth-child(4),
.clsTable td:nth-child(5),
.clsTable td:nth-child(6),
.table th:nth-child(4),
.table th:nth-child(5),
.table th:nth-child(6),
.table td:nth-child(4),
.table td:nth-child(5) {
    text-align: center;
}

.clsTable th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #333;
}

/* ソート可能列 */
.clsTable th.clsSortable {
    cursor: pointer;
    user-select: none;
}

.clsTable th.clsSortable:hover {
    background-color: #e9ecef;
}

/* テーブルラップ（追加） */
.clsTableWrap {
    overflow-x: auto;
}

/* ステータスバッジ */
.clsStatusBadge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 14px;
    background: #e9ecef;
    color: #495057;
}

/* ------------------------------------------------------------------
   結果表示パネル
   ------------------------------------------------------------------ */

.clsResultsPanel {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
}

.clsResultsHeader {
    background: #f8f9fa;
    padding: 16px 20px;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 16px;
}

.clsResultsHeader .clsToolbar {
    margin-top: 0;
}

.clsResultsTable {
    padding: 0;
}

/* ------------------------------------------------------------------
   統計カード
   ------------------------------------------------------------------ */

.clsStatsGrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.clsStatCard {
    background: white;
    padding: 32px;
    border-radius: 10px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
    text-align: center;
    transition: transform 0.3s ease;
}

.clsStatNumber {
    font-size: 40px;
    font-weight: bold;
    color: #007bff;
}

.clsStatLabel {
    color: #6c757d;
    font-size: 14px;
    margin-top: 8px;
}

/* ------------------------------------------------------------------
   セレクターパネル
   ------------------------------------------------------------------ */

.clsSelectorPanel {
    background: #f8f9fa;
    padding: 20px 24px;
    border-radius: 10px;
    margin-bottom: 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.clsSelectorRow {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    align-items: end;
}

.clsSelectorGroup {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.clsSelectorInline {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.clsSelectorValue {
    font-weight: 600;
    color: #495057;
}

.clsSelectorInline--right {
    justify-content: flex-end;
}

.clsSelectorPanelForm {
    display: contents;
}

/* ------------------------------------------------------------------
   定義リスト
   ------------------------------------------------------------------ */

.clsDefinitionList {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.clsDefinitionItem {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.clsDefinitionItem dt {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.clsDefinitionItem dd {
    font-size: 16px;
    color: #212529;
    margin: 0;
    min-height: 19px;
}

/* ------------------------------------------------------------------
   履歴項目
   ------------------------------------------------------------------ */

.clsHistoryItem {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.clsHistoryHeader {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
    gap: 8px;
}

.clsHistoryTitle {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.clsHistoryMeta {
    font-size: 14px;
    color: #6c757d;
}

.clsHistoryList {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.clsHistoryList dt {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.clsHistoryList dd {
    margin-top: 4px;
    font-size: 15px;
}

/* ------------------------------------------------------------------
   ツールバー
   ------------------------------------------------------------------ */

.clsToolbar {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

.clsToolbar--listHeader {
    justify-content: flex-end;
}

.clsToolbar--listHeader .clsBtn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.clsToolbar--listHeader .clsBtnSuccess {
    background: #28a745;
    border-color: #28a745;
    color: #fff;
    box-shadow: 0 2px 10px rgba(40, 167, 69, 0.25);
}

.clsToolbar--listHeader .clsBtnSuccess:hover,
.clsToolbar--listHeader .clsBtnSuccess:focus-visible {
    background: #218838;
    border-color: #1e7e34;
}

.clsToolbar--listHeader .clsBtnSuccess:focus-visible {
    outline: 2px solid rgba(33, 136, 56, 0.35);
    outline-offset: 2px;
}

/* ------------------------------------------------------------------
   ページング
   ------------------------------------------------------------------ */

.clsPagination {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
    padding: 12px 12px;
}

.clsPaginationList {
    display: flex;
    gap: 8px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.clsPaginationItem {
    display: inline-block;
}

.clsPaginationItem a {
    display: block;
    padding: 4px 10px;
    min-width: 32px;
    border: 1px solid #dee2e6;
    background: #fff;
    color: #007bff;
    text-align: center;
    text-decoration: none;
    font-size: 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.clsPaginationItem a:hover:not(.clsDisabled) {
    background: #e9ecef;
    border-color: #adb5bd;
}

.clsPaginationItem.clsActive a {
    background: #007bff;
    color: #fff;
    border-color: #007bff;
    cursor: default;
}

.clsPaginationItem.clsDisabled a {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.clsPageBtn {
    display: inline-block;
    padding: 4px 10px;
    min-width: 32px;
    border: 1px solid #dee2e6;
    background: #fff;
    color: #007bff;
    text-align: center;
    font-size: 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.clsPageBtn:hover:not(:disabled) {
    background: #e9ecef;
    border-color: #adb5bd;
}

.clsPageBtn.clsActive {
    background: #007bff;
    color: #fff;
    border-color: #007bff;
    cursor: default;
}

.clsPageBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ------------------------------------------------------------------
   症例詳細カード
   ------------------------------------------------------------------ */

.clsCaseViewCard {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 16px;
}

.clsCaseViewHeader {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: #fff;
    padding: 16px 20px;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.clsCaseViewHeaderTitle {
    font-weight: 600;
    font-size: 18px;
}

.clsCaseViewHeaderSub {
    font-size: 14px;
    opacity: 0.9;
}

.clsCaseViewBody {
    padding: 16px 20px;
}

.clsCaseViewSection {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e9ecef;
}

.clsCaseViewSection:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.clsCaseViewSectionTitle {
    color: #007bff;
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 12px 0;
    display: flex;
    align-items: center;
}

.clsCaseViewSectionTitle::before {
    content: attr(data-icon);
    margin-right: 8px;
    font-size: 19px;
}

.clsCaseViewGrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.clsCaseViewLabel {
    color: #007bff;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.clsCaseViewValue {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    padding: 8px 12px;
    border-radius: 6px;
}

.clsCaseViewBadge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.clsCaseViewBadge--als {
    background: #d1ecf1;
    color: #0c5460;
}

.clsCaseViewHistory .clsCaseViewBody {
    padding-top: 0;
}

.clsCaseViewActions {
    display: flex;
    gap: 8px;
}

/* ------------------------------------------------------------------
   医師情報カード（共通化）
   ------------------------------------------------------------------ */

.clsDoctorInfoCard {
    background: #fff;
    border-radius: 10px;
    border-left: 4px solid #007bff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.clsDoctorInfoHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.clsDoctorInfoLeft {
    display: flex;
    gap: 4px 16px;
    flex-wrap: wrap;
    white-space: nowrap;
}

.clsDoctorInfoRight {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 0;
}

.clsDoctorInfoRight .clsBtn {
    padding: 10px 19px;
    font-size: 15px;
    font-weight: 500;
    line-height: normal;
    min-width: auto;
    white-space: nowrap;
}

.clsDoctorInfoRight .clsBtnOutline {
    border: 2px solid #007bff;
    border-radius: 5px;
}

.clsDoctorName {
    font-size: 18px;
    font-weight: 600;
    color: #007bff;
}

.clsDoctorFacility {
    background: #e9ecef;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 14px;
    color: #495057;
}

/* ------------------------------------------------------------------
   入力セクション
   ------------------------------------------------------------------ */

.clsInputSection {
    background: #fff;
    border-radius: 10px;
    padding: 20px 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
}

.clsSectionHeader {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: #fff;
    padding: 14px 20px;
    margin: -20px -24px 16px -24px;
    border-radius: 10px 10px 0 0;
    font-size: 19px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.clsSectionTitle {
    color: #007bff;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
}

.clsSectionTotal {
    font-size: 16px;
    font-weight: 700;
    opacity: 0.95;
}

.clsInputGrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.clsInputGroup {
    position: relative;
}

.clsInputGroup .clsFormLabel {
    font-size: 14px;
    color: #555;
    margin-bottom: 4px;
}

/* ------------------------------------------------------------------
   サマリーカード
   ------------------------------------------------------------------ */

.clsSummaryCard {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: #fff;
    padding: 10px 12px;
    border-radius: 10px;
    text-align: center;
    margin: 12px 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.clsSummaryTotal {
    font-size: 22px;
    font-weight: 700;
    display: block;
}

.clsSummaryLabel {
    font-size: 14px;
    opacity: 0.9;
}

/* ------------------------------------------------------------------
   アクションパネル・ボタン
   ------------------------------------------------------------------ */

.clsActionPanel {
    padding: 8px 0;
    display: flex;
    justify-content: center;
    gap: 16px;
}

.clsActionPanel .clsBtn {
    margin: 0;
}

.clsActionRow {
    display: flex;
    gap: 8px;
}

/* ------------------------------------------------------------------
   データステータス
   ------------------------------------------------------------------ */

.clsDataStatus {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
}

.clsDataStatus.clsStatusLoading,
.clsStatusLoading {
    background: #d1ecf1;
    color: #0c5460;
}

.clsDataStatus.clsStatusExists,
.clsStatusExists {
    background: #d4edda;
    color: #155724;
}

.clsDataStatus.clsStatusNew,
.clsStatusNew {
    background: #fff3cd;
    color: #856404;
}

/* ------------------------------------------------------------------
   トースト通知
   ------------------------------------------------------------------ */

.clsToast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: 8px;
    color: #fff;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 1100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    white-space: pre-line;
}

.clsToastVisible {
    opacity: 1;
    transform: translateY(0);
}

.clsToastSuccess {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.clsToastError {
    background: linear-gradient(135deg, #dc3545 0%, #bd2130 100%);
}

.clsToastWarn {
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
    color: #212529;
}

.clsToastInfo {
    background: linear-gradient(135deg, #17a2b8 0%, #0d6efd 100%);
}

/* ------------------------------------------------------------------
   空カード
   ------------------------------------------------------------------ */

.clsCardEmpty {
    text-align: center;
    padding: 32px;
    color: #6c757d;
}

/* ------------------------------------------------------------------
   患者フォーム・ヘッダー
   ------------------------------------------------------------------ */

.clsPatientForm {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
}

.clsPatientHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: #fff;
    padding: 12px 16px;
    margin: -20px -20px 20px -20px;
    border-radius: 10px 10px 0 0;
    font-size: 15px;
}

.clsBaseInfo {
    /* 追加のスタイルが必要な場合 */
}

/* ------------------------------------------------------------------
   検索パネル
   ------------------------------------------------------------------ */

.clsSearchPanel {
    background: #f8f9fa;
    padding: 24px;
    border-radius: 10px;
    margin-bottom: 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.clsSearchPanelForm {
    display: contents;
}

.clsSearchPanelRow {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.clsSearchPanelField {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.clsSearchPanelInline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.clsSearchPanelDisplay {
    font-weight: 600;
    color: #495057;
}

.clsSearchPanelActions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    align-items: center;
    margin-top: 16px;
}

.clsFormCheck {
    display: flex;
    align-items: center;
    gap: 8px;
}

.clsSeparator {
    color: #6c757d;
}

/* ------------------------------------------------------------------
   モーダル（追加）
   ------------------------------------------------------------------ */

.clsModal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    /* iOS Safari対策: タッチスクロール無効化 */
    -webkit-overflow-scrolling: auto;
    overflow: hidden;
}

/* ------------------------------------------------------------------
   ローディング・スピナー
   ------------------------------------------------------------------ */

/* グローバルローディングオーバーレイ */
.clsLoadingOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    /* iOS Safari対策: タッチスクロール無効化 */
    -webkit-overflow-scrolling: auto;
    overflow: hidden;
}

.clsLoadingOverlay.clsVisible {
    opacity: 1;
    visibility: visible;
}

/* スピナーコンテナ */
.clsLoadingSpinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* スピナーアニメーション（円形） */
.clsSpinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: clsSpinnerRotate 0.8s linear infinite;
}

@keyframes clsSpinnerRotate {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* スピナー（小サイズ・インライン用） */
.clsSpinnerSmall {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: clsSpinnerRotate 0.8s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

/* ローディングメッセージ */
.clsLoadingMessage {
    color: #fff;
    font-size: 16px;
    font-weight: 500;
    text-align: center;
}

/* ボタンローディング状態 */
.clsBtn.clsLoading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
    cursor: not-allowed;
}

.clsBtn.clsLoading::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 50%;
    margin-top: -10px; /* スピナーの高さ（16px + border 4px）の半分 */
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: clsSpinnerRotate 0.8s linear infinite;
}

.clsBtn.clsLoading.clsBtnOutline::before {
    border-color: rgba(0, 123, 255, 0.3);
    border-top-color: #007bff;
}

/* ボタンローディング中のテキストを右に寄せる */
.clsBtn.clsLoading {
    padding-left: 40px;
}

/* インラインスピナー（テキスト内） */
.clsSpinnerInline {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0, 123, 255, 0.3);
    border-top-color: #007bff;
    border-radius: 50%;
    animation: clsSpinnerRotate 0.8s linear infinite;
    vertical-align: middle;
    margin: 0 4px;
}

/* ------------------------------------------------------------------
   レスポンシブ対応
   ------------------------------------------------------------------ */

/* タブレット対応（iPad等） */
@media (min-width: 769px) and (max-width: 1024px) {
    /* フォーム行のグリッドを調整 */
    .clsFormRow {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    .clsSelectorRow {
        grid-template-columns: 1fr;
    }

    .clsSelectorGroup {
        align-items: stretch;
    }

    .clsToast {
        bottom: 16px;
        left: 50%;
        right: auto;
        transform: translate(-50%, 10px);
        max-width: calc(100% - 32px);
    }

    .clsToastVisible {
        transform: translate(-50%, 0);
    }

    .clsInputSection {
        padding: 16px;
    }

    .clsSectionHeader {
        margin: -16px -16px 16px -16px;
        padding: 12px 16px;
        font-size: 18px;
    }

    .clsInputGrid {
        grid-template-columns: 1fr;
    }

    .clsActionPanel {
        flex-direction: column;
        gap: 8px;
    }
}

/* Navigation and button rows wrap on mobile */
.clsNavMenu,
.clsToolbar,
.clsButtonRow,
.nav-menu,
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
