:root {
    --primary: #1b5e20;
    --primary-light: #2e7d32;
    --primary-dark: #0d3e10;
    --primary-accent: #4caf50;
    --secondary: #c6a961;
    --secondary-light: #d4af37;
    --bg-primary: #f5f7f5;
    --bg-secondary: #ffffff;
    --bg-accent: #e8f5e9;
    --text-primary: #1a1a1a;
    --text-secondary: #555555;
    --border: #c8e6c9;
    --shadow: rgba(27, 94, 32, 0.1);
    --shadow-lg: rgba(27, 94, 32, 0.15);
}

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

@font-face {
    font-family: 'Jameel Noori';
    src: url('./fonts/JameelNoori-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}

@font-face {
    font-family: 'Amiri Regular';
    src: url('./fonts/Amiri-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}

@font-face {
    font-family: 'KFGQPC Uthmanic Script HAFS';
    src: url('./fonts/KFGQPC-Uthmanic-Script-HAFS-Regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}

body {
    font-family: 'Jameel Noori', serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.8;
    direction: rtl;
}

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

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 2rem 0;
    box-shadow: 0 4px 6px var(--shadow);
}

.header-content {
    text-align: center;
    margin-bottom: 1.5rem;
}

.logo {
    font-family: 'Jameel Noori', serif;
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-family: 'Jameel Noori', serif;
    font-size: 1.2rem;
    opacity: 0.9;
    font-weight: 500;
}

.nav {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.75rem 2rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.nav-btn.active {
    background: var(--secondary);
    border-color: var(--secondary);
    color: var(--primary-dark);
    font-weight: 600;
}

/* Main */
.main {
    padding: 3rem 0;
    min-height: calc(100vh - 400px);
}

.view {
    display: none;
}

.view.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

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

/* Search Section - Traditional Style */
.search-section {
    background: white;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(27, 94, 32, 0.08);
    margin-bottom: 2.5rem;
    border: 2px solid var(--border);
    border-right: 5px solid var(--primary);
}

.search-box {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.search-input {
    flex: 1;
    padding: 1.1rem 1.75rem;
    border: 2px solid var(--border);
    border-radius: 50px;
    font-size: 1.1rem;
    font-family: inherit;
    transition: all 0.3s ease;
    background: white;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(27, 94, 32, 0.1);
}

.search-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-btn:hover {
    background: var(--primary-light);
    transform: scale(1.05);
}

.volume-selector {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-accent);
    border-radius: 10px;
}

.volume-label {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
}

.volume-select {
    padding: 0.6rem 1.5rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: white;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 150px;
}

.volume-select:hover {
    border-color: var(--primary);
}

.volume-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(27, 94, 32, 0.1);
}

.filter-chips {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.chip {
    background: var(--bg-primary);
    border: 2px solid var(--border);
    padding: 0.5rem 1.5rem;
    border-radius: 50px;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chip:hover {
    border-color: var(--primary);
    background: rgba(45, 80, 22, 0.05);
}

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

/* Stats Section */
.stats-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 4px 12px var(--shadow);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-number {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Results Section - Traditional Style */
.results-section {
    background: white;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(27, 94, 32, 0.08);
    border: 1px solid var(--border);
}

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

.section-title {
    font-size: 2rem;
    color: var(--primary);
    font-weight: 700;
}

.results-count {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.results-grid {
    display: grid;
    gap: 1.5rem;
}

.fatwa-card {
    background: white;
    padding: 1.75rem;
    border-radius: 12px;
    border-right: 5px solid var(--primary);
    transition: all 0.3s ease;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

.fatwa-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 5px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-light) 100%);
    transition: width 0.3s ease;
}

.fatwa-card:hover {
    transform: translateX(-8px);
    box-shadow: 0 8px 24px rgba(45, 80, 22, 0.15);
    border-right-color: var(--secondary);
}

.fatwa-card:hover::before {
    width: 8px;
}

.fatwa-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
    gap: 1rem;
}

.fatwa-id {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 0.4rem 1rem;
    border-radius: 25px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(45, 80, 22, 0.2);
    white-space: nowrap;
}

.fatwa-chapter {
    color: var(--text-secondary);
    font-size: 0.9rem;
    background: rgba(45, 80, 22, 0.08);
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    white-space: nowrap;
}

.fatwa-topic {
    font-family: 'Jameel Noori', serif;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 1rem;
    line-height: 1.6;
    transition: color 0.2s ease;
}

.fatwa-card:hover .fatwa-topic {
    color: var(--primary);
}

.fatwa-question {
    font-family: 'Jameel Noori', serif;
    color: var(--text-secondary);
    line-height: 1.8;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 1.05rem;
}

/* Loading */
.loading {
    text-align: center;
    padding: 3rem;
}

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

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

.hidden {
    display: none !important;
}

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

.pagination-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--primary-light);
    transform: scale(1.05);
}

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

.page-info {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* Chapters Grid */
.chapters-section {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 4px 12px var(--shadow);
}

.chapters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.chapter-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 2rem;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chapter-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px var(--shadow-lg);
}

.chapter-number {
    font-size: 3rem;
    font-weight: 700;
    opacity: 0.3;
    margin-bottom: 0.5rem;
}

.chapter-name {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.chapter-count {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* About Section */
.about-section {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 4px 12px var(--shadow);
}

.about-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.about-card {
    background: var(--bg-primary);
    padding: 2rem;
    border-radius: 15px;
    border-top: 4px solid var(--primary);
}

.about-card h3 {
    color: var(--primary);
    font-size: 1.3rem;
    margin-bottom: 1rem;
}

.about-card p {
    color: var(--text-secondary);
    line-height: 1.7;
    font-size: 1.1rem;
}

/* Fatwa Detail Page View */
.fatwa-detail-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    background: var(--bg-secondary);
    min-height: calc(100vh - 300px);
    border-radius: 12px;
    box-shadow: 0 4px 16px var(--shadow);
    overflow: hidden; /* Ensure content stays in container */
    word-wrap: break-word; /* Break long words */
}

.back-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    margin-bottom: 2rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(27, 94, 32, 0.2);
}

.back-button:hover {
    background: var(--primary-dark);
    transform: translateX(-5px);
    box-shadow: 0 4px 12px rgba(27, 94, 32, 0.3);
}

.back-button span {
    font-size: 1.2rem;
}

.fatwa-detail-body {
    overflow: visible;
    padding: 0;
    background: transparent;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

.breadcrumb a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.breadcrumb a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.breadcrumb-separator {
    color: var(--text-secondary);
    margin: 0 0.25rem;
}

.breadcrumb-current {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Fatwa Main Content */
.fatwa-main-content {
    max-width: 900px;
    margin: 0 auto;
    overflow: hidden; /* Ensure content stays in container */
    word-wrap: break-word; /* Break long words */
}

.fatwa-title-section {
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 3px solid var(--primary);
}

.fatwa-main-title {
    font-family: 'Jameel Noori', serif;
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 1.5rem;
    line-height: 1.4;
    text-align: right;
}

/* Metadata */
.fatwa-metadata {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(45, 80, 22, 0.05) 0%, rgba(74, 124, 42, 0.05) 100%);
    border-radius: 8px;
    border-right: 4px solid var(--primary);
}

.metadata-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.metadata-label {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.95rem;
}

.metadata-value {
    color: var(--text-primary);
    font-size: 1rem;
}

/* Question Section */
.question-section {
    margin-bottom: 3rem;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 2rem;
    border-right: 5px solid #4a7c2a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.section-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.question-label {
    color: #2d5016;
}

.answer-label {
    color: #2d5016;
}

.label-icon {
    font-size: 1.5rem;
}

.label-text {
    font-family: 'Jameel Noori', serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.question-content {
    line-height: 2;
    font-size: 1.15rem;
    color: var(--text-primary);
    font-family: 'Jameel Noori', serif;
    white-space: pre-line; /* Preserve line breaks */
}

.question-content p {
    margin-bottom: 1rem;
}

.question-author {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.author-label {
    font-family: 'Jameel Noori', serif;
    font-weight: 600;
    color: var(--primary);
    font-size: 0.95rem;
}

.author-name {
    font-family: 'Jameel Noori', serif;
    color: var(--text-secondary);
    font-style: italic;
}

/* Answer Section */
.answer-section {
    margin-bottom: 3rem;
    background: #ffffff;
    border-radius: 12px;
    padding: 2rem;
    border-right: 5px solid var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    overflow: hidden; /* Ensure content stays in container */
    word-wrap: break-word; /* Break long words */
}

.answer-content-wrapper {
    margin-top: 1rem;
    overflow: hidden; /* Ensure content stays in container */
    word-wrap: break-word; /* Break long words */
}

.references-list {
    list-style: none;
}

.references-list li {
    background: var(--bg-primary);
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 0.75rem;
    line-height: 1.8;
    border-right: 3px solid var(--secondary);
    transition: background-color 0.3s ease;
}

/* Answer Content with Paragraphs */
.answer-content {
    line-height: 2.2;
    overflow: hidden; /* Ensure content stays in container */
    word-wrap: break-word; /* Break long words */
    word-break: break-word; /* Break words if needed */
    font-size: 1.15rem;
    color: var(--text-primary);
    font-family: 'Jameel Noori', serif !important;
    white-space: pre-line; /* Preserve line breaks */
    max-width: 100%; /* Ensure it doesn't exceed container */
    box-sizing: border-box; /* Include padding in width calculation */
}

.answer-paragraph {
    font-family: 'Jameel Noori', serif !important;
    margin-bottom: 1.5rem;
    line-height: 2.2;
    overflow-wrap: break-word; /* Break long words */
    word-wrap: break-word; /* Legacy support */
    word-break: break-word; /* Break words if needed */
    text-align: justify;
    padding-right: 0.5rem;
    white-space: pre-line; /* Preserve line breaks from <br> tags */
    max-width: 100%; /* Ensure it doesn't exceed container */
}

/* Ensure paragraph text uses Jameel Noori, but not reference links */
.answer-paragraph {
    font-family: 'Jameel Noori', serif !important;
}

/* Paragraph number should also use Jameel Noori */
.answer-paragraph .para-number {
    font-family: 'Jameel Noori', serif !important;
}

.answer-paragraph:last-child {
    margin-bottom: 0;
}

/* References Section at the end */
.references-section {
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 3px solid var(--primary);
    background: #f8f9fa;
    padding: 2rem;
    border-radius: 12px;
    margin-right: -2rem;
    margin-left: -2rem;
    margin-bottom: -2rem;
    overflow: hidden; /* Ensure content stays in container */
    word-wrap: break-word; /* Break long words */
}

.references-heading {
    font-family: 'Jameel Noori', serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1.5rem;
    text-align: right;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.references-heading::before {
    content: "📚";
    font-size: 1.5rem;
}

.references-list-full {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.ref-full {
    padding: 1.2rem;
    border-radius: 8px;
    background: white;
    border-right: 4px solid var(--secondary);
    line-height: 1.9;
    text-align: right;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.ref-full:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateX(-3px);
}

.ref-full .ref-number {
    font-weight: 700;
    color: var(--primary);
    margin-left: 0.5rem;
}

/* Hadith references - Amiri Regular */
.ref-full.ref-hadith {
    font-family: 'Amiri Regular', 'Amiri', serif !important;
    font-size: 1.1rem;
    line-height: 2;
}

/* Quran references - KFGQPC Uthmanic Script HAFS */
.ref-full.ref-quran {
    font-family: 'KFGQPC Uthmanic Script HAFS', 'Amiri', serif !important;
    font-size: 1.2rem;
    line-height: 2.2;
}

/* Tags Section */
.tags-section {
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.tags-label {
    font-weight: 600;
    color: var(--primary);
    font-size: 1rem;
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.tag {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 0.5rem 1.2rem;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 2px 6px rgba(45, 80, 22, 0.2);
    transition: all 0.2s ease;
}

.tag:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(45, 80, 22, 0.3);
}

/* Paragraph Numbers */
.para-number {
    font-family: 'Jameel Noori', serif;
    font-weight: 700;
    color: var(--primary);
    margin-left: 0.5rem;
}

/* Reference Links - Inline references from database */
.answer-paragraph sup {
    font-size: 0.85em;
    line-height: 1;
    vertical-align: super;
}

.ref-link {
    color: var(--primary);
    text-decoration: none;
    cursor: pointer;
    font-weight: 600;
    transition: color 0.2s ease;
}

/* Hadith references - Amiri Regular */
.ref-link.ref-hadith,
.answer-paragraph sup .ref-link.ref-hadith {
    font-family: 'Amiri Regular', 'Amiri', serif !important;
    font-size: 0.9em;
}

/* Quran references - KFGQPC Uthmanic Script HAFS */
.ref-link.ref-quran,
.answer-paragraph sup .ref-link.ref-quran {
    font-family: 'KFGQPC Uthmanic Script HAFS', 'Amiri', serif !important;
    font-size: 0.95em;
}

/* Arabic verses within answer paragraphs */
/* These classes are used to tag Arabic verses embedded in Urdu (Nastaleeq) text */
.arabic-verse {
    display: inline;
    /* Ensure verses blend seamlessly with surrounding text */
    vertical-align: baseline;
}

/* Hadith verses - Amiri Regular */
/* Applied to Arabic Hadith text embedded in paragraphs */
.arabic-verse-hadith {
    font-family: 'Amiri Regular', 'Amiri', serif !important;
    font-size: 1.1em;
    line-height: 1.8;
    /* Match line height with surrounding Nastaleeq text for seamless integration */
    vertical-align: baseline;
}

/* Quran verses - KFGQPC Uthmanic Script HAFS */
/* Applied to Arabic Quranic text embedded in paragraphs */
.arabic-verse-quran {
    font-family: 'KFGQPC Uthmanic Script HAFS', 'Amiri', serif !important;
    font-size: 1.15em;
    line-height: 2;
    /* Slightly larger for Quranic verses to maintain readability */
    vertical-align: baseline;
}

.ref-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Reference Popup */
.apke-masail-ref-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6) !important;
    z-index: 10000;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    backdrop-filter: blur(2px);
}

.apke-masail-ref-popup-content {
    background: #ffffff !important;
    background-color: #ffffff !important;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4) !important;
    border: 2px solid var(--primary);
    margin: auto;
    padding: 0;
    opacity: 1 !important;
}

.apke-masail-ref-popup-close {
    position: absolute;
    top: 1rem;
    left: 1rem;
    font-size: 2rem;
    color: var(--primary);
    cursor: pointer;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid var(--primary);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    z-index: 10001;
    font-weight: bold;
    line-height: 1;
}

.apke-masail-ref-popup-close:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.1);
}

.apke-masail-ref-popup-body {
    padding: 3rem 2rem 2rem 2rem;
    line-height: 2;
    font-size: 1.1rem;
    color: var(--text-primary);
    text-align: right;
    background: #ffffff !important;
    background-color: #ffffff !important;
    margin: 0;
    border-radius: 0;
    font-family: 'Amiri Regular', 'Amiri', serif !important; /* Default to Amiri */
    opacity: 1 !important;
}

/* Hadith references in popup - Amiri Regular */
.apke-masail-ref-popup-body.ref-popup-hadith {
    font-family: 'Amiri Regular', 'Amiri', serif !important;
    font-size: 1.2rem;
    line-height: 2.2;
}

/* Quran references in popup - KFGQPC Uthmanic Script HAFS */
.apke-masail-ref-popup-body.ref-popup-quran {
    font-family: 'KFGQPC Uthmanic Script HAFS', 'Amiri', serif !important;
    font-size: 1.3rem;
    line-height: 2.4;
}

/* Footer */
.footer {
    background: var(--primary-dark);
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
}

/* Responsive */
@media (max-width: 768px) {
    .logo {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .nav {
        gap: 0.5rem;
    }
    
    .nav-btn {
        padding: 0.6rem 1.5rem;
        font-size: 1rem;
    }
    
    .search-box {
        flex-direction: column;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .results-header {
        flex-direction: column;
        align-items: start;
        gap: 0.5rem;
    }
    
    .fatwa-detail-container {
        padding: 1.5rem 1rem;
        border-radius: 8px;
    }
    
    .back-button {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
        margin-bottom: 1.5rem;
    }
    
    .fatwa-main-title {
        font-size: 1.6rem;
    }
    
    .fatwa-metadata {
        flex-direction: column;
        gap: 1rem;
    }
    
    .question-section,
    .answer-section {
        padding: 1.5rem;
    }
    
    .references-section {
        margin-right: -1rem;
        margin-left: -1rem;
        padding: 1.5rem;
    }
    
    .search-section {
        padding: 1.5rem;
    }
    
    .results-section {
        padding: 1.5rem;
    }
}
