@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@400;500;600;700&display=swap');

:root {
  --bg: #050914;
  --panel: #0c1423;
  --panel-bright: #111f35;
  --line: #24466d;
  --text: #e8f4ff;
  --muted: #8ca4c3;
  --blue: #36baff;
  --blue-deep: #1976f3;
  --danger: #ff5578;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--text); background: radial-gradient(ellipse at 50% -10%, #173d76 0, transparent 43%), var(--bg); font: 500 16px/1.25 Rajdhani, Arial, sans-serif; letter-spacing: .02em; }
body::before { content: ''; position: fixed; inset: 0; pointer-events: none; background: linear-gradient(#36baff09 1px, transparent 1px), linear-gradient(90deg, #36baff09 1px, transparent 1px); background-size: 34px 34px; mask-image: linear-gradient(to bottom, #0009, transparent 68%); }
.app-shell { position: relative; z-index: 1; max-width: 1120px; margin: auto; padding: 0 22px 38px; }
.hidden { display: none !important; }

.login-view { min-height: 100vh; display: grid; place-items: center; }
.login-card { width: min(100%, 350px); display: grid; gap: 11px; padding: 28px; border: 1px solid var(--line); border-radius: 13px; background: linear-gradient(145deg, #122039, #090d17); box-shadow: 0 18px 55px #000a, 0 0 45px #36baff18; }
.logo-mark { display: grid; place-items: center; width: 44px; height: 44px; color: #06101c; background: var(--blue); font-size: 14px; font-weight: 700; clip-path: polygon(14% 0, 100% 0, 86% 100%, 0 100%); }
.logo-mark.small { width: 27px; height: 27px; font-size: 9px; }
.kicker, .scanner-head, .field-label { color: var(--blue); font-size: 11px; font-weight: 700; letter-spacing: .15em; }
h1 { margin: 5px 0 10px; color: transparent; background: linear-gradient(105deg, #fff, #c9ebff 52%, var(--blue)); background-clip: text; font-size: clamp(34px, 5vw, 56px); font-weight: 700; letter-spacing: -.035em; line-height: .95; }
h1 em { color: var(--blue); font-style: normal; }
h2 { margin: 6px 0; font-size: 21px; line-height: 1; }
.subtle, .hero-copy > p, .message { margin: 0; color: var(--muted); }
.login-card label { display: grid; gap: 5px; color: #bfd0e9; font-size: 13px; }
input, select { width: 100%; border: 1px solid #2a4a70; border-radius: 6px; padding: 9px 10px; color: var(--text); background: #070c16; font: 500 15px Rajdhani, Arial, sans-serif; }
input:focus, select:focus { outline: 1px solid var(--blue); border-color: var(--blue); }

.button { display: flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 6px; padding: 10px 13px; cursor: pointer; font: 700 15px Rajdhani, Arial, sans-serif; letter-spacing: .03em; transition: .18s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 0 20px #36baff55; }
.button:disabled { cursor: not-allowed; opacity: .42; }
.primary { color: white; background: linear-gradient(105deg, var(--blue), var(--blue-deep)); box-shadow: 0 5px 18px #1976f355; }
.secondary { color: var(--blue); border: 1px solid #2c527e; background: #102139; }
.muted { color: #c9daef; border: 1px solid #2e496b; background: #17243a; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 18px; height: 66px; border-bottom: 1px solid var(--line); background: #050914d9; backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: 8px; margin-right: auto; color: var(--text); text-decoration: none; font-size: 14px; font-weight: 700; letter-spacing: .11em; }
.brand span span { color: var(--blue); }
.tabs { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: #09111e; }
.tab { border: 0; border-radius: 4px; padding: 6px 13px; cursor: pointer; color: var(--muted); background: transparent; font: 600 14px Rajdhani, Arial, sans-serif; }
.tab.active { color: var(--blue); background: #193454; box-shadow: inset 0 0 0 1px #36baff33, 0 0 12px #36baff1c; }
.icon-button { border: 1px solid var(--line); border-radius: 5px; padding: 5px 8px; cursor: pointer; color: var(--text); background: transparent; }
.tab-view { display: none; }
.tab-view.active { display: block; animation: enter .35s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

.hero-copy { max-width: 630px; margin: 36px 0 22px; }
.hero-copy > p:last-child { max-width: 575px; font-size: 16px; }
.scanner-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(240px, .62fr); gap: 14px; }
.scanner-card, .result-card, .form-card, .enrol-camera { border: 1px solid var(--line); border-radius: 10px; padding: 13px; background: linear-gradient(145deg, var(--panel-bright), var(--panel)); box-shadow: 0 16px 38px #02071280; }
.scanner-card { position: relative; border-color: #2b5989; }
.scanner-head { display: flex; justify-content: space-between; margin-bottom: 9px; color: #8ba8ce; }
.scanner-head span:last-child { color: var(--blue); }
.status-dot { display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 9px var(--blue); }
.video-wrap { position: relative; overflow: hidden; aspect-ratio: 16 / 9; border-radius: 6px; background: #03060b; box-shadow: inset 0 0 30px #000, 0 0 0 1px #36baff22; }
.video-wrap video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.recognition-overlay { position: absolute; inset: 0; z-index: 3; width: 100%; height: 100%; pointer-events: none; }
.video-placeholder { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: #667b9b; font-size: 14px; pointer-events: none; }
.detection-box { position: absolute; border: 3px solid var(--blue); border-radius: 3px; box-shadow: 0 0 0 1px #06101d, 0 0 21px #36baff; pointer-events: none; transition: all .12s linear; }
.detection-box span { position: absolute; top: -27px; left: -3px; padding: 5px 8px; color: #06101d; background: var(--blue); font-size: 11px; font-weight: 700; letter-spacing: .07em; line-height: 1; white-space: nowrap; }
.detection-box.known-face { border-color: #46d5ff; box-shadow: 0 0 0 1px #06101d, 0 0 25px #36baff; }
.detection-box.known-face span { background: #46d5ff; }
.detection-box.unknown-face { border-color: var(--danger); box-shadow: 0 0 0 1px #16040b, 0 0 20px #ff5578aa; }
.detection-box.unknown-face span { color: white; background: var(--danger); }
.scan-footer, .progress-copy, .result-meta { display: flex; justify-content: space-between; padding-top: 9px; color: var(--muted); font-size: 11px; letter-spacing: .08em; }
.scan-footer b, .result-meta b { color: var(--blue); }

/* Result card — new flex layout */
.result-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: linear-gradient(165deg, #12294a, #0b1220 55%, #09111e);
  min-height: 340px;
  justify-content: flex-start;
  gap: 0;
}

/* Capture trigger (idle state) */
.capture-trigger-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
}

.capture-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid var(--blue);
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: .22s ease;
  box-shadow: 0 0 0 0 #36baff44;
  position: relative;
}

.capture-btn::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1px solid #36baff33;
  transition: .22s ease;
}

.capture-btn:hover {
  background: #36baff14;
  box-shadow: 0 0 28px #36baff55;
  transform: scale(1.06);
}

.capture-btn:hover::before {
  inset: -14px;
  border-color: #36baff22;
}

.capture-btn:active { transform: scale(0.97); }

.capture-hint {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .1em;
  margin: 0;
}

/* Recognition result panel */
.recognition-result-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  animation: enter .3s ease-out;
}

.result-avatar { display: grid; place-items: center; width: 70px; height: 70px; margin: 16px 0 4px; border: 1px solid #39699d; border-radius: 50%; color: var(--blue); background: radial-gradient(circle, #2175a644, transparent 68%); box-shadow: inset 0 0 24px #36baff22, 0 0 22px #36baff22; font-size: 25px; }
.result-meta { width: 100%; gap: 10px; margin: 17px 0; text-align: left; }
.result-meta div { flex: 1; display: grid; gap: 3px; border-top: 1px solid var(--line); padding-top: 7px; }
.result-meta span { font-size: 9px; }
.result-meta b { font-size: 11px; }

/* Scanning / pulse state */
.scanning-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  animation: enter .25s ease-out;
}

.pulse-ring {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 2px solid var(--blue);
  animation: pulse-out 1.4s ease-out infinite;
  position: relative;
}

.pulse-ring::after {
  content: '';
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: #36baff22;
  animation: pulse-in 1.4s ease-out infinite;
}

@keyframes pulse-out {
  0%   { box-shadow: 0 0 0 0 #36baff55; }
  70%  { box-shadow: 0 0 0 18px #36baff00; }
  100% { box-shadow: 0 0 0 0 #36baff00; }
}
@keyframes pulse-in {
  0%, 100% { opacity: .3; transform: scale(1); }
  50% { opacity: .7; transform: scale(1.1); }
}

.scan-status-text { color: var(--muted); font-size: 12px; letter-spacing: .12em; margin: 14px 0 0; }

/* Enrolment styles unchanged */
.enrolment-grid { display: grid; grid-template-columns: .7fr 1.3fr; gap: 14px; }
.form-card { display: flex; flex-direction: column; gap: 12px; }
summary { cursor: pointer; color: var(--blue); font-weight: 700; }
.employee-form { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 9px; }
.employee-form .button { grid-column: span 2; }
.selected-employee { border-left: 2px solid var(--blue); padding: 8px 10px; color: #bed2ed; background: #0b1728; font-size: 13px; }
.face-guide { position: absolute; top: 50%; left: 50%; width: 29%; height: 63%; border: 2px solid #36baff88; border-radius: 50%; transform: translate(-50%, -50%); }
.pose-guide { position: absolute; right: 12px; bottom: 12px; z-index: 4; display: flex; align-items: center; gap: 8px; max-width: 240px; padding: 8px 10px; border: 1px solid #36baff66; border-radius: 7px; color: #dff5ff; background: #07111ddd; backdrop-filter: blur(7px); }
.pose-guide span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; color: var(--blue); border: 1px solid #36baff99; font-size: 12px; }
.pose-guide small { display: block; color: #8da8c9; font-size: 9px; font-weight: 700; letter-spacing: .12em; }
.pose-guide strong { display: block; color: #fff; font-size: 14px; line-height: 1.05; }
.progress-track { height: 5px; margin-top: 6px; overflow: hidden; border-radius: 5px; background: #1a2c45; }
.progress-bar { width: 0; height: 100%; background: linear-gradient(90deg, var(--blue), #9ce8ff); transition: width .3s; }
.enrol-camera .message { padding-top: 9px; }
.message.error { color: var(--danger); }
.message.success { color: #6ddfff; }
.liveness-message { max-width: 210px; margin: 8px auto 0; color: #9edfff; font-size: 13px; line-height: 1.2; }

/* ── Portrait: viewport-filling 80 / 20 split ───────────────────────── */
/* Camera flex:4 = 80 %, result/form panel flex:1 = 20 %. No page scroll. */
@media (max-width: 1200px) and (orientation: portrait) {
  .app-shell               { padding: 0; display: flex; flex-direction: column; min-height: 100dvh; }
  #workspace               { flex: 1; display: flex; flex-direction: column; }
  .topbar                  { flex-shrink: 0; }
  .tab-view.active         { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
  .hero-copy               { display: none; }

  /* Recognition view */
  .scanner-layout          { display: flex; flex-direction: column; flex: 1; gap: 0; }
  .scanner-card            { flex: 4; display: flex; flex-direction: column; border-radius: 0; border-bottom: 1px solid var(--line); }
  .result-card             { flex: 1; min-height: unset; overflow-y: auto; border-radius: 0; border-top: none; }

  /* Enrolment view */
  .enrolment-grid          { display: flex; flex-direction: column; flex: 1; gap: 0; }
  .form-card               { flex: 1; overflow-y: auto; border-radius: 0; border-bottom: 1px solid var(--line); }
  .enrol-camera            { flex: 4; display: flex; flex-direction: column; border-radius: 0; border-top: none; }

  /* Video fills its parent card */
  .video-wrap              { aspect-ratio: unset; flex: 1; border-radius: 0; }
}

/* ── Portrait phone narrow extras (≤ 599 px) ────────────────────────── */
@media (max-width: 599px) and (orientation: portrait) {
  .topbar                  { gap: 8px; }
  .brand > span:last-child { display: none; }
  .tab                     { padding: 6px 9px; font-size: 12px; }
}

/* ── Landscape: camera dominates left, result / form right ──────────── */
@media (max-width: 1200px) and (orientation: landscape) {
  .scanner-layout          { grid-template-columns: minmax(0, 1.85fr) minmax(210px, 0.55fr); }
  .enrolment-grid          { grid-template-columns: minmax(200px, 0.5fr) minmax(0, 1.5fr); }
  .result-card             { min-height: unset; }
  .hero-copy               { margin: 16px 0 12px; }
}

/* ── Landscape phone compact chrome (≤ 768 px) ──────────────────────── */
@media (max-width: 768px) and (orientation: landscape) {
  .app-shell               { padding: 0 10px 12px; }
  .topbar                  { height: 52px; gap: 6px; }
  .brand > span:last-child { display: none; }
  .tab                     { padding: 5px 8px; font-size: 11px; }
  .hero-copy               { margin: 8px 0 6px; }
  h1                       { font-size: clamp(20px, 4vw, 32px); }
  .employee-form           { grid-template-columns: 1fr; }
  .employee-form .button   { grid-column: auto; }
}
