/* =============================================
   COMPONENTS.CSS — Reusable UI components
   ============================================= */

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  border: 2px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.1s, box-shadow 0.2s;
  user-select: none;
}

.btn:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

.btn:active { transform: scale(0.97); }

.btn--primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border-color: var(--btn-primary-bg);
}
.btn--primary:hover {
  background: var(--btn-primary-hover);
  border-color: var(--btn-primary-hover);
  color: var(--btn-primary-text);
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(var(--color-primary-rgb), 0.35);
}

.btn--outline {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn--outline:hover {
  background: var(--color-primary-subtle);
  text-decoration: none;
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: var(--color-border);
}
.btn--ghost:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
  text-decoration: none;
}

.btn--danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}
.btn--danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  text-decoration: none;
}

.btn--sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

.btn--lg {
  padding: 0.85rem 1.75rem;
  font-size: 1rem;
  border-radius: 10px;
}

.btn--full { width: 100%; }

.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn--loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn--loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  filter: invert(1);
}

/* ============ PRODUCT CARD ============ */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
}

@media (min-width: 1024px) {
  .product-grid { gap: 1.5rem; }
}

.product-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  position: relative;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--card-shadow-hover);
}

.product-card__image-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--color-surface-2);
}

.product-card__image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.product-card:hover .product-card__image-wrap img {
  transform: scale(1.06);
}

.product-card__badge {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  background: var(--color-danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.product-card__badge--new {
  background: var(--color-success);
}

.product-card__badge--featured {
  background: var(--color-primary);
}

.product-card__wishlist {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  box-shadow: 0 1px 4px var(--color-shadow);
}

.product-card__wishlist:hover {
  background: var(--color-primary-subtle);
  transform: scale(1.15);
}

.product-card__wishlist.active { color: var(--color-danger); }

.product-card__body {
  padding: 0.85rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.product-card__category {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.product-card__name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card__rating {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
}

.stars { color: var(--color-star); letter-spacing: 1px; }

.product-card__rating-count { color: var(--color-text-muted); }

.product-card__price-row {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-top: auto;
  flex-wrap: wrap;
}

.product-card__footer {
  padding: 0 0.85rem 0.85rem;
}

.product-card__footer .btn {
  width: 100%;
  font-size: 0.8rem;
  padding: 0.5rem;
}

/* ============ CATEGORY CARD ============ */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}

@media (min-width: 768px) {
  .category-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

.category-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--card-radius);
  padding: 1.25rem 1rem;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  box-shadow: var(--card-shadow);
}

.category-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--card-shadow-hover);
  border-color: var(--color-primary);
  text-decoration: none;
}

.category-card__icon {
  font-size: 2.2rem;
  line-height: 1;
}

.category-card__name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
}

.category-card__count {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* ============ FORM ELEMENTS ============ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
}

.form-label .required {
  color: var(--color-danger);
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.15);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--color-text-muted);
  opacity: 0.7;
}

.form-input--error,
.form-select--error {
  border-color: var(--color-danger);
}

.form-error {
  font-size: 0.78rem;
  color: var(--color-danger);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 1rem;
}

@media (min-width: 480px) {
  .form-row { grid-template-columns: 1fr 1fr; }
}

/* ============ STEPPER (checkout) ============ */
.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2rem;
  gap: 0;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.stepper__step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  position: relative;
  min-width: 80px;
}

.stepper__step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 18px;
  left: calc(50% + 18px);
  width: calc(100% - 4px);
  height: 2px;
  background: var(--color-border);
  transition: background 0.3s;
}

.stepper__step.completed:not(:last-child)::after {
  background: var(--color-primary);
}

.stepper__dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-text-muted);
  transition: all 0.3s;
  z-index: 1;
}

.stepper__step.active .stepper__dot {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(var(--color-primary-rgb), 0.2);
}

.stepper__step.completed .stepper__dot {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
}

.stepper__label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-align: center;
  white-space: nowrap;
}

.stepper__step.active .stepper__label { color: var(--color-primary); }
.stepper__step.completed .stepper__label { color: var(--color-success); }

/* ============ QUANTITY CONTROL ============ */
.qty-control {
  display: inline-flex;
  align-items: center;
  border: 1.5px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--color-surface);
}

.qty-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  line-height: 1;
}

.qty-btn:hover {
  background: var(--color-primary-subtle);
  color: var(--color-primary);
}

.qty-value {
  min-width: 36px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
  padding: 0 0.25rem;
  border: none;
  background: transparent;
  font-family: inherit;
}

/* ============ PRICE SUMMARY BOX ============ */
.price-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--card-radius);
  padding: 1.25rem;
}

.price-box__title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

.price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
  font-size: 0.9rem;
}

.price-row__label { color: var(--color-text-muted); }
.price-row__value { font-weight: 500; }

.price-row--total {
  border-top: 1px solid var(--color-border);
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  font-size: 1rem;
  font-weight: 700;
}

.price-row--discount .price-row__value { color: var(--color-danger); }
.price-row--savings .price-row__value  { color: var(--color-success); }

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--card-radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px var(--color-shadow);
  animation: slideUp 0.25s ease;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.modal__title { font-size: 1.1rem; font-weight: 700; }

.modal__close {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.2s;
}

.modal__close:hover { background: var(--color-surface-2); }

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

/* ============ TABS ============ */
.tabs {
  border-bottom: 2px solid var(--color-border);
  display: flex;
  gap: 0;
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.tab-btn {
  padding: 0.65rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab-btn:hover { color: var(--color-text); }

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* ============ CHIP / TAG ============ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.chip:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-subtle);
}

.chip.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

/* ============ SEARCH BAR ============ */
.search-bar {
  position: relative;
  width: 100%;
}

.search-bar__icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
}

.search-bar input {
  width: 100%;
  padding: 0.7rem 0.9rem 0.7rem 2.5rem;
  border: 1.5px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.15);
}

/* ============ REVIEW STARS ============ */
.review-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.review-card__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.review-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-primary-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--color-primary);
  flex-shrink: 0;
}

.review-name { font-weight: 600; font-size: 0.9rem; }
.review-date { font-size: 0.75rem; color: var(--color-text-muted); }
.review-text { font-size: 0.85rem; color: var(--color-text-muted); line-height: 1.5; }

/* ============ BADGE / ACHIEVEMENT ============ */
.achievement-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  text-align: center;
  min-width: 100px;
}

.achievement-badge__icon { font-size: 2rem; }
.achievement-badge__name { font-size: 0.75rem; font-weight: 700; color: var(--color-text); }
.achievement-badge__desc { font-size: 0.68rem; color: var(--color-text-muted); }

.achievement-badge--locked {
  opacity: 0.4;
  filter: grayscale(1);
}

/* ============ COURIER CARD ============ */
.courier-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border: 2px solid var(--color-border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 0.5rem;
  background: var(--color-surface);
}

.courier-card:hover { border-color: var(--color-primary); }
.courier-card.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-subtle);
}

.courier-card input[type="radio"] { accent-color: var(--color-primary); }

.courier-card__info { flex: 1; }
.courier-card__name { font-weight: 600; font-size: 0.9rem; }
.courier-card__eta  { font-size: 0.78rem; color: var(--color-text-muted); }
.courier-card__price { font-weight: 700; color: var(--color-primary); font-size: 0.95rem; white-space: nowrap; }

/* ============ VOUCHER INPUT ============ */
.voucher-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.voucher-row .form-input {
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.voucher-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--color-success-subtle);
  color: var(--color-success);
  border: 1px solid var(--color-success);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 0.4rem;
}
