/* في بداية ملف style.css */
* {
    -webkit-tap-highlight-color: transparent;
    outline: none;
    
    /* هذا هو السطر السحري لمنع قائمة المتصفح */
    -webkit-touch-callout: none; 
    
    /* لمنع تحديد النصوص والصور */
    -webkit-user-select: none;
    user-select: none;
}

/* حل خاص لمشكلة الصور تحديداً */
img {
    /* يمنع الصور من استقبال أحداث اللمس كصور، مما يمنع قائمة "حفظ الصورة" */
    pointer-events: none; 
    
    /* إذا كانت الصورة داخل زر وتريد الضغط على الزر، هذا الكود سيجعل الضغط "يمر" عبر الصورة للزر خلفها */
}

/* =======================================================
   1. أنماط أساسية وموضوع التصميم الداكن
   ======================================================= */
:root {
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --text-color-primary: #e0e0e0;
    --text-color-secondary: #a0a0a0;
    --accent-color: #e91e63; /* Pinkish-red accent */
    --accent-color-light: rgba(233, 30, 99, 0.2);
    --shadow-color: rgba(0, 0, 0, 0.5);
}

* {
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

body {
    background: var(--bg-color);
    color: var(--text-color-primary);
    font-family: 'Tajawal', sans-serif;
    text-align: center;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;

    /* (إضافة) منع سحب الصفحة للتحديث (Pull-to-refresh) */
    overscroll-behavior-y: contain;
    
    /* (إضافة) منع تحديد النص ليعطي إحساس التطبيق الأصلي */
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none;    /* Firefox */
    -ms-user-select: none;     /* IE10+ */
    user-select: none;        /* Standard */
    
    /* (إضافة) منع قائمة السياق عند الضغط المطول (iOS) */
    -webkit-touch-callout: none; 
}

#mainContent {
    flex-grow: 1;
    padding: 20px 15px; /* (تعديل: إزالة الهامش السفلي من هنا) */
    
    /* (إضافة) إضافة مساحات آمنة للأجهزة ذات النتوء (Notch) أو شريط سفلي */
    padding-top: max(20px, env(safe-area-inset-top));

    /* (*** تعديل ***) إضافة مساحة سفلية ضخمة لإفساح المجال للشريط الزجاجي */
    /* 175px (ارتفاع الشريط التقريبي) + 15px (هامش) */
    padding-bottom: calc(190px + env(safe-area-inset-bottom));
    
    z-index: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: hidden;
    transition: opacity 0.3s ease;
    
    /* (*** تحسين الأداء ***) */
    will-change: opacity;
}

#topSection {
    flex-shrink: 0;
}

/* (*** تعديل ***) جعل الشريط السفلي شريطاً زجاجياً ثابتاً */
#bottomSection {
    flex-shrink: 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;

    /* (*** تحسين الأداء: إزالة التأثير الزجاجي واستبداله بخلفية ثابتة ***) */
    background: rgba(30, 30, 30, 0.95); /* زيادة العتامة لتعويض غياب الضبابية */
    /* (تم التعطيل) backdrop-filter: blur(15px); */
    /* (تم التعطيل) -webkit-backdrop-filter: blur(15px); */
    
    /* (إضافة) حواف علوية دائرية وحدود مضيئة */
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    
    /* (إضافة) هوامش داخلية ومساحة آمنة للشريط السفلي */
    padding: 15px 15px max(15px, env(safe-area-inset-bottom));
    box-sizing: border-box; 
    
    box-shadow: 0 -5px 30px rgba(0, 0, 0, 0.3);

    /* (*** تحسين الأداء: استخدام تسريع العتاد (GPU) ***) */
    transform: translateZ(0);
}

.drag-over-zone {
    border: 3px dashed var(--accent-color) !important;
    box-shadow: 0 0 50px rgba(233, 30, 99, 0.3) inset !important;
}

/* =======================================================
   2. تصميم حاوية الميديا (صورة الغلاف) - ✨ مُعدلة بالأبعاد الجديدة
   ======================================================= */
#mediaContainer {
    width: 100%;
    max-width: 500px; 
    margin: 15px auto;
    background: var(--surface-color);
    height: auto;
    aspect-ratio: 1 / 1;
    display: flex;
    justify-content: center;
    align-items: center;

    /* (*** تعديل ***) زيادة نعومة الحواف */
    border-radius: 25px;
    
    overflow: hidden;
    position: relative;
    
    /* (*** تعديل ***) تحسين الظل */
    box-shadow: 0 10px 25px var(--shadow-color);
    
    /* (*** تحسين الأداء: إزالة box-shadow من الانتقالات ***) */
    /* تحريك الظل يسبب إعادة رسم (Repaint) مكلفة. */
    transition: max-width 0.3s ease, border-radius 0.3s ease;

    /* (*** تحسين الأداء: تفعيل تسريع العتاد للحاوية ***) */
    transform: translateZ(0); 
    will-change: transform;
}

#mediaContainerIcons {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    display: flex;
    justify-content: space-between;
    z-index: 10;
    transition: opacity 0.3s ease;
    
    /* (*** تحسين الأداء ***) */
    will-change: opacity;
}

.icon-btn {
    background: rgba(30, 30, 30, 0.7);
    border: none;
    color: var(--text-color-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    /* (*** تم الحذف لتحسين الأداء: إزالة التأثير الزجاجي من الأزرار ***) */
    /* backdrop-filter: blur(5px); */ 
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 10px var(--shadow-color);
    transition: background 0.2s, opacity 0.3s;
}
.icon-btn:hover { background: var(--surface-color); }
.icon-btn.active { color: var(--accent-color); }


#audioCanvas, #coverArt, #defaultIcon {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
    border-radius: 0;
    /* (*** تعديل لتحسين الأداء ***) */
    transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out, filter 0.5s ease-in-out;
    position: absolute;
    top: 0;
    left: 0;
    
    /* (*** تحسين الأداء: تفعيل تسريع العتاد للرسومات ***) */
    transform: translateZ(0);
    image-rendering: optimizeSpeed; /* لتحسين جودة الرسم السريع */
    will-change: opacity, transform, filter;
}

#defaultIcon {
    font-size: 100px;
    color: var(--accent-color);
    display: flex; 
    justify-content: center;
    align-items: center;
    
    /* (*** إضافة ***) تدرج خفيف في الخلفية لجعله أقل سطحية */
    background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, rgba(0,0,0,0.1) 70%);
}

#lyricsDisplay {
    position: absolute;
    
    /* (*** تعديل ***) جعلها لوحة عائمة داخل الحاوية */
    bottom: 10px; 
    left: 10px; 
    right: 10px;
    
    /* (*** تحسين الأداء: إزالة التأثير الزجاجي ***) */
    background: rgba(40, 40, 40, 0.9); /* خلفية صلبة بدلاً من الزجاج */
    /* (تم التعطيل) backdrop-filter: blur(10px); */
    /* (تم التعطيل) -webkit-backdrop-filter: blur(10px); */
    
    color: var(--text-color-primary); /* ضمان لون النص الأساسي */
    padding: 15px;
    font-size: 16px; 
    display: none; 
    z-index: 5;
    
    /* (*** تحسين الأداء: إزالة ظل النص ***) */
    /* (تم التعطيل) text-shadow: 0 0 8px var(--accent-color); */
    
    transition: opacity 0.3s ease, transform 0.3s ease;
    will-change: transform, opacity;

    line-height: 1.8;
    max-height: 40%;
    overflow-y: auto;
    
    /* (*** تعديل ***) حواف دائرية بالكامل وحدود زجاجية */
    border-radius: 15px; 
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3); /* ظل لتعزيز العمق */
}

.highlighted-lyric { color: var(--accent-color); font-weight: bold; }


/* =======================================================
   تنسيق شريط التقدم والوقت (من ملفك القديم)
   ======================================================= */

#progressContainer {
    width: 100%;
    max-width: 380px;
    margin: 15px auto; 
    cursor: pointer;
    position: relative;
    padding: 10px 0; /* (ملاحظة: هذا الهامش من ملفك القديم) */
}

#progress {
    width: 100%; 
    height: 6px; 
    background: var(--surface-color); 
    border-radius: 6px;
    position: relative;
    overflow: hidden;
}

/* (يفترض أن كود #bar موجود لديك بالفعل) */
#bar {
    height: 100%; 
    width: 100%; 
    position: absolute; 
    left: 0; 
    top: 0;
    background: var(--accent-color);
    border-radius: 6px;
    transform: translateX(-100%);
    transform-origin: left;
    
    /* (*** تحسين الأداء: تفعيل تسريع العتاد لشريط التقدم ***) */
    will-change: transform;
    transform: translateZ(0);
}

/* === هذا هو الجزء الأهم لحل مشكلتك === */
#timeDisplay {
    display: flex;                 /* 1. تفعيل flex لترتيب العدادات أفقياً */
    justify-content: space-between;/* 2. وضع واحد في البداية وواحد في النهاية */
    font-size: 12px;
    color: var(--text-color-secondary);
    margin-top: 8px;               /* 3. وضع مسافة 8px أسفل شريط التقدم */
    padding: 0 5px;
}

#currentTime { 
    color: var(--text-color-primary); 
    font-weight: 500; 
}

/* =======================================================
   4. تصميم عناصر التحكم الجديدة
   ======================================================= */
#controls {
    background: transparent;
    
    /* (*** تعديل ***) إزالة الهامش، #bottomSection يعالجه الآن */
    padding: 0; 
    
    box-shadow: none;
    display: flex;
    flex-direction: column; 
    width: 100%; max-width: 100%;
    position: static;

    /* (*** تعديل ***) تقليل الفجوة قليلاً لتحسين الشكل */
    gap: 15px;
    
    transition: opacity 0.3s ease;
    
    /* (*** تحسين الأداء ***) */
    will-change: opacity;
}

#secondaryControls {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 420px;
    width: 100%;
    margin: 0 auto;
}

.secondary-btn {
    background: none; border: none;
    color: var(--text-color-secondary);
    font-size: 24px; cursor: pointer;
    /* (*** تعديل لتحسين الأداء ***) */
    transition: color 0.3s ease, transform 0.3s ease;
    position: relative;
    
    /* (*** تحسين الأداء ***) */
    will-change: color, transform;
}
.secondary-btn:hover { color: var(--text-color-primary); }
.secondary-btn.active { 
    color: var(--accent-color);
    transform: scale(1.1);
    text-shadow: 0 0 8px var(--accent-color);
}

#randomBtn.active::after {
    content: '';
    position: absolute;
    bottom: 0px;
    left: 50%;
    transform: translateX(-50%);
    width: 5px;
    height: 5px;
    background-color: var(--accent-color);
    border-radius: 50%;
    box-shadow: 0 0 5px var(--accent-color);
}

#mainControls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    margin: 10px auto;
}

.main-ctrl-btn {
    background: none; border: none;
    color: var(--text-color-primary);
    font-size: 30px; cursor: pointer;
    transition: color 0.2s, transform 0.1s;
    padding: 10px;
    
    /* (*** تحسين الأداء ***) */
    will-change: color, transform;
}
.main-ctrl-btn:hover { color: var(--accent-color); transform: scale(1.1); }

#playPauseBtn {
    background: var(--accent-color);
    color: #fff;
    width: 70px; height: 70px;
    border-radius: 50%;
    font-size: 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 5px 20px rgba(233, 30, 99, 0.4);
    transition: background 0.3s, transform 0.2s;
    
    /* (*** تحسين الأداء ***) */
    will-change: background, transform;
}
#playPauseBtn:hover { transform: scale(1.05); }


/* (تعديل) أنماط التحكم بالصوت - إزالة الاعتماد على hover */
/* =======================================================
   تصميم شريط الصوت (Custom Range Input)
   ======================================================= */
#volumeContainer {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0;
    gap: 10px;
}

.volume-slider {
    -webkit-appearance: none; /* إلغاء التصميم الافتراضي */
    appearance: none;
    width: 100px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1); /* لون الخلفية (الجزء غير الممتلئ) */
    border-radius: 10px;
    outline: none;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}

/* تصميم المقبض (Thumb) لمتصفح Chrome/Safari/Edge */
.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--accent-color); /* إطار بلون الثيم */
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    margin-top: 0px; /* ضبط المحاذاة */
    transition: transform 0.2s, box-shadow 0.2s;
}

/* تأثير عند التمرير على مقبض الصوت */
.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 15px var(--accent-color);
    background: var(--accent-color);
    border-color: #fff;
}

/* تصميم المقبض لمتصفح Firefox */
.volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #fff;
    border: 2px solid var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    transition: transform 0.2s, box-shadow 0.2s;
}

.volume-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 15px var(--accent-color);
}


/* =======================================================
   5. أنماط قائمة التشغيل وشاشة المعلومات (Overlay)
   ======================================================= */
.overlay {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%; 
    
    /* (*** تحسين الأداء: إزالة التأثير الزجاجي واستبداله بخلفية ثابتة ***) */
    background: rgba(18, 18, 18, 0.98);
    /* (تم التعطيل) backdrop-filter: blur(10px); */
    /* (تم التعطيل) -webkit-backdrop-filter: blur(10px); */
    
    z-index: 40; padding: 50px 10px 10px 10px; 
    box-sizing: border-box; display: none; flex-direction: column;
    color: var(--text-color-primary);

    /* (*** تعديل ***) تغيير الحركة إلى انزلاق لأعلى وأكثر سلاسة */
    animation: slideUpIn 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    
    /* (*** إضافة ***) تحسين الأداء (Hardware Acceleration) */
    will-change: transform, opacity;
}

/* (*** حذف ***) @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } */

/* (*** إضافة ***) تعريف الحركة الجديد */
@keyframes slideUpIn {
    from {
        opacity: 0;
        transform: translateY(30px); /* انزلاق من أسفل قليلًا */
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* (*** إضافة ***) تعريف حركة المحتوى الداخلي */
@keyframes contentFadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.overlay h2 { 
    color: var(--accent-color); margin-bottom: 10px; 
    border-bottom: 1px solid var(--surface-color); padding-bottom: 8px; 
    font-size: 22px;
}

#listMode { 
    display: flex; 
    flex-direction: column; 
    flex-grow: 1; 
    overflow: hidden; 

    /* (*** إضافة ***) حركة للمحتوى الداخلي */
    animation: contentFadeIn 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) 0.1s;
    animation-fill-mode: backwards;
    will-change: transform, opacity;
}

#searchInput {
    width: 100%; max-width: 400px; padding: 12px; margin-bottom: 15px; 
    border-radius: 10px; border: 1px solid var(--surface-color); background: #2a2a2a; 
    color: var(--text-color-primary); font-size: 16px; align-self: center;
    box-shadow: 0 2px 10px var(--shadow-color);
}
#searchInput:focus { 
    border-color: var(--accent-color); 
    outline: 2px solid var(--accent-color-light); 
}

#sortControlsGroup {
     display: flex; justify-content: space-between; gap: 10px; width: 100%; max-width: 400px; margin-bottom: 15px; align-self: center;
}
#sortButton {
    padding: 10px 15px; border-radius: 10px; border: none; background: var(--surface-color); color: var(--accent-color); 
    font-weight: bold; cursor: pointer; font-size: 14px;
    box-shadow: 0 2px 8px var(--shadow-color);
    flex-grow: 1; transition: background 0.2s;
}
#sortButton:hover { background: #333; }
#sortModeDisplay { color: var(--text-color-secondary); font-size: 12px; align-self: center; flex-shrink: 0; text-align: left; line-height: 1.2; }

#playlist {
    list-style: none; padding: 0; margin: 0; flex-grow: 1; overflow-y: auto; 
    font-size: 15px; padding-right: 5px;
    
    /* (*** تحسين الأداء: عزل التمرير ***) */
    /* نخبر المتصفح أن محتوى هذه القائمة لا يؤثر على ما خارجها */
    contain: strict;
}

.playlist-item {
    padding: 12px 15px; margin-bottom: 8px; background: var(--surface-color); border-radius: 12px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; 
    
    /* (*** تحسين الأداء: إزالة الظل من كل عنصر ***) */
    /* وجود ظل على كل عنصر في قائمة طويلة يبطئ التمرير بشدة */
    /* (تم التعطيل) box-shadow: 0 2px 5px var(--shadow-color); */
    
    /* (*** إضافة: بديل للظل ***) */
    /* استخدام حد سفلي خفيف للفصل بين العناصر */
    border-bottom: 1px solid rgba(0, 0, 0, 0.2);
    
    transition: background 0.2s, color 0.2s; border-left: 4px solid transparent; 
    display: flex; justify-content: space-between; align-items: center;
}
.playlist-item-name {
     flex-grow: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
     padding-right: 10px; cursor: pointer; font-weight: 500;
}
.queue-btn {
    background: #333; color: var(--text-color-secondary); border: none;
    padding: 5px 10px; border-radius: 8px;
    font-weight: bold; font-size: 12px; cursor: pointer;
    flex-shrink: 0; transition: background 0.2s, transform 0.1s;
}
.queue-btn:hover { background: #444; }
.playlist-item.active {
    background: var(--accent-color-light);
    color: var(--accent-color); font-weight: bold;
    border-left: 4px solid var(--accent-color);
}
.playlist-item.queued { background: rgba(255, 170, 0, 0.2); border-left: 4px solid #ffaa00; }
.close-overlay-btn {
    margin-top: 15px; width: 100%; max-width: 380px; align-self: center; background: var(--accent-color);
    color: #fff; padding: 12px; border: none; border-radius: 12px; font-size: 16px;
    box-shadow: 0 4px 15px rgba(233, 30, 99, 0.3); cursor: pointer;
}

#infoContent {
    margin: auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-grow: 1;

    /* (*** إضافة ***) حركة للمحتوى الداخلي */
    animation: contentFadeIn 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) 0.1s;
    animation-fill-mode: backwards;
    will-change: transform, opacity;
}
#infoContent p {
    font-size: 18px;
    line-height: 2.2;
    color: var(--text-color-primary);
    margin: 5px 0;
}
#infoContent p strong {
    color: var(--text-color-secondary);
    margin-left: 10px;
    min-width: 100px;
    display: inline-block;
    text-align: right;
}

/* =======================================================
   تنسيق رأس القائمة المدمج (العنوان + الأزرار)
   ======================================================= */

.playlist-header-row {
    display: flex;
    justify-content: space-between; /* توزيع المسافة: العنوان يمين والأزرار يسار */
    align-items: center;
    width: 100%;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--surface-color); /* الخط الفاصل أسفل العنوان */
}

/* تعديل العنوان ليتناسب مع الصف الجديد */
#listTitle {
    margin: 0;
    border: none;
    padding: 0;
    font-size: 22px;
}

/* حاوية الأزرار */
.header-actions {
    display: flex;
    gap: 8px; /* مسافة بين الأزرار */
}

/* تنسيق الأزرار الجديدة (شفافة وأنيقة) */
.header-icon-btn {
    background: transparent;
    border: none;
    color: var(--text-color-secondary); /* لون رمادي افتراضي */
    width: 40px;
    height: 40px;
    border-radius: 50%; /* شكل دائري عند الضغط */
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.header-icon-btn svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    transition: stroke 0.2s;
}

/* تأثير التحويم (Hover) - إضاءة الزر */
.header-icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color-primary);
    transform: scale(1.1);
}

/* تخصيص زر المسح (عند التحويم يصبح أحمر) */
.header-icon-btn.danger:hover {
    background: rgba(244, 67, 54, 0.15);
    color: #ff5252;
}

/* تحسين الاستجابة على الشاشات الصغيرة */
@media (max-width: 380px) {
    #listTitle {
        font-size: 18px;
    }
    .header-icon-btn {
        width: 35px;
        height: 35px;
    }
}

/* =======================================================
   6. (إضافة جديدة) أنماط الإشعارات المخصصة (Toast) - ✨ مُعدلة للأعلى
   ======================================================= */
#notification-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    width: 90%;
    max-width: 500px;
    pointer-events: none;
}

.toast {
    background-color: var(--surface-color);
    color: var(--text-color-primary);
    padding: 12px 20px;
    border-radius: 10px;
    box-shadow: 0 4px 15px var(--shadow-color);
    border-left: 5px solid var(--text-color-secondary);
    font-size: 15px;
    opacity: 0;
    transform: translateY(-150%);
    
    /* (*** تحسين الأداء: تجنب transition: all ***) */
    /* تحديد الخصائص التي ستتحرك فقط (transform و opacity) */
    transition: opacity 0.4s cubic-bezier(0.215, 0.610, 0.355, 1), 
                transform 0.4s cubic-bezier(0.215, 0.610, 0.355, 1);
    
    pointer-events: auto;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    
    /* (*** تحسين الأداء ***) */
    will-change: opacity, transform;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.info {
    border-left-color: #2196F3;
}
.toast.success {
    border-left-color: #4CAF50;
}
.toast.error {
    border-left-color: #f44336;
}

@media (max-width: 600px) {
    #notification-container {
        left: 10px;
        right: 10px;
        top: 10px;
        width: auto;
        transform: none;
        align-items: center;
    }
    .toast {
        width: 100%;
        text-align: center;
    }
}

/* =======================================================
   7. أنماط الهواتف (Responsive)
   ======================================================= */
@media (max-width: 600px) {
    /* تصغير الهوامش الرئيسية لملء الشاشة */
    #mainContent {
        padding: 10px 15px; /* (*** تعديل ***) إزالة الهامش السفلي من هنا */
        
        /* إزالة المسافة الكبيرة بين الأقسام */
        justify-content: flex-start; 
        gap: 15px; 
        overflow-y: auto; /* السماح بالتمرير إذا ضاقت الشاشة جداً */
        
        /* (*** تحسين الأداء: عزل التمرير ***) */
        /* نفس مبدأ قائمة التشغيل، نحسن أداء التمرير للمحتوى الرئيسي */
        contain: paint;
        
        /* (تعديل) التأكد من تطبيق المساحات الآمنة هنا أيضاً */
        padding-top: max(10px, env(safe-area-inset-top));
        
        /* (*** تعديل ***) إضافة مساحة سفلية ضخمة لإفساح المجال للشريط الزجاجي */
        /* 160px (ارتفاع الشريط التقريبي على الهاتف) + 10px (هامش) */
        padding-bottom: calc(170px + env(safe-area-inset-bottom));
    }

    #mediaContainer {
        margin-top: 5px; /* تقليل الهامش العلوي */
        margin-bottom: 5px;
    }

    #trackInfo {
        margin-top: 10px; /* تقليل المسافات */
        margin-bottom: 5px;
    }
    
    #trackTitle {
        font-size: 28px; /* تصغير الخط لأسماء الملفات الطويلة */
    }

    #trackArtist {
        font-size: 15px;
    }

    #progressContainer {
        margin: 5px auto;
    }

    /* إخفاء شريط الصوت على الهواتف (الاعتماد على أزرار الجهاز) */
    #volumeContainer {
        display: none;
    }
    
    /* جعل الأزرار تملأ المساحة المتاحة بشكل أفضل */
    #secondaryControls {
        max-width: 100%;
        justify-content: space-between; /* توزيع الأزرار على كامل العرض */
        padding: 0 10px; /* إضافة هوامش جانبية */
        box-sizing: border-box;
    }

    /* تكبير أهداف اللمس للأزرار */
    .secondary-btn {
        font-size: 26px; /* أكبر قليلاً */
    }

    #controls {
        gap: 15px; /* تقليل المسافة بين مجموعتي الأزرار */
        padding: 0;
    }
    
    #mainControls {
        gap: 25px; /* تقريب الأزرار الرئيسية */
    }
    
    .main-ctrl-btn {
        font-size: 36px; /* تكبير أزرار السابق/التالي */
    }
    
    #playPauseBtn {
        width: 70px; /* الحفاظ على الحجم الكبير */
        height: 70px;
    }
}

/* =======================================================
   8. (*** تعديل ***) أنماط المعادل الصوتي الاحترافي
   ======================================================= */
#eqMode {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
    padding: 10px;
    width: 100%;
    max-width: 500px; /* (*** تعديل ***) زيادة العرض قليلاً */
    margin: auto;
    justify-content: center;
    gap: 15px; /* (*** إضافة ***) مسافة بين العناصر */

    /* (*** إضافة ***) حركة للمحتوى الداخلي */
    animation: contentFadeIn 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) 0.1s;
    animation-fill-mode: backwards;
    will-change: transform, opacity;
}

/* (*** إضافة ***) تنسيق قائمة الإعدادات المسبقة */
#eqPresets {
    width: 100%;
    max-width: 400px;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--surface-color);
    background: #2a2a2a;
    color: var(--text-color-primary);
    font-size: 16px;
    align-self: center;
    font-family: 'Tajawal', sans-serif;
    cursor: pointer;
}
#eqPresets:focus {
    border-color: var(--accent-color);
    outline: 2px solid var(--accent-color-light);
}

#eqContainer {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 15px; /* (*** تعديل ***) زيادة المسافة */
    padding: 20px 15px; /* (*** تعديل ***) */
    background: var(--surface-color);
    border-radius: 15px;
    height: 250px; 
    overflow-x: auto; /* (*** إضافة ***) للسماح بالتمرير على شاشات ضيقة جداً */
    
    /* (*** تحسين الأداء ***) */
    /* تحسين التمرير الأفقي */
    contain: paint;
}

.eq-band {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: center;
    gap: 10px;
    flex-grow: 1;
    min-width: 35px; /* (*** إضافة ***) حد أدنى للعرض */
}
/* (*** إضافة ***) تنسيق خاص للمضخم الأولي */
#preamp-band {
    border-right: 2px solid #333;
    padding-right: 15px;
}

.eq-band label {
    font-size: 12px;
    color: var(--text-color-secondary);
    white-space: nowrap;
}

.eq-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 8px; /* (*** تعديل ***) عرض الشريط الفعلي */
    height: 180px; /* (*** تعديل ***) ارتفاع الشريط الفعلي */
    background: #121212;
    border-radius: 5px;
    outline: none;
    cursor: pointer;
    
    /* (*** تعديل: الطريقة الاحترافية للعمودي ***) */
    -webkit-appearance: slider-vertical;
    appearance: slider-vertical;
    
    /* (*** تعديل: إزالة الخصائص القديمة ***) */
    /* writing-mode: bt-lr; */
    /* transform: rotate(180deg); */
    /* width: 180px; */
    /* margin-bottom: 20px; */
}

/* (*** إضافة ***) لون مختلف لمقبض المضخم الأولي */
#preampSlider::-webkit-slider-thumb {
     background: #2196F3; /* لون أزرق */
     border-color: #1a1a1a;
}
#preampSlider::-moz-range-thumb {
    background: #2196F3;
    border-color: #1a1a1a;
}


/* تخصيص المقبض (Thumb) للـ Slider */
.eq-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent-color);
    border-radius: 50%;
    border: 3px solid var(--bg-color);
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
    cursor: pointer;
    
    /* (*** تعديل: إزالة الخصائص القديمة ***) */
    /* transform: rotate(180deg); */
    /* writing-mode: horizontal-tb; */
}

.eq-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--accent-color);
    border-radius: 50%;
    border: 3px solid var(--bg-color);
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
    cursor: pointer;
}

/* (*** إضافة: أنماط لشريط التمرير ***) */
/* تخصيص شريط التمرير في قائمة التشغيل ليتناسب مع التصميم الداكن */
#playlist::-webkit-scrollbar {
    width: 8px;
}
#playlist::-webkit-scrollbar-track {
    background: transparent;
    margin: 10px 0;
}
#playlist::-webkit-scrollbar-thumb {
    background-color: var(--surface-color);
    border-radius: 10px;
    border: 2px solid var(--bg-color);
}
#playlist::-webkit-scrollbar-thumb:hover {
    background-color: #333;
}


/* =======================================================
   ... (الأقسام 1 إلى 8 كما هي بدون تغيير) ...
   ======================================================= */

/* =======================================================
   9. (*** تعديل ***) وضع ملء الشاشة المحاكى (عبر :target)
   ======================================================= */

/* (*** إضافة ***) تنسيقات لمجموعات الأزرار الجديدة */
#mediaContainerIcons {
    align-items: center; /* لضمان محاذاة المجموعتين */
}
#mediaIconGroupLeft, #mediaIconGroupRight {
    display: flex;
    gap: 10px; /* مسافة بين الأزرار في كل مجموعة */
}

/* (*** إضافة ***) تنسيق أيقونات SVG الجديدة */
.icon-btn svg {
    stroke: var(--text-color-primary); /* اللون الافتراضي للأيقونة */
    transition: stroke 0.2s;
    vertical-align: middle; /* لمحاذاة الأيقونة وسط الزر */
}
.icon-btn:hover svg {
    stroke: var(--accent-color); /* تغيير اللون عند التمرير */
}


/* --- أنماط :target (ملء الشاشة) --- */

#mediaContainer:target {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-width: none;
    margin: 0;
    border-radius: 0;
    aspect-ratio: auto;
    z-index: 2000; 
    transition: all 0.3s ease;
    
    /* (*** تحسين الأداء: تفعيل تسريع العتاد ***) */
    transform: translateZ(0); 
    will-change: transform;
}

#mediaContainer:target #coverArt,
#mediaContainer:target #audioCanvas,
#mediaContainer:target #defaultIcon {
     width: 100%;
     height: 100%;
     object-fit: contain; 
}

/* =======================================================
   تحسين ظهور الكلمات في وضع ملء الشاشة
   ======================================================= */

#mediaContainer:target #lyricsDisplay {
    /* 1. التأكد من الظهور */
    opacity: 1;

    /* 2. التموضع في المنتصف السفلي */
    position: absolute;
    bottom: 10%; /* رفعها بنسبة 10% من الأسفل لتناسب كل الشاشات */
    left: 50%;   /* نقطة البداية من المنتصف */
    right: auto; /* إلغاء المحاذاة القديمة */
    top: auto;
    
    /* هذه الحركة هي المسؤولة عن التوسيط الدقيق */
    transform: translateX(-50%);

    /* 3. الأبعاد والحجم */
    width: auto;        /* العرض يتناسب مع النص */
    min-width: 60%;     /* أقل عرض ممكن */
    max-width: 90%;     /* أقصى عرض حتى لا تلمس الحواف */
    height: auto;
    max-height: 40vh;   /* أقصى ارتفاع مسموح به */
    
    /* 4. التنسيق الجمالي (الكبسولة) */
    background: rgba(0, 0, 0, 0.7); /* خلفية داكنة أكثر وضوحاً وثابتة */
    /* (*** تحسين الأداء: تعطيل التمويه الثقيل ***) */
    /* backdrop-filter: blur(8px); */     
    /* -webkit-backdrop-filter: blur(8px); */
    border-radius: 30px;            /* حواف دائرية ناعمة */
    padding: 15px 25px;             /* مساحة داخلية للنص */
    border: 1px solid rgba(255, 255, 255, 0.1); /* إطار خفيف جداً */

    /* 5. تنسيق النصوص */
    text-align: center; /* توسيط الكلام */
    color: #ffffff;     /* اللون الأبيض للنص العادي */
    font-size: 22px;    /* حجم خط مريح */
    line-height: 1.6;
    overflow-y: auto;   /* السماح بالتمرير إذا كان النص طويلاً جداً */
    
    /* ظل للنص لضمان القراءة فوق أي صورة */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    
    z-index: 2010;      /* فوق كل العناصر */
}

/* تنسيق السطر الحالي (النشط) في وضع ملء الشاشة */
#mediaContainer:target .highlighted-lyric {
    color: var(--accent-color); /* لون التمييز (وردي/أحمر) */
    font-size: 1.4em;           /* تكبير السطر الحالي */
    font-weight: 800;           /* خط عريض */
    display: block;             /* وضعه في سطر منفصل */
    margin-bottom: 10px;
    
    /* توهج حول النص النشط */
    text-shadow: 0 0 15px var(--accent-color), 0 2px 4px #000;
}

/* --- (*** تعديل ***) إخفاء وإظهار الأزرار الصحيحة --- */

/* 1. إخفاء زر الخروج افتراضيًا */
#fullscreen-exit-btn {
    display: none;
}

/* 2. عند تفعيل ملء الشاشة... */

/* ... إظهار زر الخروج فقط (وتثبيته في الزاوية اليمنى) */
#mediaContainer:target #fullscreen-exit-btn {
    display: flex; 
    position: absolute;
    top: 15px;
    right: 15px; /* (*** تعديل ***) تثبيت في اليمين */
    z-index: 2010; 
}

/* ... إخفاء مجموعات الأزرار العادية */
#mediaContainer:target #mediaIconGroupLeft,
#mediaContainer:target #mediaIconGroupRight {
    display: none; 
}


/* =======================================================
   10. (*** إضافة جديدة ***) الوضع الأفقي للهواتف
   ======================================================= */
@media (orientation: landscape) and (max-height: 600px) {

    #mainContent {
        flex-direction: row; 
        justify-content: center;
        align-items: center;
        gap: 20px;
        padding: 20px; 
        padding-bottom: max(20px, env(safe-area-inset-bottom));
        padding-top: max(20px, env(safe-area-inset-top));
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
        overflow-y: hidden; 
    }

    #topSection {
        flex-grow: 1; 
        flex-basis: 0; 
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        height: 100%; 
        /* --- تعديل: منع دفع العناصر --- */
        min-width: 0; 
        overflow: hidden;
        /* ---------------------------- */
    }

    #mediaContainer {
        width: auto;
        height: calc(100vh - 180px); 
        max-height: 400px; 
        max-width: none;
        margin: 0;
    }
    
    #trackInfo {
        margin-top: 15px;
        margin-bottom: 0;
        /* --- تعديل: تقييد العرض --- */
        width: 100%;
        max-width: 300px;
        /* ----------------------- */
    }

    #bottomSection {
        position: relative; 
        flex-grow: 1.2; 
        flex-basis: 0;
        height: auto; 
        bottom: auto;
        left: auto;
        right: auto;
        border-radius: 20px; 
        box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);
        border-top: none;
        padding: 20px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 20px;
    }

    #progressContainer {
        margin: 0 auto; 
        width: 90%;
    }

    #controls {
        gap: 25px; 
        padding: 0;
    }
}
/* =======================================================
   تحديث: تنسيق أيقونات SVG
   ======================================================= */

/* إزالة الاعتماد على حجم الخط للأيقونات واستخدام الأبعاد */
.secondary-btn, .main-ctrl-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    line-height: 0; /* لمنع مسافات إضافية */
}

/* تنسيق عام لجميع أيقونات SVG داخل الأزرار */
.secondary-btn svg, 
.main-ctrl-btn svg,
#volumeContainer svg {
    width: 24px;
    height: 24px;
    stroke: currentColor; /* يرث لون النص المحدد في الزر */
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke 0.3s ease, transform 0.2s ease;
}

/* تكبير أيقونات التحكم الرئيسية قليلاً */
.main-ctrl-btn svg {
    width: 32px;
    height: 32px;
}

/* تكبير أيقونة التشغيل تحديداً */
#playPauseBtn svg {
    width: 36px;
    height: 36px;
    fill: white; /* تعبئة أيقونة التشغيل باللون الأبيض */
    stroke: white;
}

/* تأثير عند التحويم */
.secondary-btn:hover svg, 
.main-ctrl-btn:hover svg {
    stroke: var(--accent-color);
}

#playPauseBtn:hover svg {
    stroke: #eee;
}

/* إصلاح زر الصوت */
#volumeBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
}

/* =======================================================
   تحديث: تنسيق الكلمات غير المتزامنة (Static Lyrics)
   ======================================================= */

/* كلاس سيتم إضافته للجافاسكريبت عند اكتشاف كلمات بدون توقيت */
.static-lyrics-content {
    display: block;
    width: 100%;
    height: 100%;
    overflow-y: auto; /* السماح بالتمرير */
    text-align: center;
    padding: 10px;
    box-sizing: border-box;
    
    /* تحسين شكل شريط التمرير */
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) transparent;
}

.static-lyrics-content p {
    margin: 10px 0;
    font-size: 18px;
    color: var(--text-color-primary);
    opacity: 0.8;
    line-height: 1.8;
    transition: color 0.3s;
}

.static-lyrics-content p:hover {
    color: #fff;
    opacity: 1;
}

/* في وضع ملء الشاشة، نحتاج لتنسيق مختلف قليلاً */
#mediaContainer:target .static-lyrics-content {
    font-size: 24px;
    line-height: 2;
    padding: 20px;
}

/* =======================================================
   11. قائمة السياق (Context Menu) عند الضغط المطول
   ======================================================= */

.context-menu {
    position: fixed;
    background: var(--surface-color);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    display: none;
    width: 280px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: slideUpIn 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
    /* (*** تحسين الأداء: تعطيل التمويه الثقيل ***) */
    /* backdrop-filter: blur(20px); */
    /* -webkit-backdrop-filter: blur(20px); */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.context-menu.show {
    display: block;
}

.context-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(233, 30, 99, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#contextMenuTitle {
    font-weight: 700;
    color: var(--accent-color);
    font-size: 16px;
}

.context-close-btn {
    background: transparent;
    border: none;
    color: var(--text-color-secondary);
    font-size: 20px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.context-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color-primary);
}

.context-menu-list {
    list-style: none;
    margin: 0;
    padding: 10px 0;
    max-height: 400px;
    overflow-y: auto;
}

.context-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    color: var(--text-color-primary);
    cursor: pointer;
    transition: all 0.2s;
    gap: 15px;
    border-left: 3px solid transparent;

    /* === أضف هذين السطرين === */
    position: relative; /* لضمان عمل الـ z-index */
    z-index: 10;        /* لرفع الأزرار فوق الخلفية الضبابية */
}

.context-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-left: 3px solid var(--accent-color);
}

.context-item:active {
    background: rgba(233, 30, 99, 0.1);
    transform: scale(0.98);
}

.context-icon {
    font-size: 20px;
    width: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.context-text {
    flex: 1;
    font-size: 15px;
    font-weight: 500;
}

.context-item[data-action="delete"] .context-icon {
    color: #ff5252;
}

.context-item[data-action="play"] .context-icon {
    color: #4CAF50;
}

.context-item[data-action="playNext"] .context-icon {
    color: #2196F3;
}

/* تأثير عند الضغط المطول على عنصر في القائمة */
.playlist-item.long-press {
    animation: pulse 0.5s ease;
    background: var(--accent-color-light) !important;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(0.98); }
    100% { transform: scale(1); }
}

/* الظل الخلفي لقائمة السياق */
#contextMenu::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
    /* (*** تحسين الأداء: تعطيل التمويه الثقيل ***) */
    /* backdrop-filter: blur(3px); */
    /* -webkit-backdrop-filter: blur(3px); */
}

/* تحسينات للشاشات الصغيرة */
@media (max-width: 600px) {
    .context-menu {
        width: 90%;
        max-width: 300px;
        border-radius: 12px;
    }
    
    .context-item {
        padding: 12px 16px;
    }
}

/* شريط تمرير أنيق لقائمة السياق */
.context-menu-list::-webkit-scrollbar {
    width: 6px;
}

.context-menu-list::-webkit-scrollbar-track {
    background: transparent;
}

.context-menu-list::-webkit-scrollbar-thumb {
    background: var(--surface-color);
    border-radius: 10px;
}

.context-menu-list::-webkit-scrollbar-thumb:hover {
    background: #333;
}