:root {
    --bg-main: #fcfcfc;
    --surface: #ffffff;
    --text-main: #111111;
    --text-muted: #666666;
    --border: rgba(0,0,0,0.06);
    --accent: #c59b47;
    --danger: #d33c3c;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

[data-theme="dark"] {
    --bg-main: #070707;
    --surface: #0e0e0e;
    --text-main: #eeeeee;
    --text-muted: #888888;
    --border: rgba(197,155,71,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

body { font-family: 'Tajawal', sans-serif; background-color: var(--bg-main); color: var(--text-main); transition: background-color 0.3s, color 0.3s; font-size: 13px; }

.toast { position: fixed; top: 80px; left: 50%; transform: translate(-50%, -10px); background: var(--text-main); color: var(--bg-main); padding: 6px 14px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; z-index: 5000; opacity: 0; pointer-events: none; transition: all 0.4s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.navbar { position: fixed; top: 0; width: 100%; background: rgba(var(--bg-main), 0.85); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); z-index: 2500; transition: transform 0.4s ease; }
.navbar.hidden-nav { transform: translateY(-100%); }

.nav-content { max-width: 1400px; margin: 0 auto; height: 50px; padding: 0 15px; display: flex; justify-content: space-between; align-items: center; }
.logo { font-size: 1.1rem; font-weight: 900; color: var(--accent); letter-spacing: 0.5px; transition: opacity 0.2s; cursor: pointer; text-decoration: none; }
.logo:active { opacity: 0.7; }

.nav-links { display: flex; gap: 12px; }
.cat-btn { background: none; border: none; font-family: inherit; font-size: 0.8rem; font-weight: 700; color: var(--text-muted); cursor: pointer; position: relative; padding: 4px 0; transition: color 0.3s; }
.cat-btn.active, .cat-btn:hover { color: var(--text-main); }
.cat-btn::after { content: ''; position: absolute; bottom: 0; left: 0; width: 100%; height: 2px; background: var(--text-main); transform: scaleX(0); transition: transform 0.3s; }
.cat-btn.active::after { transform: scaleX(1); }

.nav-actions { display: flex; align-items: center; }
.icon-btn { background: none; border: none; color: var(--text-main); cursor: pointer; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 50%; transition: background 0.3s, transform 0.3s; position: relative; flex-shrink: 0; }
.icon-btn:hover { background: var(--surface); }

.cart-placeholder { width: 0; height: 32px; transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1), margin 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
.cart-placeholder.active { width: 32px; margin-right: 6px; }

.floating-cart { position: fixed; top: 0; left: 0; margin: 0; z-index: 2600; background: var(--surface); border: 1px solid var(--border); transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s; }
.floating-cart.in-search { border-color: transparent; background: transparent; }
#cart-count { position: absolute; top: -2px; right: -2px; background: var(--danger); color: #fff; font-size: 0.55rem; font-weight: 900; width: 14px; height: 14px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 2px solid var(--bg-main); }

.search-wrapper { position: fixed; top: 50px; width: 100%; background: var(--bg-main); padding: 8px 15px; border-bottom: 1px solid var(--border); z-index: 2400; display: flex; justify-content: center; transition: top 0.4s ease; }
.search-wrapper.scrolled-search { top: 0; }
.search-inner { display: flex; align-items: center; gap: 4px; width: 100%; max-width: 600px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 4px 12px; transition: border-color 0.3s; }
.search-inner:focus-within { border-color: var(--accent); }
.search-input { flex: 1; padding: 6px 0; background: transparent; border: none; color: var(--text-main); font-family: inherit; font-size: 0.8rem; outline: none; }
.filter-select { background: transparent; border: none; border-right: 1px solid var(--border); padding-right: 8px; margin-right: 8px; color: var(--text-muted); font-size: 0.75rem; outline: none; font-family: inherit; font-weight: bold; cursor: pointer; }
.search-btn { margin-right: 4px; }

.store-layout { padding: 110px 15px 60px; max-width: 1400px; margin: 0 auto; min-height: 100vh; }

.hero-square { width: 100%; aspect-ratio: 1/1; max-width: 450px; margin: 0 auto 15px; border-radius: var(--radius-lg); overflow: hidden; position: relative; border: 1px solid var(--border); pointer-events: none; }
.hero-slide { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: 0; transition: opacity 1s ease; }
.hero-slide.active { opacity: 1; }

.masonry-wrapper { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 15px; width: 100%; }
.masonry-col { display: flex; flex-direction: column; gap: 14px; flex: 1; min-width: 0; }

/* التصميم الجديد للبطاقات (نظيف تماماً) */
.product-card { background: var(--surface); border-radius: var(--radius-md); overflow: hidden; position: relative; width: 100%; break-inside: avoid-column; transform: translateZ(0); box-shadow: 0 4px 12px rgba(0,0,0,0.03); border: 1px solid var(--border); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease; }
.product-card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,0.06); }
[data-theme="dark"] .product-card { box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
[data-theme="dark"] .product-card:hover { box-shadow: 0 8px 24px rgba(0,0,0,0.4); }

.card-img-wrap { width: 100%; position: relative; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; }
.card-img { width: 100%; display: block; object-fit: cover; image-rendering: -webkit-optimize-contrast; image-rendering: crisp-edges; }

/* طبقة الاسم والسعر داخل الصورة */
.card-overlay-info { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 60%, transparent 100%); padding: 25px 10px 10px; z-index: 3; pointer-events: none; display: flex; flex-direction: column; gap: 2px; }
.card-overlay-info .card-title { font-size: 0.85rem; font-weight: 900; color: #ffffff; margin: 0; text-shadow: 0 1px 3px rgba(0,0,0,0.5); }
.card-overlay-info .price-wrap { display: flex; align-items: baseline; gap: 6px; }
.card-overlay-info .price { font-size: 0.8rem; font-weight: 900; color: var(--accent); text-shadow: 0 1px 2px rgba(0,0,0,0.5); }
.card-overlay-info .price.old { font-size: 0.65rem; color: #cccccc; text-decoration: line-through; font-weight: 400; }
.card-overlay-info .price.out { color: #ff6b6b; font-size: 0.75rem; }

/* إخفاء جسم البطاقة القديم لتوفير المساحة */
.product-card .card-body { display: none; }

.top-badges { position: absolute; top: 6px; left: 6px; right: 6px; display: flex; justify-content: space-between; align-items: flex-start; z-index: 4; pointer-events: none; }
.badge { background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); color: #fff; padding: 3px 6px; border-radius: 6px; font-size: 0.65rem; font-weight: 700; font-family: monospace; border: 1px solid rgba(255,255,255,0.1); pointer-events: auto; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
.badge:active { transform: scale(0.9); }
.share-badge { padding: 4px; border-radius: 50%; width: 26px; height: 26px; }

.ribbon { position: absolute; top: 10px; right: 0; background: var(--danger); color: #fff; padding: 3px 10px 3px 14px; font-size: 0.65rem; font-weight: 900; border-radius: 10px 0 0 10px; z-index: 10; box-shadow: 0 2px 8px rgba(0,0,0,0.2); pointer-events: none; }

.featured-3 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 15px; }

/* التصميم الأفقي معدل ليتماشى مع النظافة */
.feat-horizontal { grid-column: span 2; display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; position: relative; break-inside: avoid-column; transform: translateZ(0); box-shadow: 0 4px 12px rgba(0,0,0,0.03); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease; }
.feat-horizontal:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,0.06); }
[data-theme="dark"] .feat-horizontal { box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
[data-theme="dark"] .feat-horizontal:hover { box-shadow: 0 8px 24px rgba(0,0,0,0.4); }

.feat-horizontal.reverse { flex-direction: row-reverse; }
.feat-horizontal .img-part { width: 45%; background-size: cover; background-position: center; background-repeat: no-repeat; min-height: 120px; position: relative; overflow: hidden; cursor: pointer; }
.feat-horizontal .text-part { width: 55%; padding: 15px 10px; display: flex; flex-direction: column; justify-content: center; cursor: pointer; }
.feat-horizontal .card-title { font-size: 0.9rem; font-weight: 900; margin-bottom: 4px; color: var(--text-main); }
.feat-horizontal .price-wrap { display: flex; align-items: baseline; gap: 6px; }
.feat-horizontal .price { font-size: 0.9rem; font-weight: 900; color: var(--accent); }

.cats-block-spacing { margin-top: 30px; margin-bottom: 30px; }
.cats-end-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.cat-card-end { aspect-ratio: 16/9; background-size: cover; background-position: center; border-radius: var(--radius-md); position: relative; cursor: pointer; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border); overflow: hidden; }
.cat-card-end::after { content: ''; position: absolute; inset: 0; background: rgba(0,0,0,0.4); border-radius: inherit; transition: 0.3s; }
.cat-card-end:hover::after { background: rgba(0,0,0,0.6); }
.cat-card-end span { position: relative; z-index: 2; color: #fff; font-size: 1rem; font-weight: 900; }

.stacked-cats-card { position: relative; aspect-ratio: 16/9; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; cursor: pointer; border: 1px solid var(--border); background: var(--surface); transform-origin: center center; animation: baby-kick 5s infinite cubic-bezier(0.25, 1, 0.5, 1); box-shadow: 0 4px 15px rgba(197,155,71, 0.15); }
@keyframes baby-kick { 0%, 100% { transform: scale(1); } 3% { transform: scale(1.04); } 6% { transform: scale(1); } 9% { transform: scale(1.03); } 12% { transform: scale(1); } }
.stacked-cats-card .bg-img { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: 0.55; transition: opacity 0.4s; border-radius: inherit;}
.stacked-cats-card .stacked-cats-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.55); z-index: 4; display: flex; align-items: center; justify-content: center; border-radius: inherit;}
.stacked-cats-card span { position: relative; color: #fff; font-size: 1.05rem; font-weight: 900; z-index: 5; }

.full-cats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; width: 100%; padding-top: 10px; }

.skeleton-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; position: relative; width: 100%; margin-bottom: 14px; }
.skeleton-box::after { content: ""; position: absolute; top: 0; left: -100%; width: 50%; height: 100%; background: linear-gradient(90deg, transparent, rgba(197,155,71,0.1), transparent); animation: skeleton-shimmer 1.5s infinite; }
[data-theme="dark"] .skeleton-box::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent); }
@keyframes skeleton-shimmer { 100% { left: 200%; } }

.drawer { position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); z-index: 3000; display: flex; justify-content: center; align-items: flex-end; opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
.drawer:not(.hidden) { opacity: 1; pointer-events: auto; }
.drawer-content { background: var(--bg-main); width: 100%; max-width: 400px; padding: 16px; display: flex; flex-direction: column; transform: translateY(100%); transition: transform 0.3s ease; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 85vh; border-top: 1px solid var(--border); }
.drawer:not(.hidden) .drawer-content { transform: translateY(0); }

.drawer-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.drawer-header h2 { font-size: 1rem; font-weight: 900; }
.close-btn { background: var(--surface); border: 1px solid var(--border); color: var(--text-main); width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.absolute-close { position: absolute; top: 12px; right: 12px; z-index: 10; }

.cart-items-container { flex-grow: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.cart-item { display: flex; justify-content: space-between; align-items: center; padding: 10px; background: var(--surface); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.cart-item-info { font-size: 0.8rem; font-weight: 700; }
.cart-item-price { color: var(--accent); margin-right: 6px; }
.remove-btn { color: var(--danger); background: none; border: none; font-size: 1rem; cursor: pointer; }

.checkout-section { display: flex; flex-direction: column; gap: 6px; }
.checkout-section input { width: 100%; padding: 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text-main); font-family: inherit; font-size: 0.8rem; outline: none; }
.checkout-section input:focus { border-color: var(--accent); }

.btn { padding: 8px; border-radius: var(--radius-sm); font-family: inherit; font-size: 0.8rem; font-weight: 900; cursor: pointer; border: none; text-align: center; transition: transform 0.2s; display: flex; align-items: center; justify-content: center; gap: 6px; }
.btn:active { transform: scale(0.96); }
.primary-btn { background: var(--text-main); color: var(--bg-main); }
.secondary-btn { background: var(--surface); color: var(--text-main); border: 1px solid var(--border); }
.req-btn { background: var(--danger); color: #fff; }

.quick-buy-content { padding-top: 35px; text-align: right; overflow-y: auto; width: 100%; align-items: stretch; display: flex; flex-direction: column; }
.qb-image { width: 100%; border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 15px; border: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }
.qb-image img#qb-img { width: 100%; aspect-ratio: 1/1; object-fit: cover; image-rendering: high-quality; display: block; }
.qb-info { display: flex; flex-direction: column; gap: 10px; width: 100%; align-items: stretch; }
.qb-info h2 { font-size: 1.2rem; font-weight: 900; margin: 0; color: var(--text-main); line-height: 1.4; }
.qb-actions { display: flex; gap: 6px; margin-top: 5px; width: 100%; }

.gallery-thumbs { display: flex; gap: 6px; padding: 8px 0; overflow-x: auto; scrollbar-width: none; justify-content: flex-start; background: transparent; }
.gallery-thumbs::-webkit-scrollbar { display: none; }
.gallery-thumb { width: 50px; height: 50px; border-radius: var(--radius-sm); border: 2px solid transparent; cursor: pointer; object-fit: cover; opacity: 0.6; transition: 0.2s; flex-shrink: 0; image-rendering: -webkit-optimize-contrast;}
.gallery-thumb.active { border-color: var(--accent); opacity: 1; transform: scale(1.05); }

.variants-selector { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; width: 100%; justify-content: flex-start; }
.variant-btn { display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; cursor: pointer; transition: 0.2s; }
.variant-btn img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.variant-btn span { font-size: 0.8rem; font-weight: 700; color: var(--text-main); }
.variant-btn.active { border-color: var(--accent); background: rgba(197,155,71,0.08); }

/* --- تصميم واجهة المشاركة (Shared Mode) النقي جداً --- */
body.shared-mode { padding-top: 70px; }
body.shared-mode #search-wrapper { display: none !important; }
body.shared-mode #desktop-nav { display: none !important; }
body.shared-mode .nav-content { justify-content: center !important; position: relative; }
body.shared-mode .logo { font-size: 1.6rem; text-align: center; width: 100%; display: block; cursor: pointer;}
body.shared-mode .nav-actions { position: absolute; left: 15px; }

.shared-view-container { max-width: 900px; margin: 0 auto; background: var(--surface); border-radius: var(--radius-lg); overflow: hidden; padding: 20px; border: 1px solid var(--border); box-shadow: 0 4px 20px rgba(0,0,0,0.05); }
.shared-main-content { display: flex; flex-direction: column; gap: 20px; }
.shared-recommendations-wrapper { margin-top: 80px; padding-top: 40px; border-top: 2px solid var(--border); }

@media (min-width: 768px) {
    .nav-content { padding: 0 25px; }
    .store-layout { padding: 120px 25px 60px; display: flex; gap: 25px; flex-direction: row-reverse; }
    .search-wrapper { background: rgba(var(--bg-main), 0.9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
    .search-inner { border: 1px solid var(--border); background: var(--surface); }
    
    .desktop-sidebar { width: 220px; flex-shrink: 0; position: sticky; top: 65px; height: max-content; display: flex; flex-direction: column; gap: 14px; }
    .desktop-sidebar .cat-card-end { aspect-ratio: 2/1; }
    #desktop-nav { display: none; }
    
    .desktop-main { flex: 1; min-width: 0; }
    .masonry-wrapper { gap: 18px; }
    .masonry-col { gap: 18px; }
    .featured-3 { grid-template-columns: repeat(3, 1fr); gap: 18px; }
    .feat-horizontal { grid-column: span 1; flex-direction: column !important; }
    .feat-horizontal .img-part { width: 100%; height: 180px; }
    .feat-horizontal .text-part { width: 100%; padding: 12px; }
    .cats-end-grid { display: none; }
    .cats-block-spacing { display: none; }
    .drawer { align-items: center; }
    .drawer-content { border-radius: var(--radius-lg); border: 1px solid var(--border); max-height: 90vh; }
    .full-cats-grid { grid-template-columns: repeat(4, 1fr); gap: 20px; }
    
    body.shared-mode .store-layout { display: block; padding-top: 80px; }
    .shared-main-content { flex-direction: row; align-items: flex-start; }
    .shared-img-col { width: 45%; flex-shrink: 0; position: relative; }
    .shared-info-col { width: 55%; padding-top: 10px; }
}
@media (min-width: 1200px) { .masonry-wrapper { column-gap: 20px; } .full-cats-grid { grid-template-columns: repeat(5, 1fr); } }

.shared-img-large { width: 100%; border-radius: var(--radius-md); object-fit: cover; aspect-ratio: 1/1; border: 1px solid var(--border); display: block; }