/* ========================================
   タイムカード共通スタイル (スマホ縦レイアウト)
   ======================================== */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;500;700;900&display=swap');

:root {
  --bg-dark: #0d0f14;
  --bg-card: rgba(255, 255, 255, 0.05);
  --bg-card-hov: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.10);
  --accent: #4f8ef7;
  --accent-glow: rgba(79, 142, 247, 0.35);
  --green: #34d399;
  --green-glow: rgba(52, 211, 153, 0.35);
  --orange: #f59e0b;
  --orange-glow: rgba(245, 158, 11, 0.35);
  --red: #f87171;
  --red-glow: rgba(248, 113, 113, 0.35);
  --purple: #a78bfa;
  --purple-glow: rgba(167, 139, 250, 0.35);
  --text-primary: #f1f5f9;
  --text-muted: #94a3b8;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

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

html,
body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100dvh;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  padding: 0;
}

/* ── 背景グラデーション ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 20% 10%, rgba(79, 142, 247, 0.15) 0%, transparent 60%),
    radial-gradient(ellipse 50% 35% at 80% 90%, rgba(167, 139, 250, 0.12) 0%, transparent 55%);
  pointer-events: none;
  z-index: 0;
}

/* ── ヘッダー ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 15, 20, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-header .logo {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-header .shop-name {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
}

.app-header .clock {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* ── メインコンテンツ ── */
.app-main {
  flex: 1;
  position: relative;
  z-index: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── カード ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* ── タブバー ── */
.tab-bar {
  display: flex;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
}

.tab-btn {
  flex: 1;
  padding: 10px 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
}

.tab-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 16px var(--accent-glow);
}

/* ── ボタン類 ── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 18px 16px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.btn:active {
  transform: scale(0.97);
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.12);
  opacity: 0;
  transition: opacity 0.15s;
}

.btn:hover::before {
  opacity: 1;
}

.btn-primary {
  background: linear-gradient(135deg, #4f8ef7, #6366f1);
  color: #fff;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-success {
  background: linear-gradient(135deg, #34d399, #10b981);
  color: #fff;
  box-shadow: 0 4px 20px var(--green-glow);
}

.btn-warning {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  box-shadow: 0 4px 20px var(--orange-glow);
}

.btn-danger {
  background: linear-gradient(135deg, #f87171, #dc2626);
  color: #fff;
  box-shadow: 0 4px 20px var(--red-glow);
}

.btn-purple {
  background: linear-gradient(135deg, #a78bfa, #8b5cf6);
  color: #fff;
  box-shadow: 0 4px 20px var(--purple-glow);
}

.btn-ghost {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-sm {
  padding: 10px 14px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
}

/* ── グリッドボタン(2×2) ── */
.punch-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.punch-grid .btn {
  flex-direction: column;
  padding: 24px 12px;
  font-size: 0.95rem;
  gap: 6px;
}

.punch-grid .btn .btn-icon {
  font-size: 2rem;
  line-height: 1;
}

/* ── スタッフリスト ── */
.staff-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.staff-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.staff-item:active {
  transform: scale(0.98);
}

.staff-item.selected {
  border-color: var(--accent);
  background: rgba(79, 142, 247, 0.12);
  box-shadow: 0 0 16px var(--accent-glow);
}

.staff-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.staff-name {
  font-size: 1rem;
  font-weight: 500;
}

.staff-id {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── 打刻履歴 ── */
.event-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.event-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.event-badge {
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.badge-in {
  background: rgba(52, 211, 153, 0.2);
  color: var(--green);
}

.badge-out {
  background: rgba(248, 113, 113, 0.2);
  color: var(--red);
}

.badge-brk {
  background: rgba(245, 158, 11, 0.2);
  color: var(--orange);
}

.badge-back {
  background: rgba(79, 142, 247, 0.2);
  color: var(--accent);
}

.event-time {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ── QRエリア ── */
.qr-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 20px;
}

.qr-box {
  background: #fff;
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 0 40px var(--accent-glow), 0 0 80px var(--purple-glow);
}

.qr-box canvas,
.qr-box img {
  display: block;
}

/* ── カメラビュー（打刻画面のQRスキャン） ── */
.camera-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  aspect-ratio: 1 / 1;
  max-width: 280px;
  margin: 0 auto;
}

.camera-wrap video,
.camera-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-scan-line {
  position: absolute;
  left: 12%;
  right: 12%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 8px var(--accent);
  animation: scanline 2s ease-in-out infinite;
}

@keyframes scanline {
  0% {
    top: 12%;
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  90% {
    opacity: 1;
  }

  100% {
    top: 88%;
    opacity: 0;
  }
}

.camera-corners::before,
.camera-corners::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--accent);
  border-style: solid;
}

.camera-corners::before {
  top: 10px;
  left: 10px;
  border-width: 3px 0 0 3px;
  border-radius: 4px 0 0 0;
}

.camera-corners::after {
  bottom: 10px;
  right: 10px;
  border-width: 0 3px 3px 0;
  border-radius: 0 0 4px 0;
}

/* ── 集計テーブル ── */
.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.summary-table th {
  text-align: left;
  padding: 8px 10px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
}

.summary-table td {
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-variant-numeric: tabular-nums;
}

.summary-table tr:last-child td {
  border-bottom: none;
}

.summary-table .total-row td {
  font-weight: 700;
  color: var(--accent);
  border-top: 1px solid var(--border);
}

/* ── フォーム ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.form-input,
.form-select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  padding: 13px 14px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea.form-input {
  min-height: 100px;
  line-height: 1.6;
}

.form-select option,
select.form-input option {
  background: #1e2130;
  color: var(--text-primary);
}

/* select 要素が form-input クラスを使う場合もダーク背景を維持 */
select.form-input {
  background: rgba(30, 33, 48, 0.95);
  color: var(--text-primary);
}

/* ── ステータスバッジ ── */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
}

.status-pill::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status-working {
  background: rgba(52, 211, 153, 0.15);
  color: var(--green);
}

.status-break {
  background: rgba(245, 158, 11, 0.15);
  color: var(--orange);
}

.status-off {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-muted);
}

/* ── Toast通知 ── */
.toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 32px);
  max-width: 440px;
  pointer-events: none;
}

.toast {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
  pointer-events: auto;
}

.toast-success {
  background: rgba(52, 211, 153, 0.85);
  color: #fff;
}

.toast-error {
  background: rgba(248, 113, 113, 0.85);
  color: #fff;
}

.toast-info {
  background: rgba(79, 142, 247, 0.85);
  color: #fff;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* ── オーバーレイ ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(13, 15, 20, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.loading-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.loading-overlay .spinner {
  margin: 0;
  width: 40px;
  height: 40px;
  border-width: 4px;
}

.loading-text {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.05em;
}

/* ── スピナー ── */
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── ユーティリティ ── */
.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.mt-8 {
  margin-top: 8px;
}

.mt-12 {
  margin-top: 12px;
}

.mt-16 {
  margin-top: 16px;
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-8 {
  gap: 8px;
}

.gap-12 {
  gap: 12px;
}

.hidden {
  display: none !important;
}

/* ── スクロールバー ── */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* ── セーフエリア対応 ── */
.app-main {
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
