/**
 * assets/css/default/cart.css
 * =================================================================
 * تنسيق صفحة السلة + badge السلة في الأعلى + بطاقات الإجمالي.
 * يعمل مع RTL و LTR عبر inset-inline-end/:-start.
 * ================================================================= */

/* ═══ Badge in top nav ═══ */
.cart-nav-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 38px; min-height: 38px; padding: 0 10px; border-radius: 50%; background: var(--bg-secondary, #f0f2f5); transition: background .2s; }
.cart-nav-btn:hover { background: var(--bg-tertiary, #e4e6eb); }
.cart-badge { position: absolute; top: -4px; inset-inline-end: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #e41e3f; color: #fff; font-size: .65rem; font-weight: 700; display: flex; align-items: center; justify-content: center; line-height: 1; box-shadow: 0 2px 5px rgba(228,30,63,.4); }

/* ═══ Cart page ═══ */
.cart-page { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
.cart-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 22px; }
.cart-header h1 { font-size: 1.6rem; font-weight: 800; margin: 0; display: flex; align-items: center; gap: 10px; }
.cart-header h1 i { color: var(--primary, #1877f2); }

.cart-empty-state { text-align: center; padding: 60px 20px; background: var(--card-bg, #fff); border-radius: 14px; box-shadow: var(--shadow, 0 1px 3px rgba(0,0,0,.08)); }
.cart-empty-state h2 { margin: 0 0 8px; font-size: 1.3rem; color: var(--text-primary, #0f172a); }
.cart-empty-state p { color: var(--text-secondary, #65676b); margin: 0 0 12px; }

/* ═══ Cart grid (items + summary) ═══ */
.cart-grid { display: grid; grid-template-columns: 1fr 360px; gap: 22px; align-items: start; }
@media (max-width: 900px) {
    .cart-grid { grid-template-columns: 1fr; }
}

.cart-items-col { background: var(--card-bg, #fff); border-radius: 14px; box-shadow: var(--shadow, 0 1px 3px rgba(0,0,0,.08)); overflow: hidden; }
.cart-items-list { padding: 6px 18px; }
.cart-item { display: grid; grid-template-columns: 80px 1fr auto auto auto; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--border, #e4e6eb); align-items: center; }
.cart-item:last-child { border-bottom: none; }
@media (max-width: 640px) {
    .cart-item { grid-template-columns: 64px 1fr; grid-template-areas: "img info" "qty subtotal" "remove remove"; gap: 10px 12px; }
    .cart-item-img { grid-area: img; }
    .cart-item-info { grid-area: info; }
    .cart-item-qty { grid-area: qty; }
    .cart-item-subtotal { grid-area: subtotal; text-align: end; }
    .cart-item-remove { grid-area: remove; justify-self: end; }
}

.cart-item-img img { width: 80px; height: 80px; object-fit: cover; border-radius: 10px; background: var(--bg-secondary, #f0f2f5); }
@media (max-width: 640px) { .cart-item-img img { width: 64px; height: 64px; } }

.cart-item-info { min-width: 0; }
.cart-item-name { font-size: 1rem; font-weight: 700; margin: 0 0 6px; color: var(--text-primary, #0f172a); line-height: 1.4; word-break: break-word; }
.cart-item-price-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .9rem; }
.cart-item-price { color: var(--primary, #1877f2); font-weight: 700; }
.cart-item-old-price { text-decoration: line-through; color: var(--text-secondary, #65676b); font-size: .82rem; }
.cart-item-stock { display: block; margin-top: 4px; color: var(--text-secondary, #65676b); font-size: .76rem; }

.cart-item-qty { display: flex; align-items: center; gap: 0; border: 1px solid var(--border, #e4e6eb); border-radius: 8px; overflow: hidden; height: 36px; }
.qty-btn { background: var(--bg-secondary, #f0f2f5); border: none; width: 32px; height: 100%; cursor: pointer; color: var(--text-primary, #0f172a); font-size: .8rem; display: flex; align-items: center; justify-content: center; transition: background .15s; }
.qty-btn:hover { background: var(--bg-tertiary, #e4e6eb); }
.qty-input { width: 42px; height: 100%; text-align: center; border: none; border-inline: 1px solid var(--border, #e4e6eb); background: var(--card-bg, #fff); color: var(--text-primary, #0f172a); font-size: .9rem; font-weight: 600; outline: none; -moz-appearance: textfield; }
.qty-input::-webkit-outer-spin-button, .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.cart-item-subtotal { font-size: .95rem; color: var(--text-primary, #0f172a); white-space: nowrap; min-width: 90px; text-align: end; }
.cart-item-remove { background: transparent; border: none; color: #e41e3f; cursor: pointer; font-size: 1.05rem; padding: 6px 8px; border-radius: 6px; transition: background .15s; }
.cart-item-remove:hover { background: rgba(228,30,63,.12); }

.cart-actions-bottom { padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--bg-secondary, #f0f2f5); border-top: 1px solid var(--border, #e4e6eb); }

/* ═══ Summary card ═══ */
.cart-summary-col { position: sticky; top: 80px; }
.cart-summary-card { background: var(--card-bg, #fff); border-radius: 14px; padding: 22px; box-shadow: var(--shadow, 0 1px 3px rgba(0,0,0,.08)); }
.cart-summary-card h3 { margin: 0 0 16px; font-size: 1.1rem; font-weight: 800; color: var(--text-primary, #0f172a); display: flex; align-items: center; gap: 8px; }
.cart-summary-card h3 i { color: var(--primary, #1877f2); }
.cart-summary-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: .9rem; color: var(--text-primary, #0f172a); }
.cart-summary-row + hr { border: 0; border-top: 1px dashed var(--border, #e4e6eb); margin: 10px 0; }
.cart-total-row { font-size: 1.05rem; }
.cart-total-row strong { color: var(--primary, #1877f2); }

.cred-field { margin-bottom: 12px; }
.cred-field label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-secondary, #65676b); margin-bottom: 5px; }
.cred-field input, .cred-field textarea { width: 100%; border: 1.5px solid var(--border-color, #e4e6eb); border-radius: 8px; padding: 9px 12px; font-size: .92rem; font-family: inherit; background: var(--card-bg, #fff); color: var(--text-primary, #0f172a); box-sizing: border-box; }
.cred-field input:focus, .cred-field textarea:focus { border-color: var(--primary, #1877f2); outline: none; box-shadow: 0 0 0 3px rgba(24,119,242,.1); }

.gateway-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.gw-opt { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1.5px solid var(--border-color, #e4e6eb); border-radius: 8px; cursor: pointer; font-size: .88rem; background: var(--card-bg, #fff); color: var(--text-primary, #0f172a); transition: border-color .15s; }
.gw-opt:hover { border-color: var(--primary, #1877f2); }
.gw-opt input { accent-color: var(--primary, #1877f2); }

.btn-primary.btn-full { width: 100%; margin-top: 14px; padding: 12px; background: var(--primary, #1877f2); color: #fff; border: none; border-radius: 10px; font-size: .95rem; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; transition: filter .15s; }
.btn-primary.btn-full:hover { filter: brightness(1.08); }
.btn-primary.btn-full:disabled { opacity: .55; cursor: not-allowed; }

.btn-outline.btn-sm { padding: 6px 12px; border: 1.5px solid var(--border-color, #e4e6eb); border-radius: 8px; background: transparent; color: var(--text-primary, #0f172a); font-size: .85rem; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: background .15s; }
.btn-outline.btn-sm:hover { background: var(--bg-secondary, #f0f2f5); }

/* ═══ Modal login (kept consistent with product_view) ═══ */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 9999; padding: 16px; backdrop-filter: blur(2px); }
.modal-card { background: var(--card-bg, #fff); border-radius: 14px; max-width: 460px; width: 100%; padding: 28px; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-close-x { position: absolute; top: 10px; inset-inline-end: 14px; background: transparent; border: none; font-size: 1.1rem; cursor: pointer; color: var(--text-secondary, #65676b); }
.login-modal-icon { font-size: 2.4rem; text-align: center; margin-bottom: 8px; }
.modal-card h3 { margin: 0 0 14px; font-size: 1.15rem; color: var(--text-primary, #0f172a); }
.terms-box p { font-size: .85rem; color: var(--text-secondary, #65676b); margin: 8px 0; line-height: 1.6; }
.modal-actions { display: flex; gap: 10px; flex-direction: column; margin-top: 14px; }
.btn-primary, .btn-secondary { padding: 10px 16px; border-radius: 10px; border: none; font-size: .92rem; font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--primary, #1877f2); color: #fff; }
.btn-secondary { background: var(--bg-secondary, #f0f2f5); color: var(--text-primary, #0f172a); }
.btn-full { width: 100%; }
.oauth-providers { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.oauth-btn { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 14px; border-radius: 10px; text-decoration: none; font-size: .9rem; font-weight: 600; transition: filter .15s; }
.oauth-btn:hover { filter: brightness(1.05); }
.oauth-google { background: #fff; color: #3c4043; border: 1.5px solid #dadce0; }
.oauth-github { background: #24292e; color: #fff; }
.oauth-facebook { background: #1877f2; color: #fff; }
.oauth-local { background: var(--bg-secondary, #f0f2f5); color: var(--text-primary, #0f172a); }

/* Dark mode tweaks */
body.dark .cart-items-col,
body.dark .cart-summary-card,
body.dark .cart-empty-state,
body.dark .modal-card { background: var(--card-bg, #1e293b); }
body.dark .cart-item { border-color: var(--border, #334155); }
body.dark .cart-item-subtotal,
body.dark .cart-item-name,
body.dark .cart-summary-card h3,
body.dark .cart-summary-row { color: var(--text-primary, #f1f5f9); }
body.dark .cart-item-old-price,
body.dark .cart-item-stock { color: var(--text-secondary, #94a3b8); }
body.dark .qty-btn { background: var(--bg-secondary, #0f172a); color: var(--text-primary, #f1f5f9); }
body.dark .qty-input { background: var(--card-bg, #1e293b); color: var(--text-primary, #f1f5f9); border-color: var(--border, #334155); }
body.dark .cred-field input,
body.dark .cred-field textarea { background: var(--card-bg, #1e293b); color: var(--text-primary, #f1f5f9); border-color: var(--border, #334155); }
body.dark .gw-opt { background: var(--card-bg, #1e293b); color: var(--text-primary, #f1f5f9); }

/* ═══ Quick "Add to cart" button on product card (index.php) ═══ */
.product-card { position: relative; }
.product-card-cart-btn {
    position: absolute;
    bottom: 8px;
    inset-inline-end: 8px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,.92);
    color: var(--primary, #1877f2);
    border: none;
    cursor: pointer;
    font-size: .92rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,.18);
    transition: transform .15s, background .15s, color .15s;
    z-index: 5;
}
.product-card-cart-btn:hover {
    background: var(--primary, #1877f2);
    color: #fff;
    transform: scale(1.08);
}
.product-card-cart-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
body.dark .product-card-cart-btn { background: rgba(30,41,59,.92); color: #f1f5f9; }
body.dark .product-card-cart-btn:hover { background: var(--primary, #1877f2); color: #fff; }

/* Cart nav button (used on index/product_view) — keep alignment with other nav buttons */
.nav-icon-btn.cart-nav-btn { padding: 0 10px; }

/* Empty cart state styling */
.cart-empty-state { background: var(--card-bg, #fff); border-radius: 14px; padding: 60px 20px; text-align: center; box-shadow: var(--shadow, 0 1px 3px rgba(0,0,0,.08)); }

/* ════════════════════════════════════════════════════════════════════
   Related-products scroll bar (product_view.php bottom)
   شريط المنتجات الأخرى — أفقي قابل للسحب مع أزرار تنقل احترافية.
   ════════════════════════════════════════════════════════════════════ */
.related-products-bar {
    margin: 36px 0 8px;
    background: var(--card-bg, #fff);
    border-radius: 16px;
    padding: 22px 20px 20px;
    box-shadow: var(--shadow, 0 2px 12px rgba(0,0,0,.06));
    border: 1px solid var(--border, #e4e6eb);
}
.related-products-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.related-products-head h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-primary, #0f172a);
    display: flex;
    align-items: center;
    gap: 10px;
}
.related-products-head h3 i { color: var(--primary, #1877f2); }
.related-products-nav {
    display: flex;
    gap: 8px;
}
.rp-scroll-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1.5px solid var(--border, #e4e6eb);
    background: var(--bg-secondary, #f0f2f5);
    color: var(--text-primary, #0f172a);
    cursor: pointer;
    font-size: .85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, transform .15s, opacity .15s, border-color .15s;
    opacity: 1;
}
.rp-scroll-btn:hover {
    background: var(--primary, #1877f2);
    color: #fff;
    border-color: var(--primary, #1877f2);
    transform: translateY(-1px);
}
.rp-scroll-btn:active { transform: translateY(0); }

.related-products-track {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    padding: 4px 2px 14px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--primary, #1877f2) transparent;
}
.related-products-track::-webkit-scrollbar { height: 8px; }
.related-products-track::-webkit-scrollbar-track { background: transparent; border-radius: 4px; }
.related-products-track::-webkit-scrollbar-thumb {
    background: var(--border, #cbd5e1);
    border-radius: 4px;
}
.related-products-track::-webkit-scrollbar-thumb:hover { background: var(--primary, #1877f2); }

.related-product-card {
    flex: 0 0 200px;
    width: 200px;
    scroll-snap-align: start;
    background: var(--card-bg, #fff);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border, #e4e6eb);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: transform .2s, box-shadow .2s, border-color .2s;
    position: relative;
    display: block;
}
.related-product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(0,0,0,.10);
    border-color: var(--primary, #1877f2);
}
.related-product-card.out-of-stock-card { opacity: .65; filter: grayscale(.4); }
.related-product-card.out-of-stock-card:hover { transform: none; box-shadow: none; }

.rp-card-img {
    position: relative;
    width: 100%;
    height: 140px;
    background: var(--bg-secondary, #f0f2f5);
    overflow: hidden;
}
.rp-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .35s;
}
.related-product-card:hover .rp-card-img img { transform: scale(1.06); }

.rp-discount-badge {
    position: absolute;
    top: 8px;
    inset-inline-start: 8px;
    background: #ef4444;
    color: #fff;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: .72rem;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(239,68,68,.3);
    z-index: 2;
}
.rp-out-of-stock {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,.55);
    color: #fff;
    font-size: .82rem;
    font-weight: 700;
    z-index: 2;
}

.rp-card-info {
    padding: 10px 12px 14px;
    text-align: start;
}
.rp-card-title {
    margin: 0 0 6px;
    font-size: .9rem;
    font-weight: 700;
    color: var(--text-primary, #0f172a);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 38px;
}
.rp-card-pricing {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.rp-card-price {
    color: var(--primary, #1877f2);
    font-weight: 700;
    font-size: .9rem;
}
.rp-card-old-price {
    text-decoration: line-through;
    color: var(--text-secondary, #94a3b8);
    font-size: .78rem;
}

/* Dark mode for related-products */
body.dark .related-products-bar { background: var(--card-bg, #1e293b); border-color: var(--border, #334155); }
body.dark .related-products-head h3 { color: var(--text-primary, #f1f5f9); }
body.dark .rp-scroll-btn { background: var(--bg-secondary, #0f172a); color: var(--text-primary, #f1f5f9); border-color: var(--border, #334155); }
body.dark .rp-scroll-btn:hover { background: var(--primary, #1877f2); color: #fff; border-color: var(--primary, #1877f2); }
body.dark .related-product-card { background: var(--card-bg, #1e293b); border-color: var(--border, #334155); }
body.dark .rp-card-title { color: var(--text-primary, #f1f5f9); }
body.dark .rp-card-img { background: var(--bg-secondary, #0f172a); }

@media (max-width: 600px) {
    .related-product-card { flex: 0 0 150px; width: 150px; }
    .rp-card-img { height: 110px; }
    .rp-card-title { font-size: .82rem; }
    .related-products-bar { padding: 16px 14px; margin: 24px 0 0; }
    .related-products-head h3 { font-size: 1rem; }
    .rp-scroll-btn { width: 34px; height: 34px; }
}
