/* ===================================================
   audiobooks.css — يدعم الوضع النهاري والدارك مود
   =================================================== */

/* ===== إخفاء شريط التحميل فوراً ===== */
#loadingOverlay { display: none !important; }

/* ===== متغيرات الوضع النهاري ===== */
:root {
    /* الخلفية العامة */
    --ab-bg:             hsl(230, 100%, 96%);
    --ab-header-bg:      rgba(238, 242, 255, 0.88);
    --ab-header-border:  rgba(99, 102, 241, 0.12);
    --ab-sticky-bg:      rgba(238, 242, 255, 0.97);

    /* النصوص */
    --ab-title:          hsl(230, 70%, 16%);
    --ab-muted:          hsl(245, 60%, 55%);
    --ab-card-title:     hsl(230, 70%, 16%);
    --ab-card-author:    hsl(230, 16%, 45%);

    /* زر الرجوع */
    --ab-back-bg:        rgba(255,255,255,0.8);
    --ab-back-border:    rgba(99,102,241,0.2);
    --ab-back-color:     hsl(245, 70%, 50%);

    /* البحث */
    --ab-input-bg:       rgba(255,255,255,0.75);
    --ab-input-border:   rgba(99,102,241,0.2);
    --ab-input-color:    hsl(230, 70%, 16%);
    --ab-input-ph:       hsl(230, 15%, 60%);

    /* أزرار الفلتر */
    --ab-filter-bg:      rgba(255,255,255,0.7);
    --ab-filter-border:  rgba(99,102,241,0.22);
    --ab-filter-color:   hsl(245, 60%, 50%);

    /* ===== المودال — وضع نهاري ===== */
    --ab-overlay:        rgba(15, 23, 42, 0.55);
    --ab-modal-bg1:      hsl(235, 60%, 97%);
    --ab-modal-bg2:      hsl(248, 55%, 96%);
    --ab-modal-bg3:      hsl(258, 52%, 97%);
    --ab-modal-border-t: rgba(99,102,241,0.25);
    --ab-modal-border-s: rgba(99,102,241,0.1);
    --ab-modal-shadow:   rgba(80, 40, 200, 0.18);
    --ab-modal-glow1:    rgba(100, 60, 220, 0.08);
    --ab-modal-glow2:    rgba(150, 60, 200, 0.07);
    --ab-modal-glow3:    rgba(60, 90, 210, 0.04);
    --ab-line-color1:    rgba(130, 100, 255, 0.7);
    --ab-line-color2:    rgba(90, 130, 255, 0.85);
    --ab-line-color3:    rgba(160, 70, 235, 0.7);
    --ab-handle:         rgba(99,102,241,0.25);
    --ab-header-line:    rgba(99,102,241,0.1);

    /* غلاف الكتاب */
    --ab-cover-shadow:   rgba(0,0,0,0.18);
    --ab-cover-ring:     rgba(99,102,241,0.15);

    /* النصوص داخل المودال */
    --ab-modal-title:    hsl(230, 70%, 14%);
    --ab-modal-author:   hsl(230, 16%, 48%);
    --ab-modal-tag-bg1:  rgba(99,102,241,0.12);
    --ab-modal-tag-bg2:  rgba(168,85,247,0.1);
    --ab-modal-tag-bd:   rgba(99,102,241,0.22);
    --ab-modal-tag-clr:  hsl(245, 75%, 50%);
    --ab-close-bg:       rgba(99,102,241,0.09);
    --ab-close-bd:       rgba(99,102,241,0.15);
    --ab-close-clr:      hsl(245, 65%, 52%);

    /* ===== المشغل — وضع نهاري ===== */
    --ab-player-bg1:     hsl(245, 60%, 97%);
    --ab-player-bg2:     hsl(265, 52%, 96%);
    --ab-player-bg3:     hsl(245, 56%, 97%);
    --ab-player-border:  rgba(99,102,241,0.16);
    --ab-player-glow1:   rgba(140, 80, 240, 0.1);
    --ab-player-glow2:   rgba(60, 90, 220, 0.07);
    --ab-player-shadow:  rgba(99,102,241,0.08);

    /* الموجة */
    --ab-wave1:          rgba(99, 102, 241, 0.85);
    --ab-wave2:          rgba(139, 92, 246, 0.7);
    --ab-wave3:          rgba(99, 102, 241, 0.5);

    /* الوقت */
    --ab-time-current:   hsl(245, 75%, 48%);
    --ab-time-sep:       rgba(99,102,241,0.35);
    --ab-time-total:     hsl(230, 16%, 52%);

    /* شريط التقدم */
    --ab-track-bg:       rgba(99,102,241,0.12);
    --ab-fill1:          hsl(245, 78%, 60%);
    --ab-fill2:          hsl(268, 72%, 62%);
    --ab-fill3:          hsl(290, 65%, 60%);
    --ab-fill-glow:      rgba(99,102,241,0.4);
    --ab-thumb-bg1:      hsl(245, 80%, 62%);
    --ab-thumb-bg2:      hsl(275, 72%, 64%);
    --ab-thumb-border:   rgba(255,255,255,0.95);
    --ab-thumb-ring:     rgba(99,102,241,0.22);

    /* أزرار التحكم */
    --ab-side-bg:        rgba(99,102,241,0.08);
    --ab-side-border:    rgba(99,102,241,0.18);
    --ab-side-color:     hsl(245, 60%, 52%);
    --ab-side-hover-bg:  rgba(99,102,241,0.16);
    --ab-side-hover-bd:  rgba(99,102,241,0.35);
    --ab-side-hover-clr: hsl(245, 80%, 45%);

    /* زر التشغيل */
    --ab-play-bg1:       hsl(245, 78%, 60%);
    --ab-play-bg2:       hsl(268, 72%, 60%);
    --ab-play-bg3:       hsl(290, 65%, 58%);
    --ab-play-shadow:    rgba(80, 40, 200, 0.42);
    --ab-play-ring:      rgba(99,102,241,0.16);
    --ab-pulse-ring:     rgba(99,102,241,0.42);

    /* شريط السرعة */
    --ab-speed-line:     rgba(99,102,241,0.12);
    --ab-speed-label:    hsl(245, 45%, 55%);
    --ab-spd-bg:         rgba(255,255,255,0.65);
    --ab-spd-border:     rgba(99,102,241,0.2);
    --ab-spd-color:      hsl(245, 58%, 52%);
    --ab-spd-hover-bg:   rgba(99,102,241,0.1);
    --ab-spd-hover-bd:   rgba(99,102,241,0.35);
    --ab-spd-hover-clr:  hsl(245, 80%, 45%);

    /* زر المفضلة */
    --ab-fav-bg:         linear-gradient(135deg, rgba(99,102,241,0.09), rgba(168,85,247,0.09));
    --ab-fav-border:     rgba(99,102,241,0.2);
    --ab-fav-color:      hsl(245, 72%, 52%);
    --ab-fav-hover-bg:   linear-gradient(135deg, rgba(99,102,241,0.16), rgba(168,85,247,0.16));

    /* Toast */
    --ab-toast-bg:       rgba(30, 28, 70, 0.94);
    --ab-toast-border:   rgba(99,102,241,0.25);
    --ab-toast-color:    hsl(245, 80%, 80%);
}

/* ===== متغيرات الدارك مود ===== */
body.dark-theme {
    --ab-bg:             hsl(230, 12%, 8%);
    --ab-header-bg:      rgba(15, 23, 42, 0.92);
    --ab-header-border:  rgba(255,255,255,0.06);
    --ab-sticky-bg:      rgba(10, 14, 30, 0.97);

    --ab-title:          hsl(230, 48%, 85%);
    --ab-muted:          hsl(245, 40%, 65%);
    --ab-card-title:     hsl(230, 48%, 85%);
    --ab-card-author:    hsl(230, 16%, 65%);

    --ab-back-bg:        rgba(255,255,255,0.06);
    --ab-back-border:    rgba(255,255,255,0.1);
    --ab-back-color:     #818cf8;

    --ab-input-bg:       rgba(255,255,255,0.06);
    --ab-input-border:   rgba(255,255,255,0.1);
    --ab-input-color:    hsl(230, 48%, 85%);
    --ab-input-ph:       hsl(230, 15%, 50%);

    --ab-filter-bg:      rgba(255,255,255,0.06);
    --ab-filter-border:  rgba(255,255,255,0.1);
    --ab-filter-color:   #818cf8;

    /* ===== المودال — دارك ===== */
    --ab-overlay:        rgba(5, 3, 18, 0.82);
    --ab-modal-bg1:      hsl(248, 40%, 11%);
    --ab-modal-bg2:      hsl(260, 35%, 9%);
    --ab-modal-bg3:      hsl(275, 38%, 11%);
    --ab-modal-border-t: rgba(150,130,255,0.2);
    --ab-modal-border-s: rgba(150,130,255,0.08);
    --ab-modal-shadow:   rgba(90, 40, 220, 0.28);
    --ab-modal-glow1:    rgba(110, 70, 240, 0.13);
    --ab-modal-glow2:    rgba(170, 70, 210, 0.11);
    --ab-modal-glow3:    rgba(70, 110, 240, 0.06);
    --ab-line-color1:    rgba(160, 110, 255, 0.9);
    --ab-line-color2:    rgba(110, 150, 255, 1);
    --ab-line-color3:    rgba(190, 90, 255, 0.9);
    --ab-handle:         rgba(150,130,255,0.35);
    --ab-header-line:    rgba(150,130,255,0.1);

    --ab-cover-shadow:   rgba(0,0,0,0.55);
    --ab-cover-ring:     rgba(255,255,255,0.09);

    --ab-modal-title:    hsl(230, 88%, 93%);
    --ab-modal-author:   hsl(230, 22%, 58%);
    --ab-modal-tag-bg1:  rgba(99,102,241,0.22);
    --ab-modal-tag-bg2:  rgba(168,85,247,0.18);
    --ab-modal-tag-bd:   rgba(150,130,255,0.28);
    --ab-modal-tag-clr:  hsl(268, 92%, 78%);
    --ab-close-bg:       rgba(255,255,255,0.07);
    --ab-close-bd:       rgba(255,255,255,0.1);
    --ab-close-clr:      hsl(230, 22%, 60%);

    /* ===== المشغل — دارك ===== */
    --ab-player-bg1:     hsl(248, 38%, 13%);
    --ab-player-bg2:     hsl(258, 33%, 11%);
    --ab-player-bg3:     hsl(270, 36%, 13%);
    --ab-player-border:  rgba(150,130,255,0.14);
    --ab-player-glow1:   rgba(155, 90, 255, 0.14);
    --ab-player-glow2:   rgba(70, 110, 255, 0.09);
    --ab-player-shadow:  rgba(0,0,0,0.42);

    --ab-wave1:          rgba(165, 115, 255, 0.92);
    --ab-wave2:          rgba(110, 155, 255, 0.72);
    --ab-wave3:          rgba(155, 95, 255, 0.5);

    --ab-time-current:   hsl(252, 88%, 82%);
    --ab-time-sep:       rgba(150,130,255,0.38);
    --ab-time-total:     hsl(230, 16%, 48%);

    --ab-track-bg:       rgba(150,130,255,0.12);
    --ab-fill1:          hsl(248, 80%, 66%);
    --ab-fill2:          hsl(272, 76%, 68%);
    --ab-fill3:          hsl(296, 68%, 65%);
    --ab-fill-glow:      rgba(155,110,255,0.55);
    --ab-thumb-bg1:      hsl(262, 88%, 76%);
    --ab-thumb-bg2:      hsl(290, 78%, 70%);
    --ab-thumb-border:   rgba(255,255,255,0.92);
    --ab-thumb-ring:     rgba(155,110,255,0.22);

    --ab-side-bg:        rgba(255,255,255,0.06);
    --ab-side-border:    rgba(255,255,255,0.1);
    --ab-side-color:     hsl(248, 55%, 72%);
    --ab-side-hover-bg:  rgba(155,110,255,0.15);
    --ab-side-hover-bd:  rgba(155,110,255,0.3);
    --ab-side-hover-clr: hsl(262, 82%, 82%);

    --ab-play-bg1:       hsl(258, 84%, 66%);
    --ab-play-bg2:       hsl(280, 78%, 63%);
    --ab-play-bg3:       hsl(305, 70%, 60%);
    --ab-play-shadow:    rgba(110, 50, 240, 0.52);
    --ab-play-ring:      rgba(155,110,255,0.14);
    --ab-pulse-ring:     rgba(155,110,255,0.45);

    --ab-speed-line:     rgba(150,130,255,0.1);
    --ab-speed-label:    hsl(248, 30%, 55%);
    --ab-spd-bg:         rgba(255,255,255,0.04);
    --ab-spd-border:     rgba(150,130,255,0.18);
    --ab-spd-color:      hsl(248, 36%, 60%);
    --ab-spd-hover-bg:   rgba(155,110,255,0.12);
    --ab-spd-hover-bd:   rgba(155,110,255,0.3);
    --ab-spd-hover-clr:  hsl(262, 72%, 76%);

    --ab-fav-bg:         rgba(255,255,255,0.04);
    --ab-fav-border:     rgba(150,130,255,0.18);
    --ab-fav-color:      hsl(262, 68%, 72%);
    --ab-fav-hover-bg:   rgba(155,110,255,0.1);

    --ab-toast-bg:       rgba(22, 18, 52, 0.96);
    --ab-toast-border:   rgba(150,130,255,0.2);
    --ab-toast-color:    hsl(262, 80%, 83%);
}

/* ==============================================
   التصميم — يستخدم المتغيرات فقط
   ============================================== */

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--ab-bg);
    min-height: 100vh;
    padding-bottom: 40px;
    padding-top: 72px;
    transition: background 0.3s ease;
}

/* ===== الهيدر ===== */
.audio-header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 200;
    background: var(--ab-header-bg);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--ab-header-border);
    padding: 14px 20px;
    display: flex; align-items: center; gap: 14px;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.audio-header.hide-header { transform: translateY(-100%); }

.sticky-search-filters {
    position: fixed; top: 0; left: 0; right: 0; z-index: 199;
    background: var(--ab-sticky-bg);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--ab-header-border);
    padding: 12px 20px;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(-100%);
}
.sticky-search-filters.show-sticky { transform: translateY(0); }
.sticky-search-filters input {
    background-color: var(--ab-input-bg) !important;
    border-color: var(--ab-input-border) !important;
    color: var(--ab-input-color) !important;
}
.sticky-search-filters input::placeholder { color: var(--ab-input-ph) !important; }

.back-btn {
    width: 40px; height: 40px;
    background: var(--ab-back-bg); border: 1px solid var(--ab-back-border);
    border-radius: 12px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; text-decoration: none; color: var(--ab-back-color);
    font-size: 1.3rem; transition: all 0.2s ease; flex-shrink: 0;
}
.back-btn:hover { background: rgba(99,102,241,0.1); transform: translateX(3px); }

.audio-header-title h1 { font-size: 1.15rem; font-weight: 800; color: var(--ab-title); margin: 0; }
.audio-header-title span { font-size: 0.78rem; color: var(--ab-muted); font-weight: 500; }

/* ===== البحث ===== */
.search-container { display: flex; justify-content: center; align-items: center; margin: 16px 20px 0; }
.search-container input {
    width: 100%; max-width: 600px; padding: 12px 20px 12px 45px;
    font-size: 16px; border-radius: 20px;
    border: 1px solid var(--ab-input-border); outline: none;
    transition: all 0.3s ease;
    background-color: var(--ab-input-bg);
    backdrop-filter: blur(10px); text-align: center;
    font-family: 'Tajawal', sans-serif; font-weight: 500;
    color: var(--ab-input-color);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='rgba(99,102,241,0.5)' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z' /%3E%3C/svg%3E");
    background-repeat: no-repeat; background-size: 18px; background-position: left 14px center;
}
.search-container input:focus { border-color: rgba(99,102,241,0.5); box-shadow: 0 0 0 3px rgba(99,102,241,0.1); background-color: var(--ab-input-bg); }
.search-container input::placeholder { color: var(--ab-input-ph); }

/* ===== شريط الفلترة ===== */
.filter-wrapper { padding: 0 20px; margin: 16px 0 0; }
.filter-bar { display: flex; gap: 10px; overflow-x: auto; scroll-behavior: smooth; padding: 6px 0 12px; scrollbar-width: none; -ms-overflow-style: none; align-items: center; }
.filter-bar::-webkit-scrollbar { display: none; }
.filter-btn {
    flex-shrink: 0; padding: 9px 20px;
    border: 1.5px solid var(--ab-filter-border);
    background: var(--ab-filter-bg); backdrop-filter: blur(8px);
    color: var(--ab-filter-color); border-radius: 30px; cursor: pointer;
    font-size: 13px; font-family: 'Tajawal', sans-serif;
    font-weight: 600; transition: all 0.25s ease; white-space: nowrap;
}
.filter-btn:hover { background: rgba(99,102,241,0.1); border-color: rgba(99,102,241,0.4); transform: translateY(-1px); }
.filter-btn.active { background: linear-gradient(135deg, hsl(245,80%,60%), hsl(280,70%,60%)); color: #fff; border-color: transparent; box-shadow: 0 4px 14px rgba(99,102,241,0.35); transform: translateY(-1px); }

/* ===== شبكة الكتب ===== */
.audio-grid { width: 90%; margin: 10px auto 0; display: flex; flex-wrap: wrap; justify-content: space-between; padding: 10px 0 20px; }
.audio-card { width: 140px; margin: 10px auto; position: relative; cursor: pointer; }
.audio-card img { width: 100%; height: 200px; object-fit: cover; border-radius: 10px; display: block; transition: transform 0.3s ease, box-shadow 0.3s ease; }
.audio-card:hover img { transform: translateY(-4px); box-shadow: 0 12px 28px rgba(99,102,241,0.25); }
.audio-badge { position: absolute; top: 7px; right: 7px; background: rgba(99,102,241,0.92); backdrop-filter: blur(8px); color: #fff; border-radius: 8px; font-size: 13px; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(99,102,241,0.4); z-index: 2; }
.audio-card .content { margin-top: 6px; }
.audio-card .content h5 { text-overflow: ellipsis; white-space: nowrap; overflow: hidden; font-weight: 600; font-size: 12px; text-align: center; color: var(--ab-card-title); }
.audio-card .content h6 span { color: var(--ab-card-author); font-weight: 400; font-size: 11px; text-align: center; display: block; width: 100%; }
.audio-card .fav-btn { position: absolute; top: 7px; left: 7px; z-index: 10; background: rgba(255,255,255,0.88); backdrop-filter: blur(8px); border: none; border-radius: 50%; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,0.13); transition: transform 0.2s ease, background 0.2s ease; padding: 0; }
.audio-card .fav-btn:hover { background: rgba(255,255,255,0.98); transform: scale(1.15); }
.audio-card .fav-btn.active { background: rgba(255,220,220,0.95); }
.audio-card.hidden { display: none !important; }

.no-results-msg { display: none; text-align: center; padding: 50px 20px; color: var(--ab-muted); font-size: 1rem; width: 100%; }
.no-results-msg.show { display: block; }

/* ==============================================
   المودال
   ============================================== */
.audio-modal-overlay {
    display: none; position: fixed; inset: 0;
    background: var(--ab-overlay);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    z-index: 9000; justify-content: center; align-items: flex-end;
}
.audio-modal-overlay.show { display: flex; }

.audio-modal {
    background: linear-gradient(168deg,
        var(--ab-modal-bg1) 0%,
        var(--ab-modal-bg2) 55%,
        var(--ab-modal-bg3) 100%);
    border-radius: 30px 30px 0 0;
    padding: 0 0 34px;
    width: 100%; max-width: 600px;
    max-height: 92vh; overflow-y: auto; overflow-x: hidden;
    animation: slideUp 0.46s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
    border-top: 1px solid var(--ab-modal-border-t);
    border-left: 1px solid var(--ab-modal-border-s);
    border-right: 1px solid var(--ab-modal-border-s);
    box-shadow:
        0 -22px 70px var(--ab-modal-shadow),
        0 -4px 20px rgba(0,0,0,0.18),
        inset 0 1px 0 rgba(255,255,255,0.12);
    transition: background 0.3s ease;
}

/* الخط المضيء العلوي */
.audio-modal::before {
    content: ''; position: absolute; top: -1px; left: 8%; right: 8%; height: 2px;
    background: linear-gradient(90deg,
        transparent,
        var(--ab-line-color1),
        var(--ab-line-color2),
        var(--ab-line-color3),
        transparent);
    border-radius: 50%; pointer-events: none; z-index: 3;
}

/* توهجات الخلفية */
.audio-modal::after {
    content: ''; position: absolute; inset: 0;
    background:
        radial-gradient(ellipse 65% 38% at 82% 8%,  var(--ab-modal-glow1) 0%, transparent 70%),
        radial-gradient(ellipse 55% 32% at 18% 88%, var(--ab-modal-glow2) 0%, transparent 65%),
        radial-gradient(ellipse 40% 28% at 55% 48%, var(--ab-modal-glow3) 0%, transparent 70%);
    pointer-events: none; border-radius: 30px 30px 0 0; z-index: 0;
}

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.modal-handle {
    width: 46px; height: 4px;
    background: var(--ab-handle);
    border-radius: 10px; margin: 15px auto 0; position: relative; z-index: 2;
}

.modal-header {
    display: flex; align-items: center; gap: 15px;
    padding: 18px 20px 16px;
    border-bottom: 1px solid var(--ab-header-line);
    position: relative; z-index: 2;
}

.modal-cover {
    width: 64px; height: 86px; border-radius: 10px; object-fit: cover; flex-shrink: 0;
    box-shadow:
        0 8px 28px var(--ab-cover-shadow),
        0 2px 8px var(--ab-modal-shadow),
        0 0 0 1px var(--ab-cover-ring);
}

.modal-info { flex: 1; overflow: hidden; }
.modal-info h3 { font-size: 1rem; font-weight: 800; color: var(--ab-modal-title); margin: 0 0 3px; line-height: 1.35; }
.modal-info .modal-author { font-size: 0.81rem; color: var(--ab-modal-author); display: block; margin-bottom: 6px; }
.modal-category-tag {
    display: inline-block;
    background: linear-gradient(135deg, var(--ab-modal-tag-bg1), var(--ab-modal-tag-bg2));
    border: 1px solid var(--ab-modal-tag-bd);
    color: var(--ab-modal-tag-clr);
    border-radius: 20px; font-size: 10.5px; font-weight: 700; padding: 3px 11px; letter-spacing: 0.3px;
}

.modal-close {
    width: 35px; height: 35px;
    background: var(--ab-close-bg); border: 1px solid var(--ab-close-bd);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--ab-close-clr); font-size: 1.05rem;
    transition: all 0.22s ease; flex-shrink: 0;
}
.modal-close:hover { background: rgba(239,68,68,0.14); border-color: rgba(239,68,68,0.25); color: #ef4444; transform: scale(1.1); }

/* ===== المشغل ===== */
.player-section { padding: 18px 18px 8px; position: relative; z-index: 2; }

.hidden-iframe { position: absolute; width: 1px; height: 1px; opacity: 0.01; pointer-events: none; overflow: hidden; top: -9999px; left: -9999px; }
.hidden-iframe iframe { width: 300px; height: 137px; border: none; }

.custom-player {
    background: linear-gradient(158deg,
        var(--ab-player-bg1) 0%,
        var(--ab-player-bg2) 52%,
        var(--ab-player-bg3) 100%);
    border: 1px solid var(--ab-player-border);
    border-radius: 24px; padding: 26px 22px 20px;
    position: relative; overflow: hidden;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.5),
        inset 0 -1px 0 rgba(0,0,0,0.06),
        0 10px 35px var(--ab-player-shadow);
    transition: background 0.3s ease;
}
.custom-player::before { content: ''; position: absolute; top: -55px; right: -55px; width: 185px; height: 185px; background: radial-gradient(circle, var(--ab-player-glow1) 0%, transparent 65%); pointer-events: none; }
.custom-player::after  { content: ''; position: absolute; bottom: -55px; left: -55px; width: 165px; height: 165px; background: radial-gradient(circle, var(--ab-player-glow2) 0%, transparent 65%); pointer-events: none; }

/* ===== الموجة ===== */
.wave-visual { display: flex; align-items: center; justify-content: center; gap: 3.5px; height: 56px; margin-bottom: 15px; position: relative; z-index: 1; }
.wave-bar {
    width: 3.5px; border-radius: 5px;
    background: linear-gradient(180deg, var(--ab-wave1) 0%, var(--ab-wave2) 55%, var(--ab-wave3) 100%);
    transition: height 0.25s ease;
}
.wave-bar:nth-child(odd) { width: 3px; }
.wave-bar:nth-child(4n) { width: 4.5px; }
.wave-bar:nth-child(1)  { height: 9px;  } .wave-bar:nth-child(2)  { height: 18px; }
.wave-bar:nth-child(3)  { height: 30px; } .wave-bar:nth-child(4)  { height: 42px; }
.wave-bar:nth-child(5)  { height: 52px; } .wave-bar:nth-child(6)  { height: 44px; }
.wave-bar:nth-child(7)  { height: 54px; } .wave-bar:nth-child(8)  { height: 48px; }
.wave-bar:nth-child(9)  { height: 36px; } .wave-bar:nth-child(10) { height: 54px; }
.wave-bar:nth-child(11) { height: 46px; } .wave-bar:nth-child(12) { height: 32px; }
.wave-bar:nth-child(13) { height: 50px; } .wave-bar:nth-child(14) { height: 38px; }
.wave-bar:nth-child(15) { height: 22px; } .wave-bar:nth-child(16) { height: 40px; }
.wave-bar:nth-child(17) { height: 16px; } .wave-bar:nth-child(18) { height: 26px; }
.wave-bar:nth-child(19) { height: 11px; } .wave-bar:nth-child(20) { height: 7px;  }

@keyframes waveAnim { 0%,100%{transform:scaleY(0.22);opacity:0.45}50%{transform:scaleY(1);opacity:1} }
@keyframes waveIdle { 0%,100%{opacity:0.38}50%{opacity:0.72} }

.custom-player.playing .wave-bar { animation: waveAnim 0.88s ease-in-out infinite; transform-origin: center; }
.custom-player:not(.playing) .wave-bar { animation: waveIdle 3.2s ease-in-out infinite; }
.custom-player:not(.playing) .wave-bar:nth-child(even) { animation-delay: 1.6s; }
.custom-player.playing .wave-bar:nth-child(1)  { animation-delay:0.00s } .custom-player.playing .wave-bar:nth-child(2)  { animation-delay:0.07s }
.custom-player.playing .wave-bar:nth-child(3)  { animation-delay:0.14s } .custom-player.playing .wave-bar:nth-child(4)  { animation-delay:0.21s }
.custom-player.playing .wave-bar:nth-child(5)  { animation-delay:0.28s } .custom-player.playing .wave-bar:nth-child(6)  { animation-delay:0.22s }
.custom-player.playing .wave-bar:nth-child(7)  { animation-delay:0.35s } .custom-player.playing .wave-bar:nth-child(8)  { animation-delay:0.28s }
.custom-player.playing .wave-bar:nth-child(9)  { animation-delay:0.21s } .custom-player.playing .wave-bar:nth-child(10) { animation-delay:0.14s }
.custom-player.playing .wave-bar:nth-child(11) { animation-delay:0.08s } .custom-player.playing .wave-bar:nth-child(12) { animation-delay:0.15s }
.custom-player.playing .wave-bar:nth-child(13) { animation-delay:0.03s } .custom-player.playing .wave-bar:nth-child(14) { animation-delay:0.10s }
.custom-player.playing .wave-bar:nth-child(15) { animation-delay:0.18s } .custom-player.playing .wave-bar:nth-child(16) { animation-delay:0.25s }
.custom-player.playing .wave-bar:nth-child(17) { animation-delay:0.32s } .custom-player.playing .wave-bar:nth-child(18) { animation-delay:0.23s }
.custom-player.playing .wave-bar:nth-child(19) { animation-delay:0.12s } .custom-player.playing .wave-bar:nth-child(20) { animation-delay:0.05s }

/* ===== الوقت ===== */
.time-display { display:flex; align-items:center; justify-content:center; gap:5px; margin-bottom:11px; position:relative; z-index:1; font-variant-numeric:tabular-nums; }
#currentTime { font-size:1rem; font-weight:800; color:var(--ab-time-current); letter-spacing:0.5px; }
.time-sep { color:var(--ab-time-sep); font-size:0.88rem; font-weight:400; }
#totalTime { font-size:0.83rem; font-weight:500; color:var(--ab-time-total); letter-spacing:0.2px; }

/* ===== شريط التقدم ===== */
.progress-track { width:100%; height:5px; background:var(--ab-track-bg); border-radius:10px; position:relative; cursor:pointer; margin-bottom:22px; overflow:visible; z-index:1; transition:height 0.18s ease; }
.progress-track:hover { height:7px; }
.progress-fill { height:100%; width:0%; background:linear-gradient(90deg, var(--ab-fill1), var(--ab-fill2), var(--ab-fill3)); border-radius:10px; transition:width 0.55s linear; pointer-events:none; box-shadow:0 0 10px var(--ab-fill-glow); }
.progress-thumb { position:absolute; top:50%; right:calc(100% - 0%); transform:translate(50%,-50%); width:15px; height:15px; background:linear-gradient(135deg, var(--ab-thumb-bg1), var(--ab-thumb-bg2)); border:2px solid var(--ab-thumb-border); border-radius:50%; box-shadow:0 0 0 3px var(--ab-thumb-ring), 0 3px 10px rgba(0,0,0,0.3); transition:right 0.55s linear, transform 0.15s ease; pointer-events:none; }
.progress-track:hover .progress-thumb { transform:translate(50%,-50%) scale(1.28); }

/* ===== أزرار التحكم ===== */
.player-controls { display:flex; align-items:center; justify-content:center; gap:18px; margin-bottom:20px; position:relative; z-index:1; }
.ctrl-btn { border:none; cursor:pointer; display:flex; align-items:center; justify-content:center; transition:all 0.22s cubic-bezier(0.34,1.4,0.64,1); font-family:'Tajawal',sans-serif; -webkit-tap-highlight-color:transparent; }

.side-btn { width:50px; height:50px; background:var(--ab-side-bg); border:1px solid var(--ab-side-border); border-radius:50%; font-size:1.05rem; color:var(--ab-side-color); flex-direction:column; gap:1px; }
.side-btn:hover { background:var(--ab-side-hover-bg); border-color:var(--ab-side-hover-bd); color:var(--ab-side-hover-clr); transform:scale(1.08); }
.side-btn:active { transform:scale(0.94); }
.skip-label { font-size:9px; font-weight:800; line-height:1; color:inherit; letter-spacing:0.3px; }

.play-btn {
    width:68px; height:68px;
    background:linear-gradient(138deg, var(--ab-play-bg1) 0%, var(--ab-play-bg2) 50%, var(--ab-play-bg3) 100%);
    border-radius:50%; font-size:1.65rem; color:#fff !important; border:none;
    box-shadow:0 8px 28px var(--ab-play-shadow), 0 2px 8px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.28);
    transition:all 0.28s cubic-bezier(0.34,1.4,0.64,1) !important;
    position:relative; overflow:hidden;
}
.play-btn::before { content:''; position:absolute; top:-50%; left:-50%; width:200%; height:200%; background:radial-gradient(circle at 34% 34%, rgba(255,255,255,0.22) 0%, transparent 58%); pointer-events:none; }
.play-btn:hover { transform:scale(1.1) !important; box-shadow:0 0 0 8px var(--ab-play-ring), 0 12px 38px var(--ab-play-shadow), inset 0 1px 0 rgba(255,255,255,0.28) !important; }
.play-btn:active { transform:scale(0.95) !important; }

@keyframes playPulse {
    0%,100% { box-shadow:0 0 0 0px var(--ab-pulse-ring), 0 8px 28px var(--ab-play-shadow), inset 0 1px 0 rgba(255,255,255,0.28); }
    50%      { box-shadow:0 0 0 13px rgba(99,102,241,0), 0 8px 28px var(--ab-play-shadow), inset 0 1px 0 rgba(255,255,255,0.28); }
}
.custom-player.playing .play-btn { animation:playPulse 2.6s ease-in-out infinite; }

/* ===== السرعة ===== */
.speed-bar { display:flex; align-items:center; gap:9px; margin-top:2px; padding-top:16px; border-top:1px solid var(--ab-speed-line); position:relative; z-index:1; }
.speed-label { font-size:11px; font-weight:700; color:var(--ab-speed-label); white-space:nowrap; flex-shrink:0; letter-spacing:0.4px; }
.speed-btns { display:flex; gap:6px; flex-wrap:wrap; }
.spd-btn { padding:5px 11px; border-radius:20px; border:1px solid var(--ab-spd-border); background:var(--ab-spd-bg); font-family:'Tajawal',sans-serif; font-size:11px; font-weight:700; color:var(--ab-spd-color); cursor:pointer; transition:all 0.2s ease; letter-spacing:0.3px; }
.spd-btn:hover { background:var(--ab-spd-hover-bg); border-color:var(--ab-spd-hover-bd); color:var(--ab-spd-hover-clr); }
.spd-btn.active { background:linear-gradient(135deg, var(--ab-play-bg1), var(--ab-play-bg2)); color:#fff; border-color:transparent; box-shadow:0 3px 11px var(--ab-play-shadow); }

/* عناصر غير مستخدمة */
.player-status { display:none; }
.player-hint   { display:none; }

/* ===== زر المفضلة ===== */
.modal-fav-btn { display:flex; align-items:center; justify-content:center; gap:8px; margin:8px 18px 0; padding:14px; background:var(--ab-fav-bg); border:1px solid var(--ab-fav-border); border-radius:17px; font-family:'Tajawal',sans-serif; font-size:0.93rem; font-weight:700; color:var(--ab-fav-color); cursor:pointer; transition:all 0.24s ease; width:calc(100% - 36px); position:relative; z-index:2; letter-spacing:0.3px; }
.modal-fav-btn:hover { background:var(--ab-fav-hover-bg); border-color:rgba(99,102,241,0.35); transform:translateY(-1px); box-shadow:0 5px 18px rgba(0,0,0,0.1); }
.modal-fav-btn.active { background:linear-gradient(135deg, rgba(239,68,68,0.1), rgba(249,115,22,0.08)); border-color:rgba(239,68,68,0.25); color:#ef4444; }
.modal-fav-btn.active:hover { background:linear-gradient(135deg, rgba(239,68,68,0.16), rgba(249,115,22,0.12)); }

/* ===== Toast ===== */
#audio-toast { position:fixed; bottom:30px; left:50%; transform:translateX(-50%) translateY(80px); background:var(--ab-toast-bg); backdrop-filter:blur(18px); border:1px solid var(--ab-toast-border); color:var(--ab-toast-color); padding:13px 26px; border-radius:50px; font-family:'Tajawal',sans-serif; font-size:0.95rem; font-weight:600; z-index:99999; transition:transform 0.38s cubic-bezier(0.34,1.56,0.64,1), opacity 0.3s ease; opacity:0; pointer-events:none; white-space:nowrap; box-shadow:0 8px 30px rgba(0,0,0,0.2); }

/* ===== ريسبونسيف ===== */
@media (max-width: 600px) {
    .audio-card { width:100px; }
    .audio-card img { height:160px; }
    .audio-grid { width:95%; }
    .audio-modal { border-radius:26px 26px 0 0; }
    .modal-cover { width:56px; height:76px; }
    .modal-info h3 { font-size:0.9rem; }
    .play-btn { width:62px; height:62px; font-size:1.5rem; }
    .side-btn { width:45px; height:45px; }
    .custom-player { padding:20px 16px 16px; }
    .wave-visual { height:48px; }
}
@media (min-width: 601px) and (max-width: 992px) {
    .audio-card { width:120px; }
    .audio-card img { height:178px; }
}
@media (min-width: 768px) {
    .audio-modal { border-radius:30px; margin:auto; max-height:80vh; }
    .audio-modal-overlay { align-items:center; padding:20px; }
}

/* ===== شريط تقدم الكتاب على الكارد ===== */
.card-progress-bar {
    position: absolute;
    bottom: 0;
    right: 0;
    left: 0;
    height: 4px;
    background: rgba(99, 102, 241, 0.15);
    border-radius: 0 0 16px 16px;
    overflow: hidden;
    z-index: 5;
}
.card-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    border-radius: 0 0 16px 16px;
    transition: width 0.4s ease;
    min-width: 4px;
}
/* نقطة صغيرة على الكارد تشير إلى وجود تقدم محفوظ */
.audio-card:has(.card-progress-bar)::after {
    content: '▶';
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 9px;
    color: #6366f1;
    background: rgba(99,102,241,0.12);
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 18px;
    text-align: center;
    z-index: 6;
}

/* ===== شريط التقدم — حالة السحب ===== */
#progressTrack.dragging {
    cursor: grabbing;
}
#progressTrack.dragging #progressThumb,
#progressThumb:active {
    transform: translate(50%, -50%) scale(1.5);
    transition: transform 0.1s ease;
}
#progressThumb {
    cursor: grab;
    transition: transform 0.15s ease;
}
#progressThumb:hover {
    transform: translate(50%, -50%) scale(1.3);
}