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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #e8f4f8 0%, #d1e7f0 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.container {
  width: 100%;
  max-width: 700px;
}

header {
  text-align: center;
  color: #1a5f7a;
  margin-bottom: 40px;
}

header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  font-weight: 700;
}

header p {
  font-size: 1.1rem;
  opacity: 0.8;
}

main {
  background: white;
  border-radius: 15px;
  padding: 40px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

/* TABS */
.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 30px;
  border-bottom: 2px solid #e0e8f0;
}

.tab-btn {
  padding: 12px 20px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  color: #7a9fb5;
  transition: all 0.3s;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}

.tab-btn.active {
  color: #1a5f7a;
  border-bottom-color: #1a5f7a;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

label {
  display: block;
  margin-bottom: 8px;
  color: #2c5f7f;
  font-weight: 600;
}

input[type="text"] {
  width: 100%;
  padding: 12px;
  border: 2px solid #d1e7f0;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.3s;
}

input[type="text"]:focus {
  outline: none;
  border-color: #3a8fb8;
  box-shadow: 0 0 0 3px rgba(58, 143, 184, 0.1);
}

.btn-validate {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #3a8fb8 0%, #2c6f96 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
}

.btn-validate:hover {
  transform: translateY(-2px);
}

.info-box {
  background: #e8f4f8;
  color: #1a5f7a;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 15px;
  font-size: 0.9rem;
  border-left: 4px solid #3a8fb8;
}

/* CAMERA */
.camera-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.btn-camera {
  flex: 1;
  padding: 10px;
  background: #3a8fb8;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.3s;
  font-size: 0.95rem;
}

.btn-camera:hover {
  background: #2c6f96;
}

.btn-camera.stop {
  background: #c85a54;
}

.btn-camera.stop:hover {
  background: #a84742;
}

#videoContainer {
  display: none;
  margin-bottom: 15px;
}

#video {
  width: 100%;
  height: 400px;
  background: #000;
  border-radius: 8px;
  display: block;
}

#canvas {
  display: none;
}

.error-message {
  background: #fce4ec;
  color: #880e4f;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 15px;
  border-left: 4px solid #c2185b;
}

.success-message {
  background: #e8f5e9;
  color: #1b5e20;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 15px;
  border-left: 4px solid #4caf50;
}

/* ============================
   VALIDATION BADGE (Animated)
   ============================ */
.validation-badge {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  margin-top: 30px;
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border: 2px solid #6ee7b7;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.15);
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.validation-badge.show {
  transform: translateY(0);
  opacity: 1;
}

.badge-icon {
  flex-shrink: 0;
  animation: pulseIcon 2s ease-in-out infinite;
}

@keyframes pulseIcon {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.badge-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.badge-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #065f46;
  letter-spacing: -0.02em;
}

.badge-subtitle {
  font-size: 0.9rem;
  color: #047857;
  opacity: 0.85;
}

/* ============================
   CERTIFICATE PREVIEW
   ============================ */
.certificate-preview-section {
  margin-top: 24px;
  animation: slideUp 0.5s ease-out 0.3s both;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.preview-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1a5f7a;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
}

.certificate-preview-wrapper {
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid #d1e7f0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  background: #f8fafc;
}

.certificate-iframe {
  width: 100%;
  height: 420px;
  border: none;
  display: block;
}

/* STATUS BOX */
.status-box {
  padding: 20px;
  border-radius: 10px;
  margin-top: 30px;
  text-align: center;
}

.status-box.success {
  background: #e8f5e9;
  border-left: 5px solid #4caf50;
}

.status-box.error {
  background: linear-gradient(135deg, #fef2f2 0%, #fce4ec 100%);
  border: 2px solid #fca5a5;
  border-radius: 16px;
  border-left: none;
  padding: 28px 24px;
  animation: slideUp 0.5s ease-out both;
}

.error-icon {
  margin-bottom: 12px;
}

.status-box h2 {
  margin-bottom: 10px;
  font-size: 1.3rem;
}

.status-box.success h2 {
  color: #1b5e20;
}

.status-box.error h2 {
  color: #991b1b;
}

.status-box.error p {
  color: #b91c1c;
  font-size: 0.95rem;
}

/* SERTIFIKAT DETAILS */
.sertifikat-details {
  background: linear-gradient(135deg, #f0f9ff 0%, #f5f9fc 100%);
  border-radius: 12px;
  padding: 20px;
  margin-top: 20px;
  border: 1px solid #e0f2fe;
  animation: slideUp 0.5s ease-out 0.4s both;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid #d1e7f0;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  font-weight: 600;
  color: #4a7c99;
}

.detail-value {
  color: #2c5f7f;
  text-align: right;
  font-weight: 500;
}

/* DOWNLOAD BUTTON */
.btn-download {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-top: 20px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
  animation: slideUp 0.5s ease-out 0.6s both;
}

.btn-download:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 25px rgba(16, 185, 129, 0.4);
}

.btn-download:active {
  transform: translateY(-1px);
}

.admin-link {
  text-align: right;
  margin-top: 20px;
}

.admin-link a {
  color: #3a8fb8;
  text-decoration: none;
  font-size: 0.9rem;
}

.admin-link a:hover {
  text-decoration: underline;
}

footer {
  text-align: center;
  color: #1a5f7a;
  margin-top: 40px;
  font-size: 0.9rem;
  opacity: 0.8;
}

/* RESPONSIVE */
@media (max-width: 768px) {
  header h1 {
    font-size: 1.8rem;
  }

  main {
    padding: 25px;
  }

  .tabs {
    flex-direction: column;
  }

  .tab-btn {
    border-bottom: none;
    border-left: 3px solid transparent;
    margin-bottom: 0;
    padding-left: 15px;
  }

  .tab-btn.active {
    border-left-color: #1a5f7a;
    border-bottom-color: transparent;
  }

  .detail-row {
    flex-direction: column;
    gap: 5px;
  }

  .detail-value {
    text-align: left;
  }

  #video {
    height: 300px;
  }

  .certificate-iframe {
    height: 300px;
  }

  .validation-badge {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }
}

@media (max-width: 480px) {
  body {
    padding: 10px;
  }

  header h1 {
    font-size: 1.5rem;
  }

  main {
    padding: 15px;
    border-radius: 10px;
  }

  .sertifikat-details {
    padding: 15px;
  }

  .detail-row {
    padding: 10px 0;
  }

  .certificate-iframe {
    height: 250px;
  }
}
