/* Lumina管理システム 共通スタイル */

/* フォーム要素 */
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.5rem;
}
.form-label.required::after {
  content: ' *';
  color: #ef4444;
}
.form-input {
  width: 100%;
  border: 1.5px solid #d1d5db;
  border-radius: 0.5rem;
  padding: 0.625rem 0.875rem;
  font-size: 0.938rem;
  color: #1f2937;
  background: white;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
.form-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.form-group {
  background: white;
  border-radius: 0.75rem;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid #f3f4f6;
}

/* ボタン選択UI */
.select-btn {
  padding: 0.625rem 0.25rem;
  font-size: 0.8rem;
  border-radius: 0.5rem;
  border: 2px solid #e5e7eb;
  color: #6b7280;
  background: white;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  font-weight: 500;
}
.select-btn:hover {
  border-color: #93c5fd;
  color: #3b82f6;
  background: #eff6ff;
}
.select-btn.active {
  border-color: #3b82f6;
  background: #3b82f6;
  color: white;
}

/* タブ */
.tab-btn.active {
  color: white;
  border-bottom: 3px solid white;
}
.admin-tab-btn.active {
  background: rgba(255,255,255,0.15);
  color: white;
}

/* カード */
.record-card {
  background: white;
  border-radius: 0.75rem;
  padding: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  border: 1px solid #f3f4f6;
  cursor: pointer;
  transition: box-shadow 0.2s;
}
.record-card:active {
  box-shadow: 0 0 0 2px #93c5fd;
}

/* 回収バッジ */
.badge-completed  { background: #d1fae5; color: #065f46; }
.badge-partial    { background: #fef3c7; color: #92400e; }
.badge-none       { background: #fee2e2; color: #991b1b; }
.badge-insurance  { background: #dbeafe; color: #1e40af; }

/* 旧互換 */
.badge-collected  { background: #d1fae5; color: #065f46; }
.badge-processing { background: #fef3c7; color: #92400e; }
.badge-pending    { background: #f3f4f6; color: #6b7280; }

/* 回収方法ピル */
.method-cash        { background: #d1fae5; color: #065f46; }
.method-card        { background: #ede9fe; color: #5b21b6; }
.method-card_hq     { background: #ede9fe; color: #5b21b6; }
.method-card_worker { background: #e0f2fe; color: #0369a1; }
.method-transfer    { background: #dbeafe; color: #1e40af; }
.method-barcode     { background: #fce7f3; color: #9d174d; }
.method-insurance   { background: #fef3c7; color: #92400e; }

/* 回収方法ボタン（入力UI） */
.payment-method-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0.5rem 0.25rem;
  font-size: 0.75rem;
  border-radius: 0.5rem;
  border: 2px solid #d1d5db;
  background: white;
  color: #4b5563;
  cursor: pointer;
  transition: all 0.15s;
}
.payment-method-btn:hover {
  border-color: #6366f1;
  color: #4338ca;
}
.payment-method-btn.active {
  border-color: #4f46e5;
  background: #4f46e5;
  color: white;
}
.payment-method-btn i { font-size: 1.1rem; }

/* ===== dialog 要素（HTMLネイティブモーダル）===== */

/* 共通 backdrop スタイル */
dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

/* 詳細モーダル用（モバイルフルスクリーン風） */
#detail-modal,
#work-form-modal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
#detail-modal[open],
#work-form-modal[open] {
  opacity: 1;
  transform: translateY(0);
}

/* 汎用モーダル用 */
#admin-modal {
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
#admin-modal[open] {
  opacity: 1;
  transform: scale(1);
}

/* ポップアップメニュー用 */
#user-menu-popup,
#admin-menu-popup {
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
#user-menu-popup[open],
#admin-menu-popup[open] {
  opacity: 1;
  transform: translateY(0);
}

/* ローディングスピナー */
.spinner {
  border: 3px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  width: 2rem;
  height: 2rem;
  animation: spin 0.6s linear infinite;
  margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* トースト */
#toast, #admin-toast {
  transition: opacity 0.3s;
  z-index: 2147483647 !important;
}

#toast > div,
#admin-toast > div {
  position: relative;
  z-index: 2147483647;
}

/* 写真プレビュー */
.photo-thumb {
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 0.5rem;
  border: 2px solid #e5e7eb;
}
.photo-wrapper {
  position: relative;
}
.photo-delete-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #ef4444;
  color: white;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
}

/* テーブル */
table tbody tr:hover {
  background: #f8fafc;
}

/* ===== 数値入力のマウスホイール・カーソルキー調整を禁止 ===== */
/* スピナー非表示 */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* レスポンシブ */
@media (max-width: 640px) {
  .form-input { font-size: 16px; } /* iOS zoom防止 */
  /* スマホ時のヘッダーの padding を抑える */
  header .admin-wide { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
  main.admin-wide { padding-left: 0.75rem !important; padding-right: 0.75rem !important; padding-top: 1rem !important; }
  /* タブを少しコンパクトに */
  .admin-tab-btn {
    padding-left: 0.85rem !important;
    padding-right: 0.85rem !important;
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
    font-size: 0.85rem !important;
  }
  /* iOSのdate入力で高さを確実に確保 */
  input[type="date"], input[type="text"], input[type="number"], select {
    font-size: 16px;
  }
}

/* 清算タブ：期間プリセットボタン */
.preset-btn {
  padding: 0.375rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 0.375rem;
  border: 1.5px solid #d1d5db;
  color: #4b5563;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  line-height: 1.25;
}
.preset-btn:hover {
  border-color: #818cf8;
  color: #4338ca;
  background: #eef2ff;
}
.preset-btn.border-indigo-500 {
  border-color: #6366f1;
  color: #4338ca;
  background: #eef2ff;
  font-weight: 600;
}

/* =====================================================
   管理者ページ専用: フォント・余白・テーブル拡張
   ===================================================== */

/* --- 広いコンテナ：Full HD(1920px) で頭打ち ---
   注意: max-width はあくまで上限。width: 100% なので実幅は
   ビューポート幅と一致する。Windows のディスプレイスケーリング
   (125%/150%) が掛かっていると、物理1920pxでも CSSピクセルでは
   それより狭くなり、画面が「Full HDより狭い」ように見える。 */
.admin-wide {
  max-width: 2400px;
  width: 100%;
}

/* 一覧のメモ簡易表示：省略して表示し、マウスオーバー(title)で全文を確認できる */
.memo-brief {
  display: inline-block;
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  cursor: help;
}

/* --- テーブル行・セルを読みやすく --- */
/* admin.js / settlement.js が動的生成するテーブルに適用 */
#admin-tab-records table th,
#admin-tab-records table td,
#admin-tab-collections table th,
#admin-tab-collections table td,
#admin-tab-users table th,
#admin-tab-users table td,
#admin-tab-back-rates table th,
#admin-tab-back-rates table td,
#admin-tab-ad-costs table th,
#admin-tab-ad-costs table td,
#admin-tab-referrers table th,
#admin-tab-referrers table td,
#admin-tab-settlement table th,
#admin-tab-settlement table td {
  font-size: 0.9rem;
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
}

/* --- ダッシュボードのサマリー数値を大きく --- */
#admin-tab-dashboard .text-3xl { font-size: 2rem; }
#admin-tab-dashboard .text-2xl { font-size: 1.6rem; }

/* --- 検索フォームのラベル・入力 --- */
.block.text-xs.text-gray-500 { font-size: 0.8rem; }

/* --- カードの見出し --- */
.font-bold.text-gray-700 { font-size: 1rem; }

/* --- セクション見出し（h2/h3） --- */
main h2 { font-size: 1.25rem; }
main h3 { font-size: 1.05rem; }

/* --- ナビタブのアクティブ強調 --- */
.admin-tab-btn.active {
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-weight: 600;
}

/* --- モーダル幅を広げる --- */
#admin-modal {
  max-width: 720px;
}

/* --- インラインバッジを少し大きく --- */
.inline-block.px-2.py-0\.5.rounded-full.text-xs,
.inline-block.px-2.py-0\.5.rounded.text-xs {
  font-size: 0.78rem;
  padding: 2px 8px;
}

/* --- 清算タブのサマリーカード数値 --- */
#sc-summary-cards .text-base,
#sw-summary-cards .font-bold,
#sr-summary-cards .font-bold {
  font-size: 1.05rem;
}

/* --- 作業記録 / 回収管理: PC操作ボタンを押しやすく --- */
@media (min-width: 769px) {
  #admin-tab-collections .cm-pc-action-cell {
    min-width: 330px;
  }
  #admin-tab-collections .cm-hq-status-cell {
    min-width: 110px;
  }
  #admin-tab-collections .cm-pc-action-btn {
    min-height: 38px;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.1;
  }
}

/* --- プリセットボタンを少し大きく --- */
.preset-btn {
  font-size: 0.82rem;
  padding: 0.4rem 0.7rem;
}

/* --- form-label を少し大きく --- */
.form-label {
  font-size: 0.9rem;
}

/* --- form-input を少し大きく --- */
.form-input {
  font-size: 0.95rem;
  padding: 0.7rem 0.9rem;
}

/* ============================================================
   オペレーター（閲覧専用）モード時の編集UI制御
   - body.role-operator 配下で .admin-only 要素を非表示
   - 書き込み系ボタンは admin.js が動的生成する箇所に .admin-only を付与する
   ============================================================ */
body.role-operator .admin-only {
  display: none !important;
}
body.role-operator .admin-only-disabled {
  pointer-events: none;
  opacity: 0.45;
  cursor: not-allowed;
}
/* オペレーターには閲覧専用バッジを表示 */
body.role-operator .operator-only-badge {
  display: inline-block;
}
body.role-admin .operator-only-badge {
  display: none;
}

/* ============================================================
   管理画面: スマホ対応
   - 768px (md) 以下では一覧テーブルをカードビューに置き換える
   - モーダルをフルスクリーン寄りに調整
   - サマリーカードの数値を小さく
   ============================================================ */

/* スマホ時、admin の本文 padding と余白を詰める */
@media (max-width: 768px) {
  main.admin-wide {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
    padding-top: 0.75rem !important;
    padding-bottom: 5rem !important;
  }
  /* セクション h2 を少し小さく */
  main h2 { font-size: 1.05rem; }
  /* ダッシュボードの数値を抑える */
  #admin-tab-dashboard .text-2xl { font-size: 1.2rem; }
  #admin-tab-dashboard .text-3xl { font-size: 1.4rem; }
  /* 検索フォーム高さを抑える */
  .form-input {
    padding: 0.55rem 0.7rem;
    font-size: 0.95rem;
  }
  /* スマホ時にadmin系テーブル余白を縮める */
  #admin-tab-collections table th,
  #admin-tab-collections table td,
  #admin-tab-users table th,
  #admin-tab-users table td {
    padding: 0.45rem 0.5rem !important;
    font-size: 0.82rem !important;
  }
  /* モーダルをフルスクリーン寄りに */
  #admin-modal, #detail-modal, #work-form-modal {
    max-width: 100vw !important;
    width: 100vw !important;
    margin: 0 !important;
    border-radius: 0 !important;
    max-height: 100vh !important;
    height: 100vh !important;
  }
  /* モーダル内の grid-cols-2 をスマホで縦並びに */
  #admin-modal .grid.grid-cols-2,
  #detail-modal .grid.grid-cols-2,
  #work-form-modal .grid.grid-cols-2 {
    grid-template-columns: 1fr;
  }
}

/* タブナビ自体のスクロール時、スクロールバーを薄く */
#admin-nav::-webkit-scrollbar { height: 4px; }
#admin-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border-radius: 2px; }

/* ============================================================
   プリセットボタンのアクティブ表示（大地: オレンジ系）
   ============================================================ */
.preset-btn.active {
  border-color: #ea580c;
  color: #c2410c;
  background: #fff7ed;
  font-weight: 600;
}

/* ============================================================
   報告書テーブル（画面表示）
   ============================================================ */
.report-table {
  width: 100%;
  border-collapse: collapse;
}
.report-table th,
.report-table td {
  border: 1px solid #555;
  padding: 6px 8px;
  font-size: 13px;
  text-align: left;
}
.report-table th {
  background: #f3f4f6;
  font-weight: 600;
}
.report-table td.num,
.report-table th.num {
  text-align: right;
}
.report-doc-title {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

/* ============================================================
   印刷（A4横）— .print-area だけを印刷する
   ============================================================ */
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  html, body { background: #ffffff !important; }
  body * { visibility: hidden !important; }
  .print-area, .print-area * { visibility: visible !important; }
  .print-area {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    box-shadow: none !important;
    border: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .no-print { display: none !important; }
  .report-table th, .report-table td {
    border: 1px solid #333;
    padding: 4px 6px;
    font-size: 11px;
  }
}

/* 一覧テーブル: スマホ時に隠す処理は md:block で対応 */
/* カードビューのアクションボタンを押しやすく */
@media (max-width: 768px) {
  #cm-cards button {
    min-height: 36px;
  }
}
