/* ============================================================
   LINE 打卡系統 - 全局樣式
   ============================================================ */

:root {
  --line-green: #00B900;
  --line-green-dark: #009900;
  --line-green-light: #e8f9e8;
  --text-primary: #1a1a1a;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --bg-main: #f3f4f6;
  --bg-card: #ffffff;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --radius: 16px;
  --radius-sm: 8px;
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang TC', 'Microsoft JhengHei', 'Noto Sans TC', sans-serif;
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg-main);
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

/* ============================================================
   登入頁
   ============================================================ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(160deg, #00B900 0%, #007a00 50%, #005500 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-container {
  width: 100%;
  max-width: 400px;
}

.login-card {
  background: #fff;
  border-radius: 24px;
  padding: 40px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  text-align: center;
}

.login-logo {
  margin-bottom: 8px;
}

.login-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: #e8f9e8;
  margin-bottom: 16px;
}

.login-icon svg {
  width: 48px;
  height: 48px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.btn-line-login {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 20px;
  background: var(--line-green);
  color: #fff;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  transition: background .2s, transform .1s;
  cursor: pointer;
  border: none;
}

.btn-line-login:hover {
  background: var(--line-green-dark);
  transform: translateY(-1px);
}

.btn-line-login:active {
  transform: translateY(0);
}

.line-icon {
  width: 22px;
  height: 22px;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 13px;
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-admin-login {
  display: block;
  width: 100%;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 14px;
  text-align: center;
  transition: border-color .2s, color .2s;
}
.btn-admin-login:hover {
  border-color: var(--line-green);
  color: var(--line-green);
}

.login-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 20px;
  line-height: 1.6;
}

/* ============================================================
   App 頁面（打卡主頁）
   ============================================================ */
.app-page {
  background: var(--bg-main);
  min-height: 100vh;
  padding-bottom: 24px;
}

.app-header {
  background: var(--line-green);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,185,0,.3);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  max-width: 600px;
  margin: 0 auto;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.5);
  object-fit: cover;
}

.user-name {
  display: block;
  font-weight: 600;
  font-size: 15px;
}
.company-name {
  display: block;
  font-size: 12px;
  opacity: .8;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  color: #fff;
  transition: background .2s;
}
.btn-icon svg { width: 20px; height: 20px; }
.btn-icon:hover { background: rgba(255,255,255,.35); }

/* 時間顯示 */
.datetime-bar {
  background: linear-gradient(135deg, #00B900, #007a00);
  color: #fff;
  text-align: center;
  padding: 20px 16px 28px;
}
.current-date {
  font-size: 14px;
  opacity: .9;
  margin-bottom: 4px;
}
.current-time {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
}

/* 卡片 */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  margin: 12px 16px 0;
  box-shadow: var(--shadow-md);
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* 今日打卡狀態 */
.today-card { margin-top: -16px; }

.checkin-status-row {
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin-bottom: 20px;
}

.status-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  opacity: .45;
  transition: opacity .3s;
}
.status-item.done { opacity: 1; }

.status-icon svg { width: 32px; height: 32px; color: var(--text-muted); }
.status-item.done .status-icon svg { color: var(--line-green); }

.status-label {
  font-size: 13px;
  color: var(--text-secondary);
}
.status-time {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.status-divider {
  width: 1px;
  height: 60px;
  background: var(--border);
  margin: 0 12px;
}

/* 打卡按鈕 */
.btn-group {
  text-align: center;
}

.btn-checkin, .btn-checkout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 280px;
  padding: 16px 24px;
  border-radius: 50px;
  font-size: 18px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  color: #fff;
}

.btn-checkin {
  background: linear-gradient(135deg, #00B900, #00a000);
  box-shadow: 0 4px 20px rgba(0,185,0,.4);
}
.btn-checkin:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0,185,0,.5);
}
.btn-checkin:active { transform: scale(.97); }

.btn-checkout {
  background: linear-gradient(135deg, #ff6b35, #f04f00);
  box-shadow: 0 4px 20px rgba(255,107,53,.4);
}
.btn-checkout:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(255,107,53,.5);
}
.btn-checkout:active { transform: scale(.97); }

.btn-checkin svg, .btn-checkout svg {
  width: 22px;
  height: 22px;
}

.checkin-complete {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--line-green);
  font-size: 16px;
  font-weight: 600;
  padding: 12px;
}
.checkin-complete svg { width: 28px; height: 28px; }

.work-hours-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding: 10px 16px;
  background: var(--line-green-light);
  border-radius: 10px;
  color: var(--line-green-dark);
  font-size: 14px;
}

/* 統計卡片 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  background: var(--bg-main);
  border-radius: var(--radius-sm);
}
.stat-num {
  font-size: 28px;
  font-weight: 700;
  color: var(--line-green);
  font-variant-numeric: tabular-nums;
}
.stat-lbl {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* 記錄列表 */
.records-list { display: flex; flex-direction: column; gap: 10px; }

.record-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-main);
  border-radius: 12px;
}

.record-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 40px;
}
.rec-day {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
}
.rec-month {
  font-size: 11px;
  color: var(--text-muted);
}

.record-times {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.rec-in, .rec-out {
  font-size: 13px;
  color: var(--text-secondary);
}

.record-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.badge {
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.badge-normal { background: #e6f4ea; color: #1a7f37; }
.badge-late   { background: #fff3cd; color: #856404; }
.badge-early  { background: #fff3cd; color: #856404; }
.badge-absent { background: #fde8e8; color: #b91c1c; }
.badge-info   { background: #e0f2fe; color: #0369a1; }

.rec-hours {
  font-size: 13px;
  font-weight: 600;
  color: var(--line-green);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 24px 0;
  font-size: 14px;
}

/* ============================================================
   Modal & Toast
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  background: #fff;
  border-radius: 20px;
  padding: 32px 24px;
  text-align: center;
  max-width: 300px;
  width: 100%;
  animation: slideUp .25s ease;
}
.modal-icon svg {
  width: 56px;
  height: 56px;
  animation: pulse 1.5s infinite;
}
.modal-box h3 { font-size: 18px; margin: 16px 0 8px; }
.modal-box p  { font-size: 14px; color: var(--text-secondary); }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.1); }
}
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.btn-modal-cancel {
  margin-top: 16px;
  padding: 8px 20px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  padding: 12px 24px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  animation: fadeIn .3s;
}
.toast-success { background: #1a7f37; }
.toast-error   { background: #b91c1c; }
.toast-warning { background: #856404; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============================================================
   表單
   ============================================================ */
.form-group {
  margin-bottom: 16px;
  text-align: left;
}
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
}
.form-control {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  transition: border-color .2s;
}
.form-control:focus { border-color: var(--line-green); }

.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 14px;
}
.alert-error { background: #fde8e8; color: #b91c1c; }

/* ============================================================
   管理後台
   ============================================================ */
.admin-page { background: #f8fafc; }

.admin-nav {
  background: #1a1a2e;
  color: #fff;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-actions { display: flex; gap: 12px; align-items: center; }

.btn-export {
  padding: 6px 16px;
  background: #00B900;
  color: #fff;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: background .2s;
}
.btn-export:hover { background: #009900; }

.btn-nav-logout {
  padding: 6px 16px;
  border: 1.5px solid rgba(255,255,255,.3);
  color: #fff;
  border-radius: 8px;
  font-size: 13px;
  transition: border-color .2s;
}
.btn-nav-logout:hover { border-color: rgba(255,255,255,.7); }

.admin-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
}

.admin-stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.admin-stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--line-green);
}
.admin-stat-card.warn { border-left-color: #f59e0b; }
.admin-stat-card.info { border-left-color: #3b82f6; }

.admin-stat-num {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
}
.admin-stat-lbl {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.admin-filter-bar {
  background: #fff;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.filter-form {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-group label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}
.form-control-sm {
  padding: 7px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  height: 36px;
  background: #fff;
}
.form-control-sm:focus { border-color: var(--line-green); }

.btn-filter {
  padding: 7px 20px;
  background: var(--line-green);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  height: 36px;
}
.btn-filter:hover { background: var(--line-green-dark); }

.admin-table-wrap {
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th {
  background: #f8fafc;
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #f8fafc; }

.td-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tbl-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.td-location .location-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--line-green);
  font-size: 13px;
}
.td-location .location-link:hover { text-decoration: underline; }

.empty-cell {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}
.page-btn {
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  transition: all .2s;
}
.page-btn:hover, .page-btn.active {
  border-color: var(--line-green);
  color: var(--line-green);
  background: var(--line-green-light);
}

/* ============================================================
   響應式
   ============================================================ */
@media (max-width: 480px) {
  .card { margin-left: 12px; margin-right: 12px; }
  .current-time { font-size: 36px; }
  .btn-checkin, .btn-checkout { font-size: 16px; padding: 14px 20px; }
  .admin-container { padding: 16px 12px; }
  .filter-form { flex-direction: column; }
}
