/* --- المتغيرات الأساسية والوضع الليلي --- */
:root {
    --bg-color: #f4f7f6;
    --surface-color: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --brand-color: #0056b3;
    --brand-hover: #004494;
    --border-color: #e1e4e8;
    --shadow-soft: 0 2px 10px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 5px 15px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --text-primary: #e0e0e0;
    --text-secondary: #aaaaaa;
    --brand-color: #4da3ff;
    --border-color: #333333;
    --shadow-soft: 0 2px 10px rgba(0,0,0,0.5);
    --shadow-hover: 0 5px 15px rgba(0,0,0,0.8);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tajawal', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    transition: background 0.3s, color 0.3s;
}

/* --- الهيدر الجديد (Mobile-First) --- */
.main-header { 
    display: block !important; 
    background-color: var(--surface-color); 
    box-shadow: var(--shadow-soft); 
    position: sticky; 
    top: 0; 
    z-index: 100; 
    transition: background 0.3s; 
}

/* الجزء العلوي (اللوغو يمين + زر القائمة يسار) */
.header-top { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 15px 5%; 
    width: 100%;
}

.logo { 
    font-size: 2rem; 
    font-weight: 700; 
    color: var(--brand-color); 
    text-decoration: none; 
    letter-spacing: 1px;
}

.menu-toggle { 
    background: none; 
    border: none; 
    font-size: 2rem; 
    color: var(--text-primary); 
    cursor: pointer; 
}

/* شريط البحث */
.search-container { 
    padding: 0 5% 15px; 
    max-width: 800px; 
    margin: 0 auto; 
}

.search-form { 
    display: flex; 
    border: 1px solid var(--border-color); 
    border-radius: 8px; 
    overflow: hidden; 
    background: var(--surface-color); 
}

.search-input, .city-select, .search-btn { 
    border: none; 
    padding: 12px; 
    outline: none; 
    background: transparent; 
    color: var(--text-primary); 
}
.search-input { flex-grow: 1; }
.city-select { border-right: 1px solid var(--border-color); border-left: 1px solid var(--border-color); }
.search-btn { background-color: var(--brand-color); color: white; cursor: pointer; font-weight: bold; padding: 0 20px; }

/* الشريط الأفقي */
.horizontal-nav { 
    display: flex; 
    overflow-x: auto; 
    white-space: nowrap; 
    padding: 15px 5%; 
    border-top: 1px solid var(--border-color); 
    gap: 25px; 
    scrollbar-width: none; 
}

@media (min-width: 768px) {
    .horizontal-nav { justify-content: center; }
}

.horizontal-nav::-webkit-scrollbar { display: none; }
.horizontal-nav a { 
    color: var(--text-secondary); 
    text-decoration: none; 
    font-weight: 600; 
    font-size: 1rem; 
    padding-bottom: 5px; 
}
.horizontal-nav a:hover, .horizontal-nav a.active { 
    color: var(--brand-color); 
    border-bottom: 2px solid var(--brand-color); 
}

/* --- القائمة الجانبية (Sidebar) السحر الذي اختفى --- */
.sidebar { 
    position: fixed; 
    top: 0; 
    right: -300px; 
    width: 280px; 
    height: 100vh; 
    background-color: var(--surface-color); 
    box-shadow: -5px 0 15px rgba(0,0,0,0.1); 
    z-index: 1000; 
    transition: right 0.3s ease; 
    display: flex; 
    flex-direction: column; 
    padding: 20px; 
}
.sidebar.open { right: 0; }
.close-sidebar { align-self: flex-end; font-size: 1.5rem; background: none; border: none; color: var(--text-primary); cursor: pointer; margin-bottom: 20px; }
.sidebar-link { display: flex; align-items: center; justify-content: space-between; padding: 15px 0; border-bottom: 1px solid var(--border-color); color: var(--text-primary); text-decoration: none; font-size: 1.1rem; font-weight: 500; }
.sidebar-link:hover { color: var(--brand-color); }
.sidebar-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 999; display: none; }
.sidebar-overlay.active { display: block; }

/* Toggle Switch (للوضع الليلي) */
.switch { position: relative; display: inline-block; width: 40px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 20px; }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 2px; bottom: 2px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--brand-color); }
input:checked + .slider:before { transform: translateX(20px); }

/* --- الحاوية والبطاقات --- */
.container { 
    padding: 30px 2%; /* تقليل الحواف الجانبية لاستغلال المساحة */
    max-width: 96%; /* 🚀 توسيع الشاشة لتشمل الفراغات البيضاء */
    margin: 0 auto; 
    min-height: 60vh; 
}

.section-title { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin: 0px 0 25px 0; /* 🌬️ مساحة تنفس بين الأقسام */
    padding-bottom: 12px; 
    border-bottom: 2px solid var(--brand-color); /* 🔵 الخط الأزرق الفاصل */
}

.section-title h2 { 
    font-size: 1.5rem; 
    color: var(--text-primary); 
}
.jobs-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }

.job-card { 
    background: var(--surface-color); 
    border-radius: 12px; 
    padding: 20px; 
    box-shadow: var(--shadow-soft); 
    border: 1px solid var(--border-color); 
    transition: transform 0.2s ease, box-shadow 0.2s ease; 
    display: flex; 
    flex-direction: column; 
    gap: 15px; 
}
.job-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: var(--brand-color); }

.job-header { display: flex; align-items: center; gap: 15px; }
.company-logo { width: 50px; height: 50px; background-color: #eef2f5; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: bold; color: var(--brand-color); font-size: 1.2rem; }
.job-title { font-size: 1.1rem; margin-bottom: 4px; color: var(--text-primary); }
.company-name { font-size: 0.9rem; color: var(--text-secondary); }

.job-details { display: flex; flex-wrap: wrap; gap: 10px; }
.tag { background: #f0f4f8; padding: 5px 10px; border-radius: 6px; font-size: 0.85rem; color: #4a5568; font-weight: 500; }
.tag.contract { background: #e6f4ea; color: #1e8e3e; }

.job-excerpt { font-size: 0.95rem; color: var(--text-secondary); line-height: 1.5; }

.job-actions { display: flex; gap: 10px; margin-top: auto; }
.btn-apply, .btn-save { padding: 10px; border-radius: 8px; font-weight: 600; cursor: pointer; border: none; font-size: 0.95rem; transition: 0.3s; }
.btn-apply { background-color: var(--brand-color); color: white; flex-grow: 1; }
.btn-apply:hover { background-color: var(--brand-hover); }
.btn-save { background-color: transparent; border: 1px solid var(--border-color); color: var(--text-primary); width: 80px; }
.btn-save:hover { background-color: #f0f4f8; }

@media (min-width: 768px) { .jobs-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .jobs-grid { grid-template-columns: repeat(3, 1fr); } }

/* --- الفوتر --- */
.main-footer { background-color: var(--surface-color); border-top: 1px solid var(--border-color); padding: 40px 5% 20px; margin-top: 50px; }
.footer-content { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 30px; max-width: 1200px; margin: 0 auto; margin-bottom: 30px; }
.footer-section h3 { color: var(--brand-color); margin-bottom: 15px; }
.footer-section h4 { color: var(--text-primary); margin-bottom: 15px; font-size: 1.1rem; }
.footer-section p, .footer-section a { color: var(--text-secondary); text-decoration: none; display: block; margin-bottom: 10px; font-size: 0.95rem; line-height: 1.6; }
.footer-section a:hover { color: var(--brand-color); }
.footer-bottom { text-align: center; padding-top: 20px; border-top: 1px solid var(--border-color); color: var(--text-secondary); font-size: 0.9rem; }

/* --- صفحات تسجيل الدخول --- */
.auth-container { max-width: 450px; margin: 50px auto; background: var(--surface-color); padding: 30px; border-radius: 12px; box-shadow: var(--shadow-soft); border: 1px solid var(--border-color); }
.auth-container h2 { text-align: center; margin-bottom: 25px; color: var(--brand-color); }
.auth-form { display: flex; flex-direction: column; gap: 15px; }
.auth-form label { font-size: 0.95rem; font-weight: 500; color: var(--text-primary); }
.auth-form input, .auth-form select { padding: 12px; border: 1px solid var(--border-color); border-radius: 8px; outline: none; font-size: 1rem; font-family: 'Tajawal', sans-serif; background: transparent; color: var(--text-primary); }
.auth-form input:focus, .auth-form select:focus { border-color: var(--brand-color); }
.auth-form button { padding: 12px; background-color: var(--brand-color); color: white; border: none; border-radius: 8px; font-size: 1.05rem; font-weight: bold; cursor: pointer; transition: 0.3s; margin-top: 10px; }
.auth-form button:hover { background-color: var(--brand-hover); }
.auth-links { text-align: center; margin-top: 20px; font-size: 0.95rem; }
.auth-links a { color: var(--brand-color); text-decoration: none; font-weight: bold; }
.auth-links a:hover { text-decoration: underline; }
.alert { padding: 12px; border-radius: 8px; margin-bottom: 15px; text-align: center; font-size: 0.9rem; font-weight: bold; }
.alert.error { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert.success { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
/* --- صفحة تفاصيل الوظيفة (Job Details Page) --- */
.job-details-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
    align-items: start;
}

@media (min-width: 992px) {
    .job-details-layout {
        grid-template-columns: 2fr 1fr; /* 70% للتفاصيل، 30% للبطاقة الجانبية */
    }
}

.job-main-content {
    background: var(--surface-color);
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-color);
}

.job-header-large {
    display: flex;
    align-items: center;
    gap: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
}

.large-company-logo {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid var(--border-color);
}

.fallback-logo {
    background-color: #eef2f5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--brand-color);
}

.job-sidebar {
    position: sticky;
    top: 100px; /* يجعل البطاقة تلحقك عند النزول في الشاشات الكبيرة */
}

.job-summary-card {
    background: var(--surface-color);
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-color);
}
/* --- مساحات الإعلانات (Ad Spaces) --- */
.ad-space {
    background-color: #f8f9fa;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 20px;
    overflow: hidden;
}

[data-theme="dark"] .ad-space {
    background-color: #2a2a2a;
    border-color: #444;
    color: #777;
}

.ad-leaderboard {
    width: 100%;
    min-height: 90px; /* الحجم القياسي لإعلانات البانر العلوية */
}

.ad-rectangle {
    width: 100%;
    min-height: 250px; /* الحجم القياسي للإعلانات المربعة الجانبية */
    margin-top: 20px;
}
/* --- تصميم قسم النماذج الإدارية --- */
.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 40px 0 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--brand-color);
}

.category-header h2 {
    font-size: 1.4rem;
    color: var(--text-primary);
}

.view-all {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: bold;
}

.view-all:hover {
    color: var(--brand-color);
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.template-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: transform 0.2s;
}

[data-theme="dark"] .template-card {
    background: linear-gradient(135deg, #2a2a2a 0%, #1e1e1e 100%);
    border-color: #444;
}

.template-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.template-icon {
    font-size: 2.5rem;
}

.template-info h4 {
    color: var(--text-primary);
    margin-bottom: 5px;
    font-size: 1.1rem;
}

.template-download {
    color: var(--brand-color);
    text-decoration: none;
    font-weight: bold;
    font-size: 0.9rem;
}
/* --- التصميم الجديد لبطاقة الوظيفة --- */
.job-card {
    background: var(--surface-color);
    border-radius: 12px;
    padding: 0;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* حاوية الصورة لكي تطفو العلامات فوقها */
.job-cover-wrapper {
    position: relative;
    width: 100%;
}

.job-cover-image {
    width: 100%;
    height: 140px; /* تم تقليل الارتفاع لجعل البطاقة أقصر */
    object-fit: cover;
    border-bottom: 1px solid var(--border-color);
    display: block;
}

.fallback-cover {
    background: linear-gradient(135deg, var(--brand-color), #20c997);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: bold;
    height: 140px;
}

/* 🏷️ العلامات الطافية فوق الصورة (يسار أسفل) */
.job-cover-tags {
    position: absolute;
    bottom: 10px;
    left: 10px;
    display: flex;
    flex-direction: row;
    gap: 8px;
}

.overlay-tag {
    background: rgba(255, 255, 255, 0.95);
    color: #1a1a1a;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    backdrop-filter: blur(4px);
}

/* توافق العلامات مع الوضع الليلي */
[data-theme="dark"] .overlay-tag {
    background: rgba(30, 30, 30, 0.9);
    color: #e0e0e0;
}

/* تقليل الفراغات لجعل البطاقة مضغوطة أكثر */
.job-card-content {
    padding: 15px; /* تم تقليل الفراغ */
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    gap: 12px;
}
/* 📅 علامة التاريخ (يمين أعلى الصورة) */
.date-tag {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.65);
    color: white;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: bold;
    backdrop-filter: blur(4px);
    z-index: 2;
}

[data-theme="dark"] .date-tag {
    background: rgba(255, 255, 255, 0.15);
}

/* 💙 زر الحفظ عندما يكون مفعلاً (Saved) */
.btn-save.saved {
    background-color: #e7f1ff;
    color: var(--brand-color);
    border-color: var(--brand-color);
    font-weight: bold;
}

[data-theme="dark"] .btn-save.saved {
    background-color: rgba(77, 163, 255, 0.2);
    border-color: var(--brand-color);
    color: var(--brand-color);
}
/* 🖥️ إجبار الشبكة على عرض 4 بطاقات في السطر الواحد لشاشات الكمبيوتر */
@media (min-width: 1024px) {
    .jobs-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 15px !important; /* تقليل الفراغ قليلاً لكي تتسع البطاقات الـ 4 بشكل مريح */
    }
}
/* 🏷️ تصميم العلامات (المكان ونوع العقد) داخل البطاقة البيضاء */
.job-info-tags {
    display: flex;
    justify-content: center; /* توسيط العلامات لتناسب العنوان */
    gap: 10px;
    margin-top: 15px; 
    margin-bottom: 10px;
    flex-wrap: wrap; /* لكي تنزل للسطر الثاني في الشاشات الصغيرة جداً */
}

.info-tag {
    background-color: #f1f5f9; /* رمادي فاتح جداً وأنيق */
    color: #475569; /* لون نص مريح للعين */
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    border: 1px solid #e2e8f0;
}

/* توافق العلامات مع الوضع الليلي 🌙 */
[data-theme="dark"] .info-tag {
    background-color: #2a2a2a;
    color: #cbd5e1;
    border-color: #444;
}
/* =========================================
   📄 تصميم صفحة تفاصيل الوظيفة (job.php)
   ========================================= */
.job-page-header {
    background: var(--surface-color);
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-color);
    margin-bottom: 25px;
    text-align: center;
}

.job-page-logo {
    width: 90px;
    height: 90px;
    border-radius: 12px;
    object-fit: cover;
    margin: 0 auto 15px auto;
    border: 2px solid #e2e8f0;
    display: block;
}

.job-page-fallback-logo {
    width: 90px;
    height: 90px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand-color), #20c997);
    color: white;
    font-size: 2rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px auto;
}

.job-page-tags {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px dashed var(--border-color);
}

.job-page-content {
    background: var(--surface-color);
    border-radius: 12px;
    padding: 40px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-color);
    line-height: 1.9;
    font-size: 1.05rem;
    color: var(--text-primary);
    white-space: pre-wrap; /* يحافظ على المسافات والأسطر في النص */
}

.apply-action-bar {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
}

.btn-apply-large {
    flex: 3;
    background: var(--brand-color);
    color: white;
    text-align: center;
    padding: 15px;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: bold;
    text-decoration: none;
    transition: 0.2s;
}

.btn-apply-large:hover {
    background: #004494;
    transform: translateY(-2px);
}

.btn-save-large {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    font-size: 1.5rem;
    text-decoration: none;
    color: var(--text-secondary);
    transition: 0.2s;
}

.btn-save-large.saved {
    background: #e7f1ff;
    border-color: var(--brand-color);
    color: var(--brand-color);
}
/* =========================================
   🚀 توسيع الشاشة واستغلال الفراغات الجانبية
   ========================================= */

/* 1. توسيع الحاوية الرئيسية لتأخذ 96% من عرض الشاشة بدلاً من الحجم الضيق */
.container {
    max-width: 96% !important; 
    padding: 30px 2% !important;
}

/* 2. ضبط التقسيم (يمين ويسار) */
.home-layout {
    display: grid;
    /* القسم الأيمن (الوظائف) يأخذ المساحة الحرة، والقسم الأيسر (الشريط) يثبت عند 320 بيكسل */
    grid-template-columns: 1fr 320px; 
    gap: 30px;
    align-items: start;
    margin-top: 20px;
}

/* 3. إجبار الشبكة على عرض 4 بطاقات (أو أكثر) لأن المساحة أصبحت واسعة جداً! */
@media (min-width: 1200px) {
    .jobs-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 20px !important;
    }
}

/* إذا كانت الشاشة عملاقة، نعرض 5 بطاقات */
@media (min-width: 1600px) {
    .jobs-grid {
        grid-template-columns: repeat(5, 1fr) !important;
    }
}

/* 4. إخفاء الشريط الجانبي في الهواتف وجعله أسفل الوظائف */
@media (max-width: 992px) {
    .home-layout {
        grid-template-columns: 1fr; 
    }
}