/* ===================================
   Main Styles for Happy Women's Day
   =================================== */

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

body {
  font-family: 'Work Sans', sans-serif;
  overflow-x: hidden;
  background: linear-gradient(135deg, #ffeef8 0%, #ffe0f0 100%);
}

/* Section Management */
.section {
  display: none;
  min-height: 100vh;
  width: 100%;
  position: relative;
}

.section.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Intro Section (leverages happy-birthday styles) */
#intro .skip-intro {
  position: fixed;
  top: 20px;
  right: 20px;
  font-size: 14px;
  color: #999;
  cursor: pointer;
  z-index: 1000;
  transition: color 0.3s;
}

#intro .skip-intro:hover {
  color: #ff69b4;
}

#intro .start-btn {
  margin-top: 30px;
  padding: 15px 40px;
  font-size: 20px;
  font-weight: bold;
  background: linear-gradient(135deg, #ff69b4, #ff1493);
  color: white;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(255, 20, 147, 0.3);
  transition: transform 0.3s, box-shadow 0.3s;
}

#intro .start-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(255, 20, 147, 0.5);
}

/* Intro cut banner */
.gacha-intro-banner {
  margin-top: 20px;
  background: rgba(255, 255, 255, 0.85);
  border: 2px dashed #ff69b4;
  padding: 16px 20px;
  border-radius: 12px;
  text-align: center;
  color: #a31267;
  max-width: 80vw;
}
.gacha-intro-banner h2 {
  font-size: 24px;
  margin-bottom: 8px;
}
.gacha-intro-banner p {
  font-size: 16px;
}

/* Gacha Section */
#gacha {
  padding: 40px 20px;
}

.gacha-container {
  width: 100%;
  max-width: 800px;
  text-align: center;
}

.gacha-container h2 {
  font-size: 32px;
  color: #ff1493;
  margin-bottom: 30px;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.gacha-machine {
  position: relative;
  margin: 30px auto;
}

.machine-svg {
  width: 100%;
  max-width: 400px;
  height: auto;
  filter: drop-shadow(0 10px 20px rgba(0,0,0,0.2));
}

.candy-ball {
  animation: bounce 2s infinite ease-in-out;
  transform-origin: center;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-20px); }
}

.quantity-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin: 20px 0;
}

.quantity-control button {
  width: 40px;
  height: 40px;
  font-size: 24px;
  font-weight: bold;
  border: 2px solid #ff69b4;
  background: white;
  color: #ff69b4;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s;
}

.quantity-control button:hover {
  background: #ff69b4;
  color: white;
  transform: scale(1.1);
}

#quantity-input {
  width: 60px;
  text-align: center;
  font-size: 24px;
  font-weight: bold;
  border: 2px solid #ff69b4;
  border-radius: 10px;
  padding: 8px;
  color: #ff1493;
}

.spin-button {
  padding: 15px 50px;
  font-size: 22px;
  font-weight: bold;
  background: linear-gradient(135deg, #ff69b4, #ff1493);
  color: white;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(255, 20, 147, 0.3);
  transition: all 0.3s;
  margin: 20px 0;
}

.spin-button:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(255, 20, 147, 0.5);
}

.spin-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.selected-wishes {
  margin-top: 40px;
  padding: 20px;
  background: white;
  border-radius: 20px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}

.selected-wishes h3 {
  color: #ff1493;
  margin-bottom: 15px;
}

#wish-list {
  max-height: 300px;
  overflow-y: auto;
  margin: 15px 0;
}

.wish-item {
  padding: 12px;
  margin: 8px 0;
  background: linear-gradient(135deg, #fff5f8, #ffe8f0);
  border-left: 4px solid #ff69b4;
  border-radius: 8px;
  text-align: left;
  font-size: 14px;
  color: #333;
}

.next-btn {
  padding: 12px 30px;
  font-size: 18px;
  font-weight: bold;
  background: linear-gradient(135deg, #4CAF50, #45a049);
  color: white;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  margin-top: 15px;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
  transition: all 0.3s;
}

.next-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(76, 175, 80, 0.5);
}

/* Popup - Fullscreen */
.popup {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  z-index: 2000;
  justify-content: center;
  align-items: center;
}

.popup.active {
  display: flex;
}

.popup-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 40px 40px;
  position: relative;
  animation: popIn 0.3s ease-out;
}

.popup-content.popup-tree {
  max-width: 100%;
}

.popup-tree-container {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px 0;
}

#popupCanvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.popup-wish-text {
  margin: 20px 0;
  padding: 20px;
  max-width: 800px;
  text-align: center;
}

.popup-wish-text p {
  font-size: 1.8rem;
  line-height: 1.6;
  color: white;
  margin: 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

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

.popup-content h3 {
  color: white;
  margin-bottom: 20px;
  font-size: 24px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.popup-content p {
  font-size: 18px;
  line-height: 1.6;
  color: white;
  margin-bottom: 25px;
}

.popup-content button {
  position: absolute;
  top: 30px;
  right: 30px;
  width: 50px;
  height: 50px;
  background: rgba(255, 255, 255, 0.95);
  color: #667eea;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.popup-content button::before {
  content: "×";
}

.popup-content button:hover {
  background: white;
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

/* Treelove Section */
#treelove {
  padding: 40px 20px;
  background: #ffe;
  min-height: 100vh;
  overflow: visible; /* Allow scaled content to show */
}

.treelove-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
  min-height: 600px; /* Ensure enough space for scaled content */
  overflow: visible; /* Don't clip scaled content */
  position: relative; /* Create positioning context */
  display: flex;
  flex-direction: column;
  align-items: center; /* Center the tree-wrap */
}

/* Tree section - Original size for desktop */
#tree-wrap {
  position: relative;
  width: 1100px;
  height: 680px;
  margin-top: 10px;
  pointer-events: all; /* Ensure clicks work */
  transform: scale(0.65); /* Scale down canvas - desktop default */
  transform-origin: center top;
  margin-bottom: -250px; /* Compensate for scale */
}

#canvas {
  margin: 0 auto;
  width: 1100px;
  height: 680px;
  pointer-events: all; /* Ensure canvas captures clicks */
  cursor: pointer; /* Always show pointer cursor */
}

#code {
  display: none;
  font-size: 30px;
  width: 400px;
  height: 425px;
  position: absolute;
  left: 60px;
  top: 80px;
  font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
  color: #231f20;
  line-height: 1.6;
  font-weight: 400;
  pointer-events: all; /* Ensure text links work */
}

.say {
  margin-left: 5px;
  /* Bạn có thể thêm style riêng cho từng dòng text ở đây */
}

.hand {
  cursor: pointer;
  pointer-events: all; /* Ensure clickable even when scaled */
  z-index: 100; /* Bring to front */
  position: relative; /* Create stacking context */
}

.tree-controls {
  margin: 25px 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
}

.tree-controls button {
  padding: 10px 25px;
  font-size: 16px;
  font-weight: bold;
  background: white;
  color: #ff1493;
  border: 2px solid #ff1493;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s;
}

.tree-controls button:hover:not(:disabled) {
  background: #ff1493;
  color: white;
  transform: scale(1.05);
}

.tree-controls button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#wish-index {
  font-size: 18px;
  font-weight: bold;
  color: #c71585;
}

/* Wish Info - Người gửi/nhận */
.wish-info {
  text-align: center;
  margin: 30px 0 20px;
  margin-top: 100px; /* Push down 30px */
  padding: 20px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 15px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.wish-to,
.wish-from {
  font-size: 16px;
  margin: 8px 0;
  color: #555;
  line-height: 1.6;
}

.wish-label {
  font-weight: 600;
  color: #ff69b4;
  margin-right: 8px;
}

.wish-recipient,
.wish-sender {
  font-weight: 700;
  color: #333;
  font-size: 18px;
}

.wish-from {
  padding-top: 8px;
  border-top: 1px solid #f0f0f0;
  margin-top: 8px;
}

.tree-actions {
  margin-top: 50px; /* Push down 30px more from default 20px */
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
}

.action-btn {
  padding: 12px 30px;
  font-size: 16px;
  font-weight: bold;
  background: linear-gradient(135deg, #9c27b0, #7b1fa2);
  color: white;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(156, 39, 176, 0.3);
  transition: all 0.3s;
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(156, 39, 176, 0.5);
}

.action-btn.primary-btn {
  background: linear-gradient(135deg, #ff69b4, #ff1493);
  box-shadow: 0 4px 12px rgba(255, 105, 180, 0.4);
  font-size: 17px;
  padding: 14px 35px;
}

.action-btn.primary-btn:hover {
  background: linear-gradient(135deg, #ff1493, #c71585);
  box-shadow: 0 6px 20px rgba(255, 105, 180, 0.6);
  transform: translateY(-3px) scale(1.05);
}

/* QR Section */
#qr {
  padding: 40px 20px;
  background: linear-gradient(135deg, #e1f5fe 0%, #b3e5fc 100%);
}

.qr-container {
  width: 100%;
  max-width: 800px;
  text-align: center;
}

.qr-container h2 {
  font-size: 32px;
  color: #0277bd;
  margin-bottom: 30px;
}

.qr-form {
  background: white;
  padding: 30px;
  border-radius: 20px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.1);
  margin-bottom: 30px;
}

.qr-form label {
  display: block;
  text-align: left;
  font-weight: bold;
  color: #0277bd;
  margin: 15px 0 8px;
}

.qr-form textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid #4fc3f7;
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
  resize: vertical;
}

.qr-form input[type="color"] {
  width: 80px;
  height: 40px;
  border: 2px solid #4fc3f7;
  border-radius: 8px;
  cursor: pointer;
}

.gen-btn {
  padding: 15px 40px;
  font-size: 18px;
  font-weight: bold;
  background: linear-gradient(135deg, #4fc3f7, #0277bd);
  color: white;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  margin-top: 20px;
  box-shadow: 0 6px 16px rgba(79, 195, 247, 0.4);
  transition: all 0.3s;
}

.gen-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(79, 195, 247, 0.6);
}

.qr-result {
  background: white;
  padding: 30px;
  border-radius: 20px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.1);
  margin-bottom: 20px;
}

#qrCanvas {
  max-width: 100%;
  height: auto;
  border: 4px solid #4fc3f7;
  border-radius: 15px;
  margin: 20px 0;
}

.download-btn {
  padding: 12px 35px;
  font-size: 16px;
  font-weight: bold;
  background: linear-gradient(135deg, #66bb6a, #43a047);
  color: white;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(102, 187, 106, 0.4);
  transition: all 0.3s;
}

.download-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 187, 106, 0.6);
}

.qr-actions {
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
}

.back-btn, .restart-btn {
  padding: 12px 30px;
  font-size: 16px;
  font-weight: bold;
  color: white;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.3s;
}

.back-btn {
  background: linear-gradient(135deg, #ffa726, #fb8c00);
  box-shadow: 0 4px 12px rgba(255, 167, 38, 0.4);
}

.back-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 167, 38, 0.6);
}

.restart-btn {
  background: linear-gradient(135deg, #ef5350, #e53935);
  box-shadow: 0 4px 12px rgba(239, 83, 80, 0.4);
}

.restart-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(239, 83, 80, 0.6);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .gacha-container h2,
  .treelove-container h2,
  .qr-container h2 {
    font-size: 24px;
  }

  .machine-svg {
    max-width: 300px;
  }

  .spin-button {
    font-size: 18px;
    padding: 12px 35px;
  }

  /* Scale only tree-wrap (canvas), not the whole container */
  #tree-wrap {
    transform: scale(0.45);
    transform-origin: center top;
    margin-bottom: -400px; /* Adjust spacing */
  }

  #treeCanvas {
    width: 100%;
  }

  #current-wish-text {
    font-size: 16px;
  }

  .tree-controls button,
  .tree-actions button {
    padding: 8px 20px;
    font-size: 14px;
  }

  .action-btn {
    padding: 10px 20px;
    font-size: 14px;
  }

  .qr-form {
    padding: 20px;
  }

  /* Popup fullscreen mobile */
  .popup-content {
    padding: 60px 20px 20px;
  }

  .popup-wish-text p {
    font-size: 1.3rem;
  }

  .popup-content button {
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
  }

  .popup-content {
    padding: 25px;
    width: 95%;
  }

  .popup-content h3 {
    font-size: 20px;
  }

  .popup-content p {
    font-size: 16px;
  }
}

/* Extra small mobile */
@media screen and (max-width: 430px) {
  #tree-wrap {
    transform: scale(0.4);
    transform-origin: center top;
    margin-bottom: -450px; /* Adjust spacing for smaller scale */
  }
}

/* Tablet Responsive */
@media (max-width: 1024px) and (min-width: 769px) {
  #tree-wrap {
    transform: scale(0.6);
    transform-origin: center top;
    margin-bottom: -300px;
  }
}

/* Large desktop - scale to 0.65 */
@media (min-width: 1025px) {
  #tree-wrap {
    transform: scale(0.65);
    transform-origin: center top;
    margin-bottom: -250px;
  }
}

/* ===================================
   Share Modal Styles
   =================================== */

.share-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.share-modal.active {
  opacity: 1;
  visibility: visible;
}

.share-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
}

.share-modal-content {
  position: relative;
  background: white;
  border-radius: 20px;
  padding: 40px;
  max-width: 550px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.share-modal.active .share-modal-content {
  transform: scale(1);
}

.share-modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: transparent;
  border: none;
  color: #999;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: all 0.3s;
  z-index: 1;
}

.share-modal-close:hover {
  background: #f0f0f0;
  color: #333;
  transform: rotate(90deg);
}

.share-modal-header {
  text-align: center;
  margin-bottom: 30px;
}

.share-modal-header h2 {
  font-size: 28px;
  color: #ff69b4;
  margin-bottom: 10px;
  font-weight: 600;
}

.share-recipient {
  font-size: 16px;
  color: #666;
}

.share-recipient strong {
  color: #ff69b4;
}

.share-modal-body {
  display: flex;
  flex-direction: column;
  gap: 25px;
}

/* QR Code Section */
.share-qr-section {
  text-align: center;
}

.share-qr-container {
  background: linear-gradient(135deg, #ffeef8 0%, #ffe0f0 100%);
  padding: 20px;
  border-radius: 15px;
  display: inline-block;
  margin: 0 auto 15px;
  box-shadow: 0 4px 15px rgba(255, 105, 180, 0.2);
}

.share-qr-image {
  width: 280px;
  height: 280px;
  display: block;
  border-radius: 10px;
}

.share-qr-label {
  font-size: 14px;
  color: #666;
  margin: 0;
}

/* Link Section */
.share-link-section {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 12px;
}

.share-link-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #555;
  margin-bottom: 10px;
}

.share-link-input-group {
  display: flex;
  gap: 10px;
}

.share-link-input {
  flex: 1;
  padding: 12px 15px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Courier New', monospace;
  background: white;
  color: #333;
  cursor: pointer;
  transition: border-color 0.3s;
}

.share-link-input:focus {
  outline: none;
  border-color: #ff69b4;
}

/* Preview Section */
.share-preview-section {
  background: linear-gradient(135deg, #fff5f7 0%, #ffe4ec 100%);
  padding: 20px;
  border-radius: 12px;
  border-left: 4px solid #ff69b4;
}

.share-preview-text {
  font-size: 15px;
  font-style: italic;
  color: #555;
  line-height: 1.6;
  margin: 0;
}

/* Share Buttons */
.share-modal-footer {
  display: flex;
  gap: 12px;
  margin-top: 25px;
  flex-wrap: wrap;
}

.share-btn {
  flex: 1;
  min-width: 150px;
  padding: 14px 20px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s;
  font-family: 'Work Sans', sans-serif;
}

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

.share-btn-copy {
  background: #667eea;
  color: white;
}

.share-btn-copy:hover {
  background: #5568d3;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.share-btn-primary {
  background: #ff69b4;
  color: white;
}

.share-btn-primary:hover {
  background: #ff4fa1;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(255, 105, 180, 0.3);
}

.share-btn-secondary {
  background: #4facfe;
  color: white;
}

.share-btn-secondary:hover {
  background: #00a8ff;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(79, 172, 254, 0.3);
}

/* Toast Notification */
.share-toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #333;
  color: white;
  padding: 15px 25px;
  border-radius: 10px;
  font-size: 15px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
  z-index: 10000;
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 90%;
  text-align: center;
}

.share-toast.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.share-toast-success {
  background: #10b981;
}

.share-toast-error {
  background: #ef4444;
}

.share-toast-info {
  background: #3b82f6;
}

/* Responsive */
@media (max-width: 768px) {
  .share-modal-content {
    padding: 25px 20px;
    max-width: 95%;
  }

  .share-modal-header h2 {
    font-size: 24px;
  }

  .share-qr-image {
    width: 220px;
    height: 220px;
  }

  .share-modal-footer {
    flex-direction: column;
  }

  .share-btn {
    min-width: 100%;
  }

  .share-link-input-group {
    flex-direction: column;
  }

  .share-link-input {
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .share-qr-image {
    width: 180px;
    height: 180px;
  }

  .share-modal-header h2 {
    font-size: 20px;
  }

  .share-preview-text {
    font-size: 14px;
  }
}

/* ===================================
   Utility Animations
   =================================== */

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

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

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