/* =====================================================
   ANH THE SINH VIEN - MOBILE STYLE
   Kế thừa bảng màu từ style.css gốc (burgundy / trắng)
   ===================================================== */
@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700&family=Playfair+Display:wght@600;700&display=swap');

:root {
  --burgundy:        #7b2d3e;
  --burgundy-dark:   #5c1f2c;
  --burgundy-light:  #9e3d52;
  --burgundy-muted:  #f5eaec;
  --burgundy-hover:  #f0d9dd;
  --white:           #ffffff;
  --bg:              #ffffff;
  --text-dark:       #1a1a1a;
  --text-mid:        #4a4a4a;
  --text-light:      #888888;
  --border:          #e2dada;
  --border-light:    #ede8e8;
  --shadow-sm:       0 1px 3px rgba(123,45,62,0.08);
  --shadow-md:       0 2px 8px rgba(123,45,62,0.12);
  --font-main:       'Be Vietnam Pro', sans-serif;
  --font-display:    'Playfair Display', serif;
  --radius:          8px;
  --radius-lg:       14px;
  --safe-bottom:     env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%;
  overscroll-behavior-y: contain;
}

body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text-dark);
  font-size: 15px;
  line-height: 1.5;
  padding-bottom: calc(16px + var(--safe-bottom));
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input { font-family: var(--font-main); font-size: 15px; }

/* ===== HEADER ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}
.topbar .logo-box {
  width: 34px; height: 34px; min-width: 34px;
  background: var(--burgundy);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 16px;
}
.topbar .title { flex: 1; }
.topbar .title .t1 { font-size: 13.5px; font-weight: 700; color: var(--burgundy); }
.topbar .title .t2 { font-size: 11px; color: var(--text-light); }
.topbar .logout-btn {
  font-size: 12px; color: var(--text-mid); border: 1px solid var(--border);
  padding: 6px 10px; border-radius: var(--radius); background: none;
}

/* ===== CONTAINER ===== */
.wrap { padding: 14px 16px 24px; max-width: 480px; margin: 0 auto; }

/* ===== LOGIN ===== */
.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, #fff 0%, var(--burgundy-muted) 260%);
}
.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-emblem {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--burgundy);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 26px; font-weight: 700;
  margin: 0 auto 14px;
  box-shadow: var(--shadow-md);
}
.login-card h1 {
  font-family: var(--font-display);
  font-size: 19px;
  color: var(--burgundy-dark);
  margin-bottom: 4px;
}
.login-card p.sub {
  font-size: 12.5px;
  color: var(--text-light);
  margin-bottom: 22px;
}
.key-input {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 17px;
  letter-spacing: 1px;
  text-align: center;
  outline: none;
  transition: border-color .2s;
}
.key-input:focus { border-color: var(--burgundy); }
.btn-primary {
  width: 100%;
  padding: 14px;
  margin-top: 12px;
  background: var(--burgundy);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 15.5px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
}
.btn-primary:active { background: var(--burgundy-dark); }
.error-box {
  margin-top: 14px;
  background: #fbeaea;
  color: #a53030;
  border: 1px solid #f0c9c9;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
}

/* ===== SEARCH ===== */
.search-box {
  position: relative;
  margin-bottom: 14px;
}
.search-box input {
  width: 100%;
  padding: 13px 16px 13px 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 15px;
  outline: none;
}
.search-box input:focus { border-color: var(--burgundy); }
.search-box .icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-light); font-size: 15px;
}

/* ===== STUDENT LIST ===== */
.student-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  margin-bottom: 10px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.student-avatar {
  width: 44px; height: 44px; min-width: 44px;
  border-radius: 50%;
  background: var(--burgundy-muted);
  color: var(--burgundy);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
  overflow: hidden;
}
.student-avatar img { width: 100%; height: 100%; object-fit: cover; }
.student-info { flex: 1; min-width: 0; }
.student-name { font-size: 14.5px; font-weight: 600; color: var(--text-dark); }
.student-meta { font-size: 11.5px; color: var(--text-light); margin-top: 2px; }
.student-meta span + span::before { content: "•"; margin: 0 5px; color: var(--border); }
.badge-done {
  display: inline-flex; align-items: center; gap: 3px;
  background: #e8f6ec; color: #1e8e4a;
  font-size: 10.5px; font-weight: 700;
  padding: 2px 7px; border-radius: 10px;
  margin-top: 4px;
}
.student-actions { display: flex; flex-direction: column; gap: 6px; }
.btn-capture {
  background: var(--burgundy);
  color: #fff;
  border: none;
  padding: 9px 13px;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.btn-view {
  background: var(--burgundy-muted);
  color: var(--burgundy);
  border: none;
  padding: 7px 13px;
  border-radius: var(--radius);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  color: var(--text-light);
  font-size: 13px;
  padding: 40px 20px;
}

/* ===== CAPTURE SCREEN ===== */
.capture-screen {
  background: #000;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.capture-topbar {
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,0.55);
  position: relative;
  z-index: 5;
}
.capture-topbar .who { flex: 1; }
.capture-topbar .who .name { font-size: 14px; font-weight: 700; }
.capture-topbar .who .id { font-size: 11px; opacity: .75; }
.capture-topbar .close-btn {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: #fff; border: none;
  font-size: 15px;
}

.camera-stage {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
}
#video, #photoCanvas, #resultImg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#photoCanvas { display: none; }
#resultImg { display: none; object-fit: contain; background: #000; }

.guide-frame {
  position: absolute;
  border: 2px dashed rgba(255,255,255,0.85);
  border-radius: 6px;
  box-shadow: 0 0 0 2000px rgba(0,0,0,0.35);
  pointer-events: none;
  z-index: 3;
}

.capture-hint {
  position: absolute;
  top: 12px; left: 0; right: 0;
  text-align: center;
  color: #fff;
  font-size: 12.5px;
  z-index: 4;
  padding: 0 20px;
}
.capture-hint .pill {
  background: rgba(0,0,0,0.55);
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
}
.capture-hint.warn .pill { background: #a53030; }
.capture-hint.ok .pill { background: #1e8e4a; }

.capture-controls {
  background: rgba(0,0,0,0.65);
  padding: 18px 16px calc(22px + var(--safe-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  z-index: 5;
}
.shutter-btn {
  width: 68px; height: 68px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid rgba(255,255,255,0.35);
}
.shutter-btn:active { background: #ddd; }
.switch-cam-btn, .retake-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  font-size: 17px;
}

.review-controls {
  display: none;
  background: rgba(0,0,0,0.65);
  padding: 14px 16px calc(20px + var(--safe-bottom));
  gap: 10px;
  z-index: 5;
}
.review-controls button {
  flex: 1;
  padding: 13px;
  border-radius: var(--radius-lg);
  border: none;
  font-size: 14.5px;
  font-weight: 600;
}
.btn-retake { background: rgba(255,255,255,0.15); color: #fff; }
.btn-save { background: var(--burgundy); color: #fff; }
.btn-save:disabled { opacity: .5; }

.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  background: var(--burgundy-dark);
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 999;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: opacity .25s;
}
.toast.show { opacity: 1; }

/* Người chụp (localStorage) */
.recorder-box {
  background: var(--burgundy-muted);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.recorder-box label { font-size: 12px; color: var(--burgundy); font-weight: 600; white-space: nowrap; }
.recorder-box input {
  flex: 1;
  border: none;
  background: #fff;
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  outline: none;
}
.recorder-box-dark {
  background: rgba(0,0,0,0.55);
  margin: 0 16px 10px;
  border-radius: var(--radius);
}
.recorder-box-dark label { color: #fff; }

/* View photo page */
.photo-view-wrap {
  padding: 16px;
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
}
.photo-view-wrap img {
  width: 100%;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-light);
}
.photo-thumb-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0 4px;
}
.photo-thumb-row a {
  flex: 0 0 auto;
  width: 70px; height: 105px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border-light);
}
.photo-thumb-row a.active { border-color: var(--burgundy); }
.photo-thumb-row img { width: 100%; height: 100%; object-fit: cover; }
