:root {
  --bg-main: #f5f6f8;
  --bg-card: rgba(255, 255, 255, 0.82); /* Tăng độ đục để chữ hiển thị rõ nét hơn */
  --bg-image-wrapper: #faf6f0; /* Soft cream background behind product images matching the template */
  --text-title: #111827; /* Đen Slate đậm cho tiêu đề sắc nét */
  --text-muted: #4b5563; /* Xám sẫm dễ đọc cho phần mô tả */
  --primary-color: #2b6cb0; /* Xanh hoàng gia */
  --price-color: #e11d48; /* Màu đỏ hồng nổi bật cho giá tiền */
  --danger-color: #e53e3e;
  --success-color: #38a169;
  --border-radius-card: 12px;
  --border-radius-image: 8px;
  --transition-speed: 0.25s;
  --font-family: 'Outfit', sans-serif;
}

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

body {
  background: radial-gradient(circle at 10% 20%, rgba(246, 243, 237, 1) 0%, rgba(238, 233, 224, 1) 90%);
  background-attachment: fixed;
  color: var(--text-title);
  font-family: var(--font-family);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 20px 10px;
  position: relative;
}

body.modal-open {
  overflow: hidden !important;
  height: 100vh;
}

/* Subtle background decorative shapes */
body::before {
  content: '';
  position: fixed;
  top: -10%;
  left: -10%;
  width: 40vw;
  height: 40vw;
  background: radial-gradient(circle, rgba(43, 108, 176, 0.02) 0%, rgba(255, 255, 255, 0) 70%);
  z-index: -1;
  pointer-events: none;
}

body::after {
  content: '';
  position: fixed;
  bottom: -10%;
  right: -10%;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, rgba(56, 161, 105, 0.015) 0%, rgba(255, 255, 255, 0) 70%);
  z-index: -1;
  pointer-events: none;
}

#bgCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -2;
  pointer-events: none;
}

.store-container {
  width: 100%;
  max-width: 1400px;
  background-color: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 16px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.03);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header */
.store-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #edf2f7;
  padding-bottom: 16px;
}

.main-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 1px;
  text-align: center;
  flex-grow: 1;
  text-transform: uppercase;
}

.header-action-left, .header-action-right {
  width: 150px;
  display: flex;
}

.header-action-right {
  justify-content: flex-end;
}

.admin-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-main);
  border: 1px solid #e2e8f0;
  padding: 8px 14px;
  border-radius: 20px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
}

.admin-toggle-btn:hover {
  background-color: #edf2f7;
}

.admin-toggle-btn.admin-active {
  background-color: #feebc8;
  border-color: #fbd38d;
  color: #c05621;
}

/* Search Bar */
.search-wrapper {
  display: flex;
  justify-content: center;
  margin-top: 10px;
  margin-bottom: 6px;
}

.search-container {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 480px;
  background-color: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 20px;
  padding: 8px 16px;
  gap: 10px;
  transition: all var(--transition-speed) ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
}

.search-container:focus-within {
  background-color: rgba(255, 255, 255, 0.95);
  border-color: var(--primary-color);
  box-shadow: 0 8px 20px rgba(43, 108, 176, 0.12);
}

.search-icon {
  color: var(--text-muted);
  width: 18px;
  height: 18px;
}

.search-input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-title);
}

.search-input::placeholder {
  color: var(--text-muted);
}



/* Grid Wrapper */
.grid-wrapper {
  min-height: 500px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
}

/* Product Card */
.product-card {
  background-color: var(--bg-card);
  border: 1px solid #edf2f7;
  border-radius: var(--border-radius-card);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  cursor: pointer;
  
  /* Trạng thái ban đầu phục vụ hiệu ứng hiện tuần tự (Cinematic Reveal) */
  opacity: 0;
  transform: translateY(20px);
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.6s ease, box-shadow 0.3s ease, border-color 0.3s ease;
  
  /* Bật không gian 3D */
  transform-style: preserve-3d;
  will-change: transform, opacity;
}

.product-card.reveal {
  opacity: 1;
  transform: translateY(0);
}

.product-card:hover {
  box-shadow: 0 20px 45px rgba(43, 108, 176, 0.28) !important; /* Hào quang xanh đậm sắc nét */
  border-color: var(--primary-color) !important; /* Viền xanh nổi bật */
  background-color: rgba(255, 255, 255, 0.98) !important; /* Làm đặc hẳn card được chọn để làm rõ chữ */
  z-index: 10; /* Đưa card lên phía trước các card khác */
}



.product-image-wrapper {
  background-color: var(--bg-image-wrapper);
  border-radius: var(--border-radius-image);
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 8px;
  position: relative;
}

/* Glass shine animation effect */
.product-image-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  left: -150%;
  width: 50%;
  height: 100%;
  background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.4) 50%, rgba(255, 255, 255, 0) 100%);
  transform: skewX(-25deg);
  pointer-events: none;
  transition: left 0.6s ease;
}

.product-card:hover .product-image-wrapper::after {
  left: 150%;
}

.product-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  mix-blend-mode: multiply; /* Blends transparent or white images beautifully with the background card color */
  border-radius: 4px;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.product-card:hover .product-image {
  transform: scale(1.06);
}

.product-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.product-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-title);
  line-height: 1.3;
  min-height: 34px; /* Ensure 2 lines alignment */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--price-color);
  margin-top: 2px;
}

.product-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2; /* Giới hạn mô tả tối đa 2 dòng */
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 30px; /* Giữ độ cao thẻ đồng đều */
}

/* Buy Now Button inside card */
.buy-now-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: all var(--transition-speed) ease;
}

.buy-now-btn:hover {
  background-color: #1a365d; /* Tông xanh đậm hơn */
  box-shadow: 0 4px 12px rgba(43, 108, 176, 0.2);
  transform: translateY(-1px);
}

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

.buy-now-btn svg {
  width: 13px;
  height: 13px;
}

/* Delete Button on Card (Admin Mode) */
.delete-card-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background-color: var(--danger-color);
  color: white;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.delete-card-btn:hover {
  transform: scale(1.1);
  background-color: #c53030;
}

.delete-card-btn svg {
  width: 14px;
  height: 14px;
}

/* Floating Action Button (Admin Mode Only) */
.floating-action-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background-color: var(--success-color);
  color: white;
  border: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  box-shadow: 0 4px 15px rgba(56, 161, 105, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 99;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.floating-action-btn:hover {
  transform: scale(1.08);
  background-color: #2f855a;
}

.floating-action-btn svg {
  width: 24px;
  height: 24px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background-color: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 460px;
  padding: 24px;
  position: relative;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-close-btn:hover {
  color: var(--text-title);
}

.modal-card h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* Forms */
.modal-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-title);
}

.input-group input {
  padding: 10px 14px;
  border: 1px solid #cbd5e0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  transition: border-color var(--transition-speed) ease;
}

.input-group input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Image suggestion chips */
.image-suggestions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.suggestion-label {
  font-size: 11px;
  color: var(--text-muted);
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-btn {
  background-color: var(--bg-main);
  border: 1px solid #e2e8f0;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
}

.chip-btn:hover {
  background-color: #e2e8f0;
  border-color: #cbd5e0;
}

/* Buttons */
.btn {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s ease;
  margin-top: 10px;
}

.btn:hover {
  opacity: 0.9;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
}

.error-text {
  color: var(--danger-color);
  font-size: 11px;
  margin-top: 4px;
}

/* Sidebar & Layout styling */
.main-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-left, .sidebar-right {
  display: none; /* Hidden on mobile */
  flex-direction: column;
  gap: 20px;
}

.profile-card, .widget-box {
  background-color: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--border-radius-card);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.01);
}

.profile-avatar-wrapper {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--bg-main);
  margin-bottom: 12px;
}

.profile-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-title);
  margin-bottom: 4px;
}

.profile-tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-color);
  background-color: #ebf8ff;
  padding: 4px 12px;
  border-radius: 12px;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.profile-bio {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 16px;
}

.profile-socials {
  display: flex;
  gap: 12px;
}

.profile-socials a {
  color: var(--text-muted);
  transition: color var(--transition-speed);
}

.profile-socials a:hover {
  color: var(--primary-color);
}

.profile-socials svg {
  width: 18px;
  height: 18px;
}

.widget-box {
  align-items: flex-start;
  text-align: left;
  width: 100%;
}

.widget-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-title);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.widget-title svg {
  width: 16px;
  height: 16px;
  color: var(--primary-color);
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.category-item {
  background-color: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-speed);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.category-item:hover, .category-item.active {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  box-shadow: 0 4px 8px rgba(43, 108, 176, 0.15);
}

.widget-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Footer styling */
.store-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid #edf2f7;
  padding-top: 16px;
  margin-top: 20px;
}

/* Responsive grid changes for tablets and desktops */
@media (min-width: 768px) {
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

@media (min-width: 1200px) {
  .main-layout {
    flex-direction: row;
    gap: 24px;
    align-items: flex-start;
  }
  .sidebar-left {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 240px;
    position: sticky;
    top: 20px;
  }
  .grid-wrapper {
    flex-grow: 1;
  }
  .product-grid {
    grid-template-columns: repeat(5, 1fr); /* 5 columns on desktop with only 1 sidebar */
  }
}

/* See More Link under description */
.see-more-link {
  font-size: 11px;
  color: var(--primary-color);
  cursor: pointer;
  font-weight: 600;
  display: inline-block;
  margin-top: 4px;
  text-decoration: underline;
  transition: opacity var(--transition-speed);
}

.see-more-link:hover {
  opacity: 0.8;
}

/* Product Detail Modal Specific Styles */
.product-detail-card {
  max-width: 720px !important;
  width: 90% !important;
  padding: 24px !important;
  border-radius: 16px !important;
  overflow: hidden;
}

.product-detail-content {
  display: flex;
  gap: 20px;
  margin-top: 15px;
  flex-direction: row;
}

.product-detail-image-side {
  flex: 1;
  max-width: 300px;
  aspect-ratio: 1 / 1;
  background-color: var(--bg-image-wrapper);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.product-detail-image-side img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.product-detail-info-side {
  flex: 1.2;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.product-detail-info-side h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-title);
  line-height: 1.4;
  margin: 0;
}

.detail-price {
  font-size: 20px;
  font-weight: 800;
  color: var(--price-color);
  display: inline-block;
}

.detail-desc-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 100px;
  max-height: 200px; /* Scrollable description area */
  overflow-y: auto;
  padding-right: 8px;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  padding-top: 10px;
  padding-bottom: 10px;
}

/* Custom scrollbar for description area */
.detail-desc-container::-webkit-scrollbar {
  width: 4px;
}
.detail-desc-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.02);
}
.detail-desc-container::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 2px;
}

.detail-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-title);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0;
}

.detail-desc {
  font-size: 13px;
  color: #374151;
  line-height: 1.5;
  margin: 0;
  white-space: pre-line;
}

.detail-buy-btn {
  margin-top: auto;
  padding: 12px 16px;
  font-size: 14px;
  border-radius: 10px;
}

/* Responsive adjustment for Product Detail Modal */
@media (max-width: 600px) {
  .product-detail-content {
    flex-direction: column;
    gap: 15px;
  }
  .product-detail-image-side {
    max-width: 100%;
    height: 220px;
  }
  .product-detail-info-side {
    width: 100%;
  }
  .product-detail-info-side h2 {
    font-size: 16px;
  }
  .detail-desc-container {
    max-height: 150px;
  }
}

/* Mobile view adjustments (2 Columns Grid) */
@media (max-width: 480px) {
  .product-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  .product-card {
    padding: 8px !important;
    border-radius: 10px !important;
  }
  .product-title {
    font-size: 11px !important;
    min-height: 28px !important;
    margin-bottom: 2px !important;
  }
  .product-price {
    font-size: 12px !important;
  }
  .product-desc {
    font-size: 10px !important;
    min-height: 24px !important;
  }
  .store-container {
    padding: 12px !important;
    gap: 12px !important;
  }
  .main-title {
    font-size: 18px !important;
  }
  .search-wrapper {
    margin-bottom: 10px !important;
  }
  .search-container {
    padding: 6px 12px !important;
  }
  .search-input {
    font-size: 12px !important;
  }
}

/* Skeleton Loading Effects */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton-card {
  pointer-events: none;
  border-color: rgba(0, 0, 0, 0.05) !important;
  background-color: rgba(255, 255, 255, 0.5) !important;
  box-shadow: none !important;
}

.skeleton-shimmer {
  background: linear-gradient(90deg, 
    rgba(0, 0, 0, 0.04) 25%, 
    rgba(0, 0, 0, 0.08) 50%, 
    rgba(0, 0, 0, 0.04) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite linear;
}

.skeleton-card .product-image-wrapper {
  background: none !important;
}

.skeleton-text {
  border-radius: 4px;
}

