@import url('style.css');

/* =============================================
   products.css — v2 (Quantity + Performance)
   ============================================= */

/* ── Layout ── */
.products-display { width: 100%; min-width: 0; }
.shop-container { display: grid; grid-template-columns: 200px 1fr; gap: 24px; align-items: start; }

/* ── Search bar ── */
.product-search-wrap { margin-bottom: 20px; }
.product-search-input {
    width: 100%; padding: 12px 18px 12px 44px;
    border: 2px solid rgba(139,115,85,0.18); border-radius: 999px;
    font-size: 0.95rem;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%238b7355' stroke-width='2.5'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 14px center;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-user-select: text; user-select: text; outline: none; color: var(--text-dark);
}
.product-search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139,115,85,0.12); }

/* ── Sidebar filter ── */
.product-filters {
    background: rgba(255,255,255,0.92); border-radius: 18px;
    padding: 18px 14px; box-shadow: 0 6px 20px rgba(45,33,23,0.09);
    position: sticky; top: 74px;
}
.product-filters h3 { font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin-bottom: 12px; }
.types-filter-list { display: flex; flex-direction: column; gap: 6px; }
.filter-btn {
    background: transparent; color: var(--text-dark);
    border: 1.5px solid rgba(139,115,85,0.18); border-radius: 999px;
    padding: 8px 14px; font-size: 0.84rem; font-weight: 600;
    cursor: pointer; text-align: left;
    transition: all 0.18s ease;
    -webkit-user-select: none; user-select: none;
}
.filter-btn:hover { background: var(--bg-soft); border-color: var(--accent); color: var(--accent); }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 3px 10px rgba(139,115,85,0.26); }

/* ── Product grid — content-visibility for performance ── */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

/* ── Product card ── */
.product-card {
    background: #fff; border-radius: 18px;
    box-shadow: 0 6px 22px rgba(45,33,23,0.09);
    overflow: hidden; display: flex; flex-direction: column;
    cursor: pointer;
    transition: transform 0.22s ease, box-shadow 0.22s ease;
    -webkit-tap-highlight-color: transparent;
    contain: layout style;   /* perf: isolate layout */
}
.product-card:hover { transform: translateY(-4px); box-shadow: 0 16px 40px rgba(45,33,23,0.15); }
.product-card:active { transform: scale(0.98); }

/* ── Image area ── */
.product-img-wrap { position: relative; width: 100%; aspect-ratio: 1/1; overflow: hidden; background: var(--bg-soft); }
.product-img-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.4s ease; }
.product-card:hover .product-img-wrap img { transform: scale(1.06); }

.card-tap-hint {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: linear-gradient(transparent, rgba(47,36,27,0.55));
    color: #fff; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.05em;
    text-align: center; padding: 18px 8px 8px;
    opacity: 0; transition: opacity 0.25s ease; pointer-events: none;
}
.product-card:hover .card-tap-hint { opacity: 1; }

/* Badges */
.discount-badge {
    position: absolute; top: 10px; right: 10px;
    background: #e53935; color: #fff; font-size: 0.7rem; font-weight: 800;
    padding: 4px 9px; border-radius: 999px;
    box-shadow: 0 3px 10px rgba(229,57,53,0.42);
    animation: badgePulse 2s ease-in-out infinite; z-index: 2; pointer-events: none;
}
@keyframes badgePulse {
    0%,100% { transform: scale(1); box-shadow: 0 3px 10px rgba(229,57,53,0.42); }
    50%      { transform: scale(1.12); box-shadow: 0 5px 18px rgba(229,57,53,0.60); }
}
.img-count-badge {
    position: absolute; bottom: 8px; left: 8px;
    background: rgba(47,36,27,0.70); color: #fff;
    font-size: 0.68rem; font-weight: 700; padding: 3px 8px;
    border-radius: 999px; pointer-events: none;
}

/* ── Card body ── */
.product-card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-card-body h3 {
    font-size: 0.95rem; font-weight: 700; color: var(--text-dark); line-height: 1.3;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.product-card-body p {
    font-size: 0.8rem; color: var(--text-muted); line-height: 1.45;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; flex: 1;
}
.price-box { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.old-price { font-size: 0.8rem; color: var(--text-muted); text-decoration: line-through; }
.new-price { font-size: 1rem; font-weight: 800; color: var(--accent); }

/* ── QUANTITY SELECTOR on product card ── */
.card-qty-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}
.card-qty-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
}
.card-qty-controls {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg-soft, #f5efe8);
    border-radius: 10px;
    overflow: hidden;
    border: 1.5px solid rgba(139,115,85,0.18);
}
.card-qty-btn {
    width: 30px; height: 30px;
    min-width: 30px;
    background: transparent;
    border: none;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--accent, #8b7355);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.card-qty-btn:hover { background: rgba(139,115,85,0.12); }
.card-qty-btn:active { background: rgba(139,115,85,0.22); }
.card-qty-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.card-qty-display {
    min-width: 30px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-dark, #2f241b);
    border-left: 1.5px solid rgba(139,115,85,0.18);
    border-right: 1.5px solid rgba(139,115,85,0.18);
    padding: 0 4px;
    line-height: 30px;
    -webkit-user-select: none; user-select: none;
    pointer-events: none;
}

/* ── Add to Cart button ── */
.add-cart-btn {
    width: 100%; margin-top: 8px; padding: 9px 12px;
    font-size: 0.82rem; font-weight: 700; border-radius: 12px;
    background: var(--accent); color: #fff;
    box-shadow: 0 3px 10px rgba(139,115,85,0.20);
    transition: background 0.2s, transform 0.15s;
    touch-action: manipulation;
}
.add-cart-btn:hover { background: #705540; transform: translateY(-1px); }
.add-cart-btn:active { transform: scale(0.97); }
.add-cart-btn.added { background: #4caf50 !important; }

/* ── Empty/no results ── */
.no-products { color: var(--text-muted); grid-column: 1/-1; text-align: center; padding: 48px 20px; font-size: 1rem; }

/* ── Load more button ── */
.load-more-wrap { grid-column: 1/-1; display: flex; justify-content: center; margin-top: 8px; }
.load-more-btn {
    padding: 12px 32px; border-radius: 999px;
    background: var(--accent); color: #fff;
    font-weight: 700; font-size: 0.9rem; cursor: pointer;
    box-shadow: 0 4px 14px rgba(139,115,85,0.22);
    transition: background 0.2s, transform 0.15s;
}
.load-more-btn:hover { background: #705540; transform: translateY(-1px); }

/* =============================================
   PRODUCT LIGHTBOX
   ============================================= */
#product-lightbox { display: none; position: fixed; inset: 0; z-index: 5000; align-items: center; justify-content: center; padding: 16px; }
#product-lightbox.active { display: flex; }
.lb-backdrop { position: absolute; inset: 0; background: rgba(20,14,10,0.80); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.lb-box {
    position: relative; background: #fff; border-radius: 24px;
    box-shadow: 0 32px 80px rgba(20,14,10,0.35);
    display: flex; flex-direction: row;
    max-width: 860px; width: 100%; max-height: 90vh; overflow: hidden;
    animation: lbIn 0.32s cubic-bezier(.34,1.3,.64,1) both;
}
@keyframes lbIn { from { opacity:0; transform:scale(0.88) translateY(16px); } to { opacity:1; transform:scale(1) translateY(0); } }

.lb-close {
    position: absolute; top: 12px; right: 14px;
    width: 34px; height: 34px; border-radius: 50%;
    background: rgba(255,255,255,0.9); border: none; font-size: 1.1rem;
    cursor: pointer; z-index: 10; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18); color: var(--text-dark);
    transition: background 0.2s; padding: 0;
}
.lb-close:hover { background: #f0e8df; transform: none; }

.lb-img-area { position: relative; flex: 0 0 55%; background: var(--bg-soft); overflow: hidden; min-height: 340px; }
#lb-main-img { width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity 0.18s ease, transform 0.18s ease; }

.lb-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 38px; height: 38px; border-radius: 50%;
    background: rgba(255,255,255,0.88); border: none; font-size: 1.4rem;
    cursor: pointer; z-index: 3; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18); color: var(--text-dark); transition: background 0.2s; padding: 0; line-height: 1;
}
.lb-nav:hover { background: #fff; transform: translateY(-50%) scale(1.08); }
.lb-prev { left: 10px; } .lb-next { right: 10px; }

.lb-dots { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; }
.lb-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.5); cursor: pointer; transition: background 0.2s, transform 0.2s; }
.lb-dot.active { background: #fff; transform: scale(1.25); }

.lb-info { flex: 1; padding: 28px 24px 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.lb-badge { display: inline-block; background: #e53935; color: #fff; font-size: 0.72rem; font-weight: 800; padding: 4px 12px; border-radius: 999px; width: fit-content; animation: badgePulse 2s ease-in-out infinite; }
.lb-name { font-size: 1.3rem; font-weight: 700; color: var(--text-dark); line-height: 1.25; margin-top: 2px; }
.lb-desc { font-size: 0.9rem; color: var(--text-muted); line-height: 1.6; flex: 1; }

.lb-price-row {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 12px 0;
    border-top: 1px solid rgba(139,115,85,0.12);
    border-bottom: 1px solid rgba(139,115,85,0.12);
}
.lb-old { font-size: 0.9rem; color: var(--text-muted); text-decoration: line-through; }
.lb-new { font-size: 1.5rem; font-weight: 800; color: var(--accent); }
.lb-save { font-size: 0.78rem; font-weight: 700; background: #fff3e0; color: #e65100; padding: 3px 9px; border-radius: 999px; }

/* Lightbox quantity row */
.lb-qty-row { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.lb-qty-label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.lb-qty-controls {
    display: flex; align-items: center; gap: 0;
    background: var(--bg-soft, #f5efe8); border-radius: 12px;
    overflow: hidden; border: 1.5px solid rgba(139,115,85,0.22);
}
.lb-qty-btn {
    width: 38px; height: 38px; background: transparent; border: none;
    font-size: 1.2rem; font-weight: 700; color: var(--accent, #8b7355);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background 0.15s; padding: 0; touch-action: manipulation;
    box-shadow: none; border-radius: 0;
}
.lb-qty-btn:hover { background: rgba(139,115,85,0.12); }
.lb-qty-btn:active { background: rgba(139,115,85,0.22); }
.lb-qty-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.lb-qty-val {
    min-width: 40px; text-align: center;
    font-size: 1.05rem; font-weight: 700; color: var(--text-dark);
    border-left: 1.5px solid rgba(139,115,85,0.18);
    border-right: 1.5px solid rgba(139,115,85,0.18);
    padding: 0 6px; line-height: 38px;
    -webkit-user-select: none; user-select: none;
}
.lb-cart-btn {
    flex: 1; padding: 12px 16px; font-size: 0.95rem; font-weight: 700;
    border-radius: 14px; background: var(--accent); color: #fff;
    box-shadow: 0 6px 18px rgba(139,115,85,0.26);
    transition: background 0.22s, transform 0.15s;
    margin-top: 0; width: auto; touch-action: manipulation;
}
.lb-cart-btn:hover { background: #705540; transform: translateY(-1px); }

/* ── Admin media preview ── */
.product-media-preview { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.img-preview-wrap { position: relative; display: inline-block; }
.img-preview-wrap img { width: 82px; height: 82px; object-fit: cover; border-radius: 10px; display: block; border: 2px solid rgba(139,115,85,0.18); }
.img-remove-btn {
    position: absolute; top: -7px; right: -7px;
    width: 22px; height: 22px; border-radius: 50%;
    background: #e53935; color: #fff; border: 2px solid #fff;
    font-size: 0.7rem; cursor: pointer; padding: 0;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 6px rgba(229,57,53,0.4);
    transition: background 0.2s; line-height: 1;
}
.img-remove-btn:hover { background: #c62828; transform: none; }
.img-preview-num { position: absolute; bottom: 4px; left: 5px; background: rgba(0,0,0,0.55); color: #fff; font-size: 0.62rem; font-weight: 700; padding: 1px 5px; border-radius: 999px; pointer-events: none; }

/* ── Loading skeleton ── */
.product-skeleton {
    background: #fff; border-radius: 18px;
    overflow: hidden; min-height: 280px;
}
.skeleton-img { aspect-ratio: 1/1; background: linear-gradient(90deg, #f0e8df 25%, #e8ddd4 50%, #f0e8df 75%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; }
.skeleton-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.skeleton-line { height: 12px; border-radius: 6px; background: linear-gradient(90deg, #f0e8df 25%, #e8ddd4 50%, #f0e8df 75%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; }
.skeleton-line.w60 { width: 60%; } .skeleton-line.w80 { width: 80%; } .skeleton-line.w40 { width: 40%; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* =============================================
   MOBILE responsive
   ============================================= */
@media (max-width: 900px) {
    .shop-container { grid-template-columns: 1fr; gap: 14px; }
    .product-filters { position: static; padding: 12px 14px; border-radius: 14px; }
    .product-filters h3 { margin-bottom: 8px; font-size: 0.72rem; }
    .types-filter-list { flex-direction: row; overflow-x: auto; flex-wrap: nowrap; gap: 7px; padding-bottom: 2px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .types-filter-list::-webkit-scrollbar { display: none; }
    .filter-btn { flex-shrink: 0; white-space: nowrap; padding: 7px 14px; font-size: 0.8rem; }
}

@media (max-width: 600px) {
    .product-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .product-img-wrap { aspect-ratio: 1/1; }
    .product-card-body { padding: 10px 11px 12px; gap: 4px; }
    .product-card-body h3 { font-size: 0.87rem; }
    .product-card-body p { -webkit-line-clamp: 1; font-size: 0.76rem; }
    .new-price { font-size: 0.92rem; }
    .add-cart-btn { padding: 8px 10px; font-size: 0.8rem; border-radius: 10px; }
    .card-qty-btn { width: 28px; height: 28px; min-width: 28px; font-size: 0.95rem; }
    .card-qty-display { min-width: 26px; font-size: 0.82rem; line-height: 28px; }
    .card-qty-label { display: none; }

    /* Lightbox full-screen on mobile */
    .lb-box { flex-direction: column; border-radius: 20px 20px 0 0; max-height: 94vh; align-self: flex-end; width: 100%; margin: 0; border-radius: 20px 20px 0 0; }
    #product-lightbox { padding: 0; align-items: flex-end; }
    .lb-img-area { flex: 0 0 auto; min-height: 220px; height: 42vw; max-height: 260px; }
    .lb-info { padding: 16px 18px 18px; gap: 8px; }
    .lb-name { font-size: 1.1rem; }
    .lb-new { font-size: 1.25rem; }
    .lb-cart-btn { padding: 11px 14px; font-size: 0.9rem; }
}

@media (max-width: 380px) {
    .product-grid { grid-template-columns: 1fr; }
}

/* =============================================
   CART ITEMS (inside cart sidebar/modal)
   ============================================= */
.cart-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 0;
    border-bottom: 1px solid rgba(139,115,85,0.1);
}
.cart-item:last-child { border-bottom: none; }
.cart-item img {
    width: 64px; height: 64px; object-fit: cover;
    border-radius: 12px; flex-shrink: 0;
    border: 1.5px solid rgba(139,115,85,0.12);
}
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-info h4 { font-size: 0.88rem; font-weight: 700; color: var(--text-dark); margin: 0 0 4px; line-height: 1.3; }
.cart-item-info p { font-size: 0.8rem; color: var(--text-muted); margin: 0 0 6px; }
.cart-subtotal { font-size: 0.82rem; color: var(--text-dark); font-weight: 600; margin-top: 6px !important; }

/* Cart quantity controls */
.cart-qty-controls {
    display: flex; align-items: center; gap: 0;
    background: var(--bg-soft, #f5efe8);
    border-radius: 10px; overflow: hidden;
    border: 1.5px solid rgba(139,115,85,0.18);
    width: fit-content; margin: 4px 0 0;
}
.cart-qty-btn {
    width: 30px; height: 30px; background: transparent; border: none;
    font-size: 1rem; font-weight: 700; color: var(--accent, #8b7355);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background 0.15s; padding: 0; touch-action: manipulation; box-shadow: none; border-radius: 0;
}
.cart-qty-btn:hover { background: rgba(139,115,85,0.12); }
.cart-qty-btn:active { background: rgba(139,115,85,0.22); }
.cart-qty-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.cart-qty-num {
    min-width: 30px; text-align: center; font-size: 0.88rem; font-weight: 700;
    color: var(--text-dark); padding: 0 4px; line-height: 30px;
    border-left: 1.5px solid rgba(139,115,85,0.18);
    border-right: 1.5px solid rgba(139,115,85,0.18);
    -webkit-user-select: none; user-select: none;
}
.cart-remove-btn {
    width: 28px; height: 28px; border-radius: 50%;
    background: rgba(229,57,53,0.1); color: #e53935; border: none;
    font-size: 0.8rem; cursor: pointer; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s; padding: 0; box-shadow: none;
    margin-top: 2px;
}
.cart-remove-btn:hover { background: rgba(229,57,53,0.2); transform: none; }

@media (max-width: 480px) {
    .cart-item img { width: 52px; height: 52px; }
    .cart-item-info h4 { font-size: 0.82rem; }
    .cart-qty-btn { width: 28px; height: 28px; }
    .cart-qty-num { min-width: 26px; line-height: 28px; }
}
