/* ===== GLOBAL STYLES ===== */
:root {
    --primary-color: #73a15b;
    --secondary-color: #4c726c;
    --accent-color: #73a15b;
    --light-color: #4c726c;
    --dark-color: #73a15b;
    --gold-color: #73a15b;
    --green-color: #4c726c;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

body {
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    padding: 15px;
    min-height: 100vh;
}

.arabic-text {
    font-family: 'Noto Sans Arabic', sans-serif;
    direction: rtl;
}

/* ===== SEARCH BAR ===== */
.search-section {
    background: white;
    padding: 20px 0;
    margin-bottom: 25px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
    border-radius: 15px;
}

.search-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 15px;
}

.search-box {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 14px 50px 14px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 50px;
    font-size: 16px;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: #4c726c;
    box-shadow: 0 0 0 3px rgba(76, 114, 108, 0.1);
}

.search-btn {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: #4c726c;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.search-btn:hover {
    background: #73a15b;
    transform: translateY(-50%) scale(1.05);
}

/* ===== CAROUSEL STYLES ===== */
.featured-carousel-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: var(--shadow);
    margin-bottom: 25px;
    overflow: hidden;
}

.carousel-container {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
}

.carousel-track {
    display: flex;
    transition: transform 0.5s ease-in-out;
    gap: 20px;
    padding: 10px 5px;
}

.carousel-slide {
    flex: 0 0 calc(25% - 15px);
    min-width: 250px;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    transition: var(--transition);
    border: 1px solid #e2e8f0;
}

.carousel-slide:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.carousel-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.carousel-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #4c726c;
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.carousel-btn:hover {
    background: #73a15b;
    transform: scale(1.1);
}

.carousel-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.auto-play-btn {
    padding: 8px 15px;
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-radius: 25px;
    color: #73a15b;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.auto-play-btn:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.auto-play-btn.active {
    background: #4c726c;
    color: white;
    border-color: #4c726c;
}

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
    padding: 10px;
}

.carousel-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e2e8f0;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.carousel-dot:hover {
    background: #cbd5e0;
}

.carousel-dot.active {
    background: #4c726c;
    transform: scale(1.2);
}

/* FIXED: Carousel images - changed from 'cover' to 'contain' */
.carousel-slide-image {
    height: 180px;
    overflow: hidden;
    position: relative;
}

.carousel-slide-image img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* CHANGED FROM 'cover' TO 'contain' */
    transition: transform 0.5s ease;
    background: #f8f9fa; /* Added background for letterboxing */
}

.carousel-slide:hover .carousel-slide-image img {
    transform: scale(1.05);
}

.carousel-slide-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #4c726c;
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    z-index: 2;
}

.carousel-slide-content {
    padding: 18px;
}

.carousel-slide-title {
    font-size: 16px;
    font-weight: 700;
    color: #73a15b;
    margin-bottom: 8px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.carousel-slide-author {
    color: #718096;
    font-size: 13px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.carousel-slide-rating {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 15px;
}

.carousel-slide-rating .stars {
    color: #73a15b;
}

.carousel-slide-actions {
    display: flex;
    gap: 10px;
}

.carousel-read-btn,
.carousel-details-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.carousel-read-btn {
    background: #4c726c;
    color: white;
}

.carousel-read-btn:hover {
    background: #73a15b;
}

.carousel-details-btn {
    background: #f7fafc;
    color: #73a15b;
    border: 1px solid #e2e8f0;
}

.carousel-details-btn:hover {
    background: #edf2f7;
}

/* ===== MAIN CONTENT ===== */
.main-container {
    padding: 0 15px;
}

/* ===== CATEGORY FILTERS ===== */
.category-section {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 25px;
}

.section-title {
    color: #73a15b;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f1f1f1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title i {
    color: #4c726c;
}

.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.category-btn {
    padding: 8px 15px;
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-radius: 25px;
    color: #4a5568;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    flex-grow: 1;
    text-align: center;
}

.category-btn:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.category-btn.active {
    background: #4c726c;
    color: white;
    border-color: #4c726c;
}

/* ===== BOOK GRID SECTION ===== */
.book-grid-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: var(--shadow);
}

.books-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.books-count {
    color: #73a15b;
    font-weight: 600;
    background: #fff5f5;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 14px;
}

.view-controls {
    display: flex;
    gap: 10px;
}

.view-btn {
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #4a5568;
    transition: var(--transition);
}

.view-btn:hover,
.view-btn.active {
    background: #4c726c;
    color: white;
    border-color: #4c726c;
}

/* ===== BOOKS CONTAINER ===== */
.books-container {
    min-height: 300px;
}

/* ===== GRID VIEW ===== */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 25px;
}

/* ===== LIST VIEW ===== */
.book-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ===== BOOK CARD ===== */
.book-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    transition: var(--transition);
    border: 1px solid #e2e8f0;
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
    border-color: #4c726c;
}

/* Grid View Card */
.book-card.grid-view {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* FIXED: Grid view book covers - changed from 'cover' to 'contain' */
.book-card.grid-view .book-cover {
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: #f8f9fa; /* Added background for letterboxing */
}

.book-card.grid-view .book-cover img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* CHANGED FROM 'cover' TO 'contain' */
    transition: var(--transition);
}

.book-card.grid-view:hover .book-cover img {
    transform: scale(1.05);
}

.book-card.grid-view .book-info {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.book-card.grid-view .book-title {
    font-size: 18px;
    font-weight: 700;
    color: #73a15b;
    margin-bottom: 10px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-card.grid-view .book-author {
    color: #718096;
    font-size: 14px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.book-card.grid-view .book-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.book-card.grid-view .book-category,
.book-card.grid-view .book-pages {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #f7fafc;
    color: #73a15b;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.book-card.grid-view .book-description {
    color: #4a5568;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 20px;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-card.grid-view .book-actions {
    display: flex;
    gap: 10px;
    margin-top: auto;
}

/* List View Card */
.book-card.list-view {
    display: flex;
    flex-direction: row;
    min-height: 200px;
}

/* FIXED: List view book covers - changed from 'cover' to 'contain' */
.book-card.list-view .book-cover {
    width: 180px;
    height: 200px;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    background: #f8f9fa; /* Added background for letterboxing */
}

.book-card.list-view .book-cover img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* CHANGED FROM 'cover' TO 'contain' */
    transition: var(--transition);
}

.book-card.list-view:hover .book-cover img {
    transform: scale(1.05);
}

.book-card.list-view .book-info {
    flex: 1;
    padding: 25px;
    display: flex;
    flex-direction: column;
}

.book-card.list-view .book-title {
    font-size: 20px;
    font-weight: 700;
    color: #73a15b;
    margin-bottom: 10px;
    line-height: 1.3;
}

.book-card.list-view .book-author {
    color: #718096;
    font-size: 15px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.book-card.list-view .book-meta {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.book-card.list-view .book-category,
.book-card.list-view .book-pages,
.book-card.list-view .book-rating {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #f7fafc;
    color: #73a15b;
    padding: 6px 15px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.book-card.list-view .book-rating {
    color: #73a15b;
    background: #fffaf0;
}

.book-card.list-view .book-description {
    color: #4a5568;
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 20px;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-card.list-view .book-actions {
    display: flex;
    gap: 15px;
    margin-top: auto;
}

/* Common Book Card Styles */
.book-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #4c726c;
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    z-index: 2;
}

/* ===== FIXED: BUTTON SIZES AND TEXT ===== */
.book-actions .read-btn,
.book-actions .download-btn,
.book-actions .details-btn {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 14px;
    min-height: 42px;
    white-space: nowrap;
    flex: 1;
}

/* Grid View - Smaller buttons */
.book-card.grid-view .book-actions .read-btn,
.book-card.grid-view .book-actions .download-btn,
.book-card.grid-view .book-actions .details-btn {
    padding: 8px 12px;
    font-size: 13px;
    min-height: 38px;
    gap: 4px;
}

/* List View - Larger buttons */
.book-card.list-view .book-actions .read-btn,
.book-card.list-view .book-actions .download-btn,
.book-card.list-view .book-actions .details-btn {
    padding: 10px 18px;
    font-size: 15px;
    min-height: 44px;
    gap: 8px;
}

.book-actions .read-btn {
    background: #4c726c;
    color: white;
}

.book-actions .read-btn:hover {
    background: #73a15b;
    transform: translateY(-2px);
}

.book-actions .download-btn {
    background: #f7fafc;
    color: #73a15b;
    border: 2px solid #e2e8f0;
}

.book-actions .download-btn:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.book-actions .details-btn {
    background: #73a15b;
    color: white;
    min-width: 100px;
}

.book-actions .details-btn:hover {
    background: #4c726c;
    transform: translateY(-2px);
}

/* Button icons sizing */
.book-actions .read-btn i,
.book-actions .download-btn i,
.book-actions .details-btn i {
    font-size: 14px;
}

.book-card.grid-view .book-actions .read-btn i,
.book-card.grid-view .book-actions .download-btn i,
.book-card.grid-view .book-actions .details-btn i {
    font-size: 13px;
}

.book-card.list-view .book-actions .read-btn i,
.book-card.list-view .book-actions .download-btn i,
.book-card.list-view .book-actions .details-btn i {
    font-size: 15px;
}

/* ===== PAGINATION ===== */
.pagination-section {
    margin-top: 40px;
    display: flex;
    justify-content: center;
}

.pagination {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    justify-content: center;
}

.page-item {
    margin: 0 2px;
}

.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: white;
    border: 2px solid #e2e8f0;
    color: #4a5568;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
}

.page-link:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
}

.page-item.active .page-link {
    background: #4c726c;
    color: white;
    border-color: #4c726c;
}

.page-item.disabled .page-link {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== LOADING SPINNER ===== */
.loading-spinner {
    display: none;
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #4c726c;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #718096;
}

.empty-state i {
    font-size: 60px;
    color: #cbd5e0;
    margin-bottom: 20px;
}

.empty-state h4 {
    font-size: 22px;
    margin-bottom: 10px;
    color: #73a15b;
}

.empty-state p {
    font-size: 16px;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1200px) {
    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
    
    .carousel-slide {
        flex: 0 0 calc(33.333% - 13.33px);
    }
    
    .book-card.list-view .book-cover {
        width: 160px;
    }
    
    /* Button adjustments for medium screens */
    .book-card.list-view .book-actions .read-btn,
    .book-card.list-view .book-actions .download-btn,
    .book-card.list-view .book-actions .details-btn {
        padding: 9px 15px;
        font-size: 14px;
        min-height: 42px;
    }
}

@media (max-width: 992px) {
    .carousel-slide {
        flex: 0 0 calc(50% - 10px);
    }
    
    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 20px;
    }
    
    .book-card.list-view {
        flex-direction: column;
        min-height: auto;
    }
    
    .book-card.list-view .book-cover {
        width: 100%;
        height: 200px;
    }
    
    .book-card.list-view .book-info {
        padding: 20px;
    }
    
    .book-card.list-view .book-title {
        font-size: 18px;
    }
    
    .book-card.list-view .book-meta {
        gap: 10px;
    }
    
    .book-card.list-view .book-actions {
        flex-wrap: wrap;
    }
    
    /* Button adjustments for tablets */
    .book-card.grid-view .book-actions .read-btn,
    .book-card.grid-view .book-actions .download-btn,
    .book-card.grid-view .book-actions .details-btn {
        padding: 7px 10px;
        font-size: 12px;
        min-height: 36px;
    }
    
    .book-card.list-view .book-actions .read-btn,
    .book-card.list-view .book-actions .download-btn,
    .book-card.list-view .book-actions .details-btn {
        padding: 8px 14px;
        font-size: 13px;
        min-height: 40px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .search-section {
        padding: 15px 0;
        margin-bottom: 20px;
    }
    
    .featured-carousel-section {
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .book-grid-section {
        padding: 20px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .carousel-controls {
        align-self: stretch;
        justify-content: space-between;
    }
    
    /* ORIGINAL MOBILE CAROUSEL - SIMPLE */
    .carousel-slide {
        flex: 0 0 100%;
        min-width: 100%;
    }
    
    .books-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .view-controls {
        align-self: flex-end;
    }
    
    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 15px;
    }
    
    .category-section {
        padding: 15px;
    }
    
    .section-title {
        font-size: 16px;
    }
    
    .category-btn {
        padding: 7px 12px;
        font-size: 13px;
    }
    
    .book-card.grid-view .book-cover {
        height: 180px;
    }
    
    .book-card.grid-view .book-info {
        padding: 15px;
    }
    
    .book-card.grid-view .book-title {
        font-size: 16px;
    }
    
    .book-card.grid-view .book-actions {
        flex-direction: column;
    }
    
    .book-card.list-view .book-actions {
        flex-direction: column;
    }
    
    /* Mobile button adjustments */
    .book-actions .read-btn,
    .book-actions .download-btn,
    .book-actions .details-btn {
        padding: 12px;
        width: 100%;
        font-size: 14px;
        min-height: 44px;
    }
    
    .book-card.grid-view .book-actions .read-btn,
    .book-card.grid-view .book-actions .download-btn,
    .book-card.grid-view .book-actions .details-btn {
        padding: 10px;
        font-size: 13px;
        min-height: 40px;
    }
    
    .book-card.list-view .book-actions .read-btn,
    .book-card.list-view .book-actions .download-btn,
    .book-card.list-view .book-actions .details-btn {
        padding: 11px;
        font-size: 14px;
        min-height: 42px;
    }
}

@media (max-width: 576px) {
    .search-input {
        padding: 12px 45px 12px 15px;
        font-size: 14px;
    }
    
    .search-btn {
        width: 36px;
        height: 36px;
    }
    
    .book-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .carousel-controls {
        width: 100%;
    }
    
    .auto-play-btn span {
        display: none;
    }
    
    .auto-play-btn {
        padding: 8px;
        width: 40px;
        height: 40px;
        justify-content: center;
    }
    
    .books-count {
        font-size: 13px;
        padding: 5px 12px;
    }
    
    .category-filters {
        justify-content: center;
    }
    
    .book-card.grid-view .book-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .book-card.list-view .book-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .book-card.list-view .book-title {
        font-size: 17px;
    }
    
    .book-card.list-view .book-description {
        font-size: 14px;
        -webkit-line-clamp: 3;
    }
    
    .pagination {
        gap: 3px;
    }
    
    .page-link {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    
    /* Small mobile button adjustments */
    .book-actions .read-btn,
    .book-actions .download-btn,
    .book-actions .details-btn {
        font-size: 13px;
        padding: 10px;
        min-height: 40px;
    }
    
    .book-actions .read-btn i,
    .book-actions .download-btn i,
    .book-actions .details-btn i {
        font-size: 12px;
    }
}

@media (max-width: 400px) {
    body {
        padding: 8px;
    }
    
    .featured-carousel-section,
    .book-grid-section,
    .category-section {
        padding: 15px;
    }
    
    .carousel-slide-content {
        padding: 15px;
    }
    
    .carousel-slide-title {
        font-size: 15px;
    }
    
    .carousel-slide-actions {
        flex-direction: column;
    }
    
    .book-card.list-view .book-info {
        padding: 15px;
    }
    
    /* Extra small screens button adjustments */
    .book-actions .read-btn,
    .book-actions .download-btn,
    .book-actions .details-btn {
        font-size: 12px;
        padding: 8px;
        min-height: 36px;
        gap: 4px;
    }
    
    .book-actions .read-btn i,
    .book-actions .download-btn i,
    .book-actions .details-btn i {
        font-size: 11px;
    }
}
/* Book Details Modal */
.book-details-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0; top: 0;
    width: 100%; height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
}

.book-details-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 20px;
    max-width: 900px;
    border-radius: 10px;
    position: relative;
}

.book-details-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.book-details-left {
    flex: 1 1 40%;
}

/* FIXED: Modal book image - changed from 'cover' to 'contain' */
.book-details-left img {
    width: 100%;
    height: auto;
    border-radius: 10px;
    object-fit: contain; /* CHANGED FROM DEFAULT TO 'contain' */
    background: #f8f9fa; /* Added background for letterboxing */
}

.book-details-right {
    flex: 1 1 55%;
}

.modal-buttons {
    margin: 15px 0;
}

.modal-buttons button {
    margin-right: 10px;
    padding: 8px 15px;
    cursor: pointer;
}

.close-modal {
    position: absolute;
    top: 10px; right: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}
/* ===== BOOK DETAILS MODAL (Amended Cool Style) ===== */
.book-details-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0; top: 0;
    width: 100%; height: 100%;
    overflow: auto;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

.book-details-content {
    background: #fff;
    margin: 3% auto;
    padding: 25px;
    max-width: 900px;
    border-radius: 15px;
    position: relative;
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
    transform: translateY(-20px);
    opacity: 0;
    animation: slideUp 0.4s forwards;
}

@keyframes slideUp {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.book-details-row {
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
}

.book-details-left {
    flex: 1 1 40%;
}

/* FIXED: Modal book image - changed from 'cover' to 'contain' */
.book-details-left img {
    width: 100%;
    border-radius: 12px;
    object-fit: contain; /* CHANGED FROM DEFAULT TO 'contain' */
    background: #f8f9fa; /* Added background for letterboxing */
    transition: transform 0.4s ease;
}

.book-details-left img:hover {
    transform: scale(1.05);
}

.book-details-right {
    flex: 1 1 55%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.book-details-right h2 {
    font-size: 26px;
    color: #73a15b;
    margin-bottom: 15px;
}

.book-details-right p {
    font-size: 16px;
    line-height: 1.6;
    color: #4a5568;
    margin-bottom: 20px;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.modal-buttons button {
    padding: 10px 20px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.modal-buttons .read-btn {
    background: linear-gradient(135deg, #4c726c, #73a15b);
    color: white;
}

.modal-buttons .read-btn:hover {
    background: linear-gradient(135deg, #73a15b, #4c726c);
    transform: translateY(-3px) scale(1.03);
}

.modal-buttons .download-btn {
    background: #f7fafc;
    color: #73a15b;
    border: 2px solid #e2e8f0;
}

.modal-buttons .download-btn:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
    transform: translateY(-2px);
}

.close-modal {
    position: absolute;
    top: 15px; right: 20px;
    font-size: 32px;
    font-weight: bold;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
}

.close-modal:hover {
    color: #4c726c;
    transform: rotate(90deg) scale(1.2);
}

/* RESPONSIVE MODAL */
@media (max-width: 992px) {
    .book-details-row {
        flex-direction: column;
    }
    
    .book-details-left, .book-details-right {
        flex: 1 1 100%;
    }
}
/* ===== GLOBAL STYLES ===== */
:root {
    --primary-color: #73a15b;
    --secondary-color: #4c726c;
    --accent-color: #73a15b;
    --light-color: #4c726c;
    --dark-color: #73a15b;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

body {
    background-color: #f5f7fa;
    color: #73a15b;
    line-height: 1.6;
    padding: 15px;
    min-height: 100vh;
}

.arabic-text {
    font-family: 'Noto Sans Arabic', sans-serif;
    direction: rtl;
}

/* ===== SEARCH BAR ===== */
.search-section {
    background: white;
    padding: 20px 0;
    margin-bottom: 25px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
    border-radius: 15px;
}

.search-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 15px;
}

.search-box {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 14px 50px 14px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 50px;
    font-size: 16px;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: #73a15b;
    box-shadow: 0 0 0 3px rgba(115, 161, 91, 0.2);
}

.search-btn {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: #73a15b;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.search-btn:hover {
    background: #4c726c;
    transform: translateY(-50%) scale(1.05);
}

/* ===== CAROUSEL STYLES ===== */
.featured-carousel-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: var(--shadow);
    margin-bottom: 25px;
    overflow: hidden;
}

.carousel-container {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
}

.carousel-track {
    display: flex;
    transition: transform 0.5s ease-in-out;
    gap: 20px;
    padding: 10px 5px;
}

.carousel-slide {
    flex: 0 0 calc(25% - 15px);
    min-width: 250px;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    transition: var(--transition);
    border: 1px solid #e2e8f0;
}

.carousel-slide:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.carousel-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.carousel-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #73a15b;
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.carousel-btn:hover {
    background: #4c726c;
    transform: scale(1.1);
}

.carousel-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.auto-play-btn {
    padding: 8px 15px;
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-radius: 25px;
    color: #73a15b;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.auto-play-btn:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.auto-play-btn.active {
    background: #73a15b;
    color: white;
    border-color: #73a15b;
}

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
    padding: 10px;
}

.carousel-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e2e8f0;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.carousel-dot:hover {
    background: #cbd5e0;
}

.carousel-dot.active {
    background: #73a15b;
    transform: scale(1.2);
}

/* ===== BOOK GRID & CARDS ===== */
/* Replace all instances of previous gold (#d3af37) with blue-gray (#7393b3) and use black where needed */

.book-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid #e2e8f0;
    transition: var(--transition);
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.15);
    border-color: #73a15b;
}

.book-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #73a15b;
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    z-index: 2;
}

/* Buttons */
.book-actions .read-btn {
    background: #73a15b;
    color: white;
}

.book-actions .read-btn:hover {
    background: #4c726c;
}

.book-actions .download-btn {
    background: #f7fafc;
    color: #73a15b;
    border: 2px solid #e2e8f0;
}

.book-actions .download-btn:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.book-actions .details-btn {
    background: #73a15b;
    color: white;
}

.book-actions .details-btn:hover {
    background: #4c726c;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1200px) {
    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

@media (max-width: 992px) {
    .carousel-slide {
        flex: 0 0 calc(50% - 10px);
    }
    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

@media (max-width: 768px) {
    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

@media (max-width: 576px) {
    .book-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 400px) {
    body {
        padding: 8px;
    }
}

/* ===== HIERARCHICAL CATEGORY STYLES ===== */

/* Category filters container */
.category-filters {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Category button base styles */
.category-btn {
    position: relative;
    text-align: left;
    padding: 10px 15px;
    margin: 2px 0;
    transition: all 0.3s ease;
    border-radius: 6px;
    width: 100%;
    border: 1px solid #e2e8f0;
    background: #f7fafc;
    color: #4a5568;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Hover effect for all categories */
.category-btn:hover {
    background: #edf2f7;
    border-color: #73a15b;
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(115, 161, 91, 0.15);
}

/* Active category */
.category-btn.active {
    background: linear-gradient(135deg, #73a15b, #4c726c) !important;
    color: white !important;
    border-color: #73a15b !important;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(115, 161, 91, 0.25);
}

/* Book count badge */
.book-count {
    background: #e2e8f0;
    color: #4a5568;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
    min-width: 24px;
    text-align: center;
    transition: all 0.3s ease;
}

.category-btn.active .book-count {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

.category-btn:hover .book-count {
    transform: scale(1.1);
}

/* Hide all icons from categories */
.category-btn i:not(.fa-caret-down):not(.fa-caret-right) {
    display: none !important;
}

/* Add tiny book icon ONLY for parent categories */
.category-btn[style*="padding-left: 15px"]::before {
    content: '📚';
    font-size: 12px;
    margin-right: 8px;
    opacity: 0.8;
}

.category-btn.active[style*="padding-left: 15px"]::before {
    opacity: 1;
    color: white;
}

/* Child categories - NO book icon */
.category-btn[style*="padding-left: 40px"]::before,
.category-btn[style*="padding-left: 65px"]::before {
    content: '' !important;
}

/* Visual hierarchy indicators for child categories */
.category-btn[style*="padding-left: 40px"] {
    border-left: 2px solid #73a15b;
    margin-left: 5px;
    padding-left: 35px;
    background: linear-gradient(to right, rgba(115, 161, 91, 0.05), #f7fafc);
}

.category-btn[style*="padding-left: 65px"] {
    border-left: 2px solid #4c726c;
    margin-left: 5px;
    padding-left: 60px;
    background: linear-gradient(to right, rgba(115, 161, 91, 0.03), #f7fafc);
}

.category-btn[style*="padding-left: 90px"] {
    border-left: 2px solid #4c726c;
    margin-left: 5px;
    padding-left: 85px;
    background: linear-gradient(to right, rgba(115, 161, 91, 0.02), #f7fafc);
}

/* Parent categories with children */
.category-btn:has(.fa-caret-down) {
    font-weight: 600;
    background: linear-gradient(to right, rgba(115, 161, 91, 0.1), #f7fafc);
}

/* Arrow icons for expandable categories */
.category-btn .fa-caret-down,
.category-btn .fa-caret-right {
    transition: transform 0.3s ease;
    font-size: 12px;
    width: 12px;
    text-align: center;
    color: #73a15b;
}

.category-btn.active .fa-caret-down,
.category-btn.active .fa-caret-right {
    color: white;
}

.category-btn:hover .fa-caret-down,
.category-btn:hover .fa-caret-right {
    transform: rotate(90deg);
}

/* Category name styling */
.category-name {
    flex-grow: 1;
    text-align: left;
    font-size: 14px;
    transition: all 0.3s ease;
}

.category-btn:hover .category-name {
    color: #2d3748;
}

.category-btn.active .category-name {
    color: white;
}

/* Visual connecting lines for hierarchy */
.category-btn::after {
    content: '';
    position: absolute;
    left: -5px;
    top: 50%;
    width: 10px;
    height: 1px;
    background: #73a15b;
    transform: translateY(-50%);
    opacity: 0.3;
    transition: all 0.3s ease;
}

.category-btn:hover::after {
    opacity: 0.7;
    width: 15px;
}

/* Remove connecting line for root categories */
.category-btn[style*="padding-left: 15px"]::after {
    display: none;
}

/* Smooth expand/collapse animation */
.category-filters {
    overflow: hidden;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .category-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .category-btn[style*="padding-left: 40px"] {
        padding-left: 30px;
    }
    
    .category-btn[style*="padding-left: 65px"] {
        padding-left: 50px;
    }
    
    .book-count {
        font-size: 10px;
        padding: 1px 5px;
        min-width: 20px;
    }
}

@media (max-width: 576px) {
    .category-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .category-btn[style*="padding-left: 40px"] {
        padding-left: 25px;
        font-size: 12px;
    }
    
    .category-btn[style*="padding-left: 65px"] {
        padding-left: 40px;
        font-size: 11px;
    }
    
    .book-count {
        font-size: 9px;
        padding: 1px 4px;
        min-width: 18px;
    }
}
/* ============================
   MOBILE RESPONSIVE BOOK POPUP
   ============================ */

@media (max-width: 600px) {

    /* Modal Content */
    .book-details-content {
        width: 90% !important;
        max-width: 90% !important;
        padding: 15px !important;
        border-radius: 10px !important;
    }

    /* Main row inside modal */
    .book-details-row {
        flex-direction: column !important;
        align-items: center !important;
        gap: 15px !important;
    }

    /* Left Section (Image) */
    .book-details-left {
        width: 100% !important;
        text-align: center !important;
    }

    /* FIXED: Mobile modal image - changed from 'cover' to 'contain' */
    .book-details-left img {
        width: 100% !important;
        height: auto !important;
        max-height: 280px !important;
        object-fit: contain !important; /* CHANGED FROM 'cover' TO 'contain' */
        background: #f8f9fa !important; /* Added background for letterboxing */
        border-radius: 8px !important;
    }

    /* Right Section (Text) */
    .book-details-right {
        width: 100% !important;
    }

    .book-details-right h2 {
        font-size: 20px !important;
        line-height: 1.3 !important;
        text-align: center !important;
    }

    .book-details-right p {
        font-size: 15px !important;
        line-height: 1.4 !important;
    }

    /* Buttons */
    .modal-buttons {
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        margin-top: 10px !important;
    }

    .modal-buttons button,
    .modal-buttons a {
        width: 100% !important;
        font-size: 15px !important;
        padding: 12px !important;
        text-align: center !important;
        border-radius: 8px !important;
    }

    /* Close Button */
    .close-modal {
        top: 12px !important;
        right: 12px !important;
        font-size: 24px !important;
    }
}
/* ===== Fix: Close button behind scaled image (stacking + mobile) ===== */

/* Ensure modal content creates a stacking context but remains below the close button */
.book-details-content {
    position: relative; /* already present in your CSS but re-affirm */
    z-index: 1000;
}

/* Keep the left column image clipped so scaled image cannot overflow over the close button */
.book-details-left {
    position: relative;
    z-index: 1;
    overflow: hidden; /* important: prevents scaled image from overlapping close button */
}

/* Make sure the image itself stays under the close button */
.book-details-left img {
    position: relative;
    z-index: 1;
    transition: transform 0.4s ease;
}

/* Keep close button on top and clickable */
.close-modal {
    position: absolute;       /* already used, reaffirm */
    top: 12px;
    right: 16px;
    z-index: 3000 !important; /* high value to sit above image transforms */
    pointer-events: auto;     /* ensure it receives taps/clicks */
}

/* Disable hover-zoom on small/touch devices to avoid accidental zoom hiding the button */
@media (max-width: 992px) {
    .book-details-left img:hover,
    .book-details-left img:active,
    .book-details-left img:focus {
        transform: none !important;
    }
}

/* Optional: small tweak for very small screens to make sure close button remains reachable */
@media (max-width: 420px) {
    .close-modal {
        top: 8px;
        right: 10px;
        font-size: 26px;
        z-index: 4000 !important;
    }
}
/* ===== CAROUSEL SLIDES RESPONSIVE ===== */
.carousel-track {
    display: flex;
    transition: transform 0.5s ease;
    gap: 20px;
}

/* Default desktop: multiple slides */
.carousel-slide {
    flex: 0 0 calc(25% - 15px); /* 4 slides desktop */
    min-width: 250px;
}

/* Tablets */
@media (max-width: 992px) {
    .carousel-slide {
        flex: 0 0 calc(50% - 10px); /* 2 slides tablet */
        min-width: 200px;
    }
}

/* Mobile phones */
@media (max-width: 768px) {
    .carousel-slide {
        flex: 0 0 100%; /* Only 1 slide at a time */
        min-width: 100%;
    }

    .carousel-track {
        gap: 0; /* No extra space between slides */
    }
}
/* Nuclear option - inspect what's actually hiding the buttons */
.book-details-modal * {
    color: #73a15b !important;
}

/* Then specifically target buttons */
.book-details-modal button,
.book-details-modal a,
.book-details-modal .btn {
    color: #73a15b !important;
    background-color: #f7fafc !important;
    border: 2px solid #e2e8f0 !important;
}
