/* ===== BASE ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary:      #16a34a;
  --primary-dark: #15803d;
  --accent:       #22c55e;
  --bg:           #ffffff;
  --surface:      #ffffff;
  --border:       #d1fae5;
  --text:         #1e293b;
  --muted:        #475569;
  --radius:       12px;
}
body { font-family: 'Inter', sans-serif; background: #ffffff; color: var(--text); line-height: 1.6; }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* ===== NAVBAR ===== */
.navbar { background: var(--primary); border-bottom: 1px solid var(--primary-dark); position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 12px rgba(22,163,74,0.2); }
.nav-inner { display: flex; align-items: center; gap: 20px; height: 64px; }
.nav-logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: #fff; flex-shrink: 0; }
.nav-logo img { height: 36px; filter: brightness(0) invert(1); }
.nav-logo span { background: rgba(255,255,255,0.2); color: #fff; padding: 2px 10px; border-radius: 6px; font-size: 13px; }
.nav-search { flex: 1; max-width: 440px; }
.nav-search form { display: flex; border: none; border-radius: 10px; overflow: hidden; box-shadow: 0 0 0 2px rgba(255,255,255,0.3); }
.nav-search input { flex: 1; padding: 9px 14px; border: none; outline: none; font-size: 14px; background: #fff; color: var(--text); }
.nav-search button { padding: 9px 16px; background: #fff; color: var(--primary); border: none; cursor: pointer; font-size: 16px; font-weight: 700; }
.nav-search button:hover { background: #f7fdf9; }
.nav-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.cart-btn { display: flex; align-items: center; gap: 8px; padding: 8px 18px; background: rgba(255,255,255,0.15); border: 1.5px solid rgba(255,255,255,0.3); border-radius: 10px; font-weight: 600; font-size: 14px; color: #fff; transition: .2s; }
.cart-btn:hover { background: rgba(255,255,255,0.25); }
.cart-badge { background: #fff; color: var(--primary); border-radius: 20px; padding: 1px 8px; font-size: 12px; font-weight: 700; }
.btn-main-site { padding: 8px 16px; background: rgba(255,255,255,0.15); border: 1.5px solid rgba(255,255,255,0.3); color: #fff; border-radius: 8px; font-size: 13px; font-weight: 600; transition: .2s; }
.btn-main-site:hover { background: rgba(255,255,255,0.25); }

/* Member nav buttons */
.nav-login-btn { padding: 7px 14px; border: 1.5px solid rgba(255,255,255,0.4); border-radius: 8px; font-size: 13px; font-weight: 600; color: #fff; transition: .2s; }
.nav-login-btn:hover { background: rgba(255,255,255,0.15); }
.nav-register-btn { padding: 7px 14px; background: #fff; color: var(--primary); border: 1.5px solid #fff; border-radius: 8px; font-size: 13px; font-weight: 700; transition: .2s; }
.nav-register-btn:hover { background: #f7fdf9; }

/* Member dropdown */
.member-menu-wrap { position: relative; }
.member-btn { display: flex; align-items: center; gap: 7px; padding: 6px 12px 6px 6px; background: rgba(255,255,255,0.15); border: 1.5px solid rgba(255,255,255,0.3); border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 600; color: #fff; font-family: inherit; transition: .2s; }
.member-btn:hover { background: rgba(255,255,255,0.25); }
.member-avatar { width: 28px; height: 28px; background: linear-gradient(135deg, #fff, #bbf7d0); color: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.member-btn-name { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-dropdown { display: none; position: absolute; right: 0; top: calc(100% + 8px); background: #fff; border: 1.5px solid var(--border); border-radius: 12px; box-shadow: 0 8px 24px rgba(22,163,74,0.15); min-width: 200px; z-index: 200; overflow: hidden; }
.member-dropdown a { display: block; padding: 11px 16px; font-size: 14px; color: var(--text); transition: .15s; }
.member-dropdown a:hover { background: #f7fdf9; color: var(--primary); }
.member-dropdown.open { display: block; }

/* ===== SHOP LAYOUT ===== */
.shop-layout { display: grid; grid-template-columns: 220px 1fr; gap: 28px; padding: 32px 24px; }

/* Sidebar */
.sidebar-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.sidebar-box h4 { font-size: 14px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 12px; }
.cat-list { list-style: none; }
.cat-list li a { display: flex; justify-content: space-between; padding: 9px 12px; border-radius: 8px; font-size: 14px; color: var(--text); transition: .2s; }
.cat-list li a:hover, .cat-list li a.active { background: #f7fdf9; color: var(--primary); font-weight: 600; }
.cat-list li a span { background: #ffffff; border-radius: 12px; padding: 1px 8px; font-size: 12px; }

/* Products top */
.products-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.products-top h2 { font-size: 20px; font-weight: 700; }
.sort-wrap { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.sort-wrap select { padding: 7px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; }
.sort-wrap select:focus { border-color: var(--primary); }

/* Products grid */
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }

/* ===== PRODUCT CARD (Advice style) ===== */
.product-card { background: #fff; border: 1px solid #dde8f0; border-radius: 12px; overflow: hidden; transition: box-shadow .2s, border-color .2s, transform .2s; display: flex; flex-direction: column; }
.product-card:hover { box-shadow: 0 6px 24px rgba(22,163,74,0.15); border-color: #16a34a; transform: translateY(-2px); }

/* Image */
.product-img-wrap { display: block; aspect-ratio: 1; overflow: hidden; background: #fff; padding: 14px; position: relative; }
.product-img-wrap img { width: 100%; height: 100%; object-fit: contain; transition: transform .3s; }
.product-card:hover .product-img-wrap img { transform: scale(1.05); }
.product-img-placeholder { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 60px; background: #f7fdf9; }
.product-img-placeholder.lg { height: 100%; font-size: 100px; aspect-ratio: unset; }

/* Info area */
.product-info { padding: 10px 13px 13px; flex: 1; display: flex; flex-direction: column; border-top: 1px solid #f7fdf9; }

/* Brand */
.pc-brand { font-size: 11px; font-weight: 700; color: #16a34a; text-transform: uppercase; letter-spacing: .6px; margin-bottom: 4px; }

/* Product name */
.product-name { font-size: 13px; font-weight: 600; line-height: 1.45; margin-bottom: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 38px; }
.product-name a { color: #1e293b; }
.product-name a:hover { color: #16a34a; }

/* Part No */
.pc-partno { font-size: 10px; color: #94a3b8; font-family: monospace; margin-bottom: 6px; }

/* Price section */
.pc-price-section { margin-top: auto; padding-top: 8px; }
.pc-price-row { display: flex; align-items: center; gap: 6px; margin-bottom: 1px; min-height: 18px; }
.pc-orig-price { font-size: 12px; color: #aab6c4; text-decoration: line-through; }
.pc-badge-ship { font-size: 10px; font-weight: 700; color: #16a34a; background: #d1fae5; padding: 2px 7px; border-radius: 10px; white-space: nowrap; margin-left: auto; }
.pc-final-price { font-size: 20px; font-weight: 800; color: #16a34a; line-height: 1.15; }
.pc-disc-row { display: flex; align-items: center; gap: 7px; margin-top: 5px; flex-wrap: wrap; min-height: 20px; }
.pc-disc-badge { background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 20px; white-space: nowrap; }
.pc-online-note { font-size: 10px; color: #94a3b8; }

/* Stock */
.pc-stock-row { margin-top: 6px; margin-bottom: 8px; }
.product-stock { font-size: 11px; font-weight: 600; }
.product-stock.in-stock { color: #16a34a; }
.product-stock.out-stock { color: #dc2626; }

/* Buy button */
.pc-btn-buy { width: 100%; padding: 10px; background: #16a34a; color: #fff; border: none; border-radius: 8px; font-size: 14px; font-weight: 700; cursor: pointer; transition: background .2s; letter-spacing: .2px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.pc-btn-buy:hover:not(:disabled) { background: #15803d; }
.pc-btn-buy:disabled { background: #bbf7d0; color: #d0e8f4; cursor: not-allowed; }

/* Legacy compat */
.product-cat { font-size: 11px; font-weight: 600; color: var(--primary); text-transform: uppercase; letter-spacing: .5px; }
.product-price { font-size: 16px; font-weight: 700; color: var(--primary); }
.btn-add-cart { width: 100%; padding: 9px; background: var(--primary); color: #fff; border: none; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; transition: .2s; }
.btn-add-cart:hover { background: var(--primary-dark); }
.btn-add-cart.disabled { background: #bbf7d0; color: #86efac; cursor: not-allowed; }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state h3 { font-size: 20px; margin: 16px 0 8px; }
.empty-state p { color: var(--muted); margin-bottom: 20px; }

/* Buttons */
.btn-primary { display: inline-block; padding: 11px 24px; background: var(--primary); color: #fff; border-radius: 10px; font-weight: 600; font-size: 14px; border: none; cursor: pointer; transition: .2s; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary.btn-full { width: 100%; text-align: center; }
.btn-primary.btn-lg { padding: 14px 32px; font-size: 16px; width: 100%; text-align: center; }
.btn-outline { display: inline-block; padding: 11px 24px; background: transparent; color: var(--primary); border: 1.5px solid var(--primary); border-radius: 10px; font-weight: 600; font-size: 14px; text-align: center; }
.btn-outline.btn-full { width: 100%; }

/* ===== PRODUCT DETAIL (legacy) ===== */
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 24px; }
.breadcrumb a { color: var(--primary); }
.breadcrumb a:hover { text-decoration: underline; }
.product-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-bottom: 48px; }
.product-detail-img { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; height: 400px; display: flex; align-items: center; justify-content: center; }
.product-detail-img img { width: 100%; height: 100%; object-fit: cover; }
.product-detail-info { display: flex; flex-direction: column; gap: 14px; }
.product-detail-info h1 { font-size: 24px; font-weight: 700; }
.product-sku { font-size: 13px; color: var(--muted); }
.detail-price { font-size: 28px; font-weight: 800; color: var(--primary); }
.detail-price small { font-size: 16px; font-weight: 400; color: var(--muted); }
.detail-stock { font-size: 14px; font-weight: 600; }
.detail-stock.in-stock { color: var(--primary); }
.detail-stock.out-stock { color: #dc2626; }
.detail-desc { font-size: 14px; color: var(--muted); line-height: 1.7; }
.qty-wrap { display: flex; align-items: center; gap: 12px; }
.qty-wrap label { font-weight: 600; }
.qty-control { display: flex; align-items: center; border: 1.5px solid var(--border); border-radius: 8px; overflow: hidden; }
.qty-control button { padding: 8px 16px; background: #ffffff; border: none; font-size: 18px; cursor: pointer; }
.qty-control input { width: 56px; text-align: center; border: none; border-left: 1px solid var(--border); border-right: 1px solid var(--border); padding: 8px; font-size: 14px; font-weight: 600; outline: none; }
.contact-order { background: #f7fdf9; border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; font-size: 13px; }
.contact-order a { color: var(--primary); font-weight: 600; }
.related-section { margin-top: 48px; }
.related-section h3 { font-size: 20px; font-weight: 700; margin-bottom: 20px; }

/* ===== CART ===== */
.cart-layout { display: grid; grid-template-columns: 1fr 340px; gap: 28px; }
.cart-items { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cart-item { display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.cart-item:last-child { border-bottom: none; }
.cart-item-info { flex: 1; }
.cart-item-name { font-size: 14px; font-weight: 600; }
.cart-item-price { font-size: 13px; color: var(--muted); margin-top: 2px; }
.cart-item-qty { display: flex; align-items: center; gap: 10px; }
.cart-item-qty button { width: 28px; height: 28px; border: 1.5px solid var(--border); border-radius: 6px; background: #ffffff; font-size: 16px; cursor: pointer; }
.cart-item-qty span { font-weight: 600; min-width: 24px; text-align: center; }
.cart-item-subtotal { font-weight: 700; color: var(--primary); min-width: 100px; text-align: right; }
.cart-remove { background: none; border: none; color: #dc2626; font-size: 18px; cursor: pointer; padding: 4px; }
.cart-summary { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; height: fit-content; }
.cart-summary h4 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.summary-row { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 14px; }
.summary-row.total { font-size: 18px; font-weight: 700; color: var(--primary); border-top: 1px solid var(--border); padding-top: 10px; margin-top: 4px; }
.free-ship-note { background: #fef9c3; color: #854d0e; font-size: 12px; padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; }

/* ===== CHECKOUT ===== */
.checkout-layout { display: grid; grid-template-columns: 1fr 340px; gap: 28px; align-items: start; }
.checkout-form { display: flex; flex-direction: column; gap: 20px; }
.form-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.form-section h4 { font-size: 15px; font-weight: 700; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; font-family: inherit; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22,163,74,0.1); }
.payment-options { display: flex; flex-direction: column; gap: 10px; }
.payment-option { cursor: pointer; }
.payment-option input { display: none; }
.payment-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1.5px solid var(--border); border-radius: 10px; transition: .2s; }
.payment-option input:checked + .payment-card { border-color: var(--primary); background: #f7fdf9; }
.payment-card span { font-size: 28px; }
.payment-card strong { display: block; font-size: 14px; }
.payment-card small { font-size: 12px; color: var(--muted); }
.checkout-summary { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; position: sticky; top: 80px; }
.checkout-summary h4 { font-size: 15px; font-weight: 700; margin-bottom: 16px; }
.order-item { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 10px; color: var(--muted); }
.checkout-summary hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.alert-error { background: #fee2e2; color: #991b1b; padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.alert-success { background: #f7fdf9; color: #15803d; padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }

/* ===== SUCCESS ===== */
.order-success-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; text-align: left; }
.success-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.success-row:last-child { border: none; }

/* ===== FOOTER ===== */
.footer { background: #f7fdf9; border-top: 1px solid #d1fae5; color: #475569; padding: 48px 0 24px; margin-top: 60px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 40px; margin-bottom: 32px; }
.footer h5 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: #16a34a; margin-bottom: 12px; }
.footer ul { list-style: none; }
.footer ul li { margin-bottom: 8px; font-size: 14px; color: #475569; }
.footer ul li a { color: #475569; }
.footer ul li a:hover { color: #16a34a; }
.footer p { color: #475569; }
.footer-bottom { border-top: 1px solid #d1fae5; padding-top: 20px; font-size: 13px; color: #94a3b8; }

/* ===== ANIMATIONS ===== */

/* Keyframes */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(60px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideOutRight {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(60px); }
}
@keyframes badgeBounce {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.5); }
  60%  { transform: scale(0.85); }
  80%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}
@keyframes ripple {
  from { transform: scale(0); opacity: .5; }
  to   { transform: scale(3); opacity: 0; }
}
@keyframes pulseStock {
  0%, 100% { opacity: 1; }
  50%       { opacity: .45; }
}
@keyframes navbarShow {
  from { transform: translateY(-100%); }
  to   { transform: translateY(0); }
}
@keyframes spinLoader {
  to { transform: rotate(360deg); }
}

/* Page body fade-in */
body { animation: fadeIn .35s ease; }

/* Navbar scrolled shadow */
.navbar.scrolled { box-shadow: 0 4px 20px rgba(22,163,74,0.25); }

/* Product cards — animate when revealed by Intersection Observer */
.product-card {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .45s ease, transform .45s ease,
              box-shadow .2s, border-color .2s;
}
.product-card.visible { opacity: 1; transform: translateY(0); }
.product-card:hover { box-shadow: 0 8px 28px rgba(22,163,74,0.15); border-color: #16a34a; transform: translateY(-3px); }

/* Stagger delay for cards (JS sets --i) */
.product-card { transition-delay: calc(var(--i, 0) * 60ms); }

/* Image zoom */
.product-img-wrap img { transition: transform .4s cubic-bezier(.25,.46,.45,.94); }
.product-card:hover .product-img-wrap img { transform: scale(1.07); }

/* Ripple button base */
.pc-btn-buy, .btn-primary, .btn-add-cart {
  position: relative;
  overflow: hidden;
}
.ripple-circle {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  width: 60px; height: 60px;
  margin-top: -30px; margin-left: -30px;
  animation: ripple .55s linear;
  pointer-events: none;
}

/* Buy button pulse on idle */
.pc-btn-buy:not(:disabled) { transition: background .2s, transform .15s; }
.pc-btn-buy:not(:disabled):active { transform: scale(0.96); }

/* Cart badge bounce */
.cart-badge.bounce { animation: badgeBounce .5s cubic-bezier(.36,.07,.19,.97); }

/* In-stock dot pulse */
.product-stock.in-stock::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px;
  background: #16a34a;
  border-radius: 50%;
  margin-right: 5px;
  animation: pulseStock 1.8s ease-in-out infinite;
  vertical-align: middle;
}
/* Hide the ● since we use ::before dot */
.product-stock.in-stock { font-size: 11px; }

/* Sidebar links */
.cat-list li a { transition: background .18s, color .18s, padding-left .18s; }
.cat-list li a:hover { padding-left: 16px; }

/* Form inputs */
.form-group input, .form-group select, .form-group textarea {
  transition: border-color .2s, box-shadow .2s;
}

/* Toast (upgraded) */
#toast-msg {
  transition: opacity .3s, transform .3s !important;
}

/* Scroll-reveal for non-grid elements */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .5s ease, transform .5s ease;
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* Loading spinner (for btn states) */
.btn-loading::after {
  content: '';
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spinLoader .6s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .shop-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .product-detail { grid-template-columns: 1fr; }
  .cart-layout, .checkout-layout { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  .nav-search { display: none; }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .product-card { opacity: 1; transform: none; }
}
