/* الأنماط العامة */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, Segoe UI, Arial;
    margin: 0;
    background: #fafafa;
    color: #111;
    line-height: 1.6;
}

.header {
    z-index: 1000;
    padding: 12px 16px;
    background: #fff;
    position: sticky;
    top: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.topbar {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    max-width: 1100px;
    margin: 0 auto;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: #111;
}

.nav-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.btn {
    background: #111;
    color: #fff;
    padding: 10px 14px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.3s;
    border: none;
    cursor: pointer;
}

.btn:hover {
    background: #333;
}

.pill {
    display: inline-block;
    background: #f0f3f7;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    color: #666;
}

.muted {
    color: #666;
}

/* أنماط المحتوى الرئيسي */
.wrap {
    max-width: 1100px;
    margin: auto;
    padding: 16px;
    position: relative;
    z-index: 1;
}

/* شريط البحث */
.search-section {
    margin-bottom: 2rem;
}

.search-form {
    max-width: 600px;
    margin: 0 auto;
}

.search-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

.search-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 1rem;
    background: #fff;
}

.search-btn {
    white-space: nowrap;
}

.reset-btn {
    background: #666;
    white-space: nowrap;
}

.reset-btn:hover {
    background: #555;
}

/* نتائج البحث */
.search-results {
    margin-top: 2rem;
}

.no-results {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.no-results h3 {
    margin-bottom: 10px;
}

.no-results a {
    color: #111;
    text-decoration: none;
}

.no-results a:hover {
    text-decoration: underline;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 2rem;
}

.product-card {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,.05);
    padding: 16px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.3s, box-shadow 0.3s;
    display: block;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 15px rgba(0,0,0,.1);
    text-decoration: none;
    color: inherit;
}

.product-image-container {
    position: relative;
    width: 100%;
    height: 200px;
    margin-bottom: 12px;
    border-radius: 10px;
    overflow: hidden;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.product-card:hover .product-image {
    transform: scale(1.05);
}

.no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 14px;
    text-align: center;
    padding: 20px;
    background: #f0f3f7;
    border-radius: 10px;
}

/* أنماط الشبكة والبطاقات */
.grid {
    display: grid;
    gap: 16px;
}

.grid.cols-3 {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.card {
    position: relative;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,.05);
    padding: 14px;
    transition: transform 0.3s, box-shadow 0.3s;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 15px rgba(0,0,0,.1);
}

.product {
    display: flex;
    gap: 12px;
    align-items: center;
    text-decoration: none;
    color: inherit;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.product:last-child {
    border-bottom: none;
}

.product:hover {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 8px;
    margin: -8px;
}

.thumb-container {
    position: relative;
    width: 72px;
    height: 72px;
    flex-shrink: 0;
}

img.thumb {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 10px;
    background: #eee;
}

.thumb-placeholder {
    width: 72px;
    height: 72px;
    border-radius: 10px;
    background: #f0f3f7;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 12px;
    text-align: center;
    padding: 5px;
}

.thumb-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #eee;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thumb-loading::after {
    content: "";
    width: 20px;
    height: 20px;
    border: 2px solid #ccc;
    border-top: 2px solid #333;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.product-info {
    flex: 1;
}

.product-name {
    font-weight: bold;
    margin-bottom: 4px;
    color: #111;
}

.product-name-ar {
    font-weight: normal;
    color: #666;
    font-size: 0.9rem;
}

.product-category {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 4px;
    background: #f0f3f7;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
}

.product-code {
    color: #999;
    font-size: 0.8rem;
    margin-bottom: 4px;
}

.product-price {
    color: #2d6a4f;
    font-weight: bold;
    font-size: 0.9rem;
}

.category-link {
    display: inline-block;
    background: #f0f3f7;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    text-decoration: none;
    color: #666;
    margin-top: 10px;
    transition: background 0.3s;
}

.category-link:hover {
    background: #e0e3e7;
}

/* الفوتر */
.footer {
    position: relative;
    z-index: 1;
    background: #fff;
    padding: 20px 0;
    margin-top: 40px;
    border-top: 1px solid #eee;
}

.footer-content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px;
    text-align: center;
    color: #666;
}

/* تأثيرات تحميل */
.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* تحسينات للهواتف */
@media (max-width: 768px) {
    .topbar {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }

    .search-container {
        flex-direction: column;
    }

    .search-input {
        width: 100%;
    }

    .grid.cols-3,
    .products-grid {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 12px;
    }

    .product {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }

    .product-info {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: 1fr;
    }

    .product-image-container {
        height: 160px;
    }
}