/* books.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Vazir', sans-serif;
}

body {
    direction: rtl;
    background-color: #f0f4f8;
    color: #333;
    line-height: 1.6;
    font-size: 16px;
}

/* کانتینر اصلی */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 15px;
}

/* هدر */
header {
    background-color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
}

header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 0;
    flex-wrap: wrap;
}

.logo {
    font-size: 1.8rem;
    font-weight: 700;
    color: #004d99;
}

.nav-toggle {
    display: none;
    font-size: 24px;
    cursor: pointer;
    color: #004d99;
    padding: 10px;
}

.nav-menu ul {
    list-style: none;
    display: flex;
    gap: 15px;
    margin: 10px 0;
}

.nav-menu ul li a {
    text-decoration: none;
    color: #004d99;
    font-size: 15px;
    padding: 8px 12px;
    border-radius: 5px;
    transition: background-color 0.3s, color 0.3s;
}

.nav-menu ul li a:hover {
    background-color: #004d99;
    color: #fff;
}

.nav-menu ul li a i {
    margin-left: 5px;
}

/* نوار جستجو */
.search-bar {
    background-color: #fff;
    padding: 10px 0;
    border-bottom: 1px solid #ddd;
    position: sticky;
    top: 60px;
    z-index: 1001;
}

.search-container {
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}

#searchInput {
    width: 100%;
    padding: 10px 35px 10px 15px;
    border: 1px solid #ccc;
    border-radius: 20px;
    font-size: 15px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

#searchInput:focus {
    border-color: #004d99;
    box-shadow: 0 0 5px rgba(0, 77, 153, 0.3);
    outline: none;
}

.clear-search-btn {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #666;
}

.clear-search-btn:hover {
    color: #004d99;
}

/* مودال جستجو */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1002;
    overflow-y: auto;
}

.modal-content {
    background-color: #fff;
    margin: 10% auto;
    padding: 15px;
    width: 90%;
    max-width: 500px;
    border-radius: 8px;
    position: relative;
}

.close-btn {
    position: absolute;
    left: 10px;
    top: 10px;
    font-size: 20px;
    cursor: pointer;
    color: #666;
}

.close-btn:hover {
    color: #004d99;
}

.search-results {
    max-height: 60vh;
    overflow-y: auto;
    padding-top: 20px;
}

.search-result-item {
    padding: 8px;
    cursor: pointer;
    transition: background-color 0.3s;
    font-size: 14px;
}

.search-result-item:hover {
    background-color: #f0f0f0;
}

/* بخش کتاب‌ها */
.books-section {
    padding: 20px 0;
}

.main-content-wrapper {
    display: flex;
    gap: 20px;
}

.main-books-content {
    flex: 3;
}

.books-list {
    background-color: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);
    padding: 20px;
}

.books-list h1 {
    font-size: 2rem;
    color: #004d99;
    margin-bottom: 25px;
    text-align: center;
}

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

.book-item {
    background: #fff;
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.book-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.book-item img {
    max-width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 10px;
}

.book-item h3 {
    font-size: 1.1rem;
    margin: 5px 0;
    color: #004d99;
    height: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.book-item p {
    font-size: 0.9rem;
    color: #777;
    margin: 3px 0;
}

.book-item .price {
    font-size: 1rem;
    font-weight: bold;
    color: #ff6b6b;
    margin-top: 10px;
}

.message-box {
    text-align: center;
    padding: 40px;
    font-size: 1.1rem;
    color: #555;
}

/* سایدبار */
.sidebar {
    flex: 1;
    background-color: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sidebar h3 {
    font-size: 1.5rem;
    color: #004d99;
    margin-bottom: 15px;
}

.category-tree {
    list-style: none;
}

.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    margin: 4px 0;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.category-item:hover {
    background-color: #f8f9fa;
}

.category-item.active {
    background-color: #e3f2fd;
    color: #004d99;
}

.category-name {
    flex: 1;
    text-align: right;
    font-size: 14px;
}

.book-count {
    background-color: #6c757d;
    color: #fff;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 11px;
}

.category-item.active .book-count {
    background-color: #004d99;
}

.category-item.expandable::after {
    content: '▶';
    font-size: 11px;
    margin-left: 8px;
    transition: transform 0.3s ease;
}

.category-item.expanded::after {
    transform: rotate(90deg);
}

.subcategory-tree {
    margin-right: 15px;
    display: none;
}

.category-item.expanded .subcategory-tree {
    display: block;
}

.subcategory-tree .category-item {
    font-size: 13px;
    padding: 6px 8px;
}

/* پاسخگویی */

/* تبلت‌ها (768px تا 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 95%;
        padding: 0 10px;
    }

    .logo {
        font-size: 1.6rem;
    }

    .nav-menu ul {
        gap: 10px;
        flex-wrap: wrap;
    }

    .nav-menu ul li a {
        font-size: 14px;
        padding: 6px 10px;
    }

    .search-container {
        max-width: 80%;
    }

    #searchInput {
        font-size: 14px;
        padding: 8px 30px 8px 12px;
    }

    .main-content-wrapper {
        flex-direction: column;
        gap: 15px;
    }

    .sidebar {
        margin-top: 15px;
        padding: 10px;
    }

    .books-list h1 {
        font-size: 1.8rem;
    }

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

    .book-item img {
        height: 160px;
    }

    .book-item h3 {
        font-size: 1rem;
        height: 45px;
    }

    .book-item p {
        font-size: 0.85rem;
    }

    .book-item .price {
        font-size: 0.9rem;
    }

    .sidebar h3 {
        font-size: 1.4rem;
    }

    .category-item {
        font-size: 13px;
    }

    .category-name {
        font-size: 13px;
    }

    .book-count {
        font-size: 10px;
    }
}

/* موبایل‌ها (تا 768px) */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    .container {
        max-width: 100%;
        padding: 0 10px;
    }

    header .container {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .logo {
        font-size: 1.5rem;
    }

    .nav-toggle {
        display: block;
        position: absolute;
        top: 12px;
        left: 12px;
    }

    .nav-menu {
        display: none;
        width: 100%;
        background-color: #fff;
        position: absolute;
        top: 50px;
        left: 0;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        z-index: 999;
    }

    .nav-menu.active {
        display: block;
        padding: 10px 0;
    }

    .nav-menu ul {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }

    .nav-menu ul li a {
        font-size: 13px;
        padding: 6px 0;
        width: 100%;
        text-align: center;
    }

    .search-bar {
        padding: 8px 0;
    }

    .search-container {
        max-width: 95%;
    }

    #searchInput {
        font-size: 13px;
        padding: 8px 30px 8px 10px;
    }

    .modal-content {
        width: 95%;
        padding: 10px;
    }

    .main-content-wrapper {
        flex-direction: column;
        gap: 10px;
    }

    .sidebar {
        margin-top: 10px;
        padding: 10px;
    }

    .books-list {
        padding: 15px;
    }

    .books-list h1 {
        font-size: 1.6rem;
    }

    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 10px;
    }

    .book-item img {
        height: 140px;
    }

    .book-item h3 {
        font-size: 0.95rem;
        height: 40px;
    }

    .book-item p {
        font-size: 0.8rem;
    }

    .book-item .price {
        font-size: 0.85rem;
    }

    .sidebar h3 {
        font-size: 1.3rem;
    }

    .category-item {
        font-size: 12px;
        padding: 6px 8px;
    }

    .category-name {
        font-size: 12px;
    }

    .book-count {
        font-size: 9px;
    }
}

/* موبایل‌های خیلی کوچک (تا 480px) */
@media (max-width: 480px) {
    .container {
        padding: 0 8px;
    }

    .logo {
        font-size: 1.4rem;
    }

    .nav-toggle {
        top: 10px;
        left: 10px;
        font-size: 20px;
    }

    .nav-menu {
        top: 45px;
    }

    .nav-menu ul li a {
        font-size: 12px;
    }

    .search-container {
        max-width: 100%;
    }

    #searchInput {
        font-size: 12px;
        padding: 6px 25px 6px 8px;
    }

    .modal-content {
        padding: 8px;
    }

    .search-result-item {
        font-size: 12px;
        padding: 6px;
    }

    .books-list h1 {
        font-size: 1.4rem;
    }

    .books-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .book-item img {
        height: 120px;
    }

    .book-item h3 {
        font-size: 0.9rem;
        height: 35px;
    }

    .book-item p {
        font-size: 0.75rem;
    }

    .book-item .price {
        font-size: 0.8rem;
    }

    .sidebar h3 {
        font-size: 1.2rem;
    }

    .category-item {
        font-size: 11px;
        padding: 5px 6px;
    }

    .category-name {
        font-size: 11px;
    }

    .book-count {
        font-size: 8px;
    }
}