/* --- CSS VARIABLES --- */
:root {
    --primary: #2E7D32;
    --primary-dark: #1B5E20;
    --accent: #C9A227;
    --bg-body: #F3F4F6;
    --bg-card: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --text-main: #1F2937;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --radius: 12px;
    --font-ar: 'Amiri', serif;
    --font-en: 'Inter', sans-serif;
    --whatsapp-green: #25D366;
}

[data-theme="dark"] {
    --primary: #4ADE80;
    --primary-dark: #22c55e;
    --accent: #FACC15;
    --bg-body: #111827;
    --bg-card: #1F2937;
    --bg-sidebar: #1F2937;
    --text-main: #F9FAFB;
    --text-muted: #9CA3AF;
    --border: #374151;
}

* { box-sizing: border-box; margin: 0; padding: 0; outline: none; -webkit-tap-highlight-color: transparent; }

body {
    font-family: var(--font-en);
    background-color: var(--bg-body);
    color: var(--text-main);
    height: 100dvh;
    overflow: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* --- LAYOUT STRUCTURE --- */
.app-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: 100dvh;
    position: relative;
}

/* --- SIDEBAR --- */
.sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 50;
    height: 100%;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.brand-header {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.logo-area { display: flex; align-items: center; gap: 0.75rem; font-weight: 700; font-size: 1.1rem; }
.logo-img { height: 32px; width: 32px; border-radius: 50%; object-fit: cover; }

.search-wrapper { padding: 1rem; position: relative; flex-shrink: 0; }
.search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-body);
    color: var(--text-main);
    font-family: inherit;
}
.search-icon { position: absolute; left: 1.8rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

.surah-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    padding: 0 0.5rem 0.5rem;
    -webkit-overflow-scrolling: touch;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-sidebar);
    text-align: center;
    flex-shrink: 0;
}

.whatsapp-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem;
    background-color: var(--whatsapp-green);
    color: white;
    text-decoration: none;
    font-weight: 600;
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    transition: transform 0.2s;
    box-shadow: 0 4px 6px rgba(37, 211, 102, 0.2);
}
.whatsapp-btn:hover { transform: translateY(-2px); }
.copyright { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }

.surah-item {
    display: flex;
    align-items: center;
    padding: 0.85rem;
    margin-bottom: 0.25rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
    border: 1px solid transparent;
}

.surah-item:hover { background-color: var(--bg-body); }
.surah-item.active {
    background-color: rgba(46, 125, 50, 0.1);
    border-color: var(--primary);
}
[data-theme="dark"] .surah-item.active { background-color: rgba(74, 222, 128, 0.1); }

.surah-badge {
    width: 32px; height: 32px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 0.8rem;
    font-weight: 600;
    margin-right: 0.75rem;
    color: var(--primary);
    flex-shrink: 0;
}
.surah-info { flex: 1; overflow: hidden; }
.surah-eng { font-weight: 600; font-size: 0.9rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.surah-meaning { font-size: 0.75rem; color: var(--text-muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.surah-ara { font-family: var(--font-ar); font-size: 1.2rem; color: var(--primary-dark); flex-shrink: 0; }
[data-theme="dark"] .surah-ara { color: var(--primary); }

/* --- MAIN CONTENT --- */
.main-content {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
    position: relative;
    background-image: url('https://www.transparenttextures.com/patterns/arabesque.png');
    background-blend-mode: soft-light;
}

/* Top Bar */
.top-bar {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 40;
    flex-shrink: 0;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}
[data-theme="dark"] .top-bar { background: rgba(31, 41, 55, 0.9); }

.top-header-row { display: flex; justify-content: space-between; align-items: center; }
.current-surah-title h1 { font-size: 1.25rem; font-weight: 700; color: var(--primary); margin: 0; }
.current-surah-title p { font-size: 0.8rem; color: var(--text-muted); margin: 0; }
.mobile-menu-btn { display: none; background: none; border: none; font-size: 1.25rem; color: var(--text-main); cursor: pointer; padding: 0.5rem; }

.controls-row { display: flex; gap: 0.5rem; align-items: center; }

.player-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    background: var(--bg-body);
    padding: 0.4rem 0.75rem;
    border-radius: 50px;
    border: 1px solid var(--border);
}

.play-btn {
    background: var(--primary);
    color: white;
    border: none;
    width: 36px; height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.progress-wrapper { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.progress-range { width: 100%; cursor: pointer; accent-color: var(--primary); height: 4px; margin: 0; }
.time-labels { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }

.styled-select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.5rem;
    border-radius: 8px;
    color: var(--text-main);
    font-size: 0.85rem;
    max-width: 120px;
}

/* --- SCROLLING CONTAINER --- */
.quran-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1.5rem 6rem 1.5rem;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.bismillah {
    text-align: center;
    font-family: var(--font-ar);
    font-size: 2rem;
    color: var(--text-main);
    margin-bottom: 2rem;
    margin-top: 0.5rem;
}

.ayah-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
}
.ayah-card.playing { 
    border-color: var(--primary); 
    box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.2); 
    background-color: rgba(46, 125, 50, 0.02);
}

.ayah-header { display: flex; justify-content: space-between; margin-bottom: 0.75rem; }
.ayah-num { 
    background: var(--bg-body); color: var(--text-muted); 
    padding: 0.2rem 0.6rem; border-radius: 20px; font-size: 0.75rem; font-weight: 600; 
}

.arabic-text {
    font-family: var(--font-ar);
    font-size: 2.2rem;
    text-align: right;
    direction: rtl;
    line-height: 2.0;
    color: var(--text-main);
    margin-bottom: 0.75rem;
}
.translation-text { font-size: 1rem; color: var(--text-muted); line-height: 1.6; }

.skeleton { background: linear-gradient(90deg, var(--bg-card) 25%, var(--border) 50%, var(--bg-card) 75%); background-size: 200% 100%; animation: loading 1.5s infinite; border-radius: 4px; }
@keyframes loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* --- RESPONSIVE MOBILE --- */
@media (max-width: 992px) {
    .app-layout { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; top: 0; left: 0; bottom: 0; width: 85%; max-width: 320px;
        transform: translateX(-100%); box-shadow: 5px 0 25px rgba(0,0,0,0.2);
    }
    .sidebar.open { transform: translateX(0); }
    .mobile-menu-btn { display: block; }
    
    .quran-container { padding: 1rem 1rem 8rem 1rem; }
    .arabic-text { font-size: 1.8rem; line-height: 1.9; }
    .top-bar { gap: 0.5rem; padding: 0.75rem; }
}

.overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6); z-index: 45;
    display: none;
    backdrop-filter: blur(2px);
}

/* ===== PWA INSTALL POPUP CSS ===== */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
    padding: 20px;
    box-sizing: border-box;
    z-index: 350;
}
.popup-content {
    background: var(--bg-card);
    border-radius: 24px;
    padding: 30px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    position: relative;
    width: 100%;
    max-width: 400px;
    animation: slideUp 0.3s ease;
    color: var(--text-main);
}
.popup-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--bg-body);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-main);
    font-size: 1em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}
.popup-close-btn:hover {
    background: var(--border);
    transform: rotate(90deg);
}
/* Utility classes for popup */
.max-w-sm { max-width: 24rem; }
.text-center { text-align: center; }
.w-20 { width: 5rem; }
.h-20 { height: 5rem; }
.rounded-2xl { border-radius: 1rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05); }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.w-full { width: 100%; }
.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.font-bold { font-weight: 700; }
.text-gray-500 { color: #6b7280; }
.btn-premium {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1em;
    font-family: var(--font-en);
    letter-spacing: 0.5px;
    color: #fff;
    background: var(--primary);
    box-shadow: 0 8px 15px rgba(46, 125, 50, 0.3);
    transition: all 0.3s ease;
    margin-bottom: 12px;
}
.btn-premium:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 20px rgba(46, 125, 50, 0.4);
    background: var(--primary-dark);
}
.not-now-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    text-decoration: underline;
    transition: all 0.3s ease;
    padding: 5px 10px;
    font-family: var(--font-en);
}
.not-now-btn:hover {
    color: var(--text-main);
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}