/* 
  Khu Vườn Trí Tuệ - Isometric CSS
*/
body.garden-body {
  background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
  background-size: 400% 400%;
  animation: gradientBG 15s ease infinite;
  overflow: hidden; /* Prevent scrolling outside the garden view */
  touch-action: none; /* For dragging */
}

@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.garden-container {
  width: 100vw;
  height: 100vh;
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Isometric World Wrapper */
.isometric-world {
  position: relative;
  width: 600px;
  height: 600px;
  /* The core magic of Isometric 2.5D */
  transform: rotateX(60deg) rotateZ(-45deg);
  transform-style: preserve-3d;
  transition: transform 0.3s ease;
}

/* Ground Grid (Khối đất 3D) */
.garden-grid {
  position: absolute;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  /* Màu cỏ tươi tắn */
  background: linear-gradient(135deg, #7ad841 0%, #56b225 100%);
  /* Tạo độ dày cho khối đất bằng nhiều lớp box-shadow: Lớp cỏ -> Lớp đất nâu -> Bóng đổ */
  box-shadow: 
    -1px 1px 0 #4a9821,
    -2px 2px 0 #4a9821,
    -3px 3px 0 #4a9821,
    -4px 4px 0 #4a9821,
    -5px 5px 0 #6e4e2a,
    -6px 6px 0 #6e4e2a,
    -7px 7px 0 #6e4e2a,
    -8px 8px 0 #6e4e2a,
    -9px 9px 0 #4d3319,
    -10px 10px 0 #4d3319,
    -15px 15px 20px rgba(0,0,0,0.6);
  border-radius: 12px;
}

.grid-cell {
  /* Viền kẻ sọc nhẹ để phân biệt ô đất, không xài viền đứt đoạn */
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-sizing: border-box;
  position: relative;
  transition: all 0.2s;
  /* Nếu có vật phẩm, tạo hiệu ứng mảng đất nhỏ dưới gốc */
  border-radius: 4px;
}

.grid-cell.occupied {
  /* Khi có cây, hiện mảng đất nâu nhạt dưới gốc */
  background: radial-gradient(circle, rgba(139, 90, 43, 0.4) 0%, rgba(139, 90, 43, 0) 60%);
}

.grid-cell:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
}

.grid-cell.highlight-green {
  background: rgba(46, 204, 113, 0.7) !important;
  box-shadow: inset 0 0 10px rgba(255,255,255,0.5);
}

.grid-cell.highlight-red {
  background: rgba(231, 76, 60, 0.7) !important;
}

/* Objects Layer */
.objects-layer {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none; /* Let clicks pass through to the grid */
}

/* Individual Object */
.garden-item {
  position: absolute;
  width: 60px; /* 600 / 10 */
  height: 60px;
  /* Reverse the isometric rotation so objects stand up straight */
  transform: rotateZ(45deg) rotateX(-60deg) translateY(-20px);
  transform-origin: bottom center;
  pointer-events: auto; /* Re-enable clicks for items */
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: filter 0.2s, transform 0.2s;
}

.garden-item img {
  width: 150%; /* Make emojis big enough */
  height: auto;
  filter: drop-shadow(-5px 10px 5px rgba(0,0,0,0.5));
  pointer-events: none;
}

/* Animations for items */
.garden-item.anim-bounce img {
  animation: bounceItem 2s infinite ease-in-out;
}

.garden-item.anim-sway img {
  animation: swayItem 3s infinite ease-in-out;
}

@keyframes bounceItem {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(0.9) translateY(2px); }
}

@keyframes swayItem {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(2deg); }
  75% { transform: rotate(-2deg); }
}

/* Floating effect for dragging items */
.garden-item.dragging {
  opacity: 0.7;
  transform: rotateZ(45deg) rotateX(-60deg) translateY(-40px) scale(1.1);
  z-index: 1000;
}

/* Toolbar */
.garden-toolbar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 15px;
  padding: 10px 20px;
  border-radius: 30px;
  z-index: 100;
}

.toolbar-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  border-radius: 20px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.toolbar-btn img {
  width: 24px;
  height: 24px;
}

.toolbar-btn:hover, .toolbar-btn.active {
  background: rgba(255,255,255,0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.toolbar-btn.active {
  border-color: #f1c40f;
  color: #f1c40f;
}

/* Shop Modal overrides */
.shop-modal-content {
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.shop-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.tab-btn {
  flex: 1;
  background: rgba(0,0,0,0.3);
  border: none;
  color: #ccc;
  padding: 10px;
  border-radius: 12px;
  font-weight: bold;
  cursor: pointer;
}

.tab-btn.active {
  background: #6366f1;
  color: white;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 15px;
  overflow-y: auto;
  padding: 5px;
}

.shop-item {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 15px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background 0.2s;
}

.shop-item:hover {
  background: rgba(255,255,255,0.15);
}

.shop-item img {
  width: 48px;
  height: 48px;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}

.shop-item .price {
  font-weight: 800;
  color: #f1c40f;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
}

.shop-item .price img {
  width: 16px;
  height: 16px;
  filter: none;
}

/* Toast */
.toast-message {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  font-weight: bold;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 10000;
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255,255,255,0.2);
}

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