.custom-player {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    user-select: none;
}
.custom-player video {
    width: 100%;
    height: 100%;
    display: block;
    cursor: pointer;
}

/* طبقة التحميل */
.player-loading {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.4);
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s;
}
.custom-player.buffering .player-loading { opacity: 1; }
.player-loading .spinner {
    width: 44px; height: 44px;
    border: 4px solid rgba(255,255,255,0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* زر تشغيل مركزي كبير */
.center-play-btn {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.3);
    border: none; cursor: pointer;
    transition: opacity .2s;
}
.center-play-btn svg { width: 70px; height: 70px; fill: white; filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5)); }
.custom-player.playing .center-play-btn { opacity: 0; pointer-events: none; }
.custom-player:not(.playing) .center-play-btn:hover { background: rgba(0,0,0,0.45); }

/* شريط التحكم السفلي */
.player-controls {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
    padding: 30px 16px 12px;
    opacity: 1;
    transition: opacity .25s;
}
.custom-player.playing.idle .player-controls { opacity: 0; }
.custom-player.playing.idle { cursor: none; }

/* شريط التقدم */
.progress-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.progress-bar {
    flex: 1; position: relative; height: 5px; background: rgba(255,255,255,0.25);
    border-radius: 999px; cursor: pointer;
}
.progress-bar:hover { height: 7px; }
.progress-filled {
    position: absolute; right: 0; top: 0; bottom: 0;
    background: var(--gradient); border-radius: 999px; width: 0%;
}
.progress-buffered {
    position: absolute; right: 0; top: 0; bottom: 0;
    background: rgba(255,255,255,0.35); border-radius: 999px; width: 0%;
}
.progress-handle {
    position: absolute; top: 50%; width: 13px; height: 13px;
    background: white; border-radius: 50%;
    transform: translate(50%, -50%);
    right: 0%;
    box-shadow: 0 0 6px rgba(0,0,0,0.5);
    opacity: 0; transition: opacity .15s;
}
.progress-bar:hover .progress-handle { opacity: 1; }

.time-label { font-size: 12px; color: #eee; white-space: nowrap; direction: ltr; }

/* صف الأزرار */
.controls-row { display: flex; align-items: center; gap: 14px; }
.controls-row .spacer { flex: 1; }
.ctrl-btn {
    background: none; border: none; cursor: pointer; padding: 4px;
    display: flex; align-items: center; justify-content: center;
}
.ctrl-btn svg { width: 22px; height: 22px; fill: white; }
.ctrl-btn:hover svg { fill: var(--accent-2); }

/* الصوت */
.volume-group { display: flex; align-items: center; gap: 6px; }
.volume-slider {
    width: 70px; height: 4px; -webkit-appearance: none; appearance: none;
    background: rgba(255,255,255,0.3); border-radius: 999px; outline: none;
    cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none; width: 11px; height: 11px; border-radius: 50%;
    background: white; cursor: pointer;
}

/* السرعة والجودة */
.settings-wrap { position: relative; }
.settings-menu {
    position: absolute; bottom: 36px; left: 0;
    background: rgba(20,20,28,0.97); border: 1px solid #2a2a35;
    border-radius: 10px; padding: 6px; min-width: 130px;
    display: none; flex-direction: column; gap: 2px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
.settings-wrap.open .settings-menu { display: flex; }
.settings-menu button {
    background: none; border: none; color: #ddd; text-align: right;
    padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.settings-menu button:hover { background: var(--surface-2); }
.settings-menu button.active { color: var(--accent-2); font-weight: bold; }

/* شارة السرعة الحالية على الأيقونة */
.speed-badge {
    font-size: 11px; color: white; min-width: 30px; text-align: center;
}

@media (max-width: 600px) {
    .volume-slider { width: 40px; }
    .controls-row { gap: 8px; }
}

/* ===== طبقة الإعلانات داخل المشغل (Pre-roll / Mid-roll) ===== */
.custom-player.ad-playing .player-controls,
.custom-player.ad-playing .center-play-btn {
    display: none !important;
}
.ad-overlay {
    position: absolute; inset: 0; z-index: 30;
    background: #000;
    display: flex; flex-direction: column;
}
.ad-badge {
    position: absolute; top: 12px; right: 12px;
    background: rgba(0,0,0,0.75); color: #fff;
    font-size: 12px; padding: 4px 10px; border-radius: 5px;
    z-index: 2;
}
.ad-content {
    flex: 1; display: flex; align-items: center; justify-content: center;
    overflow: hidden; padding: 10px;
}
.ad-content img, .ad-content video, .ad-content iframe {
    max-width: 100%; max-height: 100%;
}
.ad-footer {
    position: absolute; bottom: 14px; left: 14px; right: 14px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px;
}
.ad-timer {
    background: rgba(0,0,0,0.65); color: #ddd; font-size: 12px;
    padding: 5px 10px; border-radius: 5px;
}
.ad-skip-btn {
    background: #fff; color: #111; border: 0; border-radius: 4px;
    padding: 8px 16px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.ad-skip-btn:hover { background: #e2e2e2; }

