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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.container {
  max-width: 800px;
  width: 100%;
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 30px;
  text-align: center;
}

header h1 {
  font-size: 2rem;
  margin-bottom: 15px;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 15px;
  flex-wrap: wrap;
  gap: 10px;
}

.button-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.status {
  background: rgba(255, 255, 255, 0.2);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.9rem;
}

main {
  padding: 30px;
  min-height: 400px;
}

.mode {
  display: none;
}

.mode.active {
  display: block;
}

.video-container {
  position: relative;
  width: 100%;
  max-width: 640px;
  margin: 0 auto 30px;
  border-radius: 15px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

video {
  width: 100%;
  height: auto;
  display: block;
}

canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.detection-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  padding: 20px 30px;
  border-radius: 10px;
  text-align: center;
  min-width: 250px;
}

.detection-overlay.hidden {
  display: none;
}

.confidence-bar {
  width: 200px;
  height: 8px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}

.confidence-progress {
  height: 100%;
  background: linear-gradient(90deg, #4ade80, #22c55e);
  width: 0%;
  transition: width 0.1s ease;
}

.detection-text {
  color: white;
  font-size: 0.9rem;
  margin: 0 0 5px 0;
}

.live-confidence {
  color: #fbbf24;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0;
}

.confidence-indicator {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.75);
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  backdrop-filter: blur(5px);
  z-index: 10;
  display: none;
}

.confidence-indicator.visible {
  display: block;
}

.confidence-indicator.excellent {
  color: #22c55e;
}

.confidence-indicator.good {
  color: #4ade80;
}

.confidence-indicator.fair {
  color: #fbbf24;
}

.confidence-indicator.low {
  color: #f87171;
}

.recognition-panel,
.unknown-panel {
  background: #f8fafc;
  padding: 30px;
  border-radius: 15px;
  text-align: center;
}

.recognition-panel.hidden,
.unknown-panel.hidden {
  display: none;
}

.employee-info h2 {
  color: #334155;
  margin-bottom: 20px;
}

.employee-details {
  margin-bottom: 25px;
}

.employee-name {
  font-size: 1.5rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 5px;
}

.employee-id {
  color: #64748b;
  margin-bottom: 5px;
}

.confidence {
  color: #16a34a;
  font-weight: 500;
}

.action-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-bottom: 15px;
}

.action-btn {
  padding: 15px 40px;
  font-size: 1.1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  flex: 1;
  max-width: 200px;
}

.signin-btn {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
}

.signin-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(34, 197, 94, 0.4);
}

.signout-btn {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
}

.signout-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(239, 68, 68, 0.4);
}

.secondary-btn {
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.5);
  color: white;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.3s ease;
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.4);
}

.timeout-text {
  color: #64748b;
  font-size: 0.9rem;
}

#countdown {
  font-weight: 600;
  color: #ef4444;
}

.unknown-info {
  margin-bottom: 20px;
}

.unknown-info h2 {
  color: #dc2626;
  margin-bottom: 10px;
}

.unknown-info p {
  color: #64748b;
}

/* Registration Mode */
.registration-container {
  max-width: 600px;
  margin: 0 auto;
}

.registration-container h2 {
  text-align: center;
  color: #1e293b;
  margin-bottom: 25px;
}

.captured-photo-preview {
  text-align: center;
  margin-top: 20px;
}

.captured-photo-preview.hidden {
  display: none;
}

.captured-photo-preview h3 {
  color: #22c55e;
  margin-bottom: 15px;
  font-size: 1.3rem;
}

.preview-image-container {
  width: 100%;
  max-width: 400px;
  margin: 0 auto 15px;
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  background: #000;
}

.preview-image-container img {
  width: 100%;
  height: auto;
  display: block;
}

.detection-confidence {
  color: #16a34a;
  font-weight: 600;
  font-size: 1.1rem;
  margin: 10px 0;
}

.detection-confidence.excellent {
  color: #16a34a;
}

.detection-confidence.good {
  color: #22c55e;
}

.detection-confidence.fair {
  color: #eab308;
}

.preview-instruction {
  color: #64748b;
  font-size: 0.95rem;
  margin-bottom: 15px;
}

.registration-form {
  background: #f8fafc;
  padding: 30px;
  border-radius: 15px;
  margin-top: 20px;
}

.registration-form.hidden {
  display: none;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  color: #334155;
  font-weight: 600;
  margin-bottom: 8px;
}

.form-group input {
  width: 100%;
  padding: 12px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.3s ease;
}

.form-group input:focus {
  outline: none;
  border-color: #667eea;
}

.form-actions {
  display: flex;
  gap: 15px;
  margin-top: 25px;
}

.form-actions .action-btn {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  max-width: none;
}

.form-actions .action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.form-actions .secondary-btn {
  flex: 1;
  background: #e2e8f0;
  color: #475569;
  border: none;
}

.form-actions .secondary-btn:hover {
  background: #cbd5e1;
}

.cancel-btn {
  display: block;
  margin: 20px auto 0;
  background: #e2e8f0;
  color: #475569;
  border: none;
}

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

/* Messages */
.message-box {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  padding: 20px 30px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  max-width: 90%;
  animation: slideDown 0.3s ease;
}

.message-box.hidden {
  display: none;
}

.message-box.success {
  border-left: 5px solid #22c55e;
}

.message-box.error {
  border-left: 5px solid #ef4444;
}

.message-box.info {
  border-left: 5px solid #3b82f6;
}

@keyframes slideDown {
  from {
    transform: translate(-50%, -100%);
    opacity: 0;
  }
  to {
    transform: translateX(-50%);
    opacity: 1;
  }
}

footer {
  background: #f1f5f9;
  padding: 20px;
  text-align: center;
  color: #64748b;
  font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .container {
    border-radius: 15px;
  }

  header {
    padding: 20px;
  }

  header h1 {
    font-size: 1.5rem;
  }

  main {
    padding: 20px;
  }

  .action-buttons {
    flex-direction: column;
  }

  .action-btn {
    max-width: none;
    width: 100%;
  }

  .form-actions {
    flex-direction: column;
  }

  .status-bar {
    flex-direction: column;
    text-align: center;
  }

  .status-bar .secondary-btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  header h1 {
    font-size: 1.3rem;
  }

  .employee-name {
    font-size: 1.2rem;
  }

  .detection-overlay {
    padding: 15px 20px;
    min-width: 200px;
  }

  .confidence-bar {
    width: 150px;
  }
}
