/* style.css - الإصدار النهائي والمراجع (مع زر النطق و YG) */

/* --- استيراد خط Poppins من Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* --- متغيرات الألوان الرئيسية --- */
:root {
    --background-start: #0f0c29;
    --background-mid: #302b63;
    --background-end: #24243e;
    --glass-bg: rgba(30, 30, 50, 0.45);
    --glass-border: rgba(255, 255, 255, 0.15);
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0c0;
    --accent-primary: #a855f7; /* بنفسجي Tailwind 500 */
    --accent-secondary: #9333ea; /* بنفسجي Tailwind 600 */
    --accent-glow: rgba(168, 85, 247, 0.35);
    --success-color: #2ecc71;
    --error-color: #e74c3c;
    --warning-color: #f39c12;
    --info-color: #3498db; /* أزرق للمساعدة */
    --youglish-color: #dc3545; /* أحمر YouGlish */
    --button-hover-brightness: 1.1;
    --disabled-opacity: 0.5;

    /* متغيرات RGB للألوان للاستخدام في الظل */
    --accent-primary-rgb: 168, 85, 247;
    --success-rgb: 46, 204, 113;
    --info-rgb: 52, 152, 219;
    --warning-rgb: 243, 156, 18;
    --error-rgb: 231, 76, 60;
    --grey-rgb: 108, 117, 125;
    --youglish-rgb: 220, 53, 69;
}

/* --- الإعدادات العامة --- */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.7;
    margin: 0; padding: 0;
    background: linear-gradient(145deg, var(--background-start), var(--background-mid), var(--background-end));
    background-attachment: fixed;
    color: var(--text-primary);
    direction: rtl;
    display: flex; flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden; position: relative;
}

/* --- النجوم --- */
body::before {
    content: ''; position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; height: 100%; z-index: -1;
    background-image:
        radial-gradient(1px 1px at 20px 30px, #eee, rgba(0,0,0,0)),
        radial-gradient(1px 1px at 40px 70px, #fff, rgba(0,0,0,0)),
        radial-gradient(1px 1px at 50px 160px, #ddd, rgba(0,0,0,0)),
        radial-gradient(1.5px 1.5px at 90px 40px, #fff, rgba(0,0,0,0)),
        radial-gradient(1px 1px at 130px 80px, #fff, rgba(0,0,0,0)),
        radial-gradient(1.2px 1.2px at 160px 120px, #ddd, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 25% 25%, #fff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 55% 45%, #eee, rgba(0,0,0,0)),
        radial-gradient(2.5px 2.5px at 75% 65%, #fff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 85% 15%, #ddd, rgba(0,0,0,0)),
        radial-gradient(2.5px 2.5px at 15% 80%, #fff, rgba(0,0,0,0));
    background-repeat: repeat;
    background-size: 200px 200px, 200px 200px, 200px 200px, 200px 200px, 200px 200px, 200px 200px, 400px 400px, 400px 400px, 400px 400px, 400px 400px, 400px 400px;
    opacity: 0.5;
}

/* --- الهيدر --- */
header {
    background: rgba(15, 12, 41, 0.4); padding: 15px 30px; text-align: center;
    border-bottom: 1px solid var(--glass-border); backdrop-filter: blur(10px);
    position: sticky; top: 0; z-index: 10;
}
header h1 { margin: 0 0 5px 0; font-size: 1.8em; font-weight: 600; color: #ffffff; text-shadow: 0 0 10px rgba(255, 255, 255, 0.4); }
header p { margin: 0; color: var(--text-secondary); font-size: 0.9em; font-weight: 400; }

/* --- جعل العنوان الرئيسي قابلاً للنقر --- */
header h1#main-title {
    cursor: pointer; /* تغيير شكل المؤشر إلى يد */
    transition: color 0.2s ease, text-shadow 0.2s ease; /* انتقال ناعم للتأثير */
}

header h1#main-title:hover {
    color: var(--accent-primary); /* تغيير اللون عند المرور (اختياري) */
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.5); /* زيادة التوهج عند المرور (اختياري) */
}

/* --- الحاوية الرئيسية (تأثير الزجاج) --- */
main {
    flex-grow: 1; max-width: 800px; width: 90%; margin: 30px auto 40px auto;
    background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: 18px;
    box-shadow: 0 10px 35px 0 rgba(0, 0, 0, 0.35); backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px); padding: 30px;
}

/* --- تنسيق الأقسام الداخلية والانتقالات --- */
/* الحالة الظاهرة (الافتراضية) */
#article-selection,
#translation-area,
#completion-message,
#feedback-container,
#correct-translation-container,
#hint-list {
    margin-bottom: 30px; /* هوامش افتراضية للظاهر */
    padding: 25px; /* حشو افتراضي */
    border-width: 1px; /* إطار افتراضي (لـ feedback/correct) */
    border-style: solid;
    border-color: transparent; /* إطار شفاف مبدئياً */
    border-radius: 12px;
    background-color: rgba(15, 12, 41, 0.45);
    opacity: 1;
    visibility: visible;
    max-height: 2000px; /* قيمة كبيرة للسماح بالمحتوى */
    overflow: hidden; /* إخفاء المحتوى الزائد أثناء الانتقال */
    transition: opacity 0.4s ease-out, max-height 0.5s ease-out, padding 0.4s ease-out, margin 0.4s ease-out, border-width 0.4s step-end, visibility 0s linear;
}
/* تعديلات خاصة ببعض الأقسام */
#feedback-container { padding: 15px; background-color: rgba(15, 12, 41, 0.35); border-color: var(--glass-border); }
#correct-translation-container { padding: 15px 0 0 0; margin-top: 15px; border-top: 1px solid var(--glass-border); border-right: none; border-left: none; border-bottom: none; background: none; }
#hint-list { list-style: none; padding: 15px 0 0 0; margin-top: 15px; border-top: 1px dashed var(--glass-border); background: none; }
#completion-message { text-align: center; background-color: rgba(46, 204, 113, 0.15); }

/* حالة الإخفاء (.hidden) */
#article-selection.hidden,
#translation-area.hidden,
#completion-message.hidden,
#feedback-container.hidden,
#correct-translation-container.hidden,
#hint-list.hidden {
    opacity: 0;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    margin-bottom: 0;
    border-width: 0;
    visibility: hidden;
    transition: opacity 0.4s ease-out, max-height 0.5s ease-out, padding 0.4s ease-out, margin 0.4s ease-out, border-width 0.4s step-start, visibility 0s linear 0.5s; /* تأخير إخفاء visibility */
}

/* تنسيق رسالة الإكمال */
#completion-message h2 { color: var(--success-color); text-shadow: 0 0 5px var(--success-color); }

/* العناوين */
h2, h3, h4, h5 { color: #ffffff; margin-top: 0; margin-bottom: 15px; font-weight: 500; }
h4 { color: var(--text-secondary); margin-bottom: 8px; font-weight: 400; font-size: 0.9em; }
h5 { color: var(--text-primary); margin-bottom: 6px; font-weight: 500; font-size: 0.9em; text-transform: uppercase; letter-spacing: 0.5px; } /* تعديل H5 */
#article-title { color: var(--accent-primary); font-weight: 600; font-size: 1.25em; border-bottom: 1px solid var(--glass-border); padding-bottom: 12px; margin-bottom: 25px; }
#original-paragraph-container p { background: rgba(0,0,0, 0.3); padding: 15px; border-radius: 8px; color: var(--text-primary); font-size: 1.0em; line-height: 1.8; }

/* --- الأزرار --- */
button {
    background: linear-gradient(135deg, var(--accent-secondary), var(--accent-primary));
    color: white; padding: 10px 20px; border: none; border-radius: 8px;
    cursor: pointer; margin: 5px; font-size: 0.9em; font-weight: 500; font-family: inherit;
    letter-spacing: 0.3px; transition: all 0.2s ease; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}
button:hover {
    filter: brightness(var(--button-hover-brightness));
    box-shadow: 0 5px 12px rgba(var(--accent-primary-rgb), 0.3);
    transform: translateY(-1px);
}
button:active { transform: translateY(0px); filter: brightness(0.95); box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3); }
/* تخصيص ألوان وظلال الأزرار */
#check-button { background: linear-gradient(135deg, #16a085, var(--success-color)); }
#check-button:hover { box-shadow: 0 5px 12px rgba(var(--success-rgb), 0.3); }
#hint-button { background: linear-gradient(135deg, #2980b9, var(--info-color)); }
#hint-button:hover { box-shadow: 0 5px 12px rgba(var(--info-rgb), 0.3); }
#next-paragraph-button { background: linear-gradient(135deg, var(--accent-secondary), var(--accent-primary)); }
#next-paragraph-button:hover { box-shadow: 0 5px 12px rgba(var(--accent-primary-rgb), 0.3); }
#prev-paragraph-button { background: linear-gradient(135deg, #6c757d, #adb5bd); }
#prev-paragraph-button:hover { box-shadow: 0 5px 12px rgba(var(--grey-rgb), 0.3); }
#select-another-article-button { background: linear-gradient(135deg, #c0392b, var(--error-color)); }
#select-another-article-button:hover { box-shadow: 0 5px 12px rgba(var(--error-rgb), 0.3); }

/* --- حقول الإدخال والقوائم --- */
select, textarea {
    width: calc(100% - 10px); padding: 12px 15px; margin: 0 5px 20px 5px;
    border: 1px solid var(--glass-border); border-radius: 8px;
    font-size: 1em; font-family: inherit; background-color: rgba(15, 12, 41, 0.55);
    color: var(--text-primary); box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
}
select:focus, textarea:focus {
    border-color: var(--accent-primary); outline: none;
    box-shadow: 0 0 0 3px var(--accent-glow), inset 0 1px 3px rgba(0,0,0,0.3);
    background-color: rgba(15, 12, 41, 0.65);
}
select option { background-color: #1e1e30; color: var(--text-primary); }
textarea { resize: vertical; min-height: 110px; }

/* --- منطقة النتيجة والمساعدة --- */
#feedback-container { /* انتقالات الإظهار والإخفاء موجودة في الكود العام أعلاه */ }
#feedback-message { font-weight: 500; margin-bottom: 10px; white-space: pre-wrap; font-size: 1.0em; }
.feedback-summary { display: flex; align-items: center; margin-bottom: 10px; }
.feedback-icon { margin-left: 10px; font-size: 1.2em; line-height: 1; }

/* --- تنسيق قسم المصطلحات المفقودة (مُحسّن للمسافات) --- */
.missed-terms-section {
    margin-top: 12px; /* تقليل المسافة فوق القسم */
    padding-top: 8px; /* تقليل الحشو العلوي */
    border-top: 1px dashed var(--glass-border);
}

.missed-terms-section p { /* تنسيق العنوان "مصطلحات لم تظهر..." */
    margin-bottom: 6px; /* تقليل المسافة تحت العنوان */
    font-weight: 500;
    font-size: 0.85em; /* تصغير الخط قليلاً */
    color: var(--text-secondary);
}

.missed-terms-list {
    list-style: none;
    padding: 6px 10px 6px 0; /* تعديل الحشو الداخلي (يمين وصفر للباقي) */
    margin: 0;
    font-size: 0.85em; /* تصغير خط المصطلحات */
    max-height: 120px; /* تقليل الارتفاع الأقصى قليلاً */
    overflow-y: auto;
    background-color: rgba(0, 0, 0, 0.2); /* زيادة طفيفة في عتامة الخلفية للتمييز */
    border-radius: 5px; /* تقليل الدائرية قليلاً */
}

.missed-terms-list li {
    margin-bottom: 4px; /* تقليل المسافة بين عناصر القائمة بشكل كبير */
    color: var(--text-secondary);
    padding: 2px 0; /* إضافة حشو رأسي بسيط جداً */
}
.missed-terms-list li:last-child {
     margin-bottom: 0; /* إزالة الهامش السفلي لآخر عنصر */
}

.missed-terms-list strong {
    color: var(--text-primary);
    font-weight: 500;
}

/* تنسيق حاوية الترجمة الصحيحة */
#correct-translation-container { /* انتقالات الإظهار والإخفاء موجودة في الكود العام أعلاه */ }
#correct-translation-container h5 { /* تم تعديل H5 أعلاه */ }
#correct-translation-container p { background-color: rgba(0, 0, 0, 0.35); padding: 12px; border-radius: 6px; border: 1px solid var(--glass-border); font-size: 1.05em; line-height: 1.8; color: #ffffff; }

/* تنسيق قائمة المساعدة (مع زر النطق و YG) */
#hint-list { /* انتقالات الإظهار والإخفاء موجودة في الكود العام أعلاه */ }
#hint-list li {
    background-color: rgba(52, 152, 219, 0.1); padding: 8px 12px; margin-bottom: 6px;
    border-radius: 6px; border: 1px solid rgba(52, 152, 219, 0.2);
    font-size: 0.9em; color: var(--text-primary);
    display: flex; justify-content: flex-start; align-items: center;
    transition: background-color 0.2s ease;
}
#hint-list li:hover { background-color: rgba(52, 152, 219, 0.2); }

/* --- تنسيق زر Reverso Context --- */
.reverso-button {
    background: none;        /* <<< إزالة الخلفية */
    border: none;           /* <<< إزالة الإطار */
    padding: 0 4px;         /* <<< تقليل الحشو جداً (يمين ويسار فقط) */
    margin: 0;              /* إزالة الهوامش الافتراضية للزر */
    margin-left: 8px;       /* مسافة بين الأزرار أو عن النص */
    cursor: pointer;
    opacity: 0.75;          /* شفافية مبدئية */
    transition: opacity 0.2s ease, transform 0.2s ease;
    font-size: 1.5em;       /* <<< حجم كبير للإيموجي */
    line-height: 1;         /* لضبط المحاذاة */
    vertical-align: middle;
    color: inherit;         /* لوراثة اللون (غير ضروري للإيموجي غالباً) */
    box-shadow: none;       /* <<< إزالة أي ظل */
}


/* تعديل ترتيب الأزرار في قائمة المساعدة */
#hint-list li {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.reverso-button { order: 1; /* Reverso أولاً */ }
.youglish-button { order: 2; /* YG ثانياً */ }
/* .speak-term-button { order: 3; } /* زر النطق (إذا كان موجوداً) */ */
#hint-list li span { order: 4; /* النص أخيراً */ margin-right: auto; text-align: right; }

/* --- تنسيق زر YouGlish */
.youglish-button {
    background: none;        /* <<< إزالة الخلفية */
    border: none;           /* <<< إزالة الإطار */
    padding: 0 4px;         /* <<< تقليل الحشو جداً (يمين ويسار فقط) */
    margin: 0;              /* إزالة الهوامش الافتراضية للزر */
    margin-left: 8px;       /* مسافة بين الأزرار أو عن النص */
    cursor: pointer;
    opacity: 0.75;          /* شفافية مبدئية */
    transition: opacity 0.2s ease, transform 0.2s ease;
    font-size: 1.5em;       /* <<< حجم كبير للإيموجي */
    line-height: 1;         /* لضبط المحاذاة */
    vertical-align: middle;
    color: inherit;    
    box-shadow: none;       /* <<< إزالة أي ظل */     /* لوراثة اللون (غير ضروري للإيموجي غالباً) */

}
/* --- تنسيق زر النطق (موجود لكن وظيفته معطلة في JS) --- */
.speak-term-button {
    background: none; border: none;
    color: var(--info-color); cursor: pointer;
    font-size: 1.4em; padding: 0;
    margin-left: 8px; /* مسافة عن النص */ margin-right: 0;
    opacity: 0.7; transition: all 0.2s ease;
    line-height: 1; display: inline-flex; align-items: center;
    order: 3; /* يظهر بعد YG */
}
.speak-term-button:hover { opacity: 1; color: #87CEEB; transform: scale(1.1); }

/* تنسيق النص بجانب الأزرار */
#hint-list li span {
    order: 4; /* يظهر أخيراً */
    margin-right: auto; /* يأخذ المساحة المتبقية */
    text-align: right;
}

/* --- الفوتر --- */
footer { margin-top: 40px; padding: 15px; text-align: center; font-size: 0.8em; color: var(--text-secondary); background-color: rgba(15, 12, 41, 0.3); border-top: 1px solid var(--glass-border); }

/* --- كلاس لتعطيل الزر --- */
button.disabled,
#prev-paragraph-button.disabled {
    background: #495057 !important; cursor: not-allowed;
    box-shadow: none !important; transform: none !important;
    opacity: var(--disabled-opacity) !important;
    filter: grayscale(60%) !important;
}

/* كلاس الإخفاء النهائي (لـ JS إذا لزم الأمر للتحكم بـ display:none) */
.force-hidden {
    display: none !important;
}