/* ==============================================================
   E-Commerce Modern Responsive Stylesheet (Mobile-First)
   With Full Arabic RTL Support Toggle
   ============================================================== */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --secondary-color: #0f172a;
    --accent-color: #f59e0b;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --text-main: #334155;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --bg-light: #f8fafc;
    --bg-white: #ffffff;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --hover-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.25s ease-in-out;
}

/* Base & Typography */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text-main);
    background-color: var(--bg-light);
    line-height: 1.6;
    overflow-x: hidden;
}

/* RTL Support */
[dir="rtl"] body, body.rtl {
    direction: rtl;
    text-align: right;
    font-family: 'Segoe UI', Tahoma, 'Arial', sans-serif;
}

[dir="rtl"] .me-auto { margin-right: 0 !important; margin-left: auto !important; }
[dir="rtl"] .ms-auto { margin-left: 0 !important; margin-right: auto !important; }
[dir="rtl"] .text-start { text-align: right !important; }
[dir="rtl"] .text-end { text-align: left !important; }

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}
a:hover {
    color: var(--primary-hover);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Header & Navigation */
.top-bar {
    background-color: var(--secondary-color);
    color: #cbd5e1;
    font-size: 0.85rem;
    padding: 6px 0;
}
.top-bar a {
    color: #e2e8f0;
}
.top-bar a:hover {
    color: #ffffff;
}

.main-navbar {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.navbar-brand {
    font-weight: 800;
    font-size: 1.45rem;
    color: var(--secondary-color) !important;
    display: flex;
    align-items: center;
    gap: 8px;
}
.navbar-brand span {
    color: var(--primary-color);
}

.search-input-group {
    border-radius: 50px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: #ffffff;
    transition: var(--transition);
}
.search-input-group:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.search-input-group input {
    border: none;
    outline: none;
    padding: 8px 18px;
    font-size: 0.95rem;
    width: 100%;
}
.search-input-group button {
    border: none;
    background: var(--primary-color);
    color: #fff;
    padding: 0 18px;
    transition: var(--transition);
}
.search-input-group button:hover {
    background: var(--primary-hover);
}

.cart-icon-btn {
    position: relative;
    font-size: 1.25rem;
    padding: 6px 12px;
    color: var(--secondary-color);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.cart-icon-btn:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}
.cart-badge {
    position: absolute;
    top: -2px;
    right: 2px;
    background-color: var(--danger-color);
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 50%;
    padding: 2px 6px;
    line-height: 1;
}
[dir="rtl"] .cart-badge {
    right: auto;
    left: 2px;
}

/* Hero Section */
.hero-banner {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #ffffff;
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    margin: 20px 0 30px;
}
.hero-banner .hero-content {
    padding: 50px 30px;
    z-index: 2;
    position: relative;
}
.hero-banner h1 {
    font-weight: 800;
    font-size: 2.5rem;
    line-height: 1.2;
    margin-bottom: 16px;
}
.hero-banner p {
    font-size: 1.15rem;
    color: #94a3b8;
    margin-bottom: 24px;
    max-width: 520px;
}

/* Category Card */
.category-card {
    background: #ffffff;
    border-radius: var(--radius-md);
    padding: 20px 15px;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: var(--transition);
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.category-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-shadow);
    border-color: var(--primary-color);
}
.category-card .cat-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin-bottom: 12px;
}
.category-card h6 {
    font-weight: 700;
    color: var(--secondary-color);
    margin-bottom: 4px;
}

/* Product Card */
.product-card {
    background: #ffffff;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
    position: relative;
    transition: var(--transition);
    height: 100%;
    display: flex;
    flex-direction: column;
}
.product-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--hover-shadow);
    border-color: #cbd5e1;
}

.product-image-wrap {
    position: relative;
    width: 100%;
    padding-top: 100%; /* 1:1 Aspect Ratio */
    background: #f1f5f9;
    overflow: hidden;
}
.product-image-wrap img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.4s ease, transform 0.4s ease;
}
.product-image-wrap .img-secondary {
    opacity: 0;
}
.product-card:hover .product-image-wrap .img-primary.has-secondary {
    opacity: 0;
}
.product-card:hover .product-image-wrap .img-secondary {
    opacity: 1;
    transform: scale(1.04);
}
.product-card:hover .product-image-wrap .img-primary:not(.has-secondary) {
    transform: scale(1.04);
}

.product-badges {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 3;
}
[dir="rtl"] .product-badges {
    left: auto;
    right: 10px;
}
.badge-promo {
    background-color: var(--danger-color);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
}
.badge-featured {
    background-color: var(--accent-color);
    color: #000;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
}

.quick-view-btn {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translate(-50%, 20px);
    background: rgba(255, 255, 255, 0.95);
    color: var(--secondary-color);
    border: none;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0;
    transition: var(--transition);
    z-index: 3;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}
.product-card:hover .quick-view-btn {
    opacity: 1;
    transform: translate(-50%, 0);
}

.product-info {
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}
.product-category-name {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 4px;
}
.product-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--secondary-color);
    margin-bottom: 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 2.8em;
}
.product-title a {
    color: inherit;
}
.product-title a:hover {
    color: var(--primary-color);
}

.product-price-row {
    margin-top: auto;
    padding-top: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.price-current {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--primary-color);
}
.price-original {
    font-size: 0.85rem;
    text-decoration: line-through;
    color: var(--text-muted);
    margin-left: 6px;
}
[dir="rtl"] .price-original {
    margin-left: 0;
    margin-right: 6px;
}

.btn-add-cart {
    background: var(--primary-light);
    color: var(--primary-color);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 0.9rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}
.btn-add-cart:hover {
    background: var(--primary-color);
    color: #ffffff;
}

/* Product Detail Page Gallery */
.gallery-main {
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--border-color);
    margin-bottom: 12px;
    cursor: zoom-in;
    position: relative;
    padding-top: 85%;
}
.gallery-main img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.gallery-thumbs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.gallery-thumb-item {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-color);
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
    background: #fff;
    transition: var(--transition);
}
.gallery-thumb-item.active, .gallery-thumb-item:hover {
    border-color: var(--primary-color);
}
.gallery-thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Countdown Promo Timer */
.promo-timer {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin-bottom: 16px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Stock Status */
.stock-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 4px 10px;
    border-radius: 20px;
    margin-bottom: 14px;
}
.stock-in {
    background: #ecfdf5;
    color: #065f46;
}
.stock-low {
    background: #fffbeb;
    color: #92400e;
}
.stock-out {
    background: #fef2f2;
    color: #991b1b;
}

/* Checkout & Cart Box */
.summary-box {
    background: #ffffff;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 24px;
    box-shadow: var(--card-shadow);
}
.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 0.95rem;
}
.summary-total {
    border-top: 2px dashed var(--border-color);
    padding-top: 14px;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--secondary-color);
}

/* Order timeline */
.timeline {
    position: relative;
    padding-left: 24px;
}
[dir="rtl"] .timeline {
    padding-left: 0;
    padding-right: 24px;
}
.timeline-item {
    position: relative;
    padding-bottom: 20px;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: -24px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary-color);
}
[dir="rtl"] .timeline-item::before {
    left: auto;
    right: -24px;
}

/* Toast Container */
.toast-container-custom {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1090;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
[dir="rtl"] .toast-container-custom {
    right: auto;
    left: 20px;
}

.custom-toast {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.12);
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.92rem;
    font-weight: 500;
    border-left: 4px solid var(--primary-color);
    animation: slideIn 0.3s ease;
}
[dir="rtl"] .custom-toast {
    border-left: none;
    border-right: 4px solid var(--primary-color);
}
@keyframes slideIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .hero-banner h1 { font-size: 1.8rem; }
    .hero-banner .hero-content { padding: 30px 18px; }
    .search-input-group { margin-top: 10px; margin-bottom: 10px; }
}
