/* 
 * ATTENDANCE FACE RECOGNITION - MAIN STYLESHEET
 * Modern Mobile-First Glassmorphism & Cyber-Biometric Design
 */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-primary: #0b0f19;
  --bg-surface: rgba(18, 26, 43, 0.85);
  --bg-surface-elevated: rgba(28, 39, 65, 0.75);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(56, 189, 248, 0.35);

  --accent-cyan: #38bdf8;
  --accent-blue: #3b82f6;
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.4);
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-violet: #8b5cf6;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  --shadow-glow-cyan: 0 0 25px rgba(56, 189, 248, 0.25);
  --shadow-glow-emerald: 0 0 25px rgba(16, 185, 129, 0.3);
  --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.5);

  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(56, 189, 248, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(139, 92, 246, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.04) 0%, transparent 50%);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* APP HEADER */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow-cyan);
}

.brand-icon svg {
  width: 24px;
  height: 24px;
  color: #fff;
}

.brand-info h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-info p {
  font-size: 0.72rem;
  color: var(--accent-cyan);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.clock-display {
  text-align: right;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
}

.clock-display .time {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}

.clock-display .date {
  font-size: 0.65rem;
  color: var(--text-secondary);
}

.btn-admin {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-admin:hover, .btn-admin:active {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

/* MAIN CONTAINER */
.main-container {
  flex: 1;
  max-width: 540px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem 1rem 2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* SYSTEM STATUS STRIP */
.status-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.9rem;
  font-size: 0.75rem;
  backdrop-filter: blur(12px);
}

.status-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background-color: var(--text-muted);
}

.status-dot.active {
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse-dot 2s infinite;
}

.status-dot.warning {
  background-color: var(--accent-amber);
  box-shadow: 0 0 8px var(--accent-amber);
}

.status-dot.error {
  background-color: var(--accent-rose);
  box-shadow: 0 0 8px var(--accent-rose);
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* SCANNER CARD */
.scanner-card {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
}

/* CAMERA VIEWPORT */
.camera-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 4/5;
  background: #000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#video-feed {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Mirror view for front camera */
  transition: transform 0.3s ease;
}

#video-feed.rear-cam {
  transform: scaleX(1);
}

#overlay-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

/* BIOMETRIC OVAL GUIDE */
.biometric-guide {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 230px;
  height: 290px;
  border-radius: 50%;
  border: 2px dashed rgba(56, 189, 248, 0.4);
  box-shadow: 0 0 0 9999px rgba(11, 15, 25, 0.55);
  pointer-events: none;
  z-index: 15;
  transition: all 0.3s ease;
}

.biometric-guide.matched {
  border-color: var(--accent-emerald);
  border-style: solid;
  border-width: 3px;
  box-shadow: 0 0 35px var(--accent-emerald-glow), 0 0 0 9999px rgba(11, 15, 25, 0.4);
}

/* SCANNING LASER BEAM */
.scanner-laser {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-cyan), #fff, var(--accent-cyan), transparent);
  box-shadow: 0 0 15px var(--accent-cyan), 0 0 25px var(--accent-blue);
  z-index: 16;
  opacity: 0.85;
  animation: laser-sweep 2.4s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate;
  pointer-events: none;
}

.scanner-laser.matched {
  background: linear-gradient(90deg, transparent, var(--accent-emerald), #fff, var(--accent-emerald), transparent);
  box-shadow: 0 0 15px var(--accent-emerald);
  animation-duration: 1.2s;
}

@keyframes laser-sweep {
  0% { top: 12%; opacity: 0.3; }
  50% { opacity: 0.95; }
  100% { top: 88%; opacity: 0.3; }
}

/* CORNER ACCENTS */
.corner-bracket {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--accent-cyan);
  border-style: solid;
  pointer-events: none;
  z-index: 18;
}

.corner-tl { top: 18%; left: 18%; border-width: 3px 0 0 3px; border-top-left-radius: 8px; }
.corner-tr { top: 18%; right: 18%; border-width: 3px 3px 0 0; border-top-right-radius: 8px; }
.corner-bl { bottom: 18%; left: 18%; border-width: 0 0 3px 3px; border-bottom-left-radius: 8px; }
.corner-br { bottom: 18%; right: 18%; border-width: 0 3px 3px 0; border-bottom-right-radius: 8px; }

/* FLOATING CAMERA CONTROLS */
.camera-controls {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 25;
}

.btn-icon-control {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--border-subtle);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.2s ease;
}

.btn-icon-control:hover, .btn-icon-control:active {
  background: var(--accent-cyan);
  color: #000;
  transform: scale(1.08);
}

.btn-icon-control svg {
  width: 20px;
  height: 20px;
}

/* SCANNER FOOTER & LIVE STATUS */
.scanner-footer {
  padding: 1rem 1.25rem;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.live-prompt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.live-prompt svg {
  width: 18px;
  height: 18px;
  color: var(--accent-cyan);
}

/* EMPLOYEE MATCH DETECTED CARD (IN SCANNER) */
.detected-card {
  display: none;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: var(--radius-lg);
  padding: 0.9rem;
  align-items: center;
  gap: 0.85rem;
  animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.detected-card.active {
  display: flex;
}

.detected-avatar {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 2px solid var(--accent-emerald);
}

.detected-details {
  flex: 1;
  min-width: 0;
}

.detected-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detected-sub {
  font-size: 0.75rem;
  color: var(--accent-emerald);
  font-weight: 600;
}

.detected-dept {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* BUTTON ACTION GROUP */
.attendance-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.btn-clock {
  padding: 0.9rem 1rem;
  border-radius: var(--radius-md);
  border: none;
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-clock:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(1);
}

.btn-clock-in {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-clock-in:hover:not(:disabled), .btn-clock-in:active:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
}

.btn-clock-out {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.btn-clock-out:hover:not(:disabled), .btn-clock-out:active:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.45);
}

.btn-clock svg {
  width: 20px;
  height: 20px;
}

/* TODAY'S RECENT ATTENDANCE TICKER */
.today-summary-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1rem;
  backdrop-filter: blur(12px);
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.section-title h2 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.badge-counter {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.recent-list::-webkit-scrollbar {
  width: 4px;
}
.recent-list::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 4px;
}

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

.recent-emp-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.recent-thumb {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: rgba(255, 255, 255, 0.05);
}

.recent-name {
  font-weight: 600;
  color: #fff;
}

.recent-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.status-badge {
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status-badge.on_time {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.late {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

/* SUCCESS MODAL POPUP */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(3, 7, 18, 0.8);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay.active {
  display: flex;
  animation: fade-in 0.2s ease forwards;
}

.modal-content {
  background: #111827;
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: var(--shadow-glow-cyan);
  animation: scale-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-icon-wrap {
  width: 70px;
  height: 70px;
  margin: 0 auto 1.25rem;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.15);
  border: 2px solid var(--accent-emerald);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-emerald);
  box-shadow: 0 0 20px var(--accent-emerald-glow);
}

.modal-icon-wrap.error {
  background: rgba(244, 63, 94, 0.15);
  border-color: var(--accent-rose);
  color: var(--accent-rose);
  box-shadow: 0 0 20px rgba(244, 63, 94, 0.3);
}

.modal-icon-wrap svg {
  width: 38px;
  height: 38px;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  color: #fff;
}

.modal-message {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  line-height: 1.4;
}

.modal-attendance-details {
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  margin-bottom: 1.25rem;
  text-align: left;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.modal-detail-row {
  display: flex;
  justify-content: space-between;
}

.modal-detail-row span:first-child {
  color: var(--text-muted);
}
.modal-detail-row span:last-child {
  font-weight: 600;
  color: #fff;
}

.btn-modal-close {
  width: 100%;
  padding: 0.8rem;
  border-radius: var(--radius-md);
  background: var(--accent-cyan);
  color: #0b0f19;
  border: none;
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-modal-close:hover {
  background: #7dd3fc;
}

/* TOAST NOTIFICATION */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  width: 90%;
  max-width: 400px;
}

.toast {
  background: rgba(17, 24, 39, 0.95);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  backdrop-filter: blur(10px);
  animation: toast-in 0.3s ease forwards;
}

.toast.success { border-color: var(--accent-emerald); }
.toast.error { border-color: var(--accent-rose); }
.toast.info { border-color: var(--accent-cyan); }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes scale-in { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
@keyframes slide-up { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* RESPONSIVE DESKTOP ENHANCEMENT */
@media (min-width: 768px) {
  .main-container {
    max-width: 800px;
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    align-items: start;
    padding-top: 2rem;
  }
  .scanner-card {
    grid-column: 1;
  }
  .side-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    grid-column: 2;
  }
}
