/* ==========================================================================
   master.css — マスタ一覧・編集画面 共通スタイル
   hospital_list / hospital_edit / org_list / org_edit で共有
   ========================================================================== */

/* ===== ベース ===== */
*, *::before, *::after { box-sizing: border-box; }

/* ===== ページヘッダー ===== */
.page-header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 16px 24px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.page-header-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.page-header-icon i { color: #fff; font-size: 1rem; }
.page-header-title { font-size: 1.1rem; font-weight: 700; color: #0f172a; margin: 0; }
.page-header-sub   { font-size: 0.75rem; color: #94a3b8; margin: 2px 0 0; }
.page-header-back {
  margin-left: auto;
  display: flex; align-items: center; gap: 6px;
  color: #15803d; font-size: 0.8rem; font-weight: 600; text-decoration: none;
  padding: 8px 16px; background: #fff; border: 2px solid #16a34a; border-radius: 8px;
  transition: all 0.2s; white-space: nowrap;
}
.page-header-back:hover { background: #16a34a; color: #fff; transform: translateY(-1px); box-shadow: 0 4px 10px rgba(22,163,74,0.2); }

/* ===== ページャー ===== */
.pager-nav { display: flex; justify-content: center; padding: 16px 0 8px; }
.pager-list { display: flex; list-style: none; gap: 4px; margin: 0; padding: 0; }
.pager-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px; padding: 0 10px;
  border: 1.5px solid #e2e8f0; border-radius: 8px;
  font-size: 0.82rem; color: #334155; background: #fff;
  text-decoration: none; transition: all 0.15s;
}
.pager-btn:hover { background: #f1f5f9; border-color: #3b82f6; color: #1e3a8a; }
.pager-current { background: #2563eb; color: #fff; border-color: #2563eb; font-weight: 700; }
.pager-current:hover { background: #2563eb; color: #fff; }
.pager-dots { display: inline-flex; align-items: center; min-width: 24px; justify-content: center; color: #94a3b8; font-size: 0.8rem; }

/* ===== コンテンツラップ ===== */
.content-wrap { padding: 12px 24px; margin: 0; }
.content-wrap-narrow { padding: 12px 24px; margin: 0; }

/* ===== 検索カード（一覧画面） ===== */
.search-card { background: #fff; border-radius: 14px; box-shadow: 0 1px 4px rgba(0,0,0,0.07); margin-bottom: 20px; overflow: hidden; }
.search-card-header { background: linear-gradient(90deg, #1e3a8a 0%, #2563eb 100%); color: #fff; padding: 10px 20px; display: flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 600; }
.search-card-body { padding: 18px 20px; }
.search-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.search-field label { display: block; font-size: 0.75rem; font-weight: 600; color: #475569; margin-bottom: 4px; letter-spacing: 0.3px; }
.search-field input, .search-field select { width: 100%; padding: 8px 12px; border: 1.5px solid #e2e8f0; border-radius: 8px; font-size: 0.875rem; font-family: inherit; color: #0f172a; background: #f8fafc; transition: border-color 0.2s, box-shadow 0.2s; outline: none; }
.search-field input:focus, .search-field select:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.12); background: #fff; }
.search-field select[disabled] { background: #f1f5f9; color: #64748b; cursor: default; }
.search-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* ===== 結果カード（一覧画面） ===== */
.result-card { background: #fff; border-radius: 14px; box-shadow: 0 1px 4px rgba(0,0,0,0.07); overflow: hidden; }
.result-card-header { padding: 12px 20px; border-bottom: 1px solid #f1f5f9; display: flex; align-items: center; gap: 8px; }
.result-card-header-title { font-size: 0.85rem; font-weight: 600; color: #374151; }
#result_count { font-size: 0.75rem; color: #94a3b8; }
.table-wrap { overflow-x: auto; }

/* ===== 一覧テーブル共通 ===== */
.master-table { width: 100%; border-collapse: collapse; font-size: 0.845rem; }
.master-table thead th { background: #1e293b; color: #e2e8f0; font-weight: 600; font-size: 0.78rem; letter-spacing: 0.4px; padding: 10px 14px; white-space: nowrap; text-align: left; border: none; }
.master-table tbody tr { border-bottom: 1px solid #f1f5f9; transition: background 0.15s; }
.master-table tbody tr:hover { background: #f8fafc; }
.master-table tbody td { padding: 10px 14px; color: #1e293b; vertical-align: middle; }

/* セル共通 */
.td-code { font-family: monospace; font-size: 0.82rem; color: #64748b; white-space: nowrap; }
.td-name a { color: #2563eb; text-decoration: none; font-weight: 500; }
.td-name a:hover { text-decoration: underline; }
.td-name2 { font-size: 0.78rem; color: #94a3b8; margin-top: 2px; }
.td-sub { font-size: 0.8rem; color: #64748b; white-space: nowrap; }
.td-memo { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #64748b; font-size: 0.8rem; }
.td-btn { white-space: nowrap; text-align: center; }

/* ===== 編集カード（編集画面） ===== */
.edit-card { background: #fff; border-radius: 14px; box-shadow: 0 1px 4px rgba(0,0,0,0.07); overflow: hidden; }
.edit-card-header { background: linear-gradient(90deg, #1e3a8a 0%, #2563eb 100%); color: #fff; padding: 10px 20px; display: flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 600; }
.edit-card-body { padding: 24px 20px; }
.section-divider { font-size: 0.8rem; font-weight: 700; color: #1e3a8a; border-bottom: 2px solid #dbeafe; padding: 16px 0 6px; margin: 16px 0 8px; }
.section-divider:first-child { margin-top: 0; padding-top: 0; }

/* フィールド行 */
.field-row { display: grid; grid-template-columns: 10em 1fr; gap: 8px 16px; align-items: center; padding: 10px 0; border-bottom: 1px solid #f1f5f9; }
.field-row:last-child { border-bottom: none; }
.field-label { font-size: 0.8rem; font-weight: 600; color: #475569; display: flex; align-items: center; gap: 4px; }
.field-label .required { color: #ef4444; font-size: 0.75rem; }
.field-input input, .field-input textarea, .field-input select,
.master-table input[type="text"] { width: 100%; padding: 7px 10px; border: 1.5px solid #e2e8f0; border-radius: 8px; font-size: 0.875rem; font-family: inherit; color: #0f172a; background: #f8fafc; transition: border-color 0.2s, box-shadow 0.2s; outline: none; }
.field-input input:focus, .field-input textarea:focus, .field-input select:focus,
.master-table input[type="text"]:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.12); background: #fff; }
.field-input input[readonly], .field-input textarea[readonly], .field-input select[disabled] { background: #f1f5f9; color: #64748b; cursor: default; }
.field-input input.w-short, .field-input select.w-short { max-width: 8em; }
.field-input input.w-mid,   .field-input select.w-mid   { max-width: 14em; }
.field-input input.w-long,  .field-input select.w-long   { max-width: 28em; }

/* ===== 編集画面マルチカラムグリッド ===== */
/* ラベル上・入力下の縦配置（共通） */
.edit-grid-2col .field-row,
.edit-grid-3col .field-row {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 3px; padding: 6px 0; border-bottom: none;
}
.edit-grid-2col .field-label,
.edit-grid-3col .field-label { font-size: 0.75rem; color: #64748b; text-align: left; }
.edit-grid-2col .field-input,
.edit-grid-3col .field-input { width: 100%; }
.edit-grid-2col .field-input input,
.edit-grid-2col .field-input select,
.edit-grid-2col .field-input textarea,
.edit-grid-3col .field-input input,
.edit-grid-3col .field-input select,
.edit-grid-3col .field-input textarea { max-width: 100%; width: 100%; }
.edit-grid-2col .field-input input.w-short,
.edit-grid-2col .field-input select.w-short,
.edit-grid-3col .field-input input.w-short,
.edit-grid-3col .field-input select.w-short { max-width: 10em; }

/* 2カラムグリッド */
@media (min-width: 768px) {
  .edit-grid-2col {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; padding-left: 12px; padding-right: 12px;
  }
  .edit-grid-2col .section-divider,
  .edit-grid-2col .field-row-wide,
  .edit-grid-2col .action-bar { grid-column: 1 / -1; }
  .edit-grid-2col .section-divider { margin-top: 18px; }
  .edit-grid-2col .section-divider:first-child { margin-top: 0; }
}

/* 3カラムグリッド */
@media (min-width: 1000px) {
  .edit-grid-3col {
    display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 24px; padding-left: 12px; padding-right: 12px;
  }
  .edit-grid-3col .section-divider,
  .edit-grid-3col .field-row-wide,
  .edit-grid-3col .action-bar { grid-column: 1 / -1; }
  .edit-grid-3col .field-row-2col { grid-column: span 2; }
  .edit-grid-3col .section-divider { margin-top: 18px; }
  .edit-grid-3col .section-divider:first-child { margin-top: 0; }
}

/* ===== 共通ボタン ===== */
.btn-search { display: inline-flex; align-items: center; gap: 6px; padding: 8px 20px; background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%); color: #fff; font-size: 0.875rem; font-weight: 600; border: none; border-radius: 8px; cursor: pointer; box-shadow: 0 2px 8px rgba(37,99,235,0.25); transition: all 0.2s; }
.btn-search:hover { background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%); box-shadow: 0 4px 12px rgba(37,99,235,0.35); transform: translateY(-1px); }
.btn-search:disabled { opacity: 0.65; cursor: not-allowed; transform: none; }
.btn-clear { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; background: #fff; color: #64748b; font-size: 0.875rem; border: 1.5px solid #e2e8f0; border-radius: 8px; cursor: pointer; transition: all 0.2s; }
.btn-clear:hover { background: #f1f5f9; border-color: #cbd5e1; color: #1e293b; }
.btn-new { display: inline-flex; align-items: center; gap: 5px; padding: 5px 14px; font-size: 0.8rem; font-weight: 600; color: #fff; background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%); border: none; border-radius: 7px; text-decoration: none; transition: all 0.15s; box-shadow: 0 2px 6px rgba(37,99,235,0.25); }
.btn-new:hover { background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%); color: #fff; transform: translateY(-1px); }
/* 住所コピーボタン（請求先セクション） */
.btn-copy-addr { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; font-size: 0.72rem; font-weight: 600; color: #0369a1; background: #f0f9ff; border: 1.5px solid #7dd3fc; border-radius: 6px; cursor: pointer; transition: all 0.15s; }
.btn-copy-addr:hover { background: #e0f2fe; border-color: #38bdf8; }

.btn-staff-add { display: inline-flex; align-items: center; gap: 5px; padding: 6px 14px; font-size: 0.8rem; font-weight: 600; color: #6d28d9; background: #fff; border: 1.5px solid #8b5cf6; border-radius: 7px; cursor: pointer; transition: all 0.15s; }
.btn-staff-add:hover { background: #8b5cf6; color: #fff; transform: translateY(-1px); }
.btn-detail { display: inline-block; padding: 4px 10px; font-size: 0.78rem; font-weight: 600; color: #2563eb; border: 1.5px solid #2563eb; border-radius: 6px; text-decoration: none; transition: all 0.15s; }
.btn-detail:hover { background: #2563eb; color: #fff; }
.btn-save { display: inline-flex; align-items: center; gap: 6px; padding: 8px 20px; background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%); color: #fff; font-size: 0.875rem; font-weight: 600; border: none; border-radius: 8px; cursor: pointer; box-shadow: 0 2px 8px rgba(37,99,235,0.25); transition: all 0.2s; }
.btn-save:hover { background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%); transform: translateY(-1px); }
.btn-back { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; background: #fff; color: #64748b; font-size: 0.875rem; border: 1.5px solid #e2e8f0; border-radius: 8px; cursor: pointer; transition: all 0.2s; }
.btn-back:hover { background: #f1f5f9; border-color: #cbd5e1; color: #1e293b; }
.btn-delete { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; background: #fff; color: #dc2626; font-size: 0.875rem; border: 1.5px solid #fca5a5; border-radius: 8px; cursor: pointer; transition: all 0.2s; }
.btn-delete:hover { background: #fef2f2; border-color: #dc2626; }
.btn-zip { display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; font-size: 0.78rem; font-weight: 600; color: #0369a1; background: #f0f9ff; border: 1.5px solid #7dd3fc; border-radius: 7px; cursor: pointer; transition: all 0.15s; white-space: nowrap; }
.btn-zip:hover { background: #e0f2fe; border-color: #38bdf8; }
.btn-zip:disabled { opacity: 0.55; cursor: not-allowed; }

/* アクションバー（編集画面） */
.action-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.action-left { display: flex; gap: 8px; }

/* メッセージ */
#msgarea .alert { border-radius: 10px; font-size: 0.875rem; margin-bottom: 16px; }

/* ローディング */
.loading-row td { text-align: center; padding: 40px; color: #94a3b8; font-size: 0.875rem; }
.spinner-sm { display: inline-block; width: 16px; height: 16px; border: 2px solid #e2e8f0; border-top-color: #2563eb; border-radius: 50%; animation: spin 0.7s linear infinite; margin-right: 6px; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== レスポンシブ ===== */
/* ===== パスワード表示トグルボタン ===== */
.btn-pw-toggle { background: none; border: 1.5px solid #e2e8f0; border-radius: 6px; padding: 5px 8px; cursor: pointer; color: #94a3b8; transition: all 0.15s; line-height: 1; }
.btn-pw-toggle:hover { color: #475569; border-color: #cbd5e1; background: #f8fafc; }

/* ===== パスワード強度インジケーター ===== */
.pw-bar { flex: 1; height: 4px; border-radius: 2px; background: #e2e8f0; transition: background 0.3s; }
.pw-bar.pw-weak   { background: #ef4444; }
.pw-bar.pw-fair   { background: #f59e0b; }
.pw-bar.pw-good   { background: #3b82f6; }
.pw-bar.pw-strong { background: #22c55e; }

/* ===== メニューカード（master_menu / user_menu 共通）===== */
.menu-page { padding-top: 2rem; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.menu-card { background: #fff; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); border: 1px solid #e2e8f0; transition: all 0.3s ease; display: flex; align-items: center; padding: 1.25rem; text-decoration: none; color: #334155; position: relative; overflow: hidden; }
.menu-card::before { content: ""; position: absolute; top: 0; left: 0; width: 4px; height: 100%; transition: width 0.3s ease; }
.menu-card:hover::before { width: 6px; }
.menu-card:hover { transform: translateY(-3px); }
.menu-card-icon { width: 48px; height: 48px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-right: 1rem; flex-shrink: 0; font-size: 1.5rem; transition: all 0.3s ease; }
.menu-card:hover .menu-card-icon { color: #fff; }
.menu-card-content { flex-grow: 1; display: flex; flex-direction: column; }
.menu-card-title { font-weight: 700; font-size: 0.95rem; margin: 0; line-height: 1.4; }
.menu-card-sub { font-size: 0.75rem; color: #64748b; margin-top: 0.25rem; }

/* メニューカード: 紫テーマ（マスタ管理）*/
.menu-card-purple::before { background: #8b5cf6; }
.menu-card-purple:hover { box-shadow: 0 8px 25px rgba(139,92,246,0.15); border-color: #a78bfa; color: #4c1d95; }
.menu-card-purple .menu-card-icon { background: #ede9fe; color: #7c3aed; }
.menu-card-purple:hover .menu-card-icon { background: #8b5cf6; }

/* メニューカード: 青テーマ（ユーザー管理）*/
.menu-card-blue::before { background: #0ea5e9; }
.menu-card-blue:hover { box-shadow: 0 8px 25px rgba(14,165,233,0.15); border-color: #38bdf8; color: #0c4a6e; }
.menu-card-blue .menu-card-icon { background: #e0f2fe; color: #0284c7; }
.menu-card-blue:hover .menu-card-icon { background: #0ea5e9; }

/* メニューページヘッダー */
.menu-header { display: flex; align-items: center; gap: 12px; margin-bottom: 1.5rem; }
.menu-header-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.menu-header h1 { font-size: 1.3rem; font-weight: 700; color: #0f172a; margin: 0; }
.menu-header p { font-size: 0.78rem; color: #94a3b8; margin: 2px 0 0; }
.menu-header-back { margin-left: auto; display: flex; align-items: center; gap: 6px; color: #15803d; font-size: 0.8rem; font-weight: 600; text-decoration: none; padding: 8px 16px; background: #fff; border: 2px solid #16a34a; border-radius: 8px; transition: all 0.2s; }
.menu-header-back:hover { background: #16a34a; color: #fff; transform: translateY(-1px); box-shadow: 0 4px 10px rgba(22,163,74,0.2); }

@media (max-width: 768px) { .content-wrap { padding: 16px; } .search-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .content-wrap-narrow { padding: 16px; } .field-row { grid-template-columns: 1fr; } }
@media (max-width: 480px) { .content-wrap { padding: 12px; } .search-grid { grid-template-columns: 1fr; } .page-header { padding: 12px 16px; } }
