/* =========================================
   تنسيق الأدوات (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-color);
    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);
    border-color: var(--primary-color);
}

/* إدارة عرض المحتوى */
.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-color);
}

.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: 15px;
    border: none;
    border-radius: 15px;
    background: var(--primary-color);
    color: white;
    font-size: 16px;
    font-weight: 700;
    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-color); 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-color); 
    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); }
}

