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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #ededed;
  color: #333;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  text-decoration: none;
}

ul {
  list-style: none;
}

button {
  border: none;
  outline: none;
  cursor: pointer;
  font-family: inherit;
}

.hidden {
  display: none !important;
}

/* ========== App Container ========== */
.app-container {
  max-width: 100vw;
  min-height: 100vh;
  background: #ededed;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ========== Screens ========== */
.screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

.screen-home {
  background: #1a1a1e;
}

.screen-checkin {
  background: #ededed;
}

/* ========== Header Bar ========== */
.header-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  padding-top: max(env(safe-area-inset-top, 10px), 10px);
  background: #f7f7f7;
  border-bottom: 0.5px solid #e0e0e0;
  min-height: 44px;
}

.header-left,
.header-right {
  width: 40px;
  display: flex;
  align-items: center;
}

.header-left {
  justify-content: flex-start;
}

.header-right {
  justify-content: flex-end;
}

.back-icon,
.more-icon {
  cursor: pointer;
}

.header-title {
  font-size: 17px;
  font-weight: 600;
  color: #000;
  text-align: center;
  flex: 1;
}

/* ========== Content Area ========== */
.content-area {
  flex: 1;
  padding: 0;
  background: #ededed;
}

/* ========== Card ========== */
.card-main {
  background: #fff;
  margin: 74px 12px 0;
  padding: 20px 24px 24px;
  text-align: center;
  border-radius: 4px;
}

/* ========== Icon Circles ========== */
.icon-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: block;
  margin: -62px auto 16px;
}


.icon-success {
  /* color baked into SVG */
  /* Slightly larger to match reference */
  width: 84px;
  height: 84px;
}

/* ========== Status Title ========== */
.status-title {
  font-size: 22px;
  font-weight: 600;
  color: #000;
  margin-bottom: 16px;
  letter-spacing: 1px;
}

/* ========== Loading Spinner ========== */
.loading-spinner {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 20px 0 40px;
  height: 24px;
  align-items: center;
}

.spinner-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #c0c0c0;
  animation: dotPulse 1.2s ease-in-out infinite;
}

.spinner-dot.dot-1 { animation-delay: 0s; }
.spinner-dot.dot-2 { animation-delay: 0.2s; }
.spinner-dot.dot-3 { animation-delay: 0.4s; }
.spinner-dot.dot-4 { animation-delay: 0.6s; }

@keyframes dotPulse {
  0%, 80%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1.1);
  }
}

/* ========== Venue Info ========== */
.venue-info {
  text-align: center;
  padding: 10px 0;
}

.venue-name {
  font-size: 17px;
  font-weight: 600;
  color: #000;
  margin-bottom: 8px;
}

.venue-manager {
  font-size: 14px;
  color: #9E9C9F;
  margin-bottom: 4px;
}

.manager-link {
  color: #5379EC;
  font-size: 14px;
}

.link-arrow {
  font-size: 10px;
  margin-left: 2px;
  vertical-align: middle;
}

.user-id {
  font-size: 14px;
  color: #9E9C9F;
  margin-top: 4px;
}

.entry-time {
  font-size: 13px;
  color: #9E9C9F;
  margin-bottom: 4px;
}

.state-success .entry-time,
.state-success .user-id {
  color: #000;
}

/* ========== Live Time Display ========== */
.live-time {
  margin: 8px 0 16px;
  text-align: center;
}

.time-display {
  font-size: 44px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "DIN Alternate", monospace;
  letter-spacing: 0;
  color: #000;
  transition: color 0.15s ease;
}

/* Time color classes */
.time-color-black { color: #000 !important; }
.time-color-blue  { color: #5573E6 !important; }
.time-color-green { color: #88E791 !important; }
.time-color-red   { color: #E46C52 !important; }

/* ========== Health Tips ========== */
.health-tips {
  margin: 12px 0 0;
  padding: 20px 24px 24px;
  background: #fff;
  /* Separate white block below the card */
}

/* Actually, looking at the screenshots, the tips are on the grey bg, not a white card */
.state-loading .health-tips,
.state-success .health-tips {
  background: transparent;
  padding: 20px 16px 24px;
}

.tips-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

.tips-icon {
  font-size: 18px;
  color: #5379EC;
  line-height: 1;
}

.tips-title {
  font-size: 15px;
  font-weight: 600;
  color: #000;
}

.tips-list {
  padding-left: 8px;
}

.tips-list li {
  position: relative;
  padding-left: 14px;
  font-size: 13px;
  color: #9E9C9F;
  line-height: 1.7;
  margin-bottom: 2px;
}

.tips-list li::before {
  content: "●";
  position: absolute;
  left: 0;
  top: 0;
  color: #5379EC;
  font-size: 8px;
  line-height: 1.7;
  /* Vertically center the bullet with the first line */
  margin-top: 5px;
}

/* ========== Return Button ========== */
.return-btn-wrapper {
  padding: 24px 40px 40px;
  text-align: center;
}

.btn-return {
  display: block;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  padding: 12px 0;
  border: 1px solid #5379EC;
  border-radius: 999px;
  background: transparent;
  color: #5379EC;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 2px;
}

.btn-return:active {
  background: rgba(83, 121, 236, 0.06);
}

/* ========== Notice Overlay ========== */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
}

.overlay-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.55);
}

.notice-dialog {
  position: relative;
  background: #fff;
  border-radius: 12px;
  padding: 28px 24px 24px;
  max-width: 340px;
  width: 100%;
  max-height: 75vh;
  display: flex;
  flex-direction: column;
  animation: dialogFadeIn 0.3s ease;
}

@keyframes dialogFadeIn {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.notice-title {
  font-size: 18px;
  font-weight: 600;
  color: #000;
  text-align: center;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.notice-content {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 20px;
  -webkit-overflow-scrolling: touch;
}

.notice-content p {
  font-size: 13px;
  color: #9E9C9F;
  line-height: 1.8;
  margin-bottom: 4px;
  text-align: justify;
}

.notice-content p strong {
  color: inherit;
}

.handbook-link {
  color: #5379EC;
  text-decoration: underline;
}

.btn-acknowledge {
  display: block;
  width: 200px;
  margin: 0 auto 16px;
  padding: 12px 0;
  background: #4e6ef2;
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  border-radius: 24px;
  letter-spacing: 2px;
  flex-shrink: 0;
}

.btn-acknowledge:active {
  opacity: 0.85;
}

.no-remind-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  flex-shrink: 0;
}

.no-remind-checkbox {
  display: none;
}

.checkbox-custom {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 1.5px solid #ccc;
  border-radius: 3px;
  position: relative;
  flex-shrink: 0;
}

.no-remind-checkbox:checked + .checkbox-custom {
  border-color: #4e6ef2;
  background: #4e6ef2;
}

.no-remind-checkbox:checked + .checkbox-custom::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 5px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.no-remind-text {
  font-size: 13px;
  color: #999;
}

/* ========== Animations ========== */
.overlay.fade-out {
  animation: overlayFadeOut 0.3s ease forwards;
}

.overlay.fade-out .notice-dialog {
  animation: dialogFadeOut 0.3s ease forwards;
}

@keyframes overlayFadeOut {
  to {
    opacity: 0;
    pointer-events: none;
  }
}

@keyframes dialogFadeOut {
  to {
    opacity: 0;
    transform: scale(0.92);
  }
}

/* State transition */
.state {
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Success checkmark animation */
.icon-success {
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  from {
    transform: scale(0);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ========== Responsive (mobile-first, max ~430px) ========== */
@media (max-width: 430px) {
  .notice-dialog {
    max-width: 90vw;
    padding: 24px 20px 20px;
  }

  .time-display {
    font-size: 38px;
  }
}

@media (min-width: 431px) {
  .app-container {
    max-width: 430px;
    margin: 0 auto;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    min-height: 100vh;
  }
}

/* ========== HOME HEADER ========== */
.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: max(env(safe-area-inset-top, 12px), 12px);
  background: #1a1a1e;
  position: sticky;
  top: 0;
  z-index: 100;
}

.home-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4e8cff, #6c5ce7);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

.home-username {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
}

.home-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.home-icon-btn {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.home-icon-btn:active {
  opacity: 0.6;
}

/* ========== SHORTCUT ROW ========== */
.shortcut-row {
  display: flex;
  gap: 16px;
  padding: 16px 16px 8px;
  background: #1a1a1e;
}

.shortcut-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.shortcut-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  text-align: center;
  line-height: 1.2;
}

.shortcut-icon-rainbow {
  background: conic-gradient(from 180deg, #ff6b6b, #ffd93d, #6bcb77, #4d96ff, #9b59b6, #ff6b6b);
}

.shortcut-icon-doc {
  background: #4e8cff;
}

.shortcut-label {
  font-size: 11px;
  color: #aaa;
  text-align: center;
}

/* ========== HOME TABS ========== */
.home-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  background: #1a1a1e;
}

.tab-filter-btn {
  background: none;
  border: none;
  padding: 4px 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
}

.tab-btn {
  background: none;
  border: none;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: #888;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.tab-active {
  background: #3a3a40;
  color: #fff;
}

/* ========== MESSAGE LIST ========== */
.message-list {
  flex: 1;
  background: #1a1a1e;
  padding: 0;
  overflow-y: auto;
}

.msg-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.msg-item:active {
  background: rgba(255,255,255,0.04);
}

.msg-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.msg-avatar-orange  { background: #e67e22; }
.msg-avatar-purple  { background: #6c5ce7; }
.msg-avatar-green   { background: #27ae60; }
.msg-avatar-blue    { background: #3498db; }
.msg-avatar-teal    { background: #1abc9c; }
.msg-avatar-red     { background: #e74c3c; }
.msg-avatar-yellow  { background: #f39c12; }

.msg-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  background: #4ade80;
  color: #000;
  font-size: 8px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  line-height: 1.2;
}

.msg-content {
  flex: 1;
  min-width: 0;
}

.msg-title {
  font-size: 15px;
  font-weight: 500;
  color: #eee;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bot-tag {
  display: inline-block;
  background: #4e8cff;
  color: #fff;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 500;
  vertical-align: middle;
  margin-left: 4px;
}

.msg-sub {
  font-size: 13px;
  color: #777;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.msg-time {
  font-size: 12px;
  color: #666;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ========== BOTTOM NAV ========== */
.bottom-nav {
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding: 8px 0 4px;
  padding-bottom: max(env(safe-area-inset-bottom, 4px), 4px);
  background: #222228;
  border-top: 0.5px solid #333;
  flex-shrink: 0;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  color: #888;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.nav-active {
  color: #4e8cff;
}

.nav-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-badge {
  position: absolute;
  top: -4px;
  right: -10px;
  font-size: 10px;
  color: #ff4757;
  font-weight: 700;
  letter-spacing: -1px;
}

/* ========== DROPDOWN MENU ========== */
.dropdown-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 199;
  -webkit-tap-highlight-color: transparent;
}

.dropdown-menu {
  position: absolute;
  top: 56px;
  right: 12px;
  background: #2d2d35;
  border-radius: 12px;
  padding: 6px 0;
  min-width: 180px;
  z-index: 200;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  animation: dropdownSlide 0.2s ease;
  transform-origin: top right;
}

@keyframes dropdownSlide {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.dropdown-arrow {
  position: absolute;
  top: -6px;
  right: 18px;
  width: 12px;
  height: 12px;
  background: #2d2d35;
  transform: rotate(45deg);
  border-radius: 2px;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 20px;
  color: #e0e0e0;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.dropdown-item:active {
  background: rgba(255,255,255,0.06);
}

.dropdown-dead {
  opacity: 0.8;
}

.dropdown-icon {
  flex-shrink: 0;
}

/* ========== QR SCANNER OVERLAY ========== */
.qr-scanner-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 600;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s ease;
}

.qr-scanner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: max(env(safe-area-inset-top, 12px), 12px);
  background: rgba(0,0,0,0.7);
  z-index: 2;
}

.qr-back-btn {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
}

.qr-scanner-title {
  color: #fff;
  font-size: 17px;
  font-weight: 600;
}

.qr-scanner-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

#qrVideo {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.qr-viewfinder {
  position: relative;
  width: 240px;
  height: 240px;
  z-index: 1;
}

.vf-corner {
  position: absolute;
  width: 30px;
  height: 30px;
  border-color: #4ade80;
  border-style: solid;
  border-width: 0;
}

.vf-tl { top: 0; left: 0; border-top-width: 3px; border-left-width: 3px; border-radius: 4px 0 0 0; }
.vf-tr { top: 0; right: 0; border-top-width: 3px; border-right-width: 3px; border-radius: 0 4px 0 0; }
.vf-bl { bottom: 0; left: 0; border-bottom-width: 3px; border-left-width: 3px; border-radius: 0 0 0 4px; }
.vf-br { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; border-radius: 0 0 4px 0; }

.vf-scanline {
  position: absolute;
  left: 4px;
  right: 4px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #4ade80 20%, #4ade80 80%, transparent);
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.6);
  animation: scanline 2s ease-in-out infinite;
}

@keyframes scanline {
  0% { top: 4px; }
  50% { top: calc(100% - 6px); }
  100% { top: 4px; }
}

.qr-hint {
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  margin-top: 32px;
  z-index: 1;
  text-align: center;
}

.qr-simulate-btn {
  margin-top: 24px;
  padding: 12px 28px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 24px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  z-index: 1;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.qr-simulate-btn:active {
  background: rgba(255,255,255,0.2);
}
