/**
 * Edu Vanguard QR - Student Mobile & Desktop Styles
 * Developed by DST Team Developers
 * MD3 Emerald Forest Scheme (#206A4D)
 */

/* ==========================================================================
 * TOP-LEVEL VIEW SWITCHER (Desktop Fallback vs Mobile Native App)
 * ========================================================================== */
#view-desktop-fallback {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  background: radial-gradient(circle at 50% 20%, #EAEFE9 0%, #F5FBF5 100%);
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

#view-mobile-app {
  display: flex;
  flex-direction: column;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
  background-color: var(--md-sys-color-surface, #F5FBF5);
}

/* Show desktop view on computers (>768px in landscape or mouse-driven) */
@media screen and (min-width: 769px) and (hover: hover) and (pointer: fine) {
  #view-desktop-fallback {
    display: flex !important;
  }
  #view-mobile-app {
    display: none !important;
  }
}

/* ==========================================================================
 * DESKTOP FALLBACK VIEW STYLES
 * ========================================================================== */
.desktop-card {
  width: 100%;
  max-width: 480px;
  background-color: var(--md-sys-color-surface-container-lowest, #FFFFFF);
  border: 1px solid var(--md-sys-color-outline-variant, #BFC9C1);
  border-radius: 32px;
  padding: 36px 32px 28px;
  box-shadow: 0 16px 40px -12px rgba(23, 29, 25, 0.12), 0 4px 16px -2px rgba(23, 29, 25, 0.04);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.desktop-brand-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.desktop-brand-logo {
  width: 72px;
  height: 60px;
  object-fit: contain;
}

.desktop-brand-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--md-sys-color-primary, #206A4D);
  letter-spacing: -0.3px;
}

.desktop-qr-wrapper {
  margin: 24px 0 20px;
  padding: 16px;
  background-color: #FFFFFF;
  border-radius: 24px;
  border: 1.5px solid var(--md-sys-color-outline-variant, #BFC9C1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
}

.desktop-qr-canvas {
  width: 220px;
  height: 220px;
  display: block;
}

.desktop-instruction-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--md-sys-color-on-surface, #171D19);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.desktop-instruction-desc {
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--md-sys-color-on-surface-variant, #404943);
  max-width: 380px;
}

/* ==========================================================================
 * MOBILE NATIVE APP EXPERIENCE
 * ========================================================================== */

/* Top App Bar */
.mobile-app-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top, 12px)) 16px 12px;
  background: linear-gradient(180deg, rgba(15, 21, 17, 0.72) 0%, rgba(15, 21, 17, 0) 100%);
  pointer-events: none;
}

.mobile-brand-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(234, 239, 233, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 6px 14px 6px 8px;
  border-radius: 9999px;
  border: 1px solid rgba(191, 201, 193, 0.4);
  pointer-events: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.mobile-brand-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.mobile-brand-text {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--md-sys-color-primary, #206A4D);
}

.student-profile-chip {
  display: none;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 6px 12px;
  border-radius: 9999px;
  border: 1px solid rgba(191, 201, 193, 0.4);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--md-sys-color-on-surface, #171D19);
  pointer-events: auto;
  cursor: pointer;
}

.student-profile-chip.visible {
  display: inline-flex;
}

/* ==========================================================================
 * STAGES CONTAINER & SHEETS
 * ========================================================================== */
.app-stage-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Card / Sheet for Onboarding & Permission */
.m3-modal-sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background-color: rgba(15, 21, 17, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s cubic-bezier(0.2, 0, 0, 1);
}

.m3-modal-sheet.active {
  opacity: 1;
  pointer-events: auto;
}

.m3-bottom-card {
  width: 100%;
  background-color: var(--md-sys-color-surface-container-lowest, #FFFFFF);
  border-top-left-radius: 32px;
  border-top-right-radius: 32px;
  padding: 24px 24px max(24px, env(safe-area-inset-bottom, 24px));
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.m3-modal-sheet.active .m3-bottom-card {
  transform: translateY(0);
}

.sheet-drag-handle {
  width: 36px;
  height: 4px;
  background-color: var(--md-sys-color-outline-variant, #BFC9C1);
  border-radius: 2px;
  margin-bottom: 16px;
}

.sheet-icon-circle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: var(--md-sys-color-primary-container, #A9F2CD);
  color: var(--md-sys-color-on-primary-container, #002114);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.sheet-icon-circle .material-symbols-rounded {
  font-size: 32px;
}

.sheet-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--md-sys-color-on-surface, #171D19);
  margin-bottom: 6px;
}

.sheet-desc {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--md-sys-color-on-surface-variant, #404943);
  margin-bottom: 20px;
  max-width: 330px;
}

/* ==========================================================================
 * CAMERA & SCANNER UI
 * ========================================================================== */
#stage-scanner {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-color: #000000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#view-camera-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: center center;
  transition: transform 0.2s ease;
}

/* Viewfinder Overlay & Scrim */
.viewfinder-scrim {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

/* DYNAMIC TRACKING TARGET BOX */
#viewfinder-target-box {
  position: absolute;
  top: 0;
  left: 0;
  width: min(72vw, 260px);
  height: min(72vw, 260px);
  border-radius: 28px;
  z-index: 20;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(15, 21, 17, 0.62);
  will-change: transform, width, height;
}

/* Corner Brackets */
.bracket {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: rgba(255, 255, 255, 0.85);
  border-style: solid;
  border-width: 0;
  transition: border-color 0.22s ease, filter 0.22s ease;
}

.bracket-tl { top: -2px; left: -2px; border-top-width: 4px; border-left-width: 4px; border-top-left-radius: 26px; }
.bracket-tr { top: -2px; right: -2px; border-top-width: 4px; border-right-width: 4px; border-top-right-radius: 26px; }
.bracket-bl { bottom: -2px; left: -2px; border-bottom-width: 4px; border-left-width: 4px; border-bottom-left-radius: 26px; }
.bracket-br { bottom: -2px; right: -2px; border-bottom-width: 4px; border-right-width: 4px; border-bottom-right-radius: 26px; }

/* Active tracking states */
#viewfinder-target-box.tracking-active .bracket {
  border-color: var(--md-sys-color-inverse-primary, #8DD5B2);
  filter: drop-shadow(0 0 6px rgba(141, 213, 178, 0.8));
}

/* Glowing Laser Scan Bar */
#scan-laser-line {
  position: absolute;
  left: 10px;
  right: 10px;
  height: 2.5px;
  background: linear-gradient(90deg, transparent, #8DD5B2 25%, #FFFFFF 50%, #8DD5B2 75%, transparent);
  box-shadow: 0 0 14px #8DD5B2, 0 0 4px #FFFFFF;
  border-radius: 9999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#viewfinder-target-box.tracking-active #scan-laser-line {
  opacity: 1;
  animation: laserScan 1.6s ease-in-out infinite alternate;
}

@keyframes laserScan {
  0% { top: 8%; }
  100% { top: 92%; }
}

/* Top Telemetry HUD */
.scanner-hud-top {
  position: absolute;
  top: max(64px, env(safe-area-inset-top, 64px));
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0 20px;
  pointer-events: none;
}

#pill-scanner-status {
  background: rgba(23, 29, 25, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 9px 20px;
  border-radius: 9999px;
  border: 1px solid rgba(191, 201, 193, 0.25);
  color: #FFFFFF;
  font-size: 13.5px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  transition: all 0.2s ease;
  pointer-events: auto;
}

/* 10-Dot Frame Pacing Bar */
#seq-dots-container {
  display: flex;
  gap: 7px;
  background: rgba(15, 21, 17, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 7px 14px;
  border-radius: 9999px;
  border: 1px solid rgba(191, 201, 193, 0.18);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  pointer-events: auto;
}

.seq-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.28);
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.18s ease, box-shadow 0.18s ease;
}

.seq-dot.filled {
  background-color: var(--md-sys-color-inverse-primary, #8DD5B2);
  transform: scale(1.35);
  box-shadow: 0 0 8px var(--md-sys-color-inverse-primary, #8DD5B2);
}

/* Bottom Controls Dock (Zoom Pill) */
.scanner-hud-bottom {
  position: absolute;
  bottom: max(32px, env(safe-area-inset-bottom, 32px));
  z-index: 30;
  display: flex;
  justify-content: center;
  width: 100%;
  pointer-events: none;
}

.zoom-dock-pill {
  display: flex;
  gap: 4px;
  background: rgba(23, 29, 25, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 4px 6px;
  border-radius: 9999px;
  border: 1px solid rgba(191, 201, 193, 0.22);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  pointer-events: auto;
}

.btn-zoom-opt {
  width: 46px;
  height: 38px;
  border-radius: 9999px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13.5px;
  font-weight: 700;
  font-family: 'Quicksand', sans-serif;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-zoom-opt.active {
  background-color: var(--md-sys-color-primary, #206A4D);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(32, 106, 77, 0.4);
}

/* ==========================================================================
 * SUCCESS CELEBRATION & ERROR DIALOGS
 * ========================================================================== */
.scrim-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  background-color: rgba(15, 21, 17, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.2, 0, 0, 1);
}

.scrim-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.scrim-backdrop.visible .success-card {
  transform: scale(1);
}

#stage-success {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  background-color: rgba(15, 21, 17, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.2, 0, 0, 1);
}

#stage-success.active {
  opacity: 1;
  pointer-events: auto;
}

.success-card {
  width: 100%;
  max-width: 390px;
  background-color: var(--md-sys-color-surface-container-lowest, #FFFFFF);
  border-radius: 32px;
  border: 1px solid var(--md-sys-color-outline-variant, #BFC9C1);
  padding: 28px 24px 20px;
  box-shadow: 0 20px 48px -8px rgba(0, 0, 0, 0.24);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transform: scale(0.92);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#stage-success.active .success-card {
  transform: scale(1);
}

.success-badge-circle {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background-color: var(--md-sys-color-primary-container, #A9F2CD);
  color: var(--md-sys-color-on-primary-container, #002114);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  box-shadow: 0 4px 16px rgba(32, 106, 77, 0.2);
  animation: pulseSuccess 2s infinite alternate ease-in-out;
}

@keyframes pulseSuccess {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(169, 242, 205, 0.6); }
  100% { transform: scale(1.04); box-shadow: 0 0 0 14px rgba(169, 242, 205, 0); }
}

.success-badge-circle .material-symbols-rounded {
  font-size: 40px;
}

.success-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--md-sys-color-primary, #206A4D);
  margin-bottom: 4px;
}

.success-subtitle {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant, #404943);
  margin-bottom: 18px;
}

/* Info Table */
.success-info-table {
  width: 100%;
  background-color: var(--md-sys-color-surface-container-low, #EFF5EF);
  border-radius: 20px;
  padding: 12px 16px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
}

.info-label {
  font-weight: 600;
  color: var(--md-sys-color-outline, #707973);
}

.info-value {
  font-weight: 700;
  color: var(--md-sys-color-on-surface, #171D19);
}

.info-value.highlight {
  color: var(--md-sys-color-primary, #206A4D);
}

.verified-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 9999px;
  background-color: var(--md-sys-color-primary-container, #A9F2CD);
  color: var(--md-sys-color-on-primary-container, #002114);
  font-size: 11.5px;
  font-weight: 800;
}
