/* ============================================================
   希望シフト収集システム - スタイルシート
   ============================================================ */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #64748b;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0891b2;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-light: #64748b;
  --sat: #dbeafe;
  --sun: #fee2e2;
  --unsubmitted: #fef2f2;
  --highlight-row: #fefce8;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --radius: 8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ============================================================
   ログイン画面
   ============================================================ */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

.login-container { width: 100%; max-width: 420px; padding: 20px; }

.login-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  padding: 40px;
}

.login-title { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 8px; color: var(--primary); }
.login-subtitle { text-align: center; color: var(--text-light); margin-bottom: 24px; font-size: 13px; }

/* ============================================================
   ヘッダー
   ============================================================ */
.app-header {
  position: sticky; top: 0; z-index: 100;
  padding: 0 20px;
  box-shadow: var(--shadow);
  height: 56px;
}

.staff-header { background: var(--primary); }
.admin-header { background: #1e293b; }

.header-inner {
  display: flex; align-items: center; gap: 16px;
  max-width: 1400px; margin: 0 auto; height: 100%;
}

.store-name { color: white; font-weight: 600; font-size: 16px; }
.user-name { color: rgba(255,255,255,0.8); font-size: 13px; }
.logout-btn {
  background: #dc2626; color: white; font-size: 13px;
  padding: 6px 16px; border-radius: 4px; border: none;
  cursor: pointer; font-weight: 600; white-space: nowrap;
  letter-spacing: 0.02em;
}
.logout-btn:hover { background: #b91c1c; }

/* ログアウト確認モーダル */
.logout-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 9999; display: flex; align-items: center; justify-content: center;
}
.logout-modal-box {
  background: white; border-radius: 12px; padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3); text-align: center;
  min-width: 280px;
}
.logout-modal-box h3 {
  font-size: 18px; font-weight: 700; color: #1e293b; margin-bottom: 8px;
}
.logout-modal-box p {
  color: #64748b; font-size: 14px; margin-bottom: 24px;
}
.logout-modal-actions {
  display: flex; gap: 12px; justify-content: center;
}
.logout-modal-actions .btn-logout-yes {
  background: #dc2626; color: white; border: none;
  padding: 8px 28px; border-radius: 6px; font-size: 14px;
  font-weight: 600; cursor: pointer;
}
.logout-modal-actions .btn-logout-yes:hover { background: #b91c1c; }
.logout-modal-actions .btn-logout-no {
  background: #f1f5f9; color: #475569; border: none;
  padding: 8px 28px; border-radius: 6px; font-size: 14px;
  font-weight: 600; cursor: pointer;
}
.logout-modal-actions .btn-logout-no:hover { background: #e2e8f0; }

.store-select {
  background: rgba(255,255,255,0.15); color: white; border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px; padding: 6px 10px; font-size: 14px; cursor: pointer;
}
.store-select option { background: #1e293b; color: white; }

.admin-nav { display: flex; gap: 4px; }
.admin-nav a {
  color: rgba(255,255,255,0.8); text-decoration: none; padding: 6px 12px;
  border-radius: 4px; font-size: 13px;
}
.admin-nav a:hover { background: rgba(255,255,255,0.1); color: white; }

/* シフト提出リンク（管理者ナビ内） — スタッフ側へのリンクとして視覚的に区別 */
.nav-shift-link {
  border: 1px solid rgba(255,255,255,0.3) !important;
  color: rgba(255,255,255,0.95) !important;
}
.nav-shift-link:hover { background: rgba(255,255,255,0.15) !important; }

/* 管理者ページへ戻るリンク（スタッフヘッダー内） */
.admin-back-link {
  color: rgba(255,255,255,0.9); text-decoration: none;
  padding: 5px 12px; border-radius: 4px; font-size: 13px; font-weight: 500;
  border: 1px solid rgba(255,255,255,0.35); white-space: nowrap;
}
.admin-back-link:hover { background: rgba(255,255,255,0.15); color: white; }

/* ============================================================
   メインコンテンツ
   ============================================================ */
.main-content {
  max-width: 900px; margin: 0 auto; padding: 24px 20px;
}
.main-content.wide { max-width: 1400px; }

.page-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.page-title { font-size: 20px; font-weight: 700; color: var(--text); }

.back-btn {
  color: var(--primary); text-decoration: none; font-size: 13px;
  padding: 6px 12px; border: 1px solid var(--primary); border-radius: 4px;
  white-space: nowrap;
}
.back-btn:hover { background: var(--primary); color: white; }

/* ============================================================
   カード
   ============================================================ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; color: var(--text); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }

/* ============================================================
   フォーム
   ============================================================ */
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text); }
.form-group-check { flex-direction: row; align-items: center; gap: 8px; margin-top: 4px; }
.form-group-btn { justify-content: flex-end; margin-top: auto; }

.form-row {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start;
  margin-bottom: 16px;
}

input[type="text"], input[type="password"], input[type="date"],
input[type="datetime-local"], input[type="number"], input[type="email"],
select, textarea {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 4px;
  font-size: 14px; font-family: inherit; color: var(--text);
  background: white; width: 100%;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
input:disabled, select:disabled {
  background: #f1f5f9; color: var(--text-light); cursor: not-allowed;
}

.required { color: var(--danger); }
.field-error { font-size: 12px; color: var(--danger); margin-top: 2px; }
.field-hint { font-size: 11px; color: var(--text-light); margin-top: 2px; }
.hint { font-size: 12px; color: var(--text-light); margin-bottom: 12px; }

.form-actions { display: flex; justify-content: center; margin-top: 20px; }
.inline-form .form-row { align-items: flex-end; }

/* ============================================================
   ボタン
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 20px; border-radius: 4px; font-size: 14px; font-weight: 500;
  cursor: pointer; border: none; text-decoration: none; font-family: inherit;
  transition: background 0.15s, opacity 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #f1f5f9; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #b45309; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-large { padding: 12px 40px; font-size: 16px; }
.btn-full { width: 100%; }

/* ============================================================
   アラート
   ============================================================ */
.alert {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px;
}
.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }
.alert-info { background: #f0f9ff; color: var(--info); border: 1px solid #bae6fd; }

/* ============================================================
   メニューグリッド
   ============================================================ */
.menu-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px; margin-top: 20px;
}

.menu-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px 16px; text-align: center; text-decoration: none; color: var(--text);
  box-shadow: var(--shadow); transition: box-shadow 0.15s, transform 0.15s;
  display: block;
}
.menu-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.15); transform: translateY(-2px); }
.menu-icon { font-size: 32px; margin-bottom: 10px; }
.menu-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.menu-desc { font-size: 12px; color: var(--text-light); }

/* ============================================================
   期間情報
   ============================================================ */
.period-notice {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 20px; display: flex; align-items: center; gap: 16px;
}
.period-info { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.period-label { font-size: 12px; color: var(--text-light); }
.period-dates { font-size: 16px; font-weight: 600; }
.deadline-info { font-size: 13px; color: var(--text-light); }

.submitted-badge {
  background: #dcfce7; color: var(--success); padding: 6px 14px;
  border-radius: 20px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.unsubmitted-badge {
  background: #fee2e2; color: var(--danger); padding: 6px 14px;
  border-radius: 20px; font-size: 13px; font-weight: 600; white-space: nowrap;
}

.period-info-bar {
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: var(--radius);
  padding: 10px 16px; margin-bottom: 16px; display: flex; gap: 24px; font-size: 13px;
  flex-wrap: wrap;
}
.closed-badge {
  background: #f1f5f9; color: var(--secondary); padding: 2px 10px;
  border-radius: 20px; font-size: 12px;
}

.period-selector { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.period-selector select { width: auto; }

/* ============================================================
   ステータスカード
   ============================================================ */
.status-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 20px;
}
.status-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.status-info { display: flex; flex-direction: column; gap: 8px; }
.status-info .label { font-size: 12px; color: var(--text-light); display: inline-block; min-width: 80px; }
.warn-badge {
  background: #fff7ed; color: var(--warning); padding: 2px 10px;
  border-radius: 20px; font-size: 12px; margin-left: 8px;
}

/* ============================================================
   通知
   ============================================================ */
.notification-banner {
  background: #fff7ed; border: 1px solid #fed7aa; border-radius: var(--radius);
  padding: 16px; margin-bottom: 20px;
}
.notif-item { font-size: 12px; color: var(--text-light); margin-top: 4px; }

/* ============================================================
   シフト入力テーブル
   ============================================================ */
.shift-table-wrapper {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  max-height: calc(100vh - 310px);
  min-height: 200px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.shift-input-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  min-width: 700px;
}

.shift-input-table th {
  background: #f8fafc; border: 1px solid var(--border); padding: 8px 6px;
  font-weight: 600; text-align: center; white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
}
.shift-input-table td {
  border: 1px solid var(--border); padding: 6px; text-align: center; vertical-align: middle;
}

.copy-actions {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.copy-hint { font-size: 12px; color: var(--text-light); }

.date-cell { white-space: nowrap; font-weight: 500; }
.dow-cell { font-size: 12px; }
.dow-cell.sat { color: #2563eb; background: var(--sat); }
.dow-cell.sun { color: #dc2626; background: var(--sun); }

.dayoff-check { cursor: pointer; width: 16px; height: 16px; }

.time-select { min-width: 80px; padding: 4px 6px; }
.time-select-2 { opacity: 0.7; }
.time-select.grayed { background: #f1f5f9 !important; color: var(--text-light); }

.remarks-input { min-width: 120px; padding: 4px 8px; font-size: 12px; }

/* ============================================================
   マトリックス表
   ============================================================ */
.matrix-wrapper {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  max-height: calc(100vh - 260px);
  min-height: 200px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.matrix-table {
  border-collapse: collapse; font-size: 13px;
  white-space: nowrap;
}

.matrix-table th {
  background: #f8fafc; border: 1px solid var(--border); padding: 8px 6px;
  font-weight: 600; text-align: center; position: sticky; top: 0; z-index: 1;
}
.matrix-table td {
  border: 1px solid var(--border); padding: 6px 8px;
  text-align: center; vertical-align: middle; min-width: 70px; max-width: 120px;
}

.name-col { min-width: 90px; max-width: 130px; text-align: left !important; }
.sticky-col { position: sticky; left: 0; background: white; z-index: 2; }
.matrix-table th.sticky-col { z-index: 3; background: #f8fafc; }
/* hover時もstickyセルに背景色を付ける */
.data-row:hover .sticky-col { background: var(--highlight-row) !important; }

.date-col { min-width: 65px; }
.date-col .dow { font-size: 11px; color: var(--text-light); }
.matrix-table th.sat { background: var(--sat) !important; }
.matrix-table th.sun { background: var(--sun) !important; }

.data-row:hover { background: var(--highlight-row) !important; }
.unsubmitted-row td { background: var(--unsubmitted); }
.unsubmitted-cell-sample { display: inline-block; width: 16px; height: 16px; background: var(--unsubmitted); border: 1px solid #fecaca; }

.day-off-badge {
  display: inline-block; background: #f1f5f9; color: var(--text-light);
  padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 600;
}
.shift-time { font-size: 12px; line-height: 1.4; }
.empty-cell { color: #cbd5e1; }

.editable-cell { cursor: pointer; }
.editable-cell:hover { background: #eff6ff !important; }

.remarks-icon {
  font-size: 14px; cursor: default;
  position: relative; margin-left: 2px;
}
.remarks-icon:hover::after {
  content: attr(title);
  position: absolute; top: -30px; left: 50%; transform: translateX(-50%);
  background: #1e293b; color: white; padding: 4px 8px; border-radius: 4px;
  font-size: 12px; white-space: nowrap; z-index: 10;
  max-width: 200px; white-space: normal;
}

/* ============================================================
   フィルターバー
   ============================================================ */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end;
  margin-bottom: 16px; background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 12px; font-weight: 500; color: var(--text-light); }
.filter-group select { min-width: 150px; }

.legend { display: flex; gap: 16px; margin-bottom: 8px; font-size: 12px; color: var(--text-light); }
.legend-item { display: flex; align-items: center; gap: 6px; }

/* ============================================================
   データテーブル
   ============================================================ */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  background: #f8fafc; border-bottom: 2px solid var(--border); padding: 10px 12px;
  text-align: left; font-weight: 600; white-space: nowrap;
}
.data-table td { border-bottom: 1px solid var(--border); padding: 10px 12px; }
.data-table tr:hover td { background: #f8fafc; }
.action-cell { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.mono { font-family: 'Consolas', 'Courier New', monospace; font-size: 12px; }

.empty-msg { text-align: center; color: var(--text-light); padding: 20px; font-size: 13px; }

/* ============================================================
   バッジ
   ============================================================ */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 500;
}
.badge-green { background: #dcfce7; color: var(--success); }
.badge-yellow { background: #fef9c3; color: #a16207; }
.badge-gray { background: #f1f5f9; color: var(--secondary); }

/* 状態バッジ（有効 / 無効） */
.status-badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.status-active { background: #dcfce7; color: var(--success); }
.status-inactive { background: #fee2e2; color: var(--danger); }

/* 無効化済み行 */
.inactive-row td { background: #fafafa; color: #9ca3af; }
.inactive-row:hover td { background: #f3f4f6 !important; }

/* 提出済みだが時間未記入のセル */
.no-time-cell { color: #94a3b8; font-size: 13px; }

/* ============================================================
   権限グリッド
   ============================================================ */
.permissions-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.permission-item {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px;
}
.permission-item:hover { background: #f8fafc; }
.permission-item-admin {
  border-color: #3b82f6; background: #eff6ff;
  grid-column: 1 / -1;
}
.permission-item-admin:hover { background: #dbeafe; }
.perm-desc { font-size: 11px; color: var(--text-light); margin-left: 4px; }

/* ============================================================
   モーダル
   ============================================================ */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal-content {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 24px; min-width: 360px; max-width: 560px; width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-light);
  padding: 4px 8px; border-radius: 4px;
}
.modal-close:hover { background: #f1f5f9; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.proxy-label { font-weight: 600; margin-bottom: 12px; color: var(--primary); }

/* ============================================================
   レスポンシブ
   ============================================================ */
@media (max-width: 640px) {
  .header-inner { gap: 8px; }
  .admin-nav { display: none; }
  .main-content { padding: 16px 12px; }
  .menu-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .form-row { flex-direction: column; }
  .login-card { padding: 24px 20px; }
  .filter-bar { flex-direction: column; }
  .period-notice { flex-direction: column; align-items: flex-start; }
}

.login-form .form-group { margin-bottom: 16px; }

/* ============================================================
   アプリ共通ダイアログ（alert / confirm 代替）
   ============================================================ */
.app-dialog-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9000;
  align-items: center;
  justify-content: center;
}
.app-dialog-box {
  background: #fff;
  border-radius: 12px;
  padding: 32px 28px 24px;
  min-width: 300px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  text-align: center;
}
.app-dialog-msg {
  font-size: 15px;
  color: #334155;
  margin: 0 0 24px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.app-dialog-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

