@font-face {
    font-family: 'Vazir';
    src: url('fonts/Vazir.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap; /* لود فوری صفحه قبل از پردازش فونت */
}

:root {
    --bg-main: #F8F6F0; --surface: #FFFFFF;
    --green-dark: #37533C; --green-light: #4A6E50;
    --gold: #A4895C; --text-main: #1A1A1A;
    --text-muted: #737373; --border: #E5E0D8;
    --radius-lg: 24px; --radius-md: 16px; --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; font-family: 'Vazir', sans-serif; }
body { background-color: var(--bg-main); color: var(--text-main); padding-bottom: 120px; overflow-x: hidden; }
button { background: none; border: none; cursor: pointer; outline: none; color: inherit; }

/* Views Routing */
.view { display: none; padding: 1.5rem; animation: fadeIn 0.2s ease; }
.view.active { display: block; }
.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* Typography */
h1 { font-size: 1.4rem; color: var(--text-main); font-weight: 800; }
h3 { font-size: 1.1rem; color: var(--text-main); }
p { font-size: 0.85rem; color: var(--text-muted); }

/* Header & Search */
.top-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--surface); display: flex; justify-content: center; align-items: center; box-shadow: 0 2px 8px rgba(0,0,0,0.03); color: var(--text-muted); }
.icon-btn svg { width: 20px; height: 20px; }
.search-bar { display: flex; align-items: center; background: var(--surface); padding: 0.8rem 1.2rem; border-radius: 30px; border: 1px solid var(--border); margin-bottom: 1.5rem; }
.search-bar input { flex: 1; border: none; outline: none; background: transparent; font-size: 0.9rem; margin-right: 0.5rem; }
.search-bar svg { width: 20px; height: 20px; color: var(--text-muted); }

/* Resume Card */
.resume-card { position: relative; border-radius: var(--radius-lg); overflow: hidden; height: 200px; margin-bottom: 2rem; box-shadow: 0 10px 20px rgba(55, 83, 60, 0.15); cursor: pointer; }
.resume-card img { width: 100%; height: 100%; object-fit: cover; }
.resume-overlay { position: absolute; inset: 0; background: linear-gradient(to left, rgba(248,246,240,0.95) 15%, rgba(248,246,240,0.3) 100%); padding: 1.5rem; display: flex; flex-direction: column; justify-content: center; }
.resume-overlay h2 { color: var(--green-dark); font-size: 1.3rem; margin-bottom: 0.3rem; font-weight: 800; }
.resume-overlay p { color: var(--text-muted); margin-bottom: 1rem; }
.resume-action { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.progress-info { width: 50%; }
.progress-info span { font-size: 0.75rem; color: var(--text-muted); }
.mini-progress-bg { height: 4px; background: rgba(0,0,0,0.1); border-radius: 2px; margin-top: 5px; }
.mini-progress-fill { height: 100%; background: var(--green-dark); border-radius: 2px; width: 0%; }
.btn-play-resume { background: var(--green-dark); color: white; padding: 0.5rem 1rem; border-radius: 20px; display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; font-weight: bold; }
.btn-play-resume svg { width: 18px; height: 18px; }

/* Lists */
.section-title { margin-bottom: 1rem; }
.list-item { display: flex; align-items: center; background: var(--surface); padding: 0.8rem; border-radius: var(--radius-md); margin-bottom: 1rem; box-shadow: 0 2px 10px rgba(0,0,0,0.03); cursor: pointer; border: 1px solid transparent; }
.list-item.playing { border-color: var(--green-dark); background: rgba(55, 83, 60, 0.03); }
.list-item img { width: 90px; height: 60px; border-radius: var(--radius-sm); object-fit: cover; margin-left: 1rem; }
.list-item-info { flex: 1; overflow: hidden; }
.list-item-info h4 { font-size: 0.95rem; color: var(--text-main); margin-bottom: 0.3rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-meta { font-size: 0.75rem; color: var(--text-muted); }
.list-play-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); display: flex; justify-content: center; align-items: center; color: var(--green-dark); margin-left: 1rem; flex-shrink: 0; }
.list-play-btn svg { width: 16px; height: 16px; }

/* Full Player */
.full-player { position: fixed; inset: 0; background: var(--bg-main); z-index: 999; display: flex; flex-direction: column; }
.player-top { display: flex; justify-content: space-between; align-items: center; padding: 1.5rem; position: absolute; top: 0; width: 100%; z-index: 10; }
.badge { background: rgba(255,255,255,0.8); backdrop-filter: blur(5px); padding: 0.4rem 0.8rem; border-radius: 20px; font-size: 0.8rem; font-weight: bold; color: var(--text-main); border: 1px solid rgba(0,0,0,0.05); }
.player-artwork { width: 100%; height: 45vh; position: relative; }
.player-artwork img { width: 100%; height: 100%; object-fit: cover; }
.artwork-fade { position: absolute; bottom: 0; left: 0; right: 0; height: 50%; background: linear-gradient(to top, var(--bg-main) 10%, transparent); }
.player-meta { padding: 0 1.5rem; text-align: center; margin-top: -1.5rem; position: relative; z-index: 5; }
.player-meta h1 { font-size: 2rem; color: var(--green-dark); margin-bottom: 0.5rem; letter-spacing: -1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-meta p { font-size: 1rem; color: var(--gold); font-weight: bold; }
.player-timeline { padding: 1rem 2rem; margin-top: auto; }
.time-labels { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.8rem; font-family: monospace; }
input[type=range] { -webkit-appearance: none; width: 100%; background: transparent; direction: ltr; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; height: 16px; width: 16px; border-radius: 50%; background: var(--green-dark); cursor: pointer; margin-top: -6px; box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 4px; cursor: pointer; background: var(--border); border-radius: 2px; }
.player-controls { display: flex; justify-content: space-between; align-items: center; padding: 0 2rem; margin-bottom: 1.5rem; }
.ctrl-btn { color: var(--green-dark); display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 0.7rem; font-weight: bold; }
.ctrl-btn svg { width: 28px; height: 28px; }
.main-play { width: 70px; height: 70px; background: var(--green-dark); color: white; border-radius: 50%; display: flex; justify-content: center; align-items: center; box-shadow: 0 10px 20px rgba(55, 83, 60, 0.3); }
.main-play svg { width: 32px; height: 32px; }
.player-bottom-actions { padding: 1.5rem 2rem; padding-bottom: calc(1.5rem + env(safe-area-inset-bottom)); display: flex; justify-content: space-between; align-items: center; background: rgba(255,255,255,0.5); border-top: 1px solid var(--border); border-radius: 30px 30px 0 0; }
.action-btn { display: flex; align-items: center; gap: 0.5rem; color: var(--text-muted); font-size: 0.85rem; font-weight: bold; }
.action-btn svg { width: 20px; height: 20px; }
.speed-btn { text-align: center; display: block; }
.fav-active svg { fill: var(--green-dark); stroke: var(--green-dark); }

/* Mini Player */
.mini-player { position: fixed; bottom: 85px; left: 1rem; right: 1rem; background: var(--surface); border-radius: var(--radius-md); padding: 0.8rem 1rem; display: flex; align-items: center; justify-content: space-between; box-shadow: 0 10px 20px rgba(0,0,0,0.08); z-index: 90; border: 1px solid var(--border); cursor: pointer; }
.mp-info { max-width: 65%; }
.mp-info h4 { font-size: 0.9rem; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-info p { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-controls button { color: var(--green-dark); padding: 5px; }
.mp-controls svg { width: 28px; height: 28px; }
.mp-progress { position: absolute; bottom: 0; left: 1.2rem; right: 1.2rem; height: 3px; background: var(--border); border-radius: 3px; overflow: hidden; }
#mp-progress-bar { height: 100%; background: var(--green-dark); width: 0%; }

/* Bottom Nav */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); display: flex; justify-content: space-around; padding: 0.5rem 0; padding-bottom: calc(0.5rem + env(safe-area-inset-bottom)); border-radius: 30px 30px 0 0; box-shadow: 0 -4px 20px rgba(0,0,0,0.04); z-index: 100; border: 1px solid var(--border); }
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 0.75rem; font-weight: bold; color: var(--text-muted); width: 33%; padding: 0.5rem; transition: all 0.2s; }
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--green-dark); }
.empty-state { text-align: center; padding: 2rem; color: var(--text-muted); font-size: 0.9rem; font-weight: bold; }

/* Loading Splash Screen */
.app-loader { position: fixed; inset: 0; background: var(--bg-main); z-index: 9999; display: flex; justify-content: center; align-items: center; transition: opacity 0.3s ease; }
.loader-content { text-align: center; }
.loader-content p { margin-top: 1rem; color: var(--text-muted); font-size: 0.9rem; font-weight: bold; }
.spinner { width: 40px; height: 40px; border: 4px solid var(--border); border-top-color: var(--green-dark); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Animations & Hardware Acceleration */
.view { animation: slideIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94); will-change: transform, opacity; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.full-player { transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94); will-change: transform; transform: translateY(100%); }
.full-player:not(.hidden) { transform: translateY(0); display: flex !important; }

/* Progress Bar RTL Fix */
input[type=range] { direction: ltr; } /* Range inputs in browsers process backgrounds LTR intrinsically */

/* Track Status Indicators */
.status-indicator { font-size: 0.7rem; padding: 2px 6px; border-radius: 10px; margin-right: 5px; font-weight: bold;    display: block;width: fit-content; }
.status-completed { background: #e6f4ea; color: var(--green-dark); border: 1px solid var(--green-light); }
.status-playing { background: #fef7e0; color: var(--gold); border: 1px solid var(--gold); }

/* Custom Modal */
.custom-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 9999; display: flex; justify-content: center; align-items: center; backdrop-filter: blur(4px); }
.modal-content { background: var(--surface); padding: 1.5rem; border-radius: var(--radius-md); width: 85%; max-width: 350px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,0.2); animation: popIn 0.2s ease-out; }
@keyframes popIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-content h3 { color: var(--text-main); margin-bottom: 0.5rem; }
.modal-content p { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1.5rem; line-height: 1.6; }
.modal-actions { display: flex; gap: 0.5rem; }
.modal-actions button { flex: 1; padding: 0.8rem; border-radius: var(--radius-sm); font-weight: bold; font-size: 0.9rem; }
.btn-primary { background: var(--green-dark); color: white; }
.btn-secondary { background: var(--border); color: var(--text-main); }

/* Toast */
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--text-main); color: white; padding: 0.8rem 1.5rem; border-radius: 30px; font-size: 0.85rem; z-index: 10000; box-shadow: 0 4px 15px rgba(0,0,0,0.2); animation: fadeUp 0.3s ease; white-space: nowrap; }
@keyframes fadeUp { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }


/* Course Info Card */
.course-info-card {
    display: flex;
    gap: 1rem;
    background: var(--surface);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    border: 1px solid var(--border);
}
.course-info-card img {
    width: 120px;
    height: 85px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.course-info-details {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.info-instructor {
    font-size: 0.85rem;
    color: var(--green-dark);
    font-weight: bold;
    margin-bottom: 0.4rem;
}
.info-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}


/* ==========================================
   Categories Scroll & Cards
   ========================================== */
   .categories-section {
    margin: 1.2rem 0;
}

.section-title {
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--text-main);
    margin-bottom: 0.8rem;
}

.categories-scroll {
    display: flex;
    gap: 0.8rem;
    overflow-x: auto;
    padding-bottom: 8px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* مخفی کردن اسکرول در فایرفاکس */
}

.categories-scroll::-webkit-scrollbar {
    display: none; /* مخفی کردن اسکرول در کروم و سافاری */
}

.category-card {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.25s ease;
    user-select: none;
}

.category-card svg {
    width: 20px;
    height: 20px;
    stroke: var(--green-dark);
    transition: transform 0.2s ease;
}

.category-card span {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
    white-space: nowrap;
}

/* حالت انتخاب شده (Active) */
.category-card.active {
    background: blanchedalmond;
    border-color: #ccc4a3;
}

.category-card.active span {
    color: #372504;
    font-weight: bold;
}

.category-card.active svg {
    stroke: #372504;

    transform: scale(1.1);
}

.category-card:hover:not(.active) {
    border-color: var(--green-light);
    transform: translateY(-2px);
}

/* ==========================================
   PWA Install Banner
   ========================================== */
   .pwa-install-container {
    position: fixed;
    bottom: 165px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--green-dark);
    border-radius: 30px;
    z-index: 9999;
    display: flex;
    align-items: center;
    padding: 6px 6px 6px 18px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.25);
    gap: 12px;
    direction: rtl;
    animation: fadeUp 0.4s ease;
}

.pwa-install-btn {
    color: #fff;
    font-weight: bold;
    font-size: 0.9rem;
    background: transparent;
    padding: 5px 0;
    white-space: nowrap;
}

.pwa-close-btn {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: background 0.3s ease;
}

.pwa-close-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}
/* ==========================================
   Mini Player Close Button
   ========================================== */
   .mp-close-btn {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-right: 4px;
}

.mp-close-btn:active {
    background: rgba(0, 0, 0, 0.15);
    transform: scale(0.92);
}

.mp-close-btn svg {
    width: 18px;
    height: 18px;
}

/* ==========================================
   Mini Player Controls & Layout
   ========================================== */
   .mini-player {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
}

.mp-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.mp-control-btn {
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--green-dark);
    border-radius: 50%;
    transition: background 0.2s ease;
}

.mp-control-btn:active {
    background: rgba(0, 0, 0, 0.08);
}

.mp-control-btn svg {
    width: 18px;
    height: 18px;
}

.mp-close-btn {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-right: 2px;
}

.mp-close-btn:active {
    background: rgba(220, 38, 38, 0.15);
    color: #dc2626;
}

.mp-close-btn svg {
    width: 16px;
    height: 16px;
}