/* ===========================
   GLOBAL & RESET
   =========================== */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    background: none !important;
    font-family: Tahoma, Arial, sans-serif;
    margin: 0;
    padding: 0;
    position: relative;
    z-index: 0;
    direction: rtl; /* تنظیم جهت راست‌چین */
}

/* لایه پس‌زمینه ثابت ۱۰۰٪ */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-image: url("/static/img/gold-bg.jpg");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    will-change: transform;
}

/* ===========================
   MAIN CONTAINER
   =========================== */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
}

.title {
    text-align: center;
    margin-bottom: 30px;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

/* ===========================
   FILTERS
   =========================== */
.filters {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 15px;
    margin-bottom: 40px;
}

.filters input,
.filters select {
    width: 100%;
    padding: 14px;
    background: rgba(17, 17, 17, 0.8);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 12px;
    color: white;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.filters input::placeholder {
    color: #aaa;
}

.filters input:focus,
.filters select:focus {
    outline: none;
    border-color: #d4af37;
    box-shadow: 0 0 15px rgba(212,175,55,0.4);
}

/* ===========================
   CARDS GRID WRAPPER
   =========================== */
#cardsContainer {
    display: grid;
    /* گرید ریسپانسیو خودکار */
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

/* ===========================
   CARD STYLE
   =========================== */
.card {
    display: flex;
    flex-direction: column; /* کارت عمودی برای یکدستی و ریسپانسیو بهتر */
    background: rgba(20, 20, 20, 0.6);
    border: 1px solid rgba(212, 175, 55, 0.25);
    backdrop-filter: blur(14px);
    border-radius: 18px;
    padding: 14px;
    color: white;
    text-decoration: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 8px 25px rgba(0,0,0,0.5);
}

.card:hover {
    background: rgba(30, 30, 30, 0.8);
    transform: translateY(-6px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.6), 0 0 20px rgba(212, 175, 55, 0.3);
    border-color: rgba(212, 175, 55, 0.8);
}

/* ===========================
   CARD IMAGE
   =========================== */
.card-img {
    width: 100%;
    height: 220px;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
    margin-bottom: 15px;
}

.card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.card:hover .card-img img {
    transform: scale(1.08);
}

.img-count {
    position: absolute;
    bottom: 8px;
    left: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    font-size: 12px;
    color: #fff;
    background: rgba(0,0,0,0.7);
    border: 1px solid rgba(212, 175, 55, 0.4);
    border-radius: 10px;
    backdrop-filter: blur(6px);
}

.img-count i {
    color: #ffd700;
}

/* ===========================
   CARD BODY
   =========================== */
.card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-body h3 {
    font-size: 18px;
    font-weight: bold;
    margin: 0 0 10px 0;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.caption {
    color: #ccc;
    font-size: 14px;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 15px;
    flex-grow: 1;
}

/* ===========================
   PRICE + CATEGORY (META)
   =========================== */
.meta {
    display: flex;
    flex-wrap: wrap; /* اجازه می‌دهد تگ‌ها در صورت کمبود فضا بشکنند */
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.meta-categories {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.category {
    background: rgba(212,175,55,0.15);
    color: #ffd700;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(212,175,55,0.4);
    font-size: 11px;
    white-space: nowrap;
}

.price {
    color: #ffd700;
    font-size: 16px;
    font-weight: bold;
    white-space: nowrap;
}

/* ===========================
   SKELETON LOADING
   =========================== */
#loading {
    display: none;
    margin-top: 20px;
}

.skeleton {
    height: 250px;
    border-radius: 18px;
    background: linear-gradient(90deg, #111 25%, #1d1d1d 50%, #111 75%);
    background-size: 200% 100%;
    animation: skeleton 1.5s infinite;
    margin-bottom: 15px;
    border: 1px solid rgba(255,255,255,0.05);
}

@keyframes skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===========================
   RESPONSIVE
   =========================== */

/* تبلت و موبایل (زیر 768 پیکسل) */
@media(max-width: 768px) {
    .filters {
        /* در موبایل، جستجو بالا و دو دراپ‌داون کنار هم در ردیف پایین قرار می‌گیرند */
        grid-template-columns: 1fr 1fr;
    }

    #searchInput {
        grid-column: span 2; /* جستجو تمام عرض شود */
    }

    .filters input, .filters select {
        padding: 10px;
        font-size: 13px;
    }

    /* === کلید اصلی برای ۲ ستونه شدن در موبایل === */
    #cardsContainer {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px; /* فاصله بین کارت‌ها در موبایل کمتر شود */
    }

    /* کوچک کردن المان‌های داخل کارت برای جا شدن در نصف صفحه */
    .card {
        padding: 10px;
        border-radius: 14px;
    }

    .card-img {
        height: 130px; /* ارتفاع عکس کمتر شود */
        margin-bottom: 10px;
        border-radius: 8px;
    }

    .img-count {
        padding: 3px 6px;
        font-size: 10px;
        bottom: 5px;
        left: 5px;
    }

    .card-body h3 {
        font-size: 13px; /* فونت عنوان کوچکتر */
        margin-bottom: 6px;
    }

    .caption {
        font-size: 11px;
        line-height: 1.5;
        margin-bottom: 10px;
    }

    /* تنظیمات تگ‌ها و قیمت در موبایل */
    .meta {
        flex-direction: column; /* تگ‌ها بالا و قیمت پایین قرار بگیرد */
        align-items: flex-start;
        gap: 6px;
        padding-top: 8px;
    }

    .meta-categories {
        gap: 4px;
    }

    .category {
        padding: 4px 8px;
        font-size: 9px;
    }

    .price {
        font-size: 13px;
        align-self: flex-end; /* قیمت می‌رود سمت چپ و پایین کارت */
    }
}

/* موبایل‌های بسیار کوچک (زیر 360 پیکسل - مثل آیفون SE) */
@media(max-width: 360px) {
    .card-img {
        height: 110px;
    }
    .card-body h3 {
        font-size: 12px;
    }
    .category {
        font-size: 8px;
        padding: 3px 6px;
    }
    .price {
        font-size: 12px;
    }
}
