/* ==============================================================
   TAMMY NAILS - GIAO DIỆN CHẤM CÔNG (KIOSK)
   Phong cách: Tối giản phẳng (Flat), Nền trắng, Font Arial,
   Không bóng đổ cầu kỳ, Bo viền vuông vắn (4px - 6px)
   ============================================================== */

@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700;800;900&display=swap');

:root {
  --bg-main: #ffffff;
  --bg-card: #ffffff;
  --border-color: #d1d5db;
  --border-subtle: #e5e7eb;
  --text-main: #111827;
  --text-muted: #4b5563;
  --primary: #1d4ed8;
  --radius-card: 6px;
  --radius-btn: 4px;
}

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

body {
  font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* HEADER NGAY NGẮN & SANG TRỌNG */
.kiosk-header {
  padding: 0.65rem 1.25rem;
  background: #ffffff;
  border-bottom: none;
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.header-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.brand-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: 0.5px;
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
}

.brand-title span {
  color: #b91c1c;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.btn-header {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
  transition: all 0.15s ease;
}

.btn-header:hover {
  background: #f3f4f6;
  border-color: #94a3b8;
}

.btn-header-admin {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a;
}

.btn-header-admin:hover {
  background: #e2e8f0;
}

/* THANH ĐỒNG HỒ TRUNG TÂM NẰM NGANG */
.header-clock-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.35rem 1rem;
  width: 100%;
  box-sizing: border-box;
}

.clock-time {
  font-size: 1.35rem;
  font-weight: bold;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: 0.5px;
}

.clock-divider {
  color: #94a3b8;
  font-size: 0.9rem;
}

.clock-date {
  font-size: 0.85rem;
  color: #475569;
  font-weight: 500;
}

/* MÀN HÌNH RỘNG (DESKTOP & IPAD NGANG) */
@media (min-width: 768px) {
  .kiosk-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 2rem;
  }

  .header-top-row {
    width: auto;
    gap: 1.5rem;
  }

  .header-clock-strip {
    width: auto;
    padding: 0.4rem 1.25rem;
  }

  .brand-title {
    font-size: 1.35rem;
  }
}

/* MAIN LAYOUT */
.kiosk-main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.5rem;
  padding: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 992px) {
  .kiosk-main {
    grid-template-columns: 1fr;
  }
}

/* SCANNER CARD */
.scanner-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.scanner-title {
  text-align: center;
  margin-bottom: 1.25rem;
}

.scanner-title h2 {
  font-size: clamp(1.05rem, 4.4vw, 1.45rem);
  font-weight: 800;
  color: #111827;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.scanner-title p {
  color: #b91c1c;
  font-size: 1rem;
  margin-top: 0.35rem;
  font-weight: bold;
}

/* CAMERA VIEWPORT */
.camera-container {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: #000000;
  border: 2px solid #374151;
}

#reader {
  width: 100% !important;
  height: 100% !important;
  border: none !important;
}

#reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

/* GUIDELINES */
.camera-guide-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.scan-box-frame {
  width: 65%;
  height: 65%;
  border: 1px dashed rgba(255, 255, 255, 0.6);
  position: relative;
  overflow: hidden;
}

/* Thanh quét ánh sáng di chuyển lên xuống nhịp nhàng */
.scan-sweep-bar {
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: #2563eb;
  box-shadow: 0 0 10px 2px rgba(37, 99, 235, 0.7);
  animation: sweepMove 2.2s ease-in-out infinite alternate;
}

.scan-sweep-bar::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 40px;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.25) 0%, transparent 100%);
  pointer-events: none;
}

@keyframes sweepMove {
  0% {
    top: 2%;
    opacity: 0.7;
  }
  100% {
    top: 96%;
    opacity: 1;
  }
}

.corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: #2563eb;
  border-style: solid;
  animation: cornerBreath 2.2s infinite ease-in-out;
}

@keyframes cornerBreath {
  0%, 100% { opacity: 0.85; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

.corner.top-left {
  top: -2px;
  left: -2px;
  border-width: 3px 0 0 3px;
}

.corner.top-right {
  top: -2px;
  right: -2px;
  border-width: 3px 3px 0 0;
}

.corner.bottom-left {
  bottom: -2px;
  left: -2px;
  border-width: 0 0 3px 3px;
}

.corner.bottom-right {
  bottom: -2px;
  right: -2px;
  border-width: 0 3px 3px 0;
}

.guide-instruction {
  position: absolute;
  bottom: 12px;
  background: rgba(17, 24, 39, 0.9);
  padding: 6px 16px;
  border-radius: var(--radius-btn);
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 6px;
}

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  animation: liveBlink 1.2s infinite ease-in-out;
}

@keyframes liveBlink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.8); }
}

/* CONTROLS */
.scanner-controls {
  width: 100%;
  max-width: 480px;
  margin-top: 1.25rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.camera-select-wrap {
  flex: 1;
}

.camera-select-wrap select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-btn);
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: normal;
  outline: none;
}

.camera-select-wrap select:focus {
  border-color: var(--primary);
}

.btn-manual-code {
  padding: 0.65rem 1.15rem;
  background: #f3f4f6;
  border: 1px solid var(--border-color);
  color: #1f2937;
  font-size: 0.9rem;
  font-weight: bold;
  border-radius: var(--radius-btn);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.btn-manual-code:hover {
  background: #e5e7eb;
}

/* SIDEBAR */
.activity-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
}

.activity-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.activity-header h3 {
  font-size: 1.15rem;
  font-weight: bold;
  color: var(--text-main);
}

.badge-counter {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  padding: 3px 8px;
  border-radius: var(--radius-btn);
  font-size: 0.8rem;
  font-weight: bold;
}

.activity-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 520px;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-btn);
}

.activity-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border-color);
  object-fit: cover;
  background: #f3f4f6;
}

.activity-details {
  flex: 1;
}

.activity-name {
  font-size: 1rem;
  font-weight: bold;
  color: var(--text-main);
}

.activity-role {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.activity-status-badge {
  text-align: right;
}

.tag-type {
  font-size: 0.75rem;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: var(--radius-btn);
  display: inline-block;
}

.tag-type.in {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.tag-type.out {
  background: #fefce8;
  color: #854d0e;
  border: 1px solid #fef08a;
}

.activity-time {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: bold;
}

/* POPUP KẾT QUẢ CHẤM CÔNG */
.kiosk-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.kiosk-modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.kiosk-popup {
  width: 90%;
  max-width: 460px;
  background: #ffffff;
  border: 2px solid #111827;
  border-radius: var(--radius-card);
  padding: 2rem;
  text-align: center;
}

.popup-avatar-ring {
  width: 90px;
  height: 90px;
  margin: 0 auto 1rem;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border-color);
  padding: 3px;
  background: #f9fafb;
}

.popup-avatar-ring img {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-btn);
  object-fit: cover;
}

.popup-greeting {
  font-size: 1.85rem;
  font-weight: bold;
  color: #111827;
  margin-bottom: 0.25rem;
}

.popup-role {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.popup-badge {
  display: inline-block;
  padding: 0.6rem 1.75rem;
  border-radius: var(--radius-btn);
  font-size: 1.25rem;
  font-weight: bold;
  margin-bottom: 1.25rem;
}

.popup-badge.in {
  background: #166534;
  color: #ffffff;
  border: 1px solid #14532d;
}

.popup-badge.out {
  background: #b45309;
  color: #ffffff;
  border: 1px solid #92400e;
}

.popup-badge.debounce {
  background: #1e40af;
  color: #ffffff;
  border: 1px solid #1e3a8a;
  font-size: 1.1rem;
}

.popup-detail-text {
  font-size: 1.1rem;
  color: #1f2937;
  margin-bottom: 1.5rem;
  font-weight: bold;
}

.popup-progress {
  width: 100%;
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  overflow: hidden;
}

.popup-progress-bar {
  height: 100%;
  background: #1d4ed8;
  width: 100%;
  transition: width 3.5s linear;
}

/* POPUP NHẬP TAY */
.manual-modal-box {
  width: 90%;
  max-width: 400px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 1.75rem;
  text-align: center;
}

.manual-modal-box h3 {
  font-size: 1.3rem;
  font-weight: bold;
  color: #111827;
  margin-bottom: 0.4rem;
}

.manual-modal-box p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.manual-modal-box input {
  width: 100%;
  padding: 0.75rem;
  font-size: 1.3rem;
  font-family: Arial, Helvetica, sans-serif;
  text-align: center;
  font-weight: bold;
  letter-spacing: 2px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: #111827;
  border-radius: var(--radius-btn);
  outline: none;
  margin-bottom: 1.25rem;
}

.manual-modal-box input:focus {
  border-color: #2563eb;
}

.manual-btn-group {
  display: flex;
  gap: 0.5rem;
}

.manual-btn-group button {
  flex: 1;
  padding: 0.65rem;
  border-radius: var(--radius-btn);
  font-size: 0.95rem;
  font-weight: bold;
  cursor: pointer;
}

.btn-confirm {
  background: #1d4ed8;
  border: 1px solid #1e40af;
  color: #ffffff;
}

.btn-confirm:hover {
  background: #1e40af;
}

.btn-cancel {
  background: #f3f4f6;
  border: 1px solid var(--border-color);
  color: #374151;
}

.btn-cancel:hover {
  background: #e5e7eb;
}
