/* =========================================
   تنسيق الأدوات (Tools Page) - محدث للدارك مود 🌑
   ========================================= */

/* توحيد الخط لكل عناصر الأدوات */
button, 
input, 
select, 
textarea, 
label,
.tab-item {
    font-family: 'Tajawal', sans-serif !important;
}

/* الأزرار العريضة */
.calc-btn, 
.app-btn, 
.action-btn {
    font-weight: 700 !important;
    letter-spacing: 0.5px;
}

/* =========================================
   تنسيق القائمة الجانبية (تم الاعتماد على style.css الرئيسي)
   لكن نحتاج هنا التعديلات الخاصة إذا كانت الصفحة منفصلة
   ========================================= */

/* 1. طبقة التعتيم الخلفية */
#sidebarOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: 0.3s;
}

#sidebarOverlay.active {
    opacity: 1;
    visibility: visible;
}

/* 2. القائمة نفسها */
#sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100%;
    background-color: var(--surface-color) !important; /* يدعم الدارك */
    z-index: 9999;
    transition: left 0.3s ease-in-out;
    box-shadow: 5px 0 15px var(--shadow-color);
    display: flex;
    flex-direction: column;
    padding: 20px;
}

#sidebar.active {
    left: 0;
}

/* 3. محتويات القائمة */
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
}

.close-btn {
    background: var(--bg-color);
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.close-btn:hover {
    background: #ffebeb;
    color: #d93025;
}

[data-theme="dark"] .close-btn:hover {
    background: #4a1b1b;
}

.sidebar-menu { list-style: none; padding: 0; margin: 0; }
.sidebar-menu li { margin-bottom: 8px; }

.sidebar-menu a {
    text-decoration: none;
    color: var(--text-dark);
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    border-radius: 12px;
    transition: 0.2s;
    font-weight: 500;
}

.sidebar-menu a:hover, 
.sidebar-menu a.active {
    background-color: var(--bg-color);
    color: var(--primary-text);
    font-weight: 700;
}

[data-theme="dark"] .sidebar-menu a:hover, 
[data-theme="dark"] .sidebar-menu a.active {
    background-color: rgba(96, 165, 250, 0.15);
}

.sidebar-menu i { font-size: 18px; }

/* =========================================
   شريط التبويبات (Tabs)
   ========================================= */
.tabs-container {
    display: flex;
    overflow-x: auto;
    background: var(--surface-color); /* يدعم الدارك */
    padding: 10px 15px;
    gap: 10px;
    position: sticky;
    top: 60px;
    z-index: 90;
    scrollbar-width: none;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.3s ease;
}

.tabs-container::-webkit-scrollbar { display: none; }

.tab-item {
    white-space: nowrap;
    padding: 8px 16px;
    background: var(--bg-color); /* يدعم الدارك */
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    transition: 0.3s;
    cursor: pointer;
    border: 1px solid transparent; /* تحسين الشكل */
}

/* الدارك مود للتاب */
[data-theme="dark"] .tab-item {
    border: 1px solid var(--border-color);
}

.tab-item.active {
    background: var(--primary-color);
    color: white; /* النص يبقى أبيض حتى في الدارك */
    box-shadow: 0 4px 10px rgba(0, 82, 204, 0.2);
}

/* إدارة عرض المحتوى */
.tool-view {
    display: none;
    padding: 20px;
    animation: fadeIn 0.3s ease-in-out;
}

.tool-view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* لوحة تنبيه "للموقع فقط" */
.desktop-only-notice {
    text-align: center;
    background: var(--surface-color);
    padding: 40px 20px;
    border-radius: 25px;
    box-shadow: 0 10px 30px var(--shadow-color);
    margin-top: 30px;
}

.desktop-only-notice i {
    font-size: 50px;
    color: #ccc;
    margin-bottom: 20px;
}

.desktop-only-notice h3 {
    margin-bottom: 10px;
    color: var(--text-dark);
}

.desktop-only-notice p {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 25px;
    line-height: 1.6;
}

/* Placeholder */
.tool-placeholder {
    text-align: center;
    padding: 50px 0;
    color: #ccc;
}
.tool-placeholder i { font-size: 40px; display: block; margin-bottom: 10px; }

/* =========================================
   تصميم كروت الأدوات والحاسبات
   ========================================= */
.tool-card {
    background: var(--surface-color);
    border-radius: 24px;
    padding: 20px;
    box-shadow: 0 10px 30px var(--shadow-color);
    border: 1px solid transparent;
}

/* إطار خفيف في الدارك مود */
[data-theme="dark"] .tool-card {
    border: 1px solid var(--border-color);
}

.tool-header-info {
    display: flex;
    gap: 10px;
    background: #f0f7ff;
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 20px;
    color: #0052cc;
    font-size: 13px;
    line-height: 1.4;
}

/* لون الهيدر في الدارك مود */
[data-theme="dark"] .tool-header-info {
    background: rgba(96, 165, 250, 0.1);
    color: #60a5fa;
}

/* مجموعات الإدخال */
.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 14px;
    color: var(--text-dark);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper i {
    position: absolute;
    right: 15px;
    color: var(--primary-text);
}

.input-wrapper input {
    width: 100%;
    padding: 15px 45px 15px 15px;
    border: 2px solid var(--bg-color); /* استخدام لون الخلفية كإطار */
    border-radius: 15px;
    font-family: 'Tajawal', sans-serif;
    font-size: 16px;
    transition: 0.3s;
    background: var(--bg-color); /* لون الخلفية */
    color: var(--text-dark);
}

[data-theme="dark"] .input-wrapper input {
    border: 1px solid var(--border-color);
    background: #252525; /* خلفية أغمق شوي من السطح */
}

.input-wrapper input:focus {
    border-color: var(--primary-color);
    outline: none;
    background: var(--surface-color);
}

/* الزر */
.calc-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 15px;
    background: linear-gradient(45deg, #0a0b4d 0%, #007bc4 100%);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
    margin-bottom: 25px;
}

.calc-btn:active { transform: scale(0.98); }

/* =========================================
   شبكة النتائج (Results Grid)
   ========================================= */
.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 25px;
    animation: slideUp 0.4s ease;
}

.result-box {
    padding: 15px;
    border-radius: 18px;
    text-align: center;
    display: flex;
    flex-direction: column;
}

/* تعديل ألوان النتائج لتناسب الدارك مود */
.result-box.safe { 
    background: #e6f4ea; 
    color: #1e7e34; 
}

[data-theme="dark"] .result-box.safe {
    background: rgba(34, 197, 94, 0.15); /* أخضر شفاف */
    color: #4ade80; /* أخضر فاتح */
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.result-box.danger { 
    background: #fce8e8; 
    color: #d93025; 
}

[data-theme="dark"] .result-box.danger {
    background: rgba(239, 68, 68, 0.15); /* أحمر شفاف */
    color: #f87171; /* أحمر فاتح */
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.res-label { font-size: 11px; font-weight: 700; margin-bottom: 5px; opacity: 0.8; }
.res-value { font-size: 24px; font-weight: 900; }
.res-unit { font-size: 11px; font-weight: 600; }

/* إخلاء المسؤولية */
.disclaimer {
    border-top: 1px dashed var(--border-color);
    padding-top: 15px;
}

.disclaimer h4 { 
    font-size: 13px; 
    margin-bottom: 5px; 
    color: var(--text-light); 
    display: flex; 
    align-items: center; 
    gap: 5px; 
}

.disclaimer p { font-size: 11px; color: var(--text-light); line-height: 1.5; margin-bottom: 8px; }

.formula { 
    font-size: 10px; 
    color: var(--text-light); 
    text-align: center; 
    background: var(--bg-color); 
    padding: 5px; 
    border-radius: 5px; 
}
.formula span { color: var(--primary-text); font-weight: bold; }

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   تنسيقات حاسبة المعدل (GPA Calculator)
   ========================================= */
.gpa-inputs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 10px;
}

.gpa-inputs-grid .input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gpa-inputs-grid label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-dark);
}

.gpa-inputs-grid input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--bg-color);
    border-radius: 12px;
    font-family: 'Tajawal', sans-serif;
    font-size: 15px;
    text-align: center;
    transition: 0.3s;
    background: var(--bg-color);
    color: var(--text-dark);
}

[data-theme="dark"] .gpa-inputs-grid input {
    border: 1px solid var(--border-color);
    background: #252525;
}

.gpa-inputs-grid input:focus {
    border-color: var(--primary-color);
    outline: none;
    background: var(--surface-color);
}

.gpa-card { margin-bottom: 15px; }

.card-subtitle { 
    font-size: 14px; 
    color: var(--primary-text); 
    margin-bottom: 15px; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
}

.subjects-container { margin-top: 20px; }

/* كرت المادة (Subject Card) */
.subject-card {
    background: #fdfdfd;
    border: 1px solid #eee;
    border-radius: 16px;
    padding: 15px;
    margin-bottom: 12px;
    position: relative;
    animation: slideIn 0.3s ease;
}

/* تحديث كرت المادة للدارك مود */
[data-theme="dark"] .subject-card {
    background: #181818;
    border: 1px solid var(--border-color);
}

.sub-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 12px;
    font-weight: bold;
    color: var(--text-light);
}

.sub-body-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.full-width { grid-column: span 2; }

.subject-card input, .subject-card select {
    padding: 10px;
    border-radius: 10px;
    border: 1px solid #ddd;
    font-family: 'Tajawal';
    font-size: 14px;
    background: white;
    color: #333;
}

/* حقول الإدخال داخل كرت المادة للدارك مود */
[data-theme="dark"] .subject-card input, 
[data-theme="dark"] .subject-card select {
    background: #2a2a2a;
    color: var(--text-dark);
    border: 1px solid var(--border-color);
}

.remove-sub {
    background: #ffeded;
    color: #ff4d4d;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

[data-theme="dark"] .remove-sub {
    background: rgba(255, 77, 77, 0.2);
}

.control-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0;
}

/* كرت النتيجة الذهبي (Result Card) */
.result-card {
    background: linear-gradient(135deg, #ffffff 0%, #fffdf0 100%);
    border: 2px solid #ffde59;
}

/* النتيجة الذهبية في الدارك مود (أسود وذهبي فخم) */
[data-theme="dark"] .result-card {
    background: linear-gradient(135deg, #1e1e1e 0%, #2a2500 100%);
    border: 2px solid #d4af37; /* ذهبي أغمق شوي */
}

.res-title { text-align: center; font-size: 16px; margin-bottom: 15px; color: var(--text-dark); }

.result-box.blue { 
    background: #eef4ff; 
    color: #0052cc; 
    border: 1px solid #d0e1ff; 
}

[data-theme="dark"] .result-box.blue {
    background: rgba(0, 82, 204, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(0, 82, 204, 0.3);
}

.result-box.gold { 
    background: #fff9db; 
    color: #856404; 
    border: 1px solid #ffeeba; 
}

[data-theme="dark"] .result-box.gold {
    background: rgba(255, 215, 0, 0.1);
    color: #ffd700;
    border: 1px solid rgba(255, 215, 0, 0.2);
}

/* =========================================
   شاشة التحميل (Preloader) - أنيقة وتدعم الدارك مود
   ========================================= */

#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--surface-color); /* 👈 ياخذ لون الخلفية حسب المود */
    z-index: 999999; /* فوق كل شي حرفياً */
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease-out, visibility 0.5s; /* حركة اختفاء ناعمة */
}

/* الحاوية اللي فيها الشعار والسبينر */
.loader-content {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* الشعار داخل الشاشة */
.loader-logo {
    width: 50px;
    height: 50px;
    object-fit: contain;
    animation: pulseLogo 2s infinite ease-in-out;
    position: relative;
    z-index: 2;
}

/* إذا كنت مفعل كود قلب ألوان الشعار للدارك مود، طبقه هنا بعد */
[data-theme="dark"] .loader-logo {
    filter: brightness(0) invert(1) opacity(0.9);
}

/* حلقة التحميل الدائرة */
.spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-top-color: var(--primary-color); /* لون التحميل أزرق */
    border-radius: 50%;
    animation: spinRing 1s linear infinite;
    z-index: 1;
}

/* كلاس الاختفاء (يضاف بالجافاسكربت) */
#preloader.fade-out {
    opacity: 0;
    visibility: hidden;
}

/* --- الحركات (Animations) --- */

/* حركة النبض للشعار */
@keyframes pulseLogo {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}

/* حركة دوران الحلقة */
@keyframes spinRing {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* =========================================
   تنسيق أداة حساب الدرجات (تصميم الكبسولة)
   متوافق مع متغيرات style.css الرئيسية
   ========================================= */

/* حاوية الأداة */
#course-calc-card {
    background: var(--surface-color); /* أبيض في اللايت، رمادي في الدارك */
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 20px;
    box-shadow: 0 10px 30px var(--shadow-color);
    margin: 20px auto;
    max-width: 600px;
}

/* العنوان */
.calc-title {
    text-align: center;
    color: var(--primary-text);
    font-weight: 800;
    margin-bottom: 25px;
    font-size: 20px;
}

/* تنسيق الصف (الكبسولة) */
.grade-row {
    background: var(--bg-color); /* خلفية أغمق شوي من الكرت */
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 15px;
    margin-bottom: 15px;
    position: relative;
    transition: 0.3s;
}

/* تنسيق الصفوف الداخلية (القائمة فوق، والخانات تحت) */
.row-top {
    display: flex;
    justify-content: space-between; /* يوزع المسافة بين القائمة وزر الحذف */
    align-items: center;
    margin-bottom: 12px;
    padding-left: 40px; /* مكان لزر الحذف */
}

.row-bottom {
    display: flex;
    gap: 10px;
}

/* حقول الإدخال والقوائم */
.grade-row select, 
.grade-row input {
    width: 100%;
    height: 50px;
    border: 1px solid var(--border-color); /* ياخذ حدود الثيم */
    border-radius: 12px;
    padding: 0 15px;
    
    background: var(--surface-color); /* خلفية الحقل */
    color: var(--text-dark); /* لون النص (أسود/أبيض) */
    
    font-family: 'Tajawal', sans-serif;
    font-size: 15px;
    outline: none;
    transition: 0.3s;
}

/* التركيز */
.grade-row input:focus, 
.grade-row select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1); /* إذا ما عندك rgb عادي يشتغل بدونه */
}

/* تنسيق خاص للأرقام (إنجليزي) */
.grade-row input[type="number"] {
    direction: ltr;
    text-align: center;
    font-weight: 700;
    font-size: 18px;
}

/* القائمة المنسدلة */
.grade-row select {
    cursor: pointer;
    font-weight: 600;
    appearance: none; /* إخفاء السهم الافتراضي */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 10px center;
    background-size: 16px;
    padding-left: 30px;
}

/* خانة الكتابة المخصصة (أخرى) */
.custom-input-title {
    text-align: right !important;
    direction: rtl !important;
    border-color: var(--primary-color) !important;
}

/* زر الحذف (X) */
.delete-btn {
    position: absolute;
    left: 10px;
    top: 15px;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid #ffcccc;
    background: #fff5f5;
    color: #ff4d4d;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: 0.2s;
    z-index: 2;
}

/* تعديل زر الحذف في الدارك مود */
[data-theme="dark"] .delete-btn {
    background: rgba(255, 77, 77, 0.15);
    border-color: rgba(255, 77, 77, 0.3);
}

.delete-btn:hover {
    background: #ff4d4d;
    color: white;
    border-color: #ff4d4d;
}

/* الأزرار السفلية */
.buttons-gap {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

/* زر الحساب (يأخذ ستايل calc-btn من ملفك) */
.action-btn {
    flex: 2;
    background: linear-gradient(45deg, #0a0b4d 0%, #007bc4 100%);
    color: white;
    padding: 12px;
    border-radius: 14px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    font-size: 16px;
}

.add-btn {
    flex: 1;
    background: var(--bg-color);
    color: var(--text-dark);
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: 14px;
    font-weight: 600;
    cursor: pointer;
}

/* =========================
   تنسيق النتائج
   ========================= */
.results-wrapper {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px dashed var(--border-color);
}

.res-card {
    flex: 1;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 15px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* كرت التقدير */
.grade-res-card {
    flex: 1;
    background: var(--primary-color); /* لون التطبيق */
    color: white;
    border-radius: 16px;
    padding: 15px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.res-lbl {
    font-size: 12px;
    margin-bottom: 5px;
    opacity: 0.8;
}

.res-val {
    font-size: 22px;
    font-weight: 800;
    direction: ltr;
}

.res-sub {
    font-size: 13px;
    font-weight: 600;
    direction: ltr;
    margin-top: 4px;
    color: var(--primary-text);
}

/* تحسينات الدارك مود للنتيجة */
[data-theme="dark"] .res-sub { color: #64b5f6; }

.grade-val {
    font-size: 38px;
    font-weight: 900;
    line-height: 1;
}

/* كلاس الخطأ */
.input-error {
    border-color: #ff4d4d !important;
    background-color: rgba(255, 77, 77, 0.05) !important;
}

/* تحسين للجوال */
@media (max-width: 480px) {
    .results-wrapper { flex-direction: column; }
    .grade-row { padding: 12px; }
}

/* تنسيق خانة اسم المادة العلوية */
.main-input {
    width: 100%;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--bg-color);
    color: var(--text-dark);
    font-family: 'Tajawal', sans-serif;
    font-size: 16px;
    text-align: right;
    outline: none;
    transition: 0.3s;
}

.main-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

/* زر الحفظ الأخضر */
.save-btn {
    width: 100%;
    margin-top: 15px;
    padding: 12px;
    background: #198754; /* أخضر */
    color: white;
    border: none;
    border-radius: 12px;
    font-family: 'Tajawal';
    font-weight: bold;
    cursor: pointer;
    font-size: 15px;
    animation: fadeIn 0.5s ease;
}
.save-btn:hover { background: #157347; }

/* تنسيق كرت المادة المحفوظة */
.saved-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 15px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px var(--shadow-color);
    transition: 0.3s;
    position: relative;
    overflow: hidden;
}

/* خط ملون يمين الكرت يعبر عن القريد */
.saved-card::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    background: var(--grade-color, var(--primary-color));
}

.saved-info h4 {
    margin: 0 0 5px 0;
    color: var(--text-dark);
    font-size: 16px;
}

.saved-info p {
    margin: 0;
    font-size: 13px;
    color: var(--text-sub); /* تأكد إن عندك هالمتغير أو استخدم color: #888 */
}

/* الدارك مود للنصوص الفرعية */
[data-theme="dark"] .saved-info p { color: #aaa; }

.saved-grade {
    text-align: center;
    background: var(--bg-color);
    padding: 8px 15px;
    border-radius: 10px;
    min-width: 60px;
}

.saved-grade .letter {
    display: block;
    font-weight: 800;
    font-size: 20px;
    color: var(--grade-color, var(--text-dark));
}

.saved-grade .percent {
    font-size: 11px;
    color: var(--text-dark);
    direction: ltr;
}

/* زر حذف الكرت */
.del-saved-btn {
    background: transparent;
    border: none;
    color: #ff4d4d;
    font-size: 18px;
    cursor: pointer;
    margin-left: 10px;
    padding: 5px;
}

/* زر حذف الكل */
.clear-btn {
    background: transparent;
    border: 1px solid #ff4d4d;
    color: #ff4d4d;
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'Tajawal';
    margin-top: 10px;
    font-size: 13px;
}
.clear-btn:hover { background: #ff4d4d; color: white; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================
   تصميم النوافذ المنبثقة (Custom Popups)
   ========================================= */

/* الخلفية المعتمة */
.popup-overlay3 {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6); /* تعتيم الخلفية */
    backdrop-filter: blur(5px); /* تأثير ضبابي عصري */
    z-index: 9999; /* فوق كل شيء */
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: 0.3s ease;
}

/* إظهار النافذة */
.popup-overlay3.active {
    opacity: 1;
    visibility: visible;
}

/* صندوق المحتوى */
.popup-content3 {
    background: var(--bg-card); /* أبيض أو رمادي غامق حسب المود */
    padding: 30px;
    border-radius: 24px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    transform: scale(0.8);
    transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* حركة ارتداد ناعمة */
}

.popup-overlay3.active .popup-content3 {
    transform: scale(1);
}

/* الأيقونة */
.popup-icon3 {
    font-size: 40px;
    margin-bottom: 15px;
    animation: popIcon 0.5s ease;
}

/* النصوص */
.popup-content3 h3 {
    color: var(--text-dark); /* يأخذ لون النص حسب المود */
    margin-bottom: 10px;
    font-size: 20px;
}

.popup-content3 p {
    color: var(--text-sub); /* لون فرعي */
    margin-bottom: 25px;
    font-size: 15px;
    line-height: 1.5;
}

/* الأزرار */
.popup-actions3 {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.pop-btn3 {
    padding: 12px 25px;
    border-radius: 12px;
    font-family: 'Tajawal';
    font-weight: bold;
    cursor: pointer;
    border: none;
    font-size: 14px;
    flex: 1;
    transition: 0.2s;
}

.pop-btn3.confirm {
    background: linear-gradient(45deg, #0a0b4d 0%, #007bc4 100%);
    color: white;
}

.pop-btn3.cancel {
    background: var(--bg-body); /* لون الخلفية العادية */
    color: var(--text-dark);
    border: 1px solid var(--border-color);
    display: none; /* مخفي افتراضياً */
}

/* تأثير بسيط للأيقونة */
@keyframes popIcon {
    0% { transform: scale(0); }
    80% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.advanced-section {
        margin-top: 30px;
        padding-top: 25px;
        border-top: 2px dashed #f1f5f9;
        font-family: inherit;
    }

    /* التنبيه الذكي */
    .smart-insight {
        background: rgba(59, 130, 246, 0.04);
        border: 1px solid rgba(59, 130, 246, 0.1);
        border-radius: 14px;
        padding: 14px 16px;
        display: flex;
        align-items: center;
        gap: 12px;
        margin-bottom: 24px;
    }
    .smart-insight .icon-box {
        background: #fff;
        color: #3b82f6;
        width: 38px;
        height: 38px;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        box-shadow: 0 4px 10px rgba(59, 130, 246, 0.1);
        flex-shrink: 0;
    }
    .smart-insight p {
        margin: 0;
        color: #1e3a8a;
        font-size: 13px;
        font-weight: 600;
        line-height: 1.6;
    }

    .section-title {
        font-size: 15px;
        font-weight: 800;
        color: #0f172a;
        margin-bottom: 16px;
        display: flex;
        align-items: center;
        gap: 8px;
    }
    .section-title i { color: #64748b; font-size: 18px;}

    /* حقول الإدخال ستايل التطبيقات (كروت) */
    .app-inputs-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        margin-bottom: 24px;
    }
    .app-input-card {
        background: #f8fafc;
        border: 1.5px solid #e2e8f0;
        border-radius: 16px;
        padding: 16px 10px;
        text-align: center;
        transition: 0.2s ease;
    }
    .app-input-card:focus-within {
        background: #fff;
        border-color: #3b82f6;
        box-shadow: 0 4px 15px rgba(59, 130, 246, 0.08);
    }
    .app-input-card label {
        display: block;
        font-size: 12px;
        color: #64748b;
        font-weight: 700;
        margin-bottom: 10px;
    }
    .app-input-card input {
        width: 100%;
        background: transparent;
        border: none;
        outline: none;
        text-align: center;
        font-size: 26px;
        font-weight: 900;
        color: #0f172a;
        font-family: monospace, sans-serif;
    }
    /* إخفاء أسهم الأرقام المزعجة من المتصفح */
    .app-input-card input::-webkit-outer-spin-button,
    .app-input-card input::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }

    /* لوحة التقدم المتكاملة */
    .app-progress-board {
        background: #fff;
        border: 1.5px solid #f1f5f9;
        border-radius: 16px;
        padding: 20px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.03);
    }
    .progress-info {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 16px;
    }
    .status-msg {
        font-size: 14px;
        font-weight: 800;
        color: #334155;
        flex: 1;
        line-height: 1.4;
    }
    /* البادج حق النسبة مع حل مشكلة الاتجاه */
    .percent-badge {
        background: #f8fafc;
        padding: 6px 12px;
        border-radius: 10px;
        font-weight: 900;
        font-size: 16px;
        color: #0f172a;
        direction: ltr; /* السحر اللي يخلي الرقم ما ينقلب */
        display: inline-flex;
        align-items: baseline;
        gap: 4px;
        border: 1px solid #e2e8f0;
    }
    .percent-badge span {
        font-size: 12px;
        color: #94a3b8;
        font-weight: 700;
    }

    /* شريط التقدم */
    .bar-container {
        height: 10px;
        background: #f1f5f9;
        border-radius: 20px;
        overflow: hidden;
        direction: rtl; /* عشان اللون يعبي من اليمين */
        margin-bottom: 14px;
    }
    .bar-fill {
        height: 100%;
        width: 0%;
        background: #22c55e;
        border-radius: 20px;
        transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.5s ease;
    }

    .board-footer {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 11.5px;
        color: #94a3b8; }
