@font-face {
    font-family: "IRANSans";
    src: url("https://rahianarshad.com/wp-content/themes/bookie/fonts/IRANSans.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "IRANSans", sans-serif;
    background: #f6f7f9;
    color: #333;
    line-height: 1.7;
    direction: rtl; /* اطمینان از راست‌چین بودن کل پیکره */
}

/* =========================
   HEADER (CENTERED)
   ========================= */

.header {
    background: #fff;
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
    align-items: center; /* تراز وسط افقی */
    text-align: center;
}

.header-top {
    display: flex;
    flex-direction: column; /* در موبایل و دسکتاپ زیر هم برای تمرکز بیشتر یا کنار هم */
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

/* اگر می‌خواهید لوگو و متن در دسکتاپ کنار هم باشند این بخش را فعال نگه دارید */
@media(min-width: 768px) {
    .header-top {
        flex-direction: row; 
        justify-content: center;
    }
}

.logo {
    width: 70px;
    height: auto;
}

.header-title {
    font-size: 18px;
    font-weight: 600;
    color: #222;
}

/* =========================
   MENU (CENTERED)
   ========================= */

.header-menu {
    display: flex;
    gap: 25px;
    justify-content: center; /* تراز وسط منو */
    flex-wrap: wrap;
}

.header-menu a {
    text-decoration: none;
    color: #444;
    font-size: 14px;
    transition: .2s;
    font-weight: 500;
}

.header-menu a:hover {
    color: #1e88e5;
}

/* =========================
   SEARCH SECTION (STICKY & CENTERED)
   ========================= */

.search-section {
    position: sticky;
    top: 0;
    background: #fff;
    border-bottom: 1px solid #eee;
    z-index: 100;
    padding: 15px;
    text-align: center; /* وسط‌چین کردن متن و اینپوت */
}

.search-wrapper {
    max-width: 700px; /* کمی جمع‌وجورتر برای ظاهر بهتر */
    margin: auto;
}

.search-text {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
}

#search-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid #ddd;
    font-size: 14px;
    outline: none;
    transition: .2s;
    font-family: "IRANSans";
    text-align: center; /* تایپ کردن در مرکز */
}

#search-input:focus {
    border-color: #1e88e5;
    box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.1);
}

/* =========================
   MAIN CONTAINER
   ========================= */

.container {
    max-width: 1200px;
    margin: auto;
    padding: 25px 15px;
}

/* =========================
   GRID & CARDS
   ========================= */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

.book-card {
    background: #fff;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 3px 10px rgba(0,0,0,.04);
    transition: .3s;
    display: flex;
    flex-direction: column;
    align-items: center; /* تراز وسط محتوای کارت */
    text-align: center;  /* تراز وسط متن‌ها */
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,.08);
}

.book-image {
    width: 100%;
    aspect-ratio: 1/1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.book-image img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 4px;
    opacity: 0;
    transition: .3s;
}

.book-image img.loaded {
    opacity: 1;
}

.book-title {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 10px;
    height: 45px; /* ارتفاع ثابت برای یکدست شدن کارت‌ها */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.book-title a {
    text-decoration: none;
    color: #333;
}

.book-price {
    font-weight: 700;
    font-size: 15px;
    color: #2e7d32;
    background: #f1f8e9;
    padding: 4px 12px;
    border-radius: 20px;
    margin-top: auto; /* چسبیدن قیمت به کف کارت */
}

/* =========================
   SKELETON LOADING
   ========================= */

.skeleton-card {
    background: #fff;
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.skeleton {
    background: linear-gradient(90deg, #eee, #f9f9f9, #eee);
    background-size: 200% 100%;
    animation: skeleton 1.5s infinite;
    border-radius: 6px;
}

.skeleton-img { width: 120px; height: 120px; margin-bottom: 15px; }
.skeleton-text { height: 12px; width: 80%; margin-bottom: 8px; }
.skeleton-price { height: 20px; width: 50%; border-radius: 20px; }

@keyframes skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* =========================
   SCROLL TO TOP
   ========================= */

#scrollTopBtn {
    position: fixed;
    left: 25px;
    bottom: 25px;
    width: 45px;
    height: 45px;
    border: none;
    border-radius: 50%;
    background: #1e88e5;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    display: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 1000;
}

/* =========================
   RESPONSIVE
   ========================= */

@media(max-width: 900px) {
    .grid { grid-template-columns: repeat(3, 1fr); }
}

@media(max-width: 650px) {
    .grid { grid-template-columns: repeat(2, 1fr); }
    .header-title { font-size: 15px; }
    .header-menu { gap: 12px; }
    .header-menu a { font-size: 13px; }
}