:root {
  --crimson: #9e1b1e;
  --crimson-dark: #7a1114;
  --crimson-bright: #c62828;
  --gold: #d49b27;
  --gold-soft: rgba(212, 155, 39, 0.35);
  --cream: rgba(255, 250, 238, 0.9);
  --text-dark: #2c1810;
  --text-muted: #6b4c3b;
  --shadow-warm: 0 18px 45px rgba(92, 22, 14, 0.16);
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text-dark);
  -webkit-font-smoothing: antialiased;
}

/* Responsive Background: Mobile/Portrait vs PC/Landscape */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: #f9eed4;
  background-image: url("/assets/bg-mobile.jpg");
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}

@media (min-width: 769px) and (orientation: landscape) {
  .bg-layer {
    background-image: url("/assets/bg-pc.jpg");
    background-position: center center;
  }
}

/* Safe area: đặt nội dung gọn vào vùng trống đồng sáng ở giữa */
.safe-stage {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(195px, 31vh, 275px) 16px clamp(90px, 15vh, 140px);
}

@media (min-width: 769px) and (orientation: landscape) {
  .safe-stage {
    padding: clamp(190px, 33vh, 290px) 24px clamp(85px, 14vh, 130px);
  }
}

.card {
  width: 100%;
  max-width: 540px;
  background: var(--cream);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1.5px solid rgba(158, 27, 30, 0.22);
  box-shadow: var(--shadow-warm), inset 0 0 0 1px rgba(255, 255, 255, 0.65);
  border-radius: 22px;
  padding: 26px 22px;
  animation: cardIn 0.35s ease-out;
}

@media (min-width: 600px) {
  .card {
    padding: 32px 34px;
  }
}

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

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* Check-in Card */
.card-header {
  text-align: center;
  margin-bottom: 18px;
}

.badge-pill {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--crimson), var(--crimson-bright));
  color: #fff8e7;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  box-shadow: 0 4px 12px rgba(158, 27, 30, 0.25);
}

.card-subtitle {
  margin: 10px 0 0;
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.checkin-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.input-group {
  position: relative;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  width: 19px;
  height: 19px;
  color: var(--crimson);
  opacity: 0.75;
  pointer-events: none;
}

#name-input {
  width: 100%;
  padding: 14px 40px 14px 42px;
  border-radius: 14px;
  border: 1.5px solid rgba(158, 27, 30, 0.25);
  background: rgba(255, 255, 255, 0.95);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-dark);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#name-input::placeholder {
  color: #9e8576;
  font-weight: 400;
}

#name-input:focus {
  border-color: var(--crimson);
  box-shadow: 0 0 0 3px rgba(158, 27, 30, 0.14);
}

.clear-btn {
  position: absolute;
  right: 10px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(158, 27, 30, 0.1);
  color: var(--crimson);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.clear-btn:hover {
  background: rgba(158, 27, 30, 0.2);
}

.suggestions-list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  margin: 0;
  padding: 6px;
  list-style: none;
  background: #fffdf7;
  border: 1.5px solid rgba(158, 27, 30, 0.22);
  border-radius: 14px;
  box-shadow: 0 14px 32px rgba(72, 18, 12, 0.18);
  max-height: 250px;
  overflow-y: auto;
  z-index: 20;
}

.suggestion-item {
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.15s;
}

.suggestion-item + .suggestion-item {
  margin-top: 2px;
}

.suggestion-item:hover,
.suggestion-item.active {
  background: rgba(158, 27, 30, 0.08);
}

.suggestion-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.suggestion-name {
  font-weight: 700;
  font-size: 0.96rem;
  color: var(--text-dark);
}

.suggestion-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e8f5e9;
  color: #1b5e20;
  white-space: nowrap;
}

.suggestion-pos {
  margin-top: 3px;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.suggestion-empty {
  padding: 12px;
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.selected-preview {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(212, 155, 39, 0.12);
  border: 1px solid var(--gold-soft);
}

.preview-name {
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--crimson-dark);
}

.preview-pos {
  margin-top: 3px;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.form-error {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 500;
  color: #b71c1c;
  text-align: center;
}

.btn-primary {
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--crimson), var(--crimson-bright));
  color: #fff9ec;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(158, 27, 30, 0.28);
  transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(158, 27, 30, 0.36);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

/* Welcome Card - 3 dòng cân đối */
.welcome-card {
  max-width: 620px;
  text-align: center;
  padding: 30px 22px;
}

@media (min-width: 600px) {
  .welcome-card {
    padding: 38px 40px;
  }
}

.welcome-ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 18px;
}

.ornament-line {
  width: 56px;
  height: 1.5px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.ornament-star {
  color: var(--crimson);
  font-size: 1rem;
}

.welcome-lines {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Dòng 1: Chào mừng đồng chí */
.welcome-greeting {
  margin: 0;
  font-size: clamp(1rem, 2.8vw, 1.25rem);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--crimson);
}

/* Dòng 2: Họ và tên */
.welcome-name {
  margin: 2px 0 4px;
  font-size: clamp(1.65rem, 5vw, 2.45rem);
  font-weight: 800;
  line-height: 1.2;
  color: var(--crimson-dark);
  text-wrap: balance;
}

/* Dòng 3: Chức vụ (tự cân đối 1-2 dòng khi chức vụ dài) */
.welcome-position {
  margin: 0 auto;
  max-width: min(100%, 42ch);
  font-size: clamp(0.96rem, 2.7vw, 1.15rem);
  font-weight: 500;
  line-height: 1.5;
  color: var(--text-dark);
  text-wrap: balance;
}

.welcome-meta {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(27, 94, 32, 0.1);
  color: #1b5e20;
  font-size: 0.84rem;
  font-weight: 600;
}

.conference-note {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-secondary {
  margin-top: 20px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid rgba(158, 27, 30, 0.28);
  background: rgba(255, 255, 255, 0.72);
  color: var(--crimson-dark);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-secondary:hover {
  background: #ffffff;
}

.admin-corner-link {
  position: fixed;
  right: 14px;
  bottom: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(44, 24, 16, 0.45);
  color: #fff8e7;
  font-size: 0.76rem;
  font-weight: 500;
  text-decoration: none;
  backdrop-filter: blur(6px);
  transition: background-color 0.2s;
}

.admin-corner-link:hover {
  background: rgba(158, 27, 30, 0.85);
}
