/* =========================================
   GLOBAL VARIABLES & RESET h
   ========================================= */
:root {
    --primary: #0F595E;
    --primary-dark: #0a3d40;
    --secondary: #D4AF37;
    --bg-color: #F8F9FA;
    --surface: #FFFFFF;
    --text-main: #2D3748;
    --text-muted: #718096;
    --border: #E2E8F0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --radius: 12px;
    --font-urdu: 'Noto Nastaliq Urdu', serif;
    --font-latin: 'Poppins', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-latin);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Urdu Specific Overrides (Only line-height, NOT huge sizes) */
body[dir="rtl"] {
    font-family: var(--font-urdu);
    line-height: 1.8; 
}

a {
    text-decoration: none;
    color: inherit;
}

/* =========================================
   HEADER (3-Column Grid Layout)
   ========================================= */
.main-header {
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr; /* Left, Center(Logo), Right */
    align-items: center;
    padding: 10px 15px;
    max-width: 1200px;
    margin: 0 auto;
}

.header-left {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.header-center {
    display: flex;
    justify-content: center;
}

.header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

/* Logo */
.logo-text {
    font-size: clamp(1.2rem, 4vw, 1.8rem); /* Fluid size */
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    line-height: 1.2;
}
body[dir="rtl"] .logo-text {
    font-size: clamp(1.3rem, 4vw, 2rem);
    padding-top: 5px; /* Slight adjustment for Nastaliq */
}

/* Desktop Nav */
.desktop-nav {
    display: none;
    gap: 20px;
}
.desktop-nav a {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-main);
    transition: color 0.3s;
}
.desktop-nav a:hover {
    color: var(--primary);
}

/* Mobile Menu Toggle */
.menu-toggle {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--primary);
    cursor: pointer;
    padding: 5px;
}

/* Language Selector */
.lang-selector {
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--bg-color);
    padding: 5px 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
}
.lang-selector i {
    color: var(--primary);
    font-size: 0.9rem;
}
.lang-selector select {
    background: transparent;
    border: none;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    outline: none;
}

/* Mobile Sidebar */
.mobile-sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 250px;
    height: 100vh;
    background: var(--surface);
    z-index: 2000;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
}
body[dir="rtl"] .mobile-sidebar {
    left: auto;
    right: -100%;
    transition: right 0.3s ease;
}
.mobile-sidebar.active {
    left: 0;
}
body[dir="rtl"] .mobile-sidebar.active {
    right: 0;
}
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    color: var(--primary);
}
.sidebar-header button {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
}
.sidebar-links {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.sidebar-links a {
    padding: 10px;
    border-radius: 8px;
    font-weight: 500;
    transition: background 0.2s;
}
.sidebar-links a:hover {
    background: var(--bg-color);
    color: var(--primary);
}
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1500;
    display: none;
}
.overlay.active {
    display: block;
}

/* =========================================
   HERO SECTION & CAROUSEL
   ========================================= */
.hero-section {
    position: relative;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    padding: 40px 15px 80px;
    text-align: center;
}

.hero-pattern {
    position: absolute;
    inset: 0;
    background-image: url('data:image/svg+xml;utf8,<svg width="60" height="60" xmlns="http://www.w3.org/2000/svg"><path d="M30 0 L60 30 L30 60 L0 30 Z" fill="none" stroke="rgba(255,255,255,0.05)" stroke-width="1"/></svg>');
    z-index: 1;
}

.carousel-container {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
    z-index: 2;
    min-height: 100px; /* Prevents jumping */
}

.carousel-slide {
    display: none;
    animation: fadeIn 0.5s ease;
}
.carousel-slide.active {
    display: block;
}

.carousel-slide h2 {
    color: #fff;
    font-size: clamp(1.4rem, 5vw, 2.5rem);
    font-weight: 600;
    margin-bottom: 10px;
}
body[dir="rtl"] .carousel-slide h2 {
    line-height: 1.8;
}

.carousel-slide p {
    color: rgba(255,255,255,0.85);
    font-size: clamp(0.9rem, 3vw, 1.1rem);
}

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

/* Search Box */
.search-wrapper {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    width: 92%;
    max-width: 600px;
    z-index: 10;
}
.search-form {
    display: flex;
    background: #fff;
    border-radius: 50px;
    padding: 5px;
    box-shadow: var(--shadow-lg);
}
.search-form input {
    flex: 1;
    border: none;
    padding: 12px 20px;
    font-family: inherit;
    font-size: 0.95rem;
    border-radius: 50px;
    outline: none;
}
.search-form button {
    background: var(--secondary);
    color: var(--primary-dark);
    border: none;
    padding: 12px 20px;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: 0.2s;
}
.search-form button:hover {
    background: #c5a130;
}

/* =========================================
   MAIN CONTENT & GRIDS
   ========================================= */
.main-container {
    max-width: 1200px;
    margin: 60px auto 40px;
    padding: 0 15px;
}

.section-header {
    text-align: center;
    margin: 30px 0 20px;
}

.section-title {
    font-size: clamp(1.2rem, 4vw, 1.6rem);
    color: var(--primary);
    font-weight: 700;
}
body[dir="rtl"] .section-title {
    padding-top: 10px;
}

.section-line {
    width: 50px;
    height: 3px;
    background: var(--secondary);
    margin: 8px auto 0;
    border-radius: 2px;
}

/* Category Grid (2 cols on mobile, 4 on desktop) */
.category-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.category-card {
    background: var(--surface);
    padding: 15px 10px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid transparent;
}
.category-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-icon {
    width: 45px;
    height: 45px;
    background: rgba(15, 89, 94, 0.08);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.category-card h3 {
    font-size: clamp(0.9rem, 3vw, 1.1rem);
    color: var(--text-main);
    font-weight: 600;
}

/* Fatwa List (1 col mobile, 2 col desktop) */
.fatwa-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

.fatwa-card {
    background: var(--surface);
    padding: 15px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--primary);
    transition: 0.3s;
    display: flex;
    flex-direction: column;
}
body[dir="rtl"] .fatwa-card {
    border-left: none;
    border-right: 4px solid var(--primary);
}
.fatwa-card:hover {
    box-shadow: var(--shadow-md);
}

.fatwa-badge {
    background: rgba(212, 175, 55, 0.15);
    color: #96760e;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    width: fit-content;
    margin-bottom: 8px;
}

.fatwa-title {
    font-size: clamp(1rem, 3vw, 1.15rem);
    color: var(--text-main);
    margin-bottom: 10px;
    font-weight: 600;
}

.fatwa-readmore {
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: auto;
}
body[dir="rtl"] .fatwa-readmore i {
    transform: rotate(180deg);
}

/* CTA Section */
.cta-section {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius);
    padding: 25px 20px;
    margin-top: 40px;
    text-align: center;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow-md);
}
.cta-section h2 {
    font-size: clamp(1.2rem, 4vw, 1.5rem);
    margin-bottom: 5px;
}
.cta-section p {
    font-size: 0.9rem;
    opacity: 0.9;
}
.cta-btn {
    background: var(--secondary);
    color: var(--primary-dark);
    padding: 10px 25px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.95rem;
    transition: 0.2s;
}
.cta-btn:hover {
    background: #fff;
    color: var(--primary);
}

/* =========================================
   FOOTER
   ========================================= */
.site-footer {
    background: #1a202c;
    color: #a0aec0;
    margin-top: 50px;
    padding: 30px 15px 0;
}
.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 25px;
    padding-bottom: 20px;
}
.footer-about h3 {
    color: #fff;
    font-size: 1.2rem;
    margin-bottom: 8px;
}
.footer-links h4 {
    color: #fff;
    font-size: 1rem;
    margin-bottom: 10px;
}
.footer-links a {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 8px;
    transition: color 0.2s;
}
.footer-links a:hover {
    color: var(--secondary);
}
.footer-bottom {
    text-align: center;
    padding: 15px 0;
    border-top: 1px solid #2d3748;
    font-size: 0.8rem;
}

/* =========================================
   MEDIA QUERIES (Tablet & Desktop Only)
   ========================================= */
@media (min-width: 768px) {
    .header-container {
        padding: 15px 30px;
    }
    .menu-toggle {
        display: none;
    }
    .desktop-nav {
        display: flex;
    }
    .hero-section {
        padding: 60px 20px 90px;
    }
    .main-container {
        padding: 0 30px;
    }
    .category-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }
    .fatwa-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    .cta-section {
        flex-direction: row;
        justify-content: space-between;
        text-align: left;
        padding: 35px 40px;
    }
    body[dir="rtl"] .cta-section {
        text-align: right;
    }
    .footer-container {
        flex-direction: row;
        justify-content: space-between;
    }
}