
:root {
  --primary-color: #ee4d2d;
  --text-color: #333;
  --bg-color: #f5f5f5;
  --white: #ffffff;
  --gray: #999;
  --border-color: #e8e8e8;
  --price-color: #ee4d2d;
  --header-height: auto;
  --bottom-nav-height: 60px;
  --card-bg: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  --hover-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  --pill-bg: #f0f0f0;
  --pill-active-bg: #fff0eb;
  --pill-active-color: #ee4d2d;
  --pill-exclude-active-bg: #ffebee;
  --pill-exclude-active-color: #d32f2f;
}

[data-theme="dark"] {
  --text-color: #e0e0e0;
  --bg-color: #121212;
  --white: #1e1e1e;
  --gray: #aaaaaa;
  --border-color: #333;
  --card-bg: #1e1e1e;
  --shadow: 0 1px 2px rgba(255, 255, 255, 0.05);
  --hover-shadow: 0 2px 4px rgba(255, 255, 255, 0.1);
  --pill-bg: #333;
  --pill-active-bg: #3a1c1c;
  --pill-exclude-active-bg: #3a1c1c;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Roboto", sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  padding-bottom: var(--bottom-nav-height);
  transition: background-color 0.3s, color 0.3s;
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  background-color: var(--bg-color);
  min-height: 100vh;
  position: relative;
}

/* Header */
.main-header {
  background-color: var(--white);
  position: fixed;
  top: 0;
  left: 50%;
  width: 100%;
  max-width: 1200px;
  z-index: 100;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transform: translateX(-50%) translateY(0);
  transition: transform 0.3s ease;
}

.main-header.hidden-header {
  transform: translateX(-50%) translateY(-100%);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  background: linear-gradient(-180deg, #f53d2d, #f63);
  color: #fff;
  gap: 10px;
}

.logo h1 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
}

/* Search Bar */
.search-bar-container {
  flex: 1;
  max-width: 600px;
}

.search-input-wrapper {
  position: relative;
  width: 100%;
}

.search-input-wrapper input {
  width: 100%;
  padding: 8px 10px 8px 35px;
  border-radius: 4px;
  border: none;
  outline: none;
  font-size: 14px;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
}

.icon-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  padding: 5px;
}

/* Filter Section */
.filter-section {
  padding: 10px 15px;
  background-color: var(--white);
  border-bottom: 1px solid var(--border-color);
  /* transition removed to prevent lag */
  max-height: 1000px;
  opacity: 1;
  overflow: hidden;
  display: block;
}

.filter-section.collapsed {
  display: none;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  border-bottom: none;
}

.filter-group {
  margin-bottom: 10px;
}

.filter-group:last-child {
  margin-bottom: 0;
}

.filter-title {
  font-size: 12px;
  font-weight: bold;
  color: var(--gray);
  margin-bottom: 5px;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-pill {
  padding: 6px 12px;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  background-color: var(--pill-bg);
  color: var(--text-color);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.filter-pill i {
  font-size: 11px;
}

/* Active States */
.filter-pill.active {
  background-color: var(--pill-active-bg);
  color: var(--pill-active-color);
  border-color: var(--pill-active-color);
}

.filter-pill.exclude.active {
  background-color: var(--pill-exclude-active-bg);
  color: var(--pill-exclude-active-color);
  border-color: var(--pill-exclude-active-color);
}

/* Time & Shop Filter */
.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.time-pill {
  padding: 6px 12px;
  border-radius: 4px;
  background-color: #333;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 4px;
}

.shop-filter-container {
  flex: 1;
  min-width: 150px;
}

/* Time Filter Pills */
.pill {
  padding: 6px 12px;
  border-radius: 4px;
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
  user-select: none;
}

.pill:hover {
  background-color: var(--border-color);
}

.pill.active {
  background-color: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(238, 77, 45, 0.3);
}

.shop-input {
  width: 100%;
  padding: 6px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-color);
  color: var(--text-color);
  font-size: 12px;
  outline: none;
}

.sort-select {
  padding: 6px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-color);
  color: var(--text-color);
  font-size: 12px;
  outline: none;
  min-width: 120px;
}

/* Stats Bar */
.stats-bar {
  display: flex;
  background-color: var(--white);
  border-bottom: 1px solid var(--border-color);
}

.stat-item {
  flex: 1;
  text-align: center;
  padding: 10px 5px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-color);
  border-bottom: 2px solid transparent;
  transition: all 0.3s;
}

.stat-item.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

.stat-count {
  font-weight: bold;
  margin-left: 4px;
}

/* Product Grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 8px;
  margin-top: 30px;
}

@media (min-width: 600px) {
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 900px) {
  .product-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 1200px) {
  .product-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

.product-card {
  background-color: var(--card-bg);
  border-radius: 2px;
  overflow: hidden;
  box-shadow: var(--shadow);
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s, background-color 0.3s;
  display: flex;
  flex-direction: column;
}

.product-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--hover-shadow);
}

.product-img-wrapper {
  position: relative;
  padding-top: 100%;
  overflow: hidden;
}

.product-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.discount-tag {
  position: absolute;
  top: 0;
  right: 0;
  background-color: rgba(255, 212, 36, 0.9);
  color: #ee4d2d;
  padding: 2px 4px;
  font-size: 12px;
  font-weight: bold;
  text-align: center;
  z-index: 1;
}

.discount-tag::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-bottom: 4px solid rgba(255, 212, 36, 0.9);
  position: absolute;
  bottom: -4px;
  left: 0;
}

.product-info {
  padding: 8px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.product-title {
  font-size: 12px;
  line-height: 14px;
  height: 28px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-bottom: 4px;
  color: var(--text-color);
}

.price-section {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.current-price {
  color: var(--primary-color);
  font-size: 16px;
  font-weight: bold;
  margin-right: 4px;
}

.current-price::before {
  content: "₫";
  font-size: 12px;
}

.original-price {
  color: var(--gray);
  font-size: 12px;
  text-decoration: line-through;
}

.original-price::before {
  content: "₫";
}

.product-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--gray);
  margin-bottom: 4px;
}

.progress-bar-container {
  position: relative;
  background-color: #ffbda6;
  border-radius: 8px;
  height: 16px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar-fill {
  background: linear-gradient(to right, #ac0b0b 0%, #ee4d2d 100%);
  height: 100%;
  border-radius: 8px 0 0 8px;
}

.progress-text {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 10px;
  text-transform: uppercase;
  font-weight: bold;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.2);
}

/* Card Actions (Always Visible) */
.card-actions-row {
  display: flex;
  gap: 4px;
  margin-top: auto;
}

.action-btn-full {
  flex: 1;
  border: 1px solid var(--primary-color);
  background-color: #fff;
  color: var(--primary-color);
  padding: 4px;
  border-radius: 2px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s;
}

.action-btn-full.primary {
  background-color: var(--primary-color);
  color: #fff;
}

.action-btn-full:hover {
  opacity: 0.9;
}

/* Floating Actions (Heart/Eye) */
.card-floating-actions {
  position: absolute;
  top: 5px;
  left: 5px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 1;
}

.action-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  color: #333;
}

[data-theme="dark"] .action-btn {
  background-color: rgba(30, 30, 30, 0.9);
  color: #e0e0e0;
}

.action-btn:hover {
  background-color: var(--white);
  color: var(--primary-color);
}

.action-btn.active {
  color: var(--primary-color);
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 1200px;
  background-color: var(--white);
  display: flex;
  border-top: 1px solid var(--border-color);
  height: var(--bottom-nav-height);
  z-index: 100;
  transition: background-color 0.3s;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--gray);
  font-size: 10px;
}

.nav-item.active {
  color: var(--primary-color);
}

.nav-icon {
  font-size: 20px;
  margin-bottom: 2px;
}

.loading,
.loading-more {
  text-align: center;
  padding: 20px;
  color: var(--gray);
  grid-column: 1 / -1;
  width: 100%;
}

.hidden {
  display: none;
}

/* Share Popup Modal */
.share-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.share-modal-content {
  background: var(--card-bg);
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  animation: modalSlideUp 0.3s ease;
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.share-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.share-modal-header h3 {
  margin: 0;
  font-size: 18px;
  color: var(--text-color);
}

.share-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--gray);
  cursor: pointer;
  transition: color 0.3s ease;
}

.share-modal-close:hover {
  color: var(--text-color);
}

.share-modal-body {
  padding: 20px;
}

.share-link-container {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.share-link-input {
  flex: 1;
  padding: 10px;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  font-size: 14px;
  background: var(--bg-color);
  color: var(--text-color);
}

.copy-btn {
  padding: 10px 20px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.copy-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(238, 77, 45, 0.3);
}

.copy-btn.copied {
  background: #4caf50;
}

.share-info {
  font-size: 12px;
  color: var(--gray);
  text-align: center;
}

/* Loading State for Buttons */
.action-btn-full.loading {
  opacity: 0.7;
  pointer-events: none;
}

.action-btn-full.loading i {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Dark Theme variables for better modal appearance */
[data-theme="dark"] .share-modal-content {
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

/* Responsive */
@media (max-width: 600px) {
  .share-modal-content {
    width: 95%;
  }

  .share-link-container {
    flex-direction: column;
  }

  .copy-btn {
    width: 100%;
  }
}
