/* المستنير - Unified Single Color Design */

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

body {
    font-family: 'Noto Sans Arabic', 'Tahoma', 'Arial', sans-serif;
    background-color: #ffffff;
    color: #333333;
    line-height: 1.6;
    direction: rtl;
    text-align: right;
    font-size: 16px;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background-color: #ffffff;
    padding: 20px 0;
    border-bottom: 1px solid #eee;
}

.site-title {
    text-align: center;
    font-size: 2.5em;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
}

.site-subtitle {
    text-align: center;
    font-size: 1.2em;
    color: #666;
    margin-bottom: 30px;
}

/* Navigation */
nav {
    text-align: center;
    margin: 20px 0;
}

.nav-buttons {
    display: inline-flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

/* UNIFIED BUTTON STYLING - SINGLE COLOR ONLY */
.btn,
.btn-primary,
.btn-secondary,
.btn-info,
.btn-success,
.btn-warning,
.btn-danger,
a.btn,
button.btn,
input[type="submit"],
input[type="button"] {
    display: inline-block !important;
    padding: 12px 25px !important;
    text-decoration: none !important;
    color: #333 !important;
    background-color: #ffffff !important;
    border: 2px solid #2D5A27 !important;
    border-radius: 5px !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    font-family: inherit !important;
    transition: none !important;
}

/* UNIFIED HOVER EFFECTS - SINGLE COLOR ONLY */
.btn:hover,
.btn-primary:hover,
.btn-secondary:hover,
.btn-info:hover,
.btn-success:hover,
.btn-warning:hover,
.btn-danger:hover,
a.btn:hover,
button.btn:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
    background-color: #2D5A27 !important;
    color: white !important;
    border-color: #2D5A27 !important;
}

/* Main Content */
main {
    padding: 40px 0;
    min-height: 60vh;
}

/* Page Title */
.page-title {
    text-align: center;
    font-size: 2.2em;
    color: #2D5A27;
    margin-bottom: 20px;
    border-bottom: 2px solid #2D5A27;
    padding-bottom: 15px;
}

/* Section Title */
.section-title {
    color: #2D5A27;
    font-size: 1.8em;
    margin-bottom: 20px;
    text-align: center;
}

/* Course Grid */
.courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin: 30px 0;
}

.course-card {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 25px;
    text-align: center;
    transition: none;
}

.course-card:hover {
    border-color: #2D5A27;
}

.course-title {
    color: #2D5A27;
    font-size: 1.4em;
    margin-bottom: 15px;
    font-weight: bold;
}

.course-description {
    color: #666;
    margin-bottom: 15px;
    line-height: 1.6;
}

.lesson-count {
    background-color: #2D5A27;
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    display: inline-block;
    font-size: 14px;
    margin-bottom: 15px;
}

/* Search Box */
.search-box {
    text-align: center;
    margin: 30px 0;
}

.search-box input {
    padding: 12px 20px;
    border: 2px solid #2D5A27;
    border-radius: 25px;
    font-size: 16px;
    width: 300px;
    max-width: 100%;
    text-align: center;
    font-family: inherit;
}

.search-box input:focus {
    outline: none;
    border-color: #2D5A27;
    box-shadow: 0 0 5px rgba(45, 90, 39, 0.3);
}

/* Lessons */
.lesson-item {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
}

.lesson-item:hover {
    border-color: #2D5A27;
}

.lesson-title {
    color: #2D5A27;
    font-size: 1.2em;
    margin-bottom: 10px;
    font-weight: bold;
}

.lesson-meta {
    color: #666;
    font-size: 14px;
    margin-bottom: 15px;
}

/* Pagination */
.pagination {
    text-align: center;
    margin: 30px 0;
}

.pagination a,
.pagination span {
    display: inline-block;
    padding: 10px 15px;
    margin: 0 5px;
    border: 2px solid #2D5A27;
    color: #333;
    text-decoration: none;
    border-radius: 5px;
    background-color: #ffffff;
}

.pagination a:hover,
.pagination .current {
    background-color: #2D5A27;
    color: white;
}

/* Enhanced Books Grid with Title Fitting Solutions */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin: 30px 0;
    padding: 0 15px;
}

/* Touch and Selection Highlighting CSS for Book Cards */

/* Base book card styling (add to your existing CSS) */
.book-card {
    /* Your existing styles... */
    position: relative;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    transition: all 0.2s ease;
    /* Add touch-action for better mobile performance */
    touch-action: manipulation;
}

/* 1. TOUCH HIGHLIGHT EFFECTS */

/* Active state when touching/clicking */
.book-card:active {
    transform: translateY(-1px) scale(0.98);
    box-shadow: 0 4px 15px rgba(45, 90, 39, 0.3);
    border-color: #2D5A27;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

/* Touch highlight overlay */
.book-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, rgba(45, 90, 39, 0.1) 0%, transparent 70%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    border-radius: inherit;
}

.book-card:active::after {
    opacity: 1;
}

/* 2. SELECTION HIGHLIGHTING */

/* Selected state class (add via JavaScript) */
.book-card.selected {
    border-color: #2D5A27;
    border-width: 3px;
    background: linear-gradient(135deg, #f0f8f0 0%, #e8f5e8 100%);
    box-shadow: 0 6px 20px rgba(45, 90, 39, 0.2);
    transform: translateY(-2px);
}

.book-card.selected::before {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 10px;
    background: #2D5A27;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    z-index: 10;
    animation: checkmarkPop 0.3s ease;
}

@keyframes checkmarkPop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 3. HOVER EFFECTS (Desktop) */
@media (hover: hover) {
    .book-card:hover {
        border-color: #2D5A27;
        transform: translateY(-3px);
        box-shadow: 0 8px 25px rgba(45, 90, 39, 0.15);
    }
    
    .book-card:hover::after {
        opacity: 0.3;
    }
}

/* 4. FOCUS EFFECTS (Keyboard Navigation) */
.book-card:focus {
    outline: none;
    border-color: #2D5A27;
    box-shadow: 0 0 0 3px rgba(45, 90, 39, 0.3);
}

.book-card:focus-visible {
    outline: 2px solid #2D5A27;
    outline-offset: 2px;
}

/* 5. RIPPLE EFFECT ON TOUCH */
.book-card {
    overflow: hidden;
}

.book-card .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(45, 90, 39, 0.3);
    transform: scale(0);
    animation: rippleEffect 0.6s linear;
    pointer-events: none;
}

@keyframes rippleEffect {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* 6. MOBILE-SPECIFIC TOUCH HIGHLIGHTS */
@media (max-width: 768px) {
    /* Remove default webkit touch highlight */
    .book-card {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
    }
    
    /* Enhanced active state for mobile */
    .book-card:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
    
    /* Larger touch target */
    .book-card {
        min-height: 44px; /* iOS minimum touch target */
    }
}

/* 7. PULSE ANIMATION FOR SELECTED ITEMS */
.book-card.selected {
    animation: selectedPulse 2s infinite;
}

@keyframes selectedPulse {
    0%, 100% {
        box-shadow: 0 6px 20px rgba(45, 90, 39, 0.2);
    }
    50% {
        box-shadow: 0 6px 20px rgba(45, 90, 39, 0.4);
    }
}

/* 8. MULTI-SELECT HIGHLIGHTING */
.book-card.multi-selected {
    border-color: #007bff;
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f3ff 100%);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.2);
}

.book-card.multi-selected::before {
    content: '✓';
    background: #007bff;
}

/* 9. LOADING STATE HIGHLIGHT */
.book-card.loading {
    pointer-events: none;
    opacity: 0.7;
    position: relative;
}

.book-card.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #2D5A27;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* 10. ERROR STATE HIGHLIGHT */
.book-card.error {
    border-color: #dc3545;
    background: linear-gradient(135deg, #fff5f5 0%, #ffe6e6 100%);
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* 11. SUCCESS STATE HIGHLIGHT */
.book-card.success {
    border-color: #28a745;
    background: linear-gradient(135deg, #f0fff4 0%, #e6ffed 100%);
    animation: successGlow 0.8s ease;
}

@keyframes successGlow {
    0% { box-shadow: 0 6px 20px rgba(40, 167, 69, 0); }
    50% { box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4); }
    100% { box-shadow: 0 6px 20px rgba(40, 167, 69, 0.1); }
}

/* 12. ACCESSIBILITY IMPROVEMENTS */
/* High contrast mode */
@media (prefers-contrast: high) {
    .book-card:active,
    .book-card.selected {
        border-width: 4px;
        border-color: #000;
    }
    
    .book-card.selected::before {
        background: #000;
        color: #fff;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .book-card,
    .book-card::after,
    .book-card::before {
        animation: none;
        transition: none;
    }
    
    .book-card:active {
        transform: none;
    }
}

/* 13. DARK MODE SUPPORT */
@media (prefers-color-scheme: dark) {
    .book-card:active {
        background: linear-gradient(135deg, #374151 0%, #4b5563 100%);
    }
    
    .book-card.selected {
        background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
        border-color: #68d391;
    }
    
    .book-card.selected::before {
        background: #68d391;
        color: #1f2937;
    }
}

/* 14. BUTTON HIGHLIGHTING WITHIN CARDS */
.book-card .action-btn:active {
    transform: scale(0.95);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.book-card .action-btn:focus {
    outline: 2px solid #2D5A27;
    outline-offset: 2px;
}

/* 15. CUSTOM SELECTION STYLES */
.book-card.highlighted {
    border-color: #ffc107;
    background: linear-gradient(135deg, #fffbf0 0%, #fff8e1 100%);
    box-shadow: 0 6px 20px rgba(255, 193, 7, 0.3);
}

.book-card.highlighted::before {
    content: '★';
    background: #ffc107;
    color: #212529;
}

/* 16. PERFORMANCE OPTIMIZATIONS */
.book-card {
    /* Enable hardware acceleration */
    will-change: transform, box-shadow;
    /* Optimize for animations */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Only apply will-change during interactions */
.book-card:hover,
.book-card:active,
.book-card:focus {
    will-change: transform, box-shadow, border-color;
}

.book-card:not(:hover):not(:active):not(:focus) {
    will-change: auto;
}



/* FIXED TITLE STYLING - Solves the text fitting issue */
.book-title {
    color: #2D5A27;
    font-size: 1.2em;
    margin-bottom: 12px;
    font-weight: bold;
    line-height: 1.3;
    /* Text fitting solutions */
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 3.9em; /* 3 lines * 1.3 line-height */
    /* Ensure proper spacing */
    padding: 0 5px;
    margin: 0 auto 12px auto;
    /* Better text rendering */
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

.book-description {
    color: #666;
    margin-bottom: 12px;
    font-size: 0.9em;
    line-height: 1.4;
    /* Text fitting for descriptions */
    word-wrap: break-word;
    overflow-wrap: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 2.8em; /* 2 lines * 1.4 line-height */
    flex: 1;
}

.book-size {
    color: #888;
    font-size: 0.8em;
    margin-bottom: 15px;
    font-weight: 500;
    background: #f8f9fa;
    padding: 4px 8px;
    border-radius: 12px;
    display: inline-block;
}

/* Enhanced Book Actions */
.book-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: auto;
    padding-top: 15px;
}

.action-btn {
    padding: 8px 16px;
    border: 2px solid #2D5A27;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.85em;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
    white-space: nowrap;
    min-width: 70px;
    flex: 1;
    max-width: 100px;
}

.preview-btn {
    background: #f8f9fa;
    color: #2D5A27;
}

.preview-btn:hover {
    background: #2D5A27;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(45, 90, 39, 0.2);
}

.download-btn {
    background: #2D5A27;
    color: white;
}

.download-btn:hover {
    background: #1e3d1a;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(45, 90, 39, 0.3);
}

/* Author styling */
.book-author {
    color: #777;
    font-size: 0.85em;
    font-style: italic;
    margin-bottom: 10px;
    /* Text fitting for author names */
    word-wrap: break-word;
    overflow-wrap: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Responsive Design - Mobile First */
@media (max-width: 768px) {
    .books-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 20px;
        margin: 20px 0;
        padding: 0 10px;
    }
    
    .book-card {
        padding: 20px 15px;
        min-height: 180px;
    }
    
    .book-title {
        font-size: 1.1em;
        line-height: 1.2;
        -webkit-line-clamp: 3;
        max-height: 3.6em; /* 3 lines * 1.2 line-height */
        margin-bottom: 10px;
    }
    
    .book-description {
        font-size: 0.85em;
        -webkit-line-clamp: 2;
        max-height: 2.4em;
    }
    
    .book-size {
        font-size: 0.75em;
        margin-bottom: 12px;
    }
    
    .action-btn {
        padding: 6px 12px;
        font-size: 0.8em;
        min-width: 60px;
    }
}

@media (max-width: 480px) {
    .books-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 15px;
        padding: 0 5px;
    }
    
    .book-card {
        padding: 15px 12px;
        min-height: 160px;
    }
    
    .book-title {
        font-size: 1em;
        line-height: 1.1;
        -webkit-line-clamp: 2;
        max-height: 2.2em; /* 2 lines * 1.1 line-height */
        margin-bottom: 8px;
    }
    
    .book-description {
        font-size: 0.8em;
        -webkit-line-clamp: 1;
        max-height: 1.4em;
        margin-bottom: 8px;
    }
    
    .book-size {
        font-size: 0.7em;
        margin-bottom: 10px;
    }
    
    .action-btn {
        padding: 5px 10px;
        font-size: 0.75em;
        min-width: 50px;
    }
    
    .book-actions {
        gap: 8px;
        padding-top: 10px;
    }
}

@media (max-width: 320px) {
    .books-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .book-card {
        padding: 12px 10px;
        min-height: 140px;
    }
    
    .book-title {
        font-size: 0.95em;
        -webkit-line-clamp: 2;
        max-height: 2.1em;
    }
    
    .book-description {
        font-size: 0.75em;
        -webkit-line-clamp: 1;
        max-height: 1.2em;
    }
    
    .action-btn {
        padding: 4px 8px;
        font-size: 0.7em;
        min-width: 45px;
    }
}

/* Large screens optimization */
@media (min-width: 1200px) {
    .books-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
        gap: 30px;
    }
    
    .book-card {
        padding: 30px 25px;
        min-height: 220px;
    }
    
    .book-title {
        font-size: 1.3em;
        line-height: 1.3;
        -webkit-line-clamp: 3;
        max-height: 3.9em;
    }
    
    .book-description {
        font-size: 0.95em;
        -webkit-line-clamp: 2;
        max-height: 2.8em;
    }
}

/* Enhanced animations and interactions */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.book-card {
    animation: fadeInUp 0.5s ease forwards;
}

.book-card:nth-child(1) { animation-delay: 0.1s; }
.book-card:nth-child(2) { animation-delay: 0.2s; }
.book-card:nth-child(3) { animation-delay: 0.3s; }
.book-card:nth-child(4) { animation-delay: 0.4s; }
.book-card:nth-child(5) { animation-delay: 0.5s; }
.book-card:nth-child(6) { animation-delay: 0.6s; }
.book-card:nth-child(7) { animation-delay: 0.7s; }
.book-card:nth-child(8) { animation-delay: 0.8s; }

/* Accessibility improvements */
.book-card:focus-within {
    outline: 2px solid #2D5A27;
    outline-offset: 2px;
}

.action-btn:focus {
    outline: 2px solid #2D5A27;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .book-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .action-btn {
        display: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .book-card {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .book-title {
        color: #68d391;
    }
    
    .book-description {
        color: #a0aec0;
    }
    
    .book-size {
        background: #4a5568;
        color: #cbd5e0;
    }
    
    .preview-btn {
        background: #4a5568;
        color: #68d391;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .book-card {
        border-width: 3px;
    }
    
    .book-title {
        font-weight: 900;
    }
    
    .action-btn {
        border-width: 3px;
        font-weight: 700;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .book-card,
    .action-btn {
        transition: none;
        animation: none;
    }
    
    .book-card:hover {
        transform: none;
    }
}



/* Footer */
footer {
    background-color: #f8f9fa;
    border-top: 1px solid #eee;
    padding: 30px 0;
    text-align: center;
    color: #666;
    margin-top: 50px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .courses-grid,
    .books-grid {
        grid-template-columns: 1fr;
    }
    
    .search-box input {
        width: 100%;
    }
    
    .site-title {
        font-size: 2em;
    }
}

/* Remove any conflicting styles */
.btn-1, .btn-2, .btn-3, .btn-4,
.button-1, .button-2, .button-3, .button-4 {
    display: none !important;
}



/* Live Search Bar with Curved Edges */
.live-search-container { 
    margin: 20px 0; 
    max-width: 600px; 
    margin-left: auto; 
    margin-right: auto; 
}

.search-wrapper { 
    position: relative; 
    display: flex; 
    align-items: center; 
    background: #ffffff; 
    border: 2px solid #2D5A27; 
    border-radius: 25px; 
    padding: 5px 15px; 
    box-shadow: 0 4px 10px rgba(45, 90, 39, 0.1); 
    transition: all 0.3s ease;
}

.search-wrapper:focus-within { 
    box-shadow: 0 6px 15px rgba(45, 90, 39, 0.2); 
    transform: translateY(-2px); 
}

#liveSearch { 
    flex: 1; 
    border: none; 
    outline: none; 
    padding: 12px 10px; 
    font-size: 16px; 
    font-family: 'Noto Sans Arabic', 'Tahoma', 'Arial', sans-serif;
    background: transparent; 
    direction: rtl; 
    text-align: right; 
    color: #333;
}

#liveSearch::placeholder {
    color: #888;
    opacity: 0.8;
}

.search-results { 
    margin-top: 10px; 
    font-size: 14px; 
    color: #666; 
    text-align: center; 
    min-height: 20px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .live-search-container {
        margin: 15px 10px;
    }
    
    .search-wrapper {
        border-radius: 20px;
    }
    
    #liveSearch {
        font-size: 14px;
        padding: 10px 8px;
    }
}

