/* Custom styles for Office Access Management System */

:root {
  --primary: #ea580c;       /* orange-600 */
  --primary-dark: #c2410c;  /* orange-700 */
  --primary-light: #f97316; /* orange-500 */
  --primary-bg: #fff7ed;    /* orange-50 */
  --primary-border: #fed7aa;/* orange-200 */
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --bg-light: #fffbf5;
}

* { box-sizing: border-box; }

body {
  font-family: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
  background: #fffbf5;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.fade-in { animation: fadeIn 0.3s ease-out; }
.pulse   { animation: pulse 2s infinite; }

/* Clock */
.clock-display {
  font-size: 2.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
  color: var(--primary);
}

/* ===== Buttons ===== */
.btn-entry {
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 16px 32px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(22,163,74,0.3);
  min-width: 140px;
}
.btn-entry:hover    { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(22,163,74,0.4); }
.btn-entry:disabled { background: #9ca3af; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-exit {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 16px 32px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(220,38,38,0.3);
  min-width: 140px;
}
.btn-exit:hover    { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(220,38,38,0.4); }
.btn-exit:disabled { background: #9ca3af; cursor: not-allowed; transform: none; box-shadow: none; }

/* ===== Status Badges ===== */
.badge-in {
  display: inline-flex; align-items: center; gap: 4px;
  background: #dcfce7; color: #166534;
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600;
}
.badge-out {
  display: inline-flex; align-items: center; gap: 4px;
  background: #fee2e2; color: #991b1b;
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600;
}
.badge-pending {
  display: inline-flex; align-items: center; gap: 4px;
  background: #fef9c3; color: #854d0e;
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600;
}

/* ===== Table ===== */
.access-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  table-layout: auto;
}
.access-table th {
  background: var(--primary);
  color: white;
  padding: 10px 10px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  font-size: 0.82rem;
}
.access-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: middle;
  font-size: 0.85rem;
}
.access-table tr:hover td          { background: #fff7ed; }
.access-table tr:nth-child(even) td{ background: #fafafa; }
.access-table tr:nth-child(even):hover td { background: #fff7ed; }

/* チェックリスト展開行 */
.cl-expand-row td {
  background: #fff7ed !important;
  border-bottom: 2px solid #fed7aa;
  padding: 8px 12px 12px 12px;
}
.cl-expand-row:hover td { background: #ffedd5 !important; }

/* チェックリスト展開行内のチップグリッド */
.cl-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 100%;
}

/* チェックリストチップ */
.cl-chip {
  display: inline-flex;
  align-items: flex-start;
  gap: 5px;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: 500;
  white-space: normal;      /* 折り返し許可 */
  word-break: break-all;
  max-width: 100%;
  line-height: 1.4;
}
.cl-chip i {
  flex-shrink: 0;           /* アイコンは縮まない */
  margin-top: 2px;
}
.cl-chip.checked   { background: #dcfce7; color: #166534; }
.cl-chip.unchecked { background: #f1f5f9; color: #94a3b8; }

/* チェックリスト展開ボタン */
.cl-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--primary);
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--primary-border);
  background: var(--primary-bg);
  transition: all 0.15s;
  white-space: nowrap;
}
.cl-toggle-btn:hover { background: #fed7aa; }

/* Checklist items (modal) */
.checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #e2e8f0;
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item input[type="checkbox"] {
  width: 20px; height: 20px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px;
}
.modal-content {
  background: white;
  border-radius: 16px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: fadeIn 0.2s ease-out;
}

/* ===== Navigation ===== */
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  color: #78716c;   /* warm-gray */
  font-weight: 500;
  font-size: 0.9rem;
}
.nav-item:hover  { background: var(--primary-bg); color: var(--primary); }
.nav-item.active { background: var(--primary-bg); color: var(--primary); font-weight: 700; }

/* ===== Sidebar ===== */
.sidebar-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

/* ===== Form Input ===== */
.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.15s;
  outline: none;
  background: white;
}
.form-input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(249,115,22,0.15);
}

/* ===== OTP Input ===== */
.otp-input {
  width: 52px; height: 60px;
  text-align: center;
  font-size: 1.5rem; font-weight: 700;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s;
}
.otp-input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(249,115,22,0.15);
}

/* ===== Locked badge ===== */
.locked-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fef3c7; color: #92400e;
  padding: 4px 12px; border-radius: 6px;
  font-size: 0.85rem; font-weight: 600;
}

/* ===== Loading spinner ===== */
.spinner {
  border: 3px solid #e2e8f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  width: 24px; height: 24px;
  animation: spin 0.8s linear infinite;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: #f1f5f9; }
::-webkit-scrollbar-thumb  { background: #d1c4b8; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #b0938a; }

/* ===== Table wrapper ===== */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 9999;
  min-width: 280px; max-width: 400px;
  border-radius: 10px;
  padding: 14px 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  animation: fadeIn 0.3s ease-out;
  display: flex; align-items: center; gap: 10px;
}
.toast.success { background: #dcfce7; color: #166534; border-left: 4px solid #16a34a; }
.toast.error   { background: #fee2e2; color: #991b1b; border-left: 4px solid #dc2626; }
.toast.info    { background: #fff7ed; color: #9a3412; border-left: 4px solid var(--primary); }

/* ===== Login page gradient ===== */
.login-gradient {
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 50%, #fed7aa 100%);
}

/* ===== Card hover ===== */
.card-hover {
  transition: box-shadow 0.2s;
}
.card-hover:hover {
  box-shadow: 0 4px 20px rgba(234,88,12,0.1);
}

/* ===== Select accent ===== */
select.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(234,88,12,0.15);
}

/* ===== Page header accent ===== */
.page-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #1c1917;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--primary-border);
  margin-bottom: 20px;
}
.page-header i {
  color: var(--primary);
}

/* ===== Approval bar ===== */
.approval-bar {
  background: white;
  border: 1px solid var(--primary-border);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  padding: 12px 16px;
}

/* ===== Filter bar ===== */
.filter-bar {
  background: white;
  border: 1px solid var(--primary-border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

/* ===== Bottom Navigation Bar (mobile) ===== */
.bottom-nav {
  display: none; /* PCでは非表示 */
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: white;
  border-top: 2px solid var(--primary-border);
  z-index: 500;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
  /* bottom-nav自体をflexコンテナにして直接アイテムを均等配置 */
  flex-direction: row;
  align-items: stretch;
}
/* inner wrapperはwidth:100%を保証するだけ */
.bottom-nav-inner {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: 100%;
  height: 100%;
}
.bottom-nav-item {
  flex: 1 1 0%;      /* 均等幅：item数に関わらず等分 */
  min-width: 0;      /* テキスト溢れ防止 */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  color: #9ca3af;
  font-size: 0.62rem;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
  padding: 4px 2px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.bottom-nav-item i {
  font-size: 1.1rem;
  line-height: 1;
}
.bottom-nav-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  line-height: 1.2;
}
.bottom-nav-item.active {
  color: var(--primary);
}
.bottom-nav-item.active i {
  transform: translateY(-1px);
}

/* ===== Responsive fix ===== */
@media (max-width: 767px) {
  /* サイドバーを非表示 */
  .sidebar-desktop {
    display: none !important;
  }
  /* ボトムナビゲーション表示 */
  .bottom-nav {
    display: flex;  /* flexコンテナとして表示 */
  }
  /* メインコンテンツに下部ナビ分のパディング */
  .main-content-wrap {
    padding-bottom: 60px;
  }
  /* ページコンテンツのパディングを調整 */
  .page-pad {
    padding: 16px 12px;
  }
  /* 時計を小さく */
  .clock-display {
    font-size: 2.8rem;
  }
  /* 入室・退室ボタンを全幅 */
  .btn-entry,
  .btn-exit {
    flex: 1;
    min-width: 0;
    padding: 18px 12px;
    font-size: 1.05rem;
  }
  /* フォームの余白縮小 */
  .form-input {
    padding: 10px 12px;
    font-size: 0.95rem;
  }
  /* テーブルはスクロール */
  .access-table th,
  .access-table td {
    padding: 6px 8px;
    font-size: 0.8rem;
  }
  /* モーダルを画面下部に表示 */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal-content {
    border-radius: 20px 20px 0 0;
    max-height: 92vh;
    padding: 20px 18px 28px;
    width: 100%;
    max-width: 100%;
  }
  /* トーストを下部に */
  .toast {
    top: auto;
    bottom: 72px;
    right: 12px;
    left: 12px;
    min-width: 0;
  }
  /* OTP入力を小さく */
  .otp-input {
    width: 44px;
    height: 54px;
    font-size: 1.3rem;
  }
  /* カード余白縮小 */
  .mobile-card-pad {
    padding: 14px 12px;
  }
}

/* モバイル用月次記録カードレイアウト */
.record-card-mobile {
  display: none;
}
@media (max-width: 767px) {
  .record-table-wrap {
    display: none;
  }
  .record-card-mobile {
    display: block;
  }
}
.rec-card {
  background: white;
  border: 1px solid var(--primary-border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.rec-card-date {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.rec-card-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 0.82rem;
}
.rec-card-label {
  color: #9ca3af;
  font-size: 0.72rem;
  margin-bottom: 1px;
}
.rec-card-val {
  font-weight: 600;
  color: #1c1917;
}
.rec-card-time {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
}
.rec-card-time.exit {
  color: #dc2626;
}
.rec-card-chips {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
}
