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

html,
body {
  height: 100%;
}

body {
  font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, #f5f7fa 0%, #e8eef5 100%);
  color: #333;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
  position: relative;
}

.app-header {
  background: linear-gradient(135deg, #283b41 20%, #0097b9 200%);
  padding: 15px 20px;
  height: 60px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.652);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.header-logo {
  height: 50px;
  width: auto;
  object-fit: contain;
  position: absolute;
  left: 20px;
}

.toast-container {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: #ed224b;
  color: white;
  padding: 16px 24px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  font-size: 16px;
  font-weight: 500;
  text-align: center;
  min-width: 280px;
  max-width: 90vw;
  animation: slideDown 0.3s ease-out;
  pointer-events: auto;
}

.toast.hiding {
  animation: slideUp 0.3s ease-out forwards;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: transparent;
  transition: background-color 0.3s ease;
}

.container.scanner-active {
  background: #000000;
}

.home-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.5s ease-out;
}

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

.home-card {
  background: #ffffff;
  border-radius: 24px;
  padding: 48px 32px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: scaleIn 0.4s ease-out;
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.camera-icon-wrapper {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, #283b41 0%, #0097b9 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  box-shadow: 0 8px 24px rgba(30, 136, 229, 0.3);
  animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%,
  100% {
    box-shadow: 0 8px 24px rgba(30, 136, 229, 0.3);
  }
  50% {
    box-shadow: 0 8px 32px rgba(30, 136, 229, 0.5);
  }
}

.camera-icon {
  color: #ffffff;
  width: 48px;
  height: 48px;
}

.home-title {
  font-size: 32px;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 16px;
  letter-spacing: -0.5px;
}

.home-description {
  font-size: 16px;
  color: #6b7280;
  line-height: 1.6;
  margin-bottom: 32px;
  max-width: 360px;
}

.home-description a {
  color: #0097b9;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.3s ease;
  border-bottom: 2px solid transparent;
}

.start-button {
  background: linear-gradient(135deg, #ed224b 0%, #c91d3f 100%);
  color: #ffffff;
  border: none;
  border-radius: 16px;
  padding: 18px 48px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 16px rgba(237, 34, 75, 0.3);
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  width: 100%;
  max-width: 280px;
}

.start-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(237, 34, 75, 0.4);
}

.start-button:active {
  transform: translateY(0);
}

.button-icon {
  width: 20px;
  height: 20px;
}

.home-footer {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid #e5e7eb;
  font-size: 12px;
  color: #9ca3af;
  width: 100%;
}

.action-button-container {
  display: none !important;
}

.scanner-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  background: #000000;
}

.close-scanner-button {
  position: absolute;
  top: 76px;
  right: 20px;
  width: 44px;
  height: 44px;
  background: rgba(40, 59, 65, 0.8);
  color: white;
  border-radius: 50%;
  font-size: 24px;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: all 0.3s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.652);
  border: none;
}

.close-scanner-button:hover {
  background: rgba(40, 59, 65, 0.95);
}

.close-scanner-button:active {
  transform: scale(0.95);
}

.video-container {
  flex: 1;
  width: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000;
}

#qrVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 280px;
  height: 280px;
  border: 4px dashed rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  pointer-events: none;
  z-index: 99;
  box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.3);
}

.scan-overlay-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 120;
  color: white;
  font-size: 26px;
  text-shadow: #000000 0px 0px 6px;
}
.camera-controls {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.camera-label {
  color: white;
  font-size: 16px;
  font-weight: 500;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.camera-select {
  background: rgba(40, 59, 65, 0.95);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  padding: 12px 44px 12px 20px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  min-width: 220px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  transition: all 0.3s ease;
  font-family: "Open Sans", sans-serif;
}

.camera-select:hover {
  border-color: rgba(255, 255, 255, 0.6);
  background-color: rgba(40, 59, 65, 1);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.camera-select:focus {
  outline: none;
  border-color: #0097b9;
  box-shadow: 0 0 0 3px rgba(0, 151, 185, 0.3);
}

.camera-select option {
  background: #283b41;
  color: white;
  padding: 12px;
  font-size: 15px;
  font-weight: 500;
}

.result-screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.405);
  flex-direction: column;
  padding: 16px;
  padding-bottom: 20px;
  justify-content: flex-start;
}

.result-screen.show .content-text {
  animation: fadeInUp 0.5s ease-out forwards;
}

.result-screen.show .language-selector {
  animation: fadeInUp 0.6s ease-out 0.2s forwards;
  opacity: 0;
}

.result-screen.show .result-action-button-container {
  animation: fadeInUp 0.6s ease-out 0.3s forwards;
  opacity: 0;
}

.result-screen.show .lang-button:nth-child(1) {
  animation: scaleInButton 0.4s ease-out 0.3s forwards;
  opacity: 0;
}

.result-screen.show .lang-button:nth-child(2) {
  animation: scaleInButton 0.4s ease-out 0.4s forwards;
  opacity: 0;
}

.result-screen.show .lang-button:nth-child(3) {
  animation: scaleInButton 0.4s ease-out 0.5s forwards;
  opacity: 0;
}

.result-screen.hiding {
  animation: fadeOut 0.5s ease-out forwards;
}

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

@keyframes scaleInButton {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.language-selector {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 30px;
  margin-bottom: 0;
  margin-top: 10px;
  background: transparent;
  box-shadow: none;
  padding-bottom: 10px;
  position: relative;
  z-index: 260;
}

.result-action-button-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px 0;
}

.action-button {
  background: #ed224b;
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 14px 28px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 200px;
}

.action-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.action-button:active {
  transform: translateY(0);
}

.lang-button {
  background: transparent;
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 10px 18px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 24px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}

.lang-button:hover {
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.1);
}

.lang-button.active {
  border-color: #ffffff;
  background: rgba(192, 190, 191, 0.601);
}

.flag {
  font-size: 26px;
}

.content-display {
  background: transparent;
  box-shadow: none;
  margin: 80px 20px 20px 20px;
  padding-top: 20px;
  padding-bottom: 100px;
  padding-right: 20px;
  text-align: left;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
  mask-image: linear-gradient(to bottom, black 0%, black 85%, transparent 100%);
  -webkit-mask-image: linear-gradient(
    to bottom,
    black 0%,
    black 75%,
    transparent 100%
  );
}

.content-display::-webkit-scrollbar {
  width: 8px;
  display: block;
}

.content-display::-webkit-scrollbar-track {
  background: transparent;
  margin-right: 26px;
}

.content-display::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  margin-right: 26px;
}

.content-text {
  color: rgba(255, 255, 255, 0.92);
  font-size: clamp(24px, 4.5vw, 34px);
  font-family: "Poppins", sans-serif;
  line-height: 1.6;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.35), 0 4px 8px rgba(0, 0, 0, 0.361);
  padding-top: 20px;
  padding-bottom: 20px;
  margin: auto 0;
  white-space: pre-wrap;
  opacity: 0;
  transform: translateY(30px);
}

.content-text p {
  margin-bottom: 1.5em;
}

.content-text p:last-child {
  margin-bottom: 0;
}

.camera-error-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0, 0, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  padding: 20px;
}

.camera-error-content {
  background: #283b41;
  border-radius: 16px;
  padding: 40px 30px;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.error-icon {
  font-size: 64px;
  margin-bottom: 20px;
  opacity: 0.8;
}

.camera-error-content h3 {
  color: #ffffff;
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 16px;
}

.camera-error-content p {
  color: rgba(255, 255, 255, 0.85);
  font-size: 16px;
  line-height: 1.5;
  margin-bottom: 12px;
}

.retry-camera-button,
.cancel-camera-button {
  background: #ed224b;
  color: white;
  border: none;
  border-radius: 12px;
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  margin: 8px;
  min-width: 180px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.retry-camera-button:hover {
  background: #d41d42;
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.cancel-camera-button {
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.cancel-camera-button:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
}

.retry-camera-button:active,
.cancel-camera-button:active {
  transform: translateY(0);
}

.error-message {
  display: none;
}

.permission-steps {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
  text-align: left;
}

.permission-steps p {
  margin: 8px 0;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.9);
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 6px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

@media (max-width: 600px) {
  .home-card {
    padding: 40px 24px;
  }

  .home-title {
    font-size: 28px;
  }

  .camera-icon-wrapper {
    width: 80px;
    height: 80px;
  }

  .camera-icon {
    width: 40px;
    height: 40px;
  }
}
