:root {
    --italy-green: #008C45;
    --italy-red: #CD212A;
    --italy-white: #F4F4F9;
    --dark-bg: #121212;
    --dark-card: #1e1e1e;
    --text-primary: #2c3e50;
    --text-light: #ffffff;
}

body {
    font-family: 'Tajawal', 'Segoe UI', sans-serif; /* أضفت خط تجوال لدعم العربية بشكل أجمل */
    background-color: var(--italy-white);
    margin: 0; padding: 0;
    overflow: hidden; height: 100vh;
    direction: rtl;
}

.logo-area img {
    filter: drop-shadow(0 5px 15px rgba(0,0,0,0.2));
    margin-bottom: 20px;
}

/* === إدارة الشاشات === */
.view {
    display: none; height: 100%; width: 100%;
    position: absolute; top: 0; left: 0;
    background: var(--italy-white);
    overflow-y: auto;
    animation: fadeIn 0.3s ease-in-out;
    padding-bottom: 100px; /* تأكد أن هذا الرقم كافٍ */
    box-sizing: border-box
}
.view.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === صفحة تسجيل الدخول === */
#login-view {
    background:linear-gradient(to bottom, #1DB954 0%, #00BCD4 100%);
    color: white;
    display: none; /* يتم تفعيله بـ JS */
    justify-content: center;
    align-items: center;
}
#login-view.active { display: flex; }
.login-card { text-align: center; width: 90%; max-width: 500px; }
.login-card input {
    width: 100%; padding: 15px; margin: 10px 0;
    border-radius: 25px; border: none; text-align: center;
    box-sizing: border-box;
}
.login-card button {
    width: 100%; padding: 15px; background: var(--italy-green);
    color: white; border: none; border-radius: 25px; cursor: pointer; font-size: 16px;
    font-weight: bold;
}

button#loop-btn {
    font-family: 'Tajawal', 'Segoe UI', sans-serif;
}



/* === الصفحة الرئيسية === */
.italy-bar { display: flex; height: 6px; width: 100%; position: fixed; top: 0; z-index: 100; }
.italy-bar div { flex: 1; }
.green-stripe { background: var(--italy-green); }
.white-stripe { background: #fff; }
.red-stripe { background: var(--italy-red); }

.home-header { padding: 40px 25px 20px; background: white; border-radius: 0 0 30px 30px; box-shadow: 0 4px 15px rgba(0,0,0,0.03); }
.welcome-text h1 { margin: 0; font-size: 28px; color: var(--text-primary); }
.sub-welcome { color: var(--italy-green); font-weight: bold; font-size: 14px; display: block; margin-bottom: 5px; }

.grid-menu { padding: 25px; display: flex; flex-direction: column; gap: 20px; }
.card {
    background: white; padding: 20px; border-radius: 20px;
    display: flex; align-items: center; gap: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05); cursor: pointer;
    transition: transform 0.2s;
}
.card:active { transform: scale(0.98); }
.card-green { border-right: 5px solid var(--italy-green); }
.card-red { border-right: 5px solid var(--italy-red); }
.card-mixed { border-right: 5px solid var(--text-primary); }
.card-icon { width: 50px; height: 50px; border-radius: 15px; background: #f5f5f5; display: flex; justify-content: center; align-items: center; font-size: 24px; }
.card-info h3 { margin: 0; font-size: 18px; color: var(--text-primary); }
.card-info p { margin: 5px 0 0; font-size: 13px; color: #7f8c8d; }

/* === القوائم وزر الرجوع الأحمر === */
.sub-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px; background: white; box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.sub-header h2 { margin: 0; font-size: 20px; }

.btn-back-red {
    background-color: var(--italy-red);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(205, 33, 42, 0.3);
    transition: transform 0.2s;
}
.btn-back-red:active { transform: scale(0.95); }

.list-item {
    background: white; padding: 18px; margin: 15px 20px;
    border-radius: 15px; display: flex; justify-content: space-between;
    cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* === المشغل الصوتي (التصميم الكامل والمصحح) === */
#player-view {
    /* تدرج لوني احترافي: أخضر عميق -> أسود هادئ -> أحمر قاني */
    background: linear-gradient(to bottom, #1DB954 0%, #00BCD4 100%);
    color: var(--text-light);
    display: none;
    flex-direction: column;
}
#player-view.active { display: flex; }

.player-container {
    padding: 20px;
    height: 100%;
    display: flex; flex-direction: column; justify-content: space-evenly;
    box-sizing: border-box;
    /* طبقة شفافة خفيفة لجعل النصوص أوضح فوق التدرج */
    background: rgba(0,0,0,0.2); 
}

/* 1. رأس المشغل */
.player-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 10px;
}
.player-header span { font-size: 16px; font-weight: bold; color: #ccc; }

/* 2. القرص (غلاف الألبوم) */
/* تنسيق القرص الدوار */
.disk-area {
    width: 220px; 
    height: 220px;
    background: linear-gradient(145deg, #1e1e1e, #2a2a2a);
    border-radius: 50%;
    margin: 0 auto;
    
    /* التمركز (Flexbox) - نكتبها مرة واحدة فقط */
    display: flex; 
    justify-content: center; 
    align-items: center;
    
    /* الظل والحدود */
    box-shadow: 0 15px 35px rgba(0,0,0,0.5);
    border: 5px solid #333;
    
    /* لضمان أن الصورة لا تخرج عن الدائرة */
    overflow: hidden; 
    
    /* إعدادات الحركة (الدوران) */
    animation: rotateDisk 20s linear infinite;
    animation-play-state: paused; /* متوقف افتراضياً */
}

/* عندما نضيف كلاس .playing للأب، يدور القرص */
.player-container.playing .disk-area { 
    animation-play-state: running; 
}

/* تنسيق اللوجو داخل القرص */
.disk-logo {
    width: 100%;  /* حجم مناسب ليبقى هامش من الحواف */
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 5px 10px rgba(0,0,0,0.5)); /* ظل للصورة نفسها */
    pointer-events: none; /* لمنع سحب الصورة بالخطأ */
}

/* تعريف حركة الدوران (مهم جداً أن يكون موجوداً) */
@keyframes rotateDisk {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* 3. معلومات الدرس */
.track-info { text-align: center; margin-top: 10px; }
.track-info h2 { margin: 0; font-size: 22px; color: white; }
.track-info p { color: #aaa; margin-top: 5px; font-size: 14px; }

/* 4. شريط التقدم */
.progress-area { width: 100%; margin: 15px 0; }
input[type=range] {
    width: 100%; accent-color: var(--italy-green);
    cursor: pointer; margin-bottom: 5px;
}
.time-stamps { display: flex; justify-content: space-between; font-size: 12px; color: #ccc; }

/* 5. أزرار التحكم النصية */
.text-controls {
    display: flex; justify-content: center; align-items: center; gap: 15px;
    margin-bottom: 20px;
}

.text-controls button {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    font-size: 16px;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.text-controls button:active { transform: scale(0.95); background: rgba(255,255,255,0.2); }

/* زر التشغيل الرئيسي المميز */
.text-controls .main-text-btn {
    background: var(--italy-green);
    border: none;
    font-weight: bold;
    padding: 15px 35px;
    font-size: 18px;
    box-shadow: 0 5px 15px rgba(0, 140, 69, 0.4);
}

/* 6. الأزرار الإضافية (أسفل) */
.extra-controls { display: flex; justify-content: space-between; padding: 0 10px; }
.secondary-btn {
    background: rgba(255,255,255,0.1);
    color: white; border: none; padding: 10px 20px;
    border-radius: 6px; font-size: 14px; cursor: pointer;
    font-family: 'Tajawal', 'Segoe UI', sans-serif;
}
.active-loop { background: var(--italy-green) !important; color: white; }

/* === القائمة المنبثقة === */
.playlist-drawer {
    position: fixed; bottom: 0; left: 0; width: 100%; height: 70%;
    background: #1e1e1e; border-radius: 25px 25px 0 0;
    transform: translateY(110%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.6);
    z-index: 300; display: flex; flex-direction: column;
}
.playlist-drawer.open { transform: translateY(0); }

.drawer-header {
    padding: 15px 20px;
    background: #2a2a2a;
    border-radius: 25px 25px 0 0;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid #333;
}
.drawer-header h3 { margin: 0; color: white; font-size: 16px; }

.close-drawer-btn {
    background: var(--italy-red);
    color: white; border: none;
    padding: 5px 15px; border-radius: 15px;
    font-size: 12px; cursor: pointer;
    font-family: 'Tajawal', 'Segoe UI', sans-serif;
}

#playlist-items {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.playlist-track {
    padding: 15px; border-bottom: 1px solid #333; cursor: pointer;
    color: #ccc;
}
.playlist-track.current { color: var(--italy-green); font-weight: bold; background: rgba(0,140,69,0.1); border-radius: 10px; }

/* === تصميم الفوتر (الشريط السفلي) === */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-evenly; /* توزيع متساوي */
    align-items: center;
    padding: 10px 0;
    z-index: 150;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.05);
}

.footer-link {
    text-decoration: none;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 12px;
    font-weight: bold;
    flex: 1; /* يأخذ مساحة متساوية */
    transition: transform 0.2s;
}

.footer-link:active { transform: scale(0.95); }

/* تنسيق صور الأيقونات (واتساب وتيك توك) */
.footer-img {
    width: 28px;  /* حجم مناسب للأيقونة */
    height: 28px;
    margin-bottom: 4px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1)); /* ظل خفيف للأيقونة */
}

/* الخط الفاصل في الوسط */
.footer-divider {
    width: 1px;       /* سمك الخط */
    height: 35px;     /* طول الخط */
    background-color: #ddd; /* لون رمادي فاتح */
    border-radius: 5px;
}

/* عندما يكون المشغل نشطاً (active)، ابحث عن الفوتر وقم بإخفائه */
#player-view.active ~ .app-footer {
    display: none !important;
}

/* حل بديل: رفع المشغل ليكون فوق الفوتر تماماً */
#player-view {
    z-index: 2000 !important; /* رقم عالي جداً ليكون فوق كل شيء */
    padding-bottom: 0 !important; /* إزالة المسافة السفلية في المشغل */
}


/* === زر التحديث الذكي === */
.update-area {
    text-align: center;
    margin-top: 30px;
    padding-bottom: 20px; /* مسافة للفوتر */
}

.update-btn {
    background: white;
    border: 2px solid var(--italy-green);
    color: var(--italy-green);
    padding: 10px 25px;
    border-radius: 15px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    transition: all 0.2s;
    width: 80%;
    max-width: 250px;
    font-family: Tajawal, 'Segoe UI', sans-serif;
}

.update-btn:active {
    background: var(--italy-green);
    color: white;
    transform: scale(0.95);
}