/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
}

a { text-decoration: none; }

/* ===== Scanner Page ===== */
.scanner-page {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  padding: 20px;
  min-height: 100vh;
}

.scanner-container {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.scanner-header {
  text-align: center;
  color: white;
  padding: 20px 0 10px;
}

.scanner-header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.current-time {
  font-size: 1rem;
  color: rgba(255,255,255,0.7);
  margin-bottom: 8px;
}

.admin-link {
  display: inline-block;
  color: rgba(255,255,255,0.5);
  font-size: 0.85rem;
  transition: color 0.2s;
}
.admin-link:hover { color: rgba(255,255,255,0.9); }

/* Card */
.card {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 24px;
  padding: 28px 24px;
  animation: fadeIn 0.3s ease;
}
.card.hidden { display: none; }

.step-label {
  text-align: center;
  color: rgba(255,255,255,0.75);
  font-size: 0.95rem;
  margin: 0 0 20px;
}

/* Login form */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-form input {
  width: 100%;
  padding: 14px 16px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 12px;
  color: white;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.login-form input::placeholder { color: rgba(255,255,255,0.35); }
.login-form input:focus { border-color: rgba(255,255,255,0.6); }

.login-error {
  color: #ff7675;
  font-size: 0.85rem;
  text-align: center;
}
.login-error.hidden { display: none; }

.login-btn {
  width: 100%;
  padding: 14px;
  background: white;
  color: #1a1a2e;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-top: 4px;
}
.login-btn:hover { opacity: 0.9; }

/* QR display */
.qr-wrap {
  display: flex;
  justify-content: center;
  margin: 8px 0 16px;
  position: relative;
}

#qrImage {
  width: 240px;
  height: 240px;
  border-radius: 16px;
  border: 4px solid rgba(255,255,255,0.2);
}

.waiting-label {
  text-align: center;
  color: rgba(255,255,255,0.7);
  font-size: 0.95rem;
  margin-bottom: 20px;
}

.dot-anim {
  display: inline-block;
  animation: pulse 1.2s ease-in-out infinite;
  color: #00cec9;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

.btn-back {
  display: block;
  width: 100%;
  padding: 12px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  color: rgba(255,255,255,0.6);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-back:hover { background: rgba(255,255,255,0.15); color: white; }

/* Result */
.result-card-wrap {
  text-align: center;
  padding: 36px 24px;
}
.result-card-wrap.result-in { background: linear-gradient(135deg, rgba(0,184,148,0.3), rgba(0,206,201,0.2)); border-color: #00b894; }
.result-card-wrap.result-out { background: linear-gradient(135deg, rgba(232,67,147,0.3), rgba(253,121,168,0.2)); border-color: #e84393; }

.result-icon { font-size: 3.5rem; margin-bottom: 10px; }
.result-name { font-size: 1.9rem; font-weight: 800; color: white; margin-bottom: 4px; }
.result-type { font-size: 1.2rem; font-weight: 600; color: rgba(255,255,255,0.85); margin-bottom: 6px; }
.result-time { font-size: 0.9rem; color: rgba(255,255,255,0.6); margin-bottom: 10px; }
.result-message { font-size: 1rem; color: rgba(255,255,255,0.8); }

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

/* ===== Admin Page ===== */
.admin-page {
  background: #f0f2f5;
}

.navbar {
  background: #1a1a2e;
  color: white;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.nav-title { font-size: 1.1rem; font-weight: 700; }
.nav-links { display: flex; align-items: center; gap: 16px; }
.nav-link { color: rgba(255,255,255,0.7); font-size: 0.9rem; transition: color 0.2s; }
.nav-link:hover { color: white; }
.nav-logout { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: rgba(255,255,255,0.7); padding: 6px 14px; border-radius: 8px; font-size: 0.85rem; cursor: pointer; transition: all 0.2s; }
.nav-logout:hover { background: rgba(255,255,255,0.2); color: white; }

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

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: white;
  padding: 6px;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  width: fit-content;
}

.tab {
  padding: 10px 24px;
  border: none;
  background: transparent;
  color: #666;
  font-size: 0.95rem;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.2s;
  font-weight: 500;
}

.tab:hover { background: #f0f2f5; color: #333; }
.tab.active { background: #1a1a2e; color: white; }

/* Tab content */
.tab-content.hidden { display: none; }

/* Section header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-header h2 { font-size: 1.3rem; color: #1a1a2e; }

.filters {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filters label {
  font-size: 0.9rem;
  color: #555;
  display: flex;
  align-items: center;
  gap: 6px;
}

.filters input[type="date"] {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

/* Summary Cards */
.summary-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.summary-card {
  background: white;
  border-radius: 16px;
  padding: 20px 16px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border-left: 4px solid transparent;
}

.card-in { border-left-color: #00b894; }
.card-done { border-left-color: #6c5ce7; }
.card-absent { border-left-color: #b2bec3; }
.card-total { border-left-color: #0984e3; }

.s-num { font-size: 2.2rem; font-weight: 800; color: #1a1a2e; }
.s-label { font-size: 0.85rem; color: #888; margin-top: 4px; }

/* Table */
.table-wrapper {
  background: white;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  overflow: auto;
  margin-bottom: 16px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th {
  background: #f8f9fa;
  color: #555;
  font-weight: 600;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid #eee;
  white-space: nowrap;
}

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

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

.row-absent td { color: #aaa; }
.row-in td:first-child { font-weight: 600; }

code {
  background: #f0f0f0;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-family: monospace;
}

.empty { text-align: center; color: #aaa; padding: 40px !important; }

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}
.badge-in { background: #d5f5e3; color: #27ae60; }
.badge-done { background: #e8e4f9; color: #6c5ce7; }
.badge-absent { background: #f0f0f0; color: #888; }

/* Raw log */
.raw-log {
  margin-top: 8px;
}
.raw-log summary {
  cursor: pointer;
  color: #888;
  font-size: 0.9rem;
  padding: 8px 0;
  user-select: none;
}
.raw-log summary:hover { color: #555; }

/* Buttons */
.btn {
  padding: 9px 18px;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-primary { background: #1a1a2e; color: white; }
.btn-primary:hover { background: #2d2d4e; }

.btn-secondary { background: #f0f2f5; color: #555; }
.btn-secondary:hover { background: #e0e0e0; }

.btn-danger { background: #ffe0e0; color: #e74c3c; }
.btn-danger:hover { background: #ffcccc; }

.btn-sm { padding: 6px 12px; font-size: 0.82rem; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.btn-icon:hover { opacity: 1; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  backdrop-filter: blur(4px);
}

.modal.hidden { display: none; }

.modal-content {
  background: white;
  border-radius: 20px;
  padding: 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-content h3 { font-size: 1.2rem; margin-bottom: 20px; color: #1a1a2e; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.85rem; color: #555; margin-bottom: 6px; font-weight: 500; }
.form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #eee;
  border-radius: 10px;
  font-size: 0.95rem;
  transition: border-color 0.2s;
  outline: none;
}
.form-group input:focus { border-color: #1a1a2e; }

.required { color: #e74c3c; }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

.error-msg { color: #e74c3c; font-size: 0.85rem; margin-top: 10px; padding: 8px 12px; background: #fff0f0; border-radius: 8px; }
.error-msg.hidden { display: none; }

/* QR Modal */
.modal-qr { text-align: center; max-width: 360px; }
.modal-qr h3 { font-size: 1.4rem; }
.qr-sub { color: #888; font-size: 0.9rem; margin-bottom: 16px; }
.modal-qr img { width: 260px; height: 260px; border: 1px solid #eee; border-radius: 8px; margin-bottom: 12px; }
.qr-hint { font-size: 0.82rem; color: #aaa; margin-bottom: 16px; }

/* Responsive */
@media (max-width: 600px) {
  .section-header { flex-direction: column; align-items: flex-start; }
  .summary-row { grid-template-columns: repeat(2, 1fr); }
  .navbar { padding: 0 12px; }
  .admin-container { padding: 0 8px; }
  .modal-content { padding: 20px; }
}
