/* Reset và font */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(135deg, #e0e7ff 0%, #f3e8ff 100%);
  -webkit-animation: gradientBG 10s ease infinite;
  animation: gradientBG 10s ease infinite;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  overflow-x: hidden;
}

/* Gradient background */
@-webkit-keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.container {
  background: rgba(255, 255, 255, 0.95);
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  max-width: 550px;
  width: 100%;
  text-align: center;
  overflow: hidden;
  -webkit-animation: fadeIn 0.8s ease-in-out;
  animation: fadeIn 0.8s ease-in-out;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

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

h1 {
  font-size: 28px;
  color: #1f2a44;
  margin-bottom: 30px;
  font-weight: 700;
  letter-spacing: -0.5px;
  text-transform: uppercase;
  background: linear-gradient(90deg, #6366f1, #a855f7);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-fill-color: transparent;
  -webkit-animation: glow 2s ease-in-out infinite alternate;
  animation: glow 2s ease-in-out infinite alternate;
}

@-webkit-keyframes glow {
  from { -webkit-text-shadow: 0 0 5px rgba(99, 102, 241, 0.3); text-shadow: 0 0 5px rgba(99, 102, 241, 0.3); }
  to { -webkit-text-shadow: 0 0 10px rgba(99, 102, 241, 0.6); text-shadow: 0 0 10px rgba(99, 102, 241, 0.6); }
}
@keyframes glow {
  from { text-shadow: 0 0 5px rgba(99, 102, 241, 0.3); }
  to { text-shadow: 0 0 10px rgba(99, 102, 241, 0.6); }
}

/* Form */
#qrForm {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

input, select {
  padding: 14px;
  font-size: 16px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  outline: none;
  background: #f8fafc;
  transition: all 0.3s ease;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

input:focus, select:focus {
  border-color: #6366f1;
  background: #fff;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.3), inset 0 2px 4px rgba(0, 0, 0, 0.05);
  -webkit-transform: scale(1.02);
  transform: scale(1.02);
}

input::placeholder { color: #94a3b8; }

/* Custom select */
.custom-select {
  position: relative;
  user-select: none;
  transition: all 0.3s ease;
}

.select-selected {
  background: #f8fafc;
  padding: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  font-size: 16px;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.3s ease;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
  min-height: 48px;
}

.select-selected.search-mode {
  padding: 0;
}

.select-selected input.search-bank {
  width: 100%;
  height: 100%;
  padding: 14px;
  font-size: 16px;
  border: none;
  border-radius: 12px;
  background: #f8fafc;
  outline: none;
  transition: all 0.3s ease;
}

.select-selected input.search-bank:focus {
  background: #fff;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.3);
}

.select-selected::after {
  content: '▼';
  position: absolute;
  right: 15px;
  transition: -webkit-transform 0.3s ease, transform 0.3s ease;
  font-size: 12px;
}

.select-selected:hover {
  background-color: #f1f5f9;
  -webkit-transform: translateY(-2px);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.select-selected:hover::after {
  -webkit-transform: rotate(180deg);
  transform: rotate(180deg);
}

.select-items {
  position: absolute;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 99;
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  opacity: 0;
  -webkit-transform: translateY(-10px);
  transform: translateY(-10px);
  transition: all 0.3s ease;
  pointer-events: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.select-items.show {
  opacity: 1;
  -webkit-transform: translateY(0);
  transform: translateY(0);
  pointer-events: all;
  -webkit-animation: slideDown 0.3s ease-out;
  animation: slideDown 0.3s ease-out;
}

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

.select-items div {
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 16px;
}

.select-items div:hover {
  background: #f1f5f9;
  color: #6366f1;
  -webkit-transform: translateX(5px);
  transform: translateX(5px);
}

.select-items img, .select-selected img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

/* Button */
button {
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(90deg, #6366f1, #a855f7);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
  position: relative;
  overflow: hidden;
}

button::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
  -webkit-transform: scale(0);
  transform: scale(0);
  transition: -webkit-transform 0.5s ease, transform 0.5s ease;
  z-index: 1;
}

button:hover::before {
  -webkit-transform: scale(1);
  transform: scale(1);
  -webkit-animation: sparkle 1.5s ease-out;
  animation: sparkle 1.5s ease-out;
}

@-webkit-keyframes sparkle {
  0% { -webkit-transform: scale(0); transform: scale(0); }
  50% { -webkit-transform: scale(1.5); transform: scale(1.5); }
  100% { -webkit-transform: scale(0); transform: scale(0); }
}
@keyframes sparkle {
  0% { transform: scale(0); }
  50% { transform: scale(1.5); }
  100% { transform: scale(0); }
}

button:hover {
  -webkit-transform: translateY(-3px) scale(1.02);
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

button:active {
  -webkit-transform: translateY(0) scale(0.98);
  transform: translateY(0) scale(0.98);
}

#qrCode {
  margin-top: 25px;
  padding: 15px;
  background: linear-gradient(135deg, #f1f5f9, #e0e7ff);
  border-radius: 15px;
  display: flex;
  justify-content: center;
}

#qrCode img, #qrCode svg {
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  max-width: 100%;
  transition: all 0.3s ease;
}

#qrCode img.qr-small, #qrCode svg.qr-small { width: 150px; }
#qrCode img.qr-medium, #qrCode svg.qr-medium { width: 250px; }
#qrCode img.qr-large, #qrCode svg.qr-large { width: 350px; }

#qrCode img:hover, #qrCode svg:hover {
  -webkit-transform: scale(1.05);
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.2);
}

/* Payment Preview */
#paymentPreview {
  margin-top: 20px;
  padding: 15px;
  background: #f8fafc;
  border-radius: 12px;
  text-align: left;
  border: 1px solid #e2e8f0;
}

#paymentPreview p {
  font-size: 15px;
  margin: 5px 0;
  color: #1f2a44;
}

/* History and Templates Section */
#qrHistory, #templates {
  margin-top: 20px;
  padding: 15px;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

#qrHistory h3, #templates h3 {
  font-size: 18px;
  color: #1f2a44;
  margin-bottom: 10px;
}

#qrHistoryList, #templateList {
  max-height: 200px;
  overflow-y: auto;
}

.history-item, .template-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid #e2e8f0;
  cursor: pointer;
}

.history-item img, .template-item img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.history-item:hover, .template-item:hover {
  background: #f1f5f9;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: #4f46e5;
  color: white;
  padding: 16px 24px;
  border-radius: 10px;
  font-size: 15px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  opacity: 0;
  -webkit-transform: translateY(50px);
  transform: translateY(50px);
  transition: all 0.5s ease;
  z-index: 9999;
}

.toast.show {
  opacity: 1;
  -webkit-transform: translateY(0);
  transform: translateY(0);
  -webkit-animation: bounceIn 0.5s ease-out forwards;
  animation: bounceIn 0.5s ease-out forwards;
}

@-webkit-keyframes bounceIn {
  0% { -webkit-transform: translateY(50px) scale(0.9); transform: translateY(50px) scale(0.9); opacity: 0; }
  50% { -webkit-transform: translateY(-10px) scale(1.1); transform: translateY(-10px) scale(1.1); }
  100% { -webkit-transform: translateY(0) scale(1); transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes bounceIn {
  0% { transform: translateY(50px) scale(0.9); opacity: 0; }
  50% { transform: translateY(-10px) scale(1.1); }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* Modal for QR Scanning */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

.modal-content {
  background: white;
  padding: 20px;
  border-radius: 15px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  -webkit-animation: slideDown 0.3s ease-out;
  animation: slideDown 0.3s ease-out;
}

.close {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 24px;
  cursor: pointer;
  color: #1f2a44;
}

#qrVideo {
  width: 100%;
  max-width: 300px;
  border-radius: 10px;
  margin: 15px 0;
  border: 2px solid #6366f1;
}

#stopScanBtn {
  margin-top: 10px;
}

/* Responsive */
@media (max-width: 480px) {
  .container {
    padding: 20px;
    border-radius: 15px;
  }

  h1 {
    font-size: 22px;
  }

  input, select, .select-selected, button {
    font-size: 14px;
    padding: 12px;
  }

  .select-selected {
    min-height: 44px;
  }

  .select-selected input.search-bank {
    font-size: 14px;
    padding: 12px;
  }

  #qrCode img, #qrCode svg {
    max-width: 100%;
  }

  .toast {
    bottom: 15px;
    right: 15px;
    padding: 12px 18px;
    font-size: 14px;
  }

  .modal-content {
    padding: 15px;
    max-width: 90%;
  }

  #qrVideo {
    max-width: 250px;
  }
}

@media (max-width: 320px) {
  .container {
    padding: 15px;
  }

  input, select, .select-selected, button {
    padding: 10px;
  }

  .select-selected {
    min-height: 40px;
  }

  .select-selected input.search-bank {
    font-size: 13px;
    padding: 10px;
  }

  #qrVideo {
    max-width: 200px;
  }
}