/* ============================================================
   スマートフォン対応 responsive.css
   ブレークポイント: max-width 640px
   ============================================================ */

@media (max-width: 640px) {

  /* ---- mypage: サイドバー + メインを縦並び ---- */
  .mypage-container {
    flex-direction: column;
    padding: 12px;
    gap: 12px;
  }
  .mypage-sidebar {
    width: 100%;
  }

  /* ---- mypage: form-group 入力欄 100% ---- */
  .form-group input,
  .form-group textarea,
  .form-group select {
    width: 100%;
    box-sizing: border-box;
  }

  /* ---- siteadmin/attendance-status: 不要列を非表示 ---- */
  /* 取得単位(3), 添付書類(4), 根拠規定(5), 表示順(6) */
  #attendance-status-table th:nth-child(3),
  #attendance-status-table td:nth-child(3),
  #attendance-status-table th:nth-child(4),
  #attendance-status-table td:nth-child(4),
  #attendance-status-table th:nth-child(5),
  #attendance-status-table td:nth-child(5),
  #attendance-status-table th:nth-child(6),
  #attendance-status-table td:nth-child(6) {
    display: none;
  }

  /* ---- siteadmin/org-calendar: フォームグリッドを縦並び ---- */
  #org-cal-form-grid {
    grid-template-columns: 1fr !important;
  }

  /* ---- siteadmin/org-calendar: 曜日(2), 登録日時(5) を非表示 ---- */
  #org-calendar-table th:nth-child(2),
  #org-calendar-table td:nth-child(2),
  #org-calendar-table th:nth-child(5),
  #org-calendar-table td:nth-child(5) {
    display: none;
  }

  /* ---- siteadmin/leave-grants: 有効開始日(4), 有効終了日(5) を非表示 ---- */
  .leave-grant-table th:nth-child(4),
  .leave-grant-table td:nth-child(4),
  .leave-grant-table th:nth-child(5),
  .leave-grant-table td:nth-child(5) {
    display: none;
  }

  /* ---- siteadmin/leave-types: 種類コード/種類(1), 期間(3), 出勤簿記載(4) を非表示 ---- */
  #leave-type-table th:nth-child(1),
  #leave-type-table td:nth-child(1),
  #leave-type-table th:nth-child(3),
  #leave-type-table td:nth-child(3),
  #leave-type-table th:nth-child(4),
  #leave-type-table td:nth-child(4) {
    display: none;
  }

  /* ---- siteadmin/work-schedule: sa-form-grid を縦並び ---- */
  .sa-form-grid {
    grid-template-columns: 1fr !important;
  }

  /* ---- siteadmin/approval-settings: 承認者名を折り返し ---- */
  #approver-tbody td select,
  #approver-tbody td {
    white-space: normal;
    word-break: break-all;
  }

  /* ---- siteadmin/travel-expense: 入力欄 100% ---- */
  .sa-field input,
  .sa-field select,
  .sa-field textarea {
    width: 100%;
    box-sizing: border-box;
  }

  /* ---- triprequest/apply: 日付入力が横並びのものを縦並びに ---- */
  .trip-row {
    flex-direction: column;
    gap: 0;
  }
  .trip-row .trip-field {
    width: 100%;
  }
  /* 旅行命令年月日など date 入力を 100% に */
  .trip-field input[type="date"],
  .trip-field input[type="text"] {
    width: 100%;
    box-sizing: border-box;
  }

  /* ---- information/article_list: カード形式 (スマホ) ---- */
  .article-list-wrapper {
    border: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
  }
  .article-list-table thead { display: none; }
  .article-list-table,
  .article-list-table tbody { display: block; }
  .article-list-table tr.article-row {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 8px;
    padding: 8px 12px;
    cursor: pointer;
  }
  .article-list-table tr.article-row td {
    display: block !important;
    border: none !important;
    padding: 0 !important;
    text-align: left !important;
    white-space: normal !important;
  }
  .article-list-table tr.article-row td:nth-child(1) { flex: 0 0 auto; }
  .article-list-table tr.article-row td:nth-child(2) { flex: 1 1 0; min-width: 0; font-size: 14px; }
  .article-list-table tr.article-row td:nth-child(3),
  .article-list-table tr.article-row td:nth-child(4),
  .article-list-table tr.article-row td:nth-child(5),
  .article-list-table tr.article-row td:nth-child(6) {
    flex: 0 0 auto; font-size: 11px; color: #6b7280;
  }
  .article-list-table tr.article-row td:last-child {
    flex: 0 0 100%; text-align: right !important; margin-top: 2px;
  }
  .article-list-table tr:not(.article-row) {
    display: flex !important; justify-content: center; padding: 20px;
  }
  .article-list-table tr:not(.article-row) td {
    display: block !important; border: none !important;
  }

  /* ---- information/article_detail: ヘッダーを縦並び ---- */
  /* 1行目: 戻るリンク + 操作ボタン、2行目: タイトル */
  .article-detail-header {
    flex-wrap: wrap;
    gap: 8px;
  }
  /* タイトルを2行目へ（全幅で折り返し） */
  .article-title-wrap {
    order: 2;
    width: 100% !important;
    flex: none !important;
    min-width: 0;
  }
  .article-back {
    order: 1;
  }
  .article-actions {
    order: 1;
    margin-left: auto;
  }

  /* ---- information/article_detail: メタ情報を縦並び ---- */
  .article-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

}
