/* ============================ */
/* 1. الحاوية الرئيسية والتنسيق العام */
/* ============================ */
#cf-main-wrapper {
    max-width: 600px;
    margin: 30px auto;
    padding: 20px;
    background: #ffffff;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    direction: rtl; /* لضمان ظهور العربية بشكل صحيح */
    text-align: center;
}

.hidden-view { display: none !important; }

/* ============================ */
/* 2. شاشة الاختيار (Systems Grid) */
/* ============================ */
.systems-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.system-card {
    background: #f8f9fa;
    border: 2px solid #eee;
    padding: 15px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.system-card:hover { border-color: #3498db; background: #eef7ff; }

.system-card input { margin-bottom: 10px; transform: scale(1.3); }

.start-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 15px 40px;
    border-radius: 30px;
    font-size: 1.1em;
    cursor: pointer;
    width: 100%;
    font-weight: bold;
}

/* ============================ */
/* 3. تصميم البطاقة (The Flashcard) */
/* ============================ */
.flashcard-container {
    perspective: 1000px;
    width: 100%;
    height: 280px;
    margin: 25px 0;
}

.flashcard {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flashcard-container.flipped .flashcard {
    transform: rotateY(180deg);
}

.front, .back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    border-radius: 15px;
    font-size: 1.3em;
    font-weight: 500;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    border: 1px solid #eee;
    box-sizing: border-box;
}

.front { background: #ffffff; color: #2c3e50; }
.back { 
    background: #fdfdfd; 
    color: #16a085; 
    transform: rotateY(180deg);
    border-top: 5px solid #16a085;
}

/* ============================ */
/* 4. الأزرار والتحكم */
/* ============================ */
.rating-controls, .nav-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.rate-btn, #prev-btn, #next-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: opacity 0.2s;
}

.difficult { background: #e74c3c; color: white; }
.easy { background: #2ecc71; color: white; }
#prev-btn, #next-btn { background: #95a5a6; color: white; }

.review-btn {
    background: #f39c12;
    color: white;
    border: none;
    padding: 10px;
    width: 100%;
    border-radius: 8px;
    margin-top: 10px;
    cursor: pointer;
}

/* ============================ */
/* 5. شريط التحميل (Loader) */
/* ============================ */
#loader-container {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex; justify-content: center; align-items: center;
    z-index: 9999;
}

.spinner {
    width: 50px; height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
/* حافظ على الكود القديم كما هو وأضف/عدل الأجزاء التالية فقط */

/* 1. عداد البطاقات (رقم البطاقة من الإجمالي) */
.card-status {
    font-size: 0.9em;
    color: #7f8c8d;
    margin-bottom: 10px;
    font-weight: bold;
}

/* 2. شاشة النهاية (End View) */
#end-view {
    padding: 40px 20px;
}

#end-view h2 {
    color: #27ae60;
    margin-bottom: 15px;
}

.restart-btn {
    background: #34495e;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    cursor: pointer;
    margin-top: 20px;
    transition: background 0.3s;
}

.restart-btn:hover {
    background: #2c3e50;
}

/* 3. تحسين شريط التقدم داخل الـ Loader */
.progress-bar-bg {
    background: #eee;
    border-radius: 10px;
    height: 8px;
    width: 200px;
    margin: 10px auto;
    overflow: hidden;
}

#loader-progress {
    width: 0%;
    height: 100%;
    background: #3498db;
    transition: width 0.4s ease;
}

/* 4. جعل النصوص داخل البطاقات قابلة للقراءة بشكل أفضل */
.front, .back {
    line-height: 1.6;
    overflow-y: auto; /* للسماح بالتمرير إذا كان السؤال طويلاً جداً */
}
#end-view .review-btn {
    background: #f39c12;
    color: white;
    padding: 15px 30px;
    font-size: 1.1em;
    border-radius: 30px;
    margin-bottom: 10px;
    display: block;
    width: 100%;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.3);
}

#end-view .review-btn:hover {
    background: #e67e22;
}

#cf-main-wrapper { position: relative; min-height: 400px; }
.hidden-view { display: none !important; opacity: 0; visibility: hidden; }
#flashcard-view, #end-view { width: 100%; }
