/* ==================================================================
   Ostadyar Pro - دکمه‌های یکپارچه «پخش» و «دانلود» فایل صوتی
   ================================================================== */

/* ------------------------------------------------------------------
   ۱) دکمه‌های پخش و دانلود
   ------------------------------------------------------------------ */
.course-lesson .panel-heading-right a.play-end-btn,
.course-lesson .panel-heading-right a.download-end-btn,
.course-lesson .panel-heading-right .ostadyarpro-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    min-width: 100px !important;
    width: auto !important;
    height: auto !important;
    margin: 0 4px !important;
    padding: 9px 16px !important;
    border: 1px solid #111827 !important;
    border-radius: 8px !important;
    background: #111827 !important;
    background-image: none !important;
    background-color: #111827 !important;
    color: #ffffff !important;
    font-family: inherit !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    text-align: center !important;
    text-decoration: none !important;
    text-shadow: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    white-space: nowrap !important;
    box-shadow: none !important;
    outline: none !important;
    opacity: 1 !important;
    cursor: pointer !important;
    transition: background-color .18s ease, border-color .18s ease, transform .18s ease !important;
}

.course-lesson .panel-heading-right a.play-end-btn i,
.course-lesson .panel-heading-right a.download-end-btn i,
.course-lesson .panel-heading-right .ostadyarpro-btn i,
.course-lesson .panel-heading-right a.play-end-btn span,
.course-lesson .panel-heading-right a.download-end-btn span,
.course-lesson .panel-heading-right .ostadyarpro-btn span {
    color: #ffffff !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
}

/* هاور و فوکوس */
.course-lesson .panel-heading-right a.play-end-btn:hover,
.course-lesson .panel-heading-right a.download-end-btn:hover,
.course-lesson .panel-heading-right a.play-end-btn:focus,
.course-lesson .panel-heading-right a.download-end-btn:focus {
    background: #374151 !important;
    background-color: #374151 !important;
    border-color: #374151 !important;
    color: #ffffff !important;
    text-decoration: none !important;
    transform: translateY(-1px) !important;
}

.course-lesson .panel-heading-right a.play-end-btn:hover i,
.course-lesson .panel-heading-right a.download-end-btn:hover i,
.course-lesson .panel-heading-right a.play-end-btn:hover span,
.course-lesson .panel-heading-right a.download-end-btn:hover span {
    color: #ffffff !important;
}

/* حالت در حال پخش */
.course-lesson .panel-heading-right a.play-end-btn.is-playing {
    background: #16a34a !important;
    background-color: #16a34a !important;
    border-color: #16a34a !important;
    color: #ffffff !important;
}

.course-lesson .panel-heading-right a.play-end-btn.is-playing i,
.course-lesson .panel-heading-right a.play-end-btn.is-playing span {
    color: #ffffff !important;
}

/* حالت در حال دانلود */
.course-lesson .panel-heading-right a.download-end-btn.is-busy {
    opacity: .6 !important;
    pointer-events: none !important;
    cursor: default !important;
}

/* ------------------------------------------------------------------
   ۲) مودال پیشرفت دانلود
   ------------------------------------------------------------------ */
#ajax-download-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
    font-family: inherit;
}

#ajax-download-modal * {
    box-sizing: border-box;
}

.ajax-download-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .62);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.ajax-download-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(460px, calc(100% - 24px));
    padding: 32px 28px 24px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, .28);
    text-align: center;
    direction: rtl;
}

.ajax-download-close {
    position: absolute;
    top: 12px;
    left: 14px;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #aaa;
    font-size: 26px;
    line-height: 32px;
    cursor: pointer;
    transition: color .2s, transform .2s;
}
.ajax-download-close:hover { color: #222; transform: rotate(90deg); }

/* --- اسپینر --- */
.ajax-download-spinner-wrap {
    position: relative;
    width: 72px;
    height: 72px;
    margin: 0 auto 20px;
}

.ajax-dl-spinner {
    width: 72px;
    height: 72px;
    animation: spin 1.4s linear infinite;
}

#ajax-download-modal.download-complete .ajax-dl-spinner,
#ajax-download-modal.download-error   .ajax-dl-spinner {
    display: none;
}

.ajax-dl-spinner-track {
    stroke: #e9ecef;
}

.ajax-dl-spinner-arc {
    stroke: #111827;
    stroke-linecap: round;
    stroke-dasharray: 80 46;
    animation: spinner-arc 1.4s ease-in-out infinite;
}

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

@keyframes spinner-arc {
    0%   { stroke-dasharray: 1 125;  stroke-dashoffset: 0; }
    50%  { stroke-dasharray: 100 25; stroke-dashoffset: -30; }
    100% { stroke-dasharray: 1 125;  stroke-dashoffset: -125; }
}

/* آیکون موفقیت */
.ajax-download-icon-check {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #e9f8f0;
    color: #16a34a;
    font-size: 26px;
}

#ajax-download-modal.download-complete .ajax-download-icon-check {
    display: flex;
}

/* آیکون خطا */
.ajax-download-icon-error {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #fdecea;
    color: #dc2626;
    font-size: 26px;
}

#ajax-download-modal.download-error .ajax-download-icon-error {
    display: flex;
}

/* --- متن‌ها --- */
.ajax-download-title {
    margin-bottom: 6px;
    color: #111827;
    font-size: 17px;
    font-weight: 700;
}

.ajax-download-name {
    color: #374151;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    direction: ltr;
    text-align: center;
    margin-bottom: 4px;
}

.ajax-download-path {
    color: #9ca3af;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    direction: ltr;
    text-align: center;
    margin-bottom: 18px;
    font-family: monospace;
    padding: 4px 8px;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

/* --- نوار پیشرفت --- */
.ajax-download-progress {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 20px;
    overflow: hidden;
}

.ajax-download-progress-bar {
    width: 0;
    height: 100%;
    background: #111827;
    border-radius: 20px;
    transition: width .15s linear;
}

#ajax-download-modal.download-complete .ajax-download-progress-bar {
    background: #16a34a;
}

#ajax-download-modal.download-error .ajax-download-progress-bar {
    background: #dc2626;
}

/* انیمیشن نوار نامشخص (وقتی Content-Length نیست) */
#ajax-download-modal:not(.download-complete):not(.download-error)
.ajax-download-progress-bar[style*="100%"] {
    background: linear-gradient(90deg, #111827 25%, #4b5563 50%, #111827 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.ajax-download-info {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    direction: ltr;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
}

.ajax-download-size { color: #6b7280; }

.ajax-download-status {
    margin-top: 14px;
    color: #6b7280;
    font-size: 13px;
}

#ajax-download-modal.download-complete .ajax-download-status { color: #16a34a; font-weight: 700; }
#ajax-download-modal.download-error   .ajax-download-status { color: #dc2626; font-weight: 700; }

.ajax-download-timer {
    margin-top: 6px;
    color: #9ca3af;
    font-size: 11px;
    direction: rtl;
    min-height: 16px;
}

/* ------------------------------------------------------------------
   ۳) ریسپانسیو - تبلت و موبایل
   ------------------------------------------------------------------ */

/* تبلت (≤ 768px) */
@media (max-width: 768px) {
    .course-lesson .panel-heading-right a.play-end-btn,
    .course-lesson .panel-heading-right a.download-end-btn,
    .course-lesson .panel-heading-right .ostadyarpro-btn {
        min-width: 80px !important;
        padding: 8px 12px !important;
        font-size: 12px !important;
        gap: 5px !important;
        margin: 0 2px !important;
    }
}

/* موبایل (≤ 480px) */
@media (max-width: 480px) {
    .course-lesson .panel-heading-right a.play-end-btn,
    .course-lesson .panel-heading-right a.download-end-btn,
    .course-lesson .panel-heading-right .ostadyarpro-btn {
        min-width: 0 !important;
        width: 38px !important;
        height: 38px !important;
        padding: 0 !important;
        gap: 0 !important;
        border-radius: 50% !important;
        margin: 0 2px !important;
    }

    .course-lesson .panel-heading-right a.play-end-btn span,
    .course-lesson .panel-heading-right a.download-end-btn span,
    .course-lesson .panel-heading-right .ostadyarpro-btn span {
        display: none !important;
    }

    .course-lesson .panel-heading-right a.play-end-btn i,
    .course-lesson .panel-heading-right a.download-end-btn i,
    .course-lesson .panel-heading-right .ostadyarpro-btn i {
        font-size: 15px !important;
    }

    .ajax-download-box {
        padding: 24px 16px 20px;
        border-radius: 16px;
    }

    .ajax-download-title { font-size: 15px; }
    .ajax-download-name  { font-size: 13px; }
    .ajax-download-path  { font-size: 10px; }
}
