/* CSS Variables */
:root {
    --primary-color: #104F55;
    --primary-light: #1a6b73;
    --primary-dark: #0a353a;
    --secondary-color: #D4AF37;
    --secondary-light: #e4c560;
    --background: #F9F9F7;
    --surface: #ffffff;
    --surface-hover: #f5f5f3;
    --text-primary: #2D3748;
    --text-secondary: #718096;
    --text-muted: #a0aec0;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.2s ease;
    --arabic-font: 'Amiri', serif;
}

/* Dark Theme */
[data-theme="dark"] {
    --background: #1a1f2e;
    --surface: #242938;
    --surface-hover: #2d3347;
    --text-primary: #e2e8f0;
    --text-secondary: #a0aec0;
    --text-muted: #718096;
    --border-color: #374151;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
}

/* Header */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.logo:hover {
    opacity: 0.85;
}

.logo-icon {
    font-size: 1.75rem;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.search-container {
    flex: 1;
    max-width: 500px;
    display: flex;
    gap: 0.5rem;
}

.search-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    background: var(--background);
    color: var(--text-primary);
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(16, 79, 85, 0.1);
}

.search-btn {
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.search-btn:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Font Selector */
.font-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.font-selector label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.font-selector select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.font-selector select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.font-selector select:hover {
    border-color: var(--primary-light);
}

.theme-toggle {
    padding: 0.5rem 0.75rem;
    background: var(--surface-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1.25rem;
    transition: var(--transition);
}

.theme-toggle:hover {
    background: var(--border-color);
}

/* Breadcrumb */
.breadcrumb {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.breadcrumb-item {
    cursor: pointer;
    color: var(--primary-color);
    font-weight: 500;
    transition: var(--transition);
}

.breadcrumb-item:hover {
    text-decoration: underline;
}

.breadcrumb-item:last-child {
    color: var(--text-secondary);
    cursor: default;
    text-decoration: none;
}

/* Main Content */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem 2rem;
    min-height: calc(100vh - 200px);
}

/* Loading State */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    gap: 1rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error State */
.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.error-container h2 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.error-container p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.retry-btn {
    padding: 0.75rem 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.retry-btn:hover {
    background: var(--primary-light);
}

/* Views */
.view {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.view-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.view-header h1 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.view-header p {
    color: var(--text-secondary);
}

/* Books Grid */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.book-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.book-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-color);
    transform: scaleX(0);
    transition: var(--transition);
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.book-card:hover::before {
    transform: scaleX(1);
}

.book-card-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.book-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    flex-shrink: 0;
}

.book    font-size: 1.1-info h3 {
rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.book-info .arabic-title {
    font-family: var(--arabic-font);
    font-size: 1rem;
    color: var(--primary-color);
    font-weight: 600;
}

.book-stats {
    display: flex;
    gap: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Chapters List */
.chapters-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chapter-item {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chapter-item:hover {
    background: var(--surface-hover);
    border-color: var(--primary-color);
    transform: translateX(4px);
}

.chapter-number {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.chapter-details {
    flex: 1;
}

.chapter-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.chapter-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.chapter-count {
    background: var(--surface-hover);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.chapter-filter {
    margin-top: 1rem;
    max-width: 400px;
}

.chapter-filter input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    background: var(--surface);
    color: var(--text-primary);
    transition: var(--transition);
}

.chapter-filter input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Hadiths List */
.hadiths-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.hadith-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: var(--transition);
}

.hadith-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.hadith-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.hadith-reference {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.hadith-book {
    background: var(--primary-color);
    color: white;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
}

.hadith-number {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.hadith-grade {
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
}

.grade-sahih {
    background: #dcfce7;
    color: #166534;
}

.grade-hasan {
    background: #fef3c7;
    color: #92400e;
}

.grade-daif,
.grade-munkar,
.grade-matrook {
    background: #fee2e2;
    color: #991b1b;
}

.grade-default {
    background: var(--surface-hover);
    color: var(--text-secondary);
}

.hadith-body {
    margin-bottom: 1rem;
}

.hadith-arabic {
    font-family: var(--arabic-font);
    font-size: 1.4rem;
    line-height: 2;
    color: #000000;
    margin-bottom: 1rem;
    text-align: right;
    direction: rtl;
}

.hadith-arabic a {
    color: var(--primary-color);
    text-decoration: none;
}

.hadith-translation {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-primary);
    padding-left: 1rem;
    border-left: 3px solid var(--secondary-color);
}

.hadith-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.hadith-narrator {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.hadith-narrator strong {
    color: var(--text-primary);
}

.hadith-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    padding: 0.5rem 0.75rem;
    background: var(--surface-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.action-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.hadith-filters {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.hadith-filters select {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.hadith-filters select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.page-btn {
    padding: 0.6rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
    transition: var(--transition);
}

.page-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.page-info {
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    background: var(--surface-hover);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-secondary);
    transition: var(--transition);
    z-index: 10;
}

.modal-close:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Footer */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer p {
    margin: 0.5rem 0;
    line-height: 1.6;
}

.footer-copyright {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.footer-dedication {
    color: var(--primary-color);
}

.footer-dedication strong {
    color: var(--secondary-color);
}

.footer-license {
    max-width: 700px;
    margin-left: auto !important;
    margin-right: auto !important;
    font-size: 0.85rem;
}

.footer-disclaimer {
    font-size: 0.8rem;
    font-style: italic;
    color: var(--text-muted);
}

.footer-data {
    margin-top: 1rem !important;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.footer a:hover {
    text-decoration: underline;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .logo-text {
        font-size: 1rem;
    }

    .search-container {
        order: 3;
        flex: 100%;
        max-width: none;
    }

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

    .book-stats {
        flex-wrap: wrap;
    }

    .hadith-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .hadith-footer {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .hadith-actions {
        width: 100%;
    }

    .action-btn {
        flex: 1;
        text-align: center;
    }

    .hadith-arabic {
        font-size: 1.2rem;
    }

    .hadith-translation {
        font-size: 0.95rem;
    }
}

/* No Results */
.no-results {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.no-results-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.no-results h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, var(--surface-hover) 25%, var(--border-color) 50%, var(--surface-hover) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

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

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-title {
    height: 1.5rem;
    width: 60%;
    margin-bottom: 0.75rem;
}

.skeleton-card {
    padding: 1.5rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
}
