/*
 * =========================================
 * style.css (نسخه کامل، مرتب‌شده و بهینه‌سازی شده)
 * =========================================
 */

/* --- بخش ۰: ایمپورت فونت‌ها و متغیرهای اصلی (Root) --- */
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Amiri+Quran&display=swap');

:root {
    /* پالت رنگی اصلی */
    --bg-dark: #0f172a;           /* Slate 900 */
    --bg-medium: #1e293b;         /* Slate 800 */
    --bg-light: #334155;          /* Slate 700 */
    --text-light: #f1f5f9;         /* Slate 100 */
    --text-medium: #94a3b8;        /* Slate 400 */
    --accent-amber: #f59e0b;
    --accent-cyan: #06b6d4;
    --accent-cyan-dark: #0e7490;
    --accent-cyan-darker: #075985;
    --accent-green: #16a34a;
    --accent-blue: #2563eb;
    --accent-blue-dark: #1d4ed8;
    
    /* فونت‌ها */
    --font-ui: 'Vazirmatn', sans-serif;
    --font-quran: 'Amiri Quran', 'Uthmanic Taha', 'Noto Naskh Arabic', serif;
}


/* --- بخش ۱: تنظیمات کلی بدنه، اسکرول‌بار و ساختار اصلی --- */
body {
    margin: 0;
    font-family: var(--font-ui);
    background-color: var(--bg-dark);
    color: var(--text-light);
    direction: rtl;
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    transition: background-image 0.5s;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* ⭐️ تغییر: افزودن این دو خط برای مرکزیت صفحه ورود */
    justify-content: center;
    align-items: center;
    /* overflow-y: hidden; */
}

.hidden {
    display: none !important; /* ⭐️ اضافه کردن !important برای غلبه بر تداخلات احتمالی flex/grid */
}
/* ⭐️ جدید: اطمینان از اینکه کانتینر لاگین، کل صفحه را بپوشاند ⭐️ */
#login-screen {
    position: fixed; /* یا absolute */
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    z-index: 100; /* اطمینان از قرارگیری در بالاترین لایه */
    display: flex; /* باید ثابت باشد تا محتوای داخلی را مرکز کند */
    align-items: center;
    justify-content: center;
    background-color: var(--bg-dark); /* برای پوشاندن کامل محتوای پشت */
}

/* ⭐️ جدید: در حالت عادی، app-container نباید دیده شود ⭐️ */
#app-container {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto; 
    z-index: 10;
}
/* ⭐️ جدید: این قانون باعث می‌شود کانتینر اصلی برنامه، تمام عرض و ارتفاع را بگیرد و محتوای آن به هم نریزد */
#app-container {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

::-webkit-scrollbar {
    width: 12px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
    background-color: var(--bg-light);
    border-radius: 10px;
    border: 3px solid var(--bg-dark);
}
::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-medium);
}

header {
    background-color: var(--bg-medium);
    color: var(--text-light);
    padding: 20px 15px;
    text-align: center;
    font-size: 1.8rem;
    font-weight: 800;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    border-bottom: 1px solid var(--bg-light);
}

footer {
    background-color: var(--bg-medium);
    color: var(--text-medium);
    padding: 15px;
    text-align: center;
    font-size: 1rem;
    margin-top: auto;
    border-top: 1px solid var(--bg-light);
}

.main-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 15px;
}

.view {
    background-color: var(--bg-medium);
    padding: 30px 40px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    width: 100%;
    max-width: 1000px; 
    text-align: center;
    border: 1px solid var(--bg-light);
}

.view.hidden {
    display: none;
}


/* --- بخش ۲: کامپوننت‌های مشترک (دکمه‌ها، لیست‌ها، عناوین) --- */

/* دکمه‌های عمومی */
.btn-control {
    padding: 12px 25px;
    border-radius: 10px;
    font-size: 1.2rem;
    color: white !important; /* اطمینان از سفید بودن متن در همه حال */
    border: none;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    font-family: var(--font-ui);
    font-weight: bold;
}
.btn-control:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.back-button {
    background-color: var(--bg-light);
    color: white;
    padding: 15px 30px;
    border-radius: 10px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
    width: 100%;
    box-shadow: 0 3px #1e293b;
}
.back-button:hover {
    background-color: #475569;
}

/* لیست‌ها */
.list-container {
    text-align: right;
    padding: 10px;
}

.list-title {
    font-size: 2.5rem;
    color: var(--accent-amber);
    border-bottom: 2px solid var(--bg-light);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.list-box {
    max-height: 500px;
    overflow-y: auto;
    padding-left: 10px; 
}

.surah-item {
    padding: 18px;
    border-bottom: 1px solid var(--bg-light);
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s, border-right-color 0.2s;
    border-right: 6px solid transparent;
    display: flex;
    align-items: center;
    font-size: 1.2rem;
}
.surah-item:hover {
    background-color: #273447;
    border-right-color: var(--accent-amber);
    transform: translateX(5px);
}
.surah-item:focus {
    outline: none;
    background-color: var(--bg-light);
}


/* --- بخش ۳: صفحه منوی اصلی --- */
.banner-image {
    max-width: 100%;
    height: auto;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 8px 15px rgba(0,0,0,0.3);
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.menu-btn {
    background-color: var(--accent-cyan-dark);
    color: white;
    padding: 25px;
    border: none;
    border-radius: 15px;
    font-size: 1.4rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 5px var(--accent-cyan-darker);
    display: flex;
    align-items: center;
    justify-content: center;
}
.menu-btn:hover {
    background-color: var(--accent-cyan);
    transform: translateY(-3px);
    box-shadow: 0 8px var(--accent-cyan-darker);
}
.menu-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px var(--accent-cyan-darker);
}


/* --- بخش ۴: صفحه پخش قرآن --- */
.player-header {
    border-bottom: 2px solid var(--bg-light);
    padding-bottom: 15px;
    margin-bottom: 20px;
}
.player-header h1 {
    color: var(--accent-amber);
}

.ayah-container {
    max-height: 500px;
    overflow-y: auto;
    padding-left: 10px;
    margin-top: 20px;
}

.ayah-item {
    margin-bottom: 25px;
    padding: 20px;
    border-radius: 12px;
    border-right: 5px solid transparent;
    background-color: var(--bg-medium);
    transition: all 0.3s ease-out;
}
.ayah-item:hover {
    background-color: var(--bg-light);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.2);
}
.ayah-item.playing-ayah {
    background-color: #2b3a4f;
    border-right-color: #fca311;
    transform: scale(1.01);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}
.ayah-item.playing-ayah .ayah-arabic {
    color: #fff;
}
.ayah-item.playing-ayah .ayah-translation {
    color: #bae6fd;
}

.quran-text {
    font-family: var(--font-quran);
    font-size: 2.2rem;
    line-height: 2.5;
    color: #ffffff;
}
.ayah-arabic {
    margin-bottom: 10px;
}

.ayah-translation {
    font-size: 1.2rem;
    color: var(--text-medium);
    border-top: 1px dashed var(--bg-light);
    padding-top: 10px;
}

.ayah-number {
    font-size: 1.2rem;
    color: #fca311;
    margin-right: 10px;
}

.quran-word {
    transition: color 0.2s ease-out, background-color 0.2s ease-out;
    display: inline-block;
}
.quran-word.highlighted-word {
    color: #fca311;
    background-color: rgba(252, 163, 17, 0.1);
    transition: color 0.1s ease-in-out, background-color 0.1s ease-in-out;
    border-radius: 3px;
    padding: 0 2px;
}

/* استایل تگ‌های تجویدی */
.quran-text .madd  { color: #ff8b8b; }
.quran-text .kasrah{ color: #a0c4ff; }
.quran-text .hamza { color: #9bf6ff; }


/* --- بخش ۵: نمایشگرهای تعاملی (Drill Viewers) --- */

/* الف) استایل‌های مشترک نمایشگرها */
.rokhani-viewer, .amali-viewer, .ahkam-viewer { /* نام کلاس فرضی برای یکپارچگی */
    background-color: var(--bg-dark);
    border: 1px solid var(--bg-light);
    box-shadow: inset 0 0 30px rgba(0,0,0,0.5);
    border-radius: 20px;
    padding: 30px;
}

.drill-step-title { /* نام کلاس عمومی برای عناوین */
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--accent-amber);
    margin-bottom: 5px;
}
#rokhani-step-title {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--accent-amber);
    margin-bottom: 5px;
}


.drill-step-counter { /* نام کلاس عمومی برای شمارنده */
    font-size: 1.3rem;
    color: var(--text-medium);
    margin-bottom: 25px;
}
#rokhani-step-counter {
    font-size: 1.3rem;
    color: var(--text-medium);
    margin-bottom: 25px;
}


.drill-nav-container { /* نام کلاس عمومی برای دکمه‌های ناوبری */
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

.rokhani-nav-container {
    display: flex;
    justify-content: space-between;
    gap: 15px;
}


/* دکمه‌های ناوبری (بعدی و قبلی) */
#rokhani-next-btn, #amali-next-btn, #ahkam-next-btn {
    background-color: var(--accent-green);
    box-shadow: 0 4px #0d6b30;
    flex-grow: 1;
}
#rokhani-next-btn:hover, #amali-next-btn:hover, #ahkam-next-btn:hover {
    background-color: #15803d;
}

#rokhani-next-btn.is-last, #amali-next-btn.is-last, #ahkam-next-btn.is-last {
    background-color: var(--accent-blue);
    box-shadow: 0 4px var(--accent-blue-dark);
}
#rokhani-next-btn.is-last:hover, #amali-next-btn.is-last:hover, #ahkam-next-btn.is-last:hover {
    background-color: var(--accent-blue-dark);
}

#rokhani-prev-btn, #amali-prev-btn, #ahkam-prev-btn {
    background-color: var(--bg-light);
    box-shadow: 0 4px var(--bg-medium);
    flex-grow: 1;
}
#rokhani-prev-btn:hover, #amali-prev-btn:hover, #ahkam-prev-btn:hover {
    background-color: #475569;
}

#rokhani-prev-btn:disabled, #amali-prev-btn:disabled, #ahkam-prev-btn:disabled {
    background-color: #2a3344;
    box-shadow: none;
    color: #5a6982;
    opacity: 1;
    cursor: not-allowed;
}

/* ب) نمایشگر روخوانی */
#rokhani-flashcard {
    width: 100%;
    min-height: 350px;
    background-color: #000;
    border-radius: 15px;
    box-shadow: 0 0 30px rgba(0,0,0,0.7);
    border: 2px solid var(--bg-light);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    margin-bottom: 30px;
}

#rokhani-flashcard-arabic {
    font-family: var(--font-quran);
    font-size: 10rem;
    font-weight: 800;
    color: var(--text-light);
    line-height: 1;
    margin: 0;
    padding: 0;
    text-shadow: 0 5px 25px rgba(255, 255, 255, 0.1);
    text-align: center;
}

#rokhani-flashcard-pronun {
    font-size: 2.5rem;
    color: var(--accent-cyan);
    margin-top: 15px;
}

#rokhani-play-btn {
    width: 7rem;
    height: 7rem;
    border-radius: 50%;
    background-color: var(--accent-cyan);
    color: white;
    font-size: 3rem;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 30px;
    box-shadow: 0 8px 25px rgba(6, 182, 212, 0.3);
    transition: all 0.2s ease-out;
    animation: pulse 2s infinite;
}
#rokhani-play-btn:hover {
    background-color: #0891b2;
    transform: scale(1.05);
    animation-play-state: paused;
}
#rokhani-play-btn:active {
    transform: scale(0.95);
}

@keyframes pulse {
    0%   { transform: scale(1); box-shadow: 0 0 0 0 rgba(6, 182, 212, 0.4); }
    70%  { transform: scale(1); box-shadow: 0 0 0 20px rgba(6, 182, 212, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(6, 182, 212, 0); }
}

/* ج) نمایشگر احکام عملی */
.salat-word, .highlighted-word {
    transition: background-color 0.2s, color 0.2s;
    padding: 2px 4px;
    border-radius: 4px;
}
.highlighted-word {
    background-color: var(--accent-cyan);
    color: var(--bg-medium); 
}

.amali-image-container {
    height: 400px;
    width: 100%;
    background-color: #000;
    padding: 1rem;
    border-radius: 1rem;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.amali-image-content {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.amali-dhikr-arabic { font-size: 6rem; font-weight: 800; color: var(--text-light); line-height: 1.3; padding: 0.5rem; }
.amali-dhikr-translation { font-size: 2.25rem; color: var(--accent-cyan); margin-top: 1rem; }

.amali-qiraat-image { width: 100%; max-width: 24rem; height: auto; border-radius: 0.5rem; box-shadow: 0 4px 6px rgba(0,0,0,0.1); margin-bottom: 1rem; }
.amali-qiraat-arabic { font-size: 4.5rem; font-weight: 600; color: var(--text-light); line-height: 1.6; margin-bottom: 1rem; }
.amali-qiraat-translation { font-size: 1.875rem; font-style: italic; color: var(--text-medium); margin-top: 0.5rem; }

.qiraat-item .btn-control {
    background-color: var(--accent-cyan-dark); 
    box-shadow: 0 4px var(--accent-cyan-darker);
    padding: 0.5rem 1.25rem; 
    font-size: 1rem;
    font-weight: bold;
    width: auto;
}
.qiraat-item .btn-control:hover { background-color: var(--accent-cyan); }

/* د) نمایشگر احکام نظری */
#ahkam-flashcard-container p.font-bold { font-size: 2.75rem; line-height: 1.5; }
#ahkam-flashcard-container .prose { font-size: 2.125rem !important; line-height: 1.9 !important; }
#ahkam-flashcard-container .prose p { margin-top: 0.75em !important; margin-bottom: 0.75em !important; }
#ahkam-flashcard-container .text-sm { font-size: 1.125rem; }

.ahkam-topic-content-box {
    background-color: var(--bg-dark);
    padding: 30px;
    border-radius: 15px;
    min-height: 350px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
    border: 1px solid var(--bg-light);
    text-align: right;
    font-size: 1.25rem;
    line-height: 1.8;
}


/* --- بخش ۶: استایل‌های ریسپانسیو --- */
@media (max-width: 900px) {
    .view {
        max-width: 95%;
        padding: 20px;
    }
    #rokhani-flashcard-arabic { font-size: 8rem; }
    #rokhani-flashcard-pronun { font-size: 2rem; }
}

@media (max-width: 600px) {
    body { flex-direction: column; }
    header { font-size: 1.3rem; padding: 10px; }
    .main-container { padding: 10px; }
    .view { padding: 15px; }
    .list-title { font-size: 2rem; }
    .ayah-arabic { font-size: 2.2rem; line-height: 2.2; }
    .button-grid { grid-template-columns: 1fr; }

    /* روخوانی در موبایل */
    #rokhani-flashcard { min-height: 250px; }
    #rokhani-flashcard-arabic { font-size: 5.5rem; }
    #rokhani-flashcard-pronun { font-size: 1.5rem; }
    #rokhani-play-btn { width: 5.5rem; height: 5.5rem; font-size: 2rem; }
    .rokhani-nav-container { flex-direction: column-reverse; }
}

/* --- بخش ۷: استایل‌های گیمیفیکیشن (کارنامه و جدول امتیازات) --- */

/* استایل کارنامه (Profile View) */
.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding-bottom: 20px;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--bg-light);
}

.profile-avatar {
    font-size: 4rem;
    color: var(--accent-cyan);
}

.profile-username {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-light);
}

.profile-total-points {
    background-color: var(--accent-amber);
    color: var(--bg-dark);
    padding: 10px 25px;
    border-radius: 50px;
    font-size: 1.5rem;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.3);
}

.badges-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.badge-item {
    background-color: var(--bg-dark);
    border: 1px solid var(--bg-light);
    border-radius: 15px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.2s;
}

.badge-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
    border-color: var(--accent-amber);
}

.badge-item img {
    width: 70px;
    height: 70px;
}

.badge-info h4 {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-light);
    margin: 0 0 5px;
}

.badge-info p {
    font-size: 1rem;
    color: var(--text-medium);
    margin: 0;
}

/* استایل جدول امتیازات (Leaderboard) */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    font-size: 1.2rem;
}

.leaderboard-table th, .leaderboard-table td {
    padding: 15px;
    text-align: right;
    border-bottom: 1px solid var(--bg-light);
}

.leaderboard-table th {
    color: var(--accent-amber);
    font-weight: bold;
    font-size: 1.3rem;
}

.leaderboard-table tr:nth-child(even) {
    background-color: var(--bg-dark);
}

.leaderboard-table .rank {
    font-weight: 800;
    font-size: 1.5rem;
    text-align: center;
    color: var(--accent-cyan);
}

.leaderboard-table .rank-1, .leaderboard-table .rank-2, .leaderboard-table .rank-3 {
    color: var(--accent-amber);
    text-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}