/* ============================================
   Check-in System - Stylesheet
   Mobile-first, responsive design
   ============================================ */

:root {
  --primary: #4A90D9;
  --primary-hover: #357ABD;
  --success: #52c41a;
  --error: #ff4d4f;
  --bg: #f5f5f5;
  --card-bg: #ffffff;
  --text: #333333;
  --text-light: #666666;
  --border: #d9d9d9;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
    "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.6;
  padding: 16px;
}

.container {
  width: 100%;
  max-width: 480px;
  padding: 16px;
  margin: 0 auto;
}

.card {
  background-color: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

h1 {
  font-size: 1.5rem;
  text-align: center;
  color: var(--text);
  margin-bottom: 24px;
  font-weight: 600;
}

h2 {
  font-size: 1.25rem;
  color: var(--text);
  margin-bottom: 16px;
  font-weight: 600;
}

/* Date Display */
.date-display {
  text-align: center;
  padding: 12px 16px;
  margin-bottom: 20px;
  background-color: #e6f7ff;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.date-label {
  font-size: 0.9rem;
  color: var(--text-light);
  font-weight: 500;
}

.date-value {
  font-size: 1.1rem;
  color: var(--primary);
  font-weight: 700;
}

/* Form Styles */
.form-group {
  margin-bottom: 12px;
}

label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 6px;
  font-weight: 500;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  color: var(--text);
  background-color: var(--card-bg);
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

input[type="text"]:focus,
input[type="password"]:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.2);
}

/* Button Styles */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 14px;
  background-color: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, opacity 0.2s;
  min-height: 44px;
  line-height: 1.4;
}

button:hover {
  background-color: var(--primary-hover);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button:disabled:hover {
  background-color: var(--primary);
}

/* Message Styles */
.message {
  padding: 12px;
  border-radius: var(--radius);
  margin-top: 16px;
  display: none;
  font-size: 0.9rem;
  line-height: 1.5;
}

.message:not([hidden]) {
  display: block;
}

.message-success {
  background-color: #f6ffed;
  border: 1px solid var(--success);
  color: #389e0d;
}

.message-error {
  background-color: #fff2f0;
  border: 1px solid var(--error);
  color: #cf1322;
}

.message-loading {
  background-color: #e6f7ff;
  border: 1px solid var(--primary);
  color: #096dd9;
}

/* Spinner Animation */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

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

/* Shake Animation */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.shake {
  animation: shake 0.5s ease-in-out;
}

/* Footer */
footer {
  text-align: center;
  color: var(--text-light);
  font-size: 12px;
  margin-top: 24px;
}

/* ============================================
   Toggle Switch — iOS style (shared by admin filter dialog)
   ============================================ */

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input[type="checkbox"] {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  border-radius: 24px;
  transition: background-color 0.2s ease;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.toggle-switch input:focus-visible + .toggle-slider {
  box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.3);
}

/* ============================================
   Admin Page Table Styles
   ============================================ */

.admin-container {
  max-width: 960px;
}

.stats-bar {
  text-align: center;
  padding: 12px;
  background-color: #e6f7ff;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 1rem;
  color: var(--text);
  font-weight: 500;
}

.stats-bar strong {
  color: var(--primary);
  font-size: 1.2rem;
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.button-group button {
  width: auto;
  padding: 8px 16px;
  font-size: 14px;
  min-height: 36px;
}

.btn-export {
  background-color: #52c41a;
}

.btn-export:hover {
  background-color: #389e0d;
}

.btn-refresh {
  background-color: #722ed1;
}

.btn-refresh:hover {
  background-color: #531dab;
}

.btn-danger {
  background-color: var(--error);
}

.btn-danger:hover {
  background-color: #cf1322;
}

/* Table Styles */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  white-space: nowrap;
}

thead th {
  background-color: #fafafa;
  color: var(--text);
  font-weight: 600;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f0f0;
  color: var(--text);
}

tbody tr:nth-child(even) {
  background-color: #fafafa;
}

tbody tr:hover {
  background-color: #f0f5ff;
}

tr.duplicate-row td {
  background-color: #fff1f0;
}
tr.duplicate-row:hover td {
  background-color: #ffe7e7;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.pagination button {
  width: auto;
  padding: 8px 20px;
  font-size: 14px;
  min-height: 36px;
}

.pagination-info {
  font-size: 0.875rem;
  color: var(--text-light);
}

/* Login Gate */
.login-gate {
  text-align: center;
}

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

.login-gate button {
  width: 100%;
}

/* Confirm Dialog Overlay */
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.dialog-box {
  background-color: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 24px;
  max-width: 400px;
  width: 90%;
  text-align: center;
}

.dialog-box p {
  margin-bottom: 20px;
  font-size: 1rem;
  color: var(--text);
  line-height: 1.6;
}

.dialog-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.dialog-buttons button {
  width: auto;
  padding: 8px 24px;
  font-size: 14px;
  min-height: 36px;
}

.dialog-buttons .btn-cancel {
  background-color: #f5f5f5;
  color: var(--text);
  border: 1px solid var(--border);
}

.dialog-buttons .btn-cancel:hover {
  background-color: #e8e8e8;
}

/* Export dialog date input */
.dialog-date-group {
  margin-bottom: 16px;
  text-align: left;
}

.dialog-date-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.9rem;
  color: var(--text);
}

.dialog-date-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  box-sizing: border-box;
  background-color: #fff;
  color: var(--text);
}

.dialog-date-input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.2);
}

.btn-export-all {
  background-color: #4A90D9;
}

.btn-export-all:hover {
  background-color: #3a7bc8;
}

/* Row Action Buttons (Edit / Delete) */
.row-actions {
  display: inline-flex;
  gap: 4px;
  white-space: nowrap;
}

.btn-edit-row,
.btn-delete-row,
.btn-save-row,
.btn-cancel-row {
  width: auto;
  padding: 4px 10px;
  font-size: 12px;
  min-height: 28px;
  border-radius: 4px;
}

.btn-edit-row {
  background-color: var(--primary);
}

.btn-edit-row:hover {
  background-color: var(--primary-hover);
}

.btn-delete-row {
  background-color: var(--error);
}

.btn-delete-row:hover {
  background-color: #cf1322;
}

.btn-save-row {
  background-color: var(--success);
}

.btn-save-row:hover {
  background-color: #389e0d;
}

.btn-cancel-row {
  background-color: #999;
}

.btn-cancel-row:hover {
  background-color: #777;
}

/* Edit Mode Row Highlight */
tr.editing td {
  background-color: #fffbe6;
}

/* Edit Mode Inputs */
tr.editing td input[type="text"] {
  width: 100%;
  font-size: 0.875rem;
  padding: 4px 6px;
  box-sizing: border-box;
}

/* Checkbox column (multi-select) */
thead th:first-child,
tbody td:first-child {
  width: 40px;
  text-align: center;
}

.row-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Batch Delete Button — pushed to the right */
.btn-batch-delete {
  background-color: #fa8c16;
  margin-left: auto;
}

.btn-batch-delete:hover {
  background-color: #d46b08;
}

#btn-batch-delete[hidden] {
  display: none;
}

/* Find Duplicates Button */
.btn-find-duplicates {
  background-color: #eb2f96;
}

.btn-find-duplicates:hover {
  background-color: #c41d7f;
}

/* Duplicate mode active — button acts as clear toggle */
.btn-find-duplicates.active {
  background-color: #fa8c16;
}

.btn-find-duplicates.active:hover {
  background-color: #d87a0d;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 32px;
  color: var(--text-light);
}

/* ============================================
   Admin Gear Icon (Filter Settings)
   ============================================ */

.btn-filter-settings {
  position: absolute;
  right: 0;
  font-size: 1.3rem;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s;
  line-height: 1;
  user-select: none;
}

.btn-filter-settings:hover {
  opacity: 1;
}

/* Filter Rule Styles (used in admin dialog) */
.filter-rule {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-top: 1px solid #eee;
  gap: 12px;
}

.filter-rule:first-child {
  border-top: none;
}

.filter-rule-info {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.filter-rule-label {
  display: block;
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 2px;
}

.filter-rule-desc {
  display: block;
  font-size: 0.75rem;
  color: #999;
  line-height: 1.4;
}

/* ============================================
   Responsive: Desktop
   ============================================ */

@media (min-width: 768px) {
  .container {
    padding: 32px;
  }

  .card {
    padding: 32px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  }

  h1 {
    font-size: 1.75rem;
  }

  input[type="text"],
  input[type="password"] {
    font-size: 16px;
  }

  button {
    font-size: 16px;
  }

  .admin-container {
    max-width: 960px;
  }

  table {
    font-size: 0.9rem;
  }
}
