:root {
    --bg-color: #f8f9fa;
    --card-bg-color: #ffffff;
    --primary-text-color: #212529;
    --secondary-text-color: #5a6268;
    --accent-color: #007bff;
    --border-color: #dee2e6;
    --shadow-color: rgba(0, 0, 0, 0.05);
}

/* --- Smooth Transitions for Theme Change --- */
body, .container, .profile-pic, .entry .date, .language-switcher a {
    transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease;
}

/* --- General Setup --- */
body {
    font-family: 'Roboto', 'Vazirmatn', sans-serif;
    background-color: var(--bg-color);
    color: var(--primary-text-color);
    line-height: 1.6;
    margin: 0;
    overflow-x: hidden; 
}

.container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 40px;
    background-color: var(--card-bg-color);
    border-radius: 12px;
    box-shadow: 0 8px 25px var(--shadow-color);
    position: relative;
}

h1, h2, h3 { font-family: 'Poppins', 'Vazirmatn', sans-serif; }
h1 { font-size: 2.5em; margin-bottom: 10px; margin-top: 0; }
h2 { font-size: 1.5em; color: var(--accent-color); border-bottom: 2px solid var(--border-color); padding-bottom: 10px; margin-bottom: 25px; }
h2 i { margin-right: 12px; }
h3 { font-size: 1.15em; margin: 0; color: var(--primary-text-color); }
p, li { color: var(--secondary-text-color); text-align: justify; }

/* --- Header --- */
.main-header {
    display: flex;
    align-items: center;
    gap: 30px;
    margin-bottom: 40px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 30px;
}
.profile-pic {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    border: 5px solid var(--card-bg-color);
    box-shadow: 0 0 15px rgba(0,0,0,0.15);
    object-fit: cover;
}
.header-text { flex: 1; }
.subtitle { font-size: 1.2em; color: var(--secondary-text-color); margin-top: 0; margin-bottom: 15px; text-align: left; }
.contact-info { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 15px 25px; }
.contact-info a, .contact-info span { color: var(--secondary-text-color); text-decoration: none; font-size: 0.95em; }
.contact-info a:hover { color: var(--accent-color); }
.contact-info i { margin-right: 8px; color: var(--accent-color); }

/* --- Language Switcher --- */
.language-switcher {
    position: absolute;
    top: 25px;
    right: 25px;
    font-size: 0.9em;
}
.language-switcher a {
    color: var(--secondary-text-color);
    text-decoration: none;
    font-weight: 500;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}
.language-switcher a:hover {
    background-color: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}
.language-switcher i {
    margin-right: 6px;
}

/* --- Layout --- */
.content-wrapper { display: flex; gap: 40px; }
.main-content { flex: 3; }
.skills-sidebar { flex: 2; }

/* --- Entry Styles --- */
.entry { margin-bottom: 25px; padding-left: 20px; border-left: 3px solid var(--border-color); }
.entry-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.entry .date { font-style: italic; color: #888; font-size: 0.9em; }
.entry .institution { font-weight: 500; color: var(--primary-text-color); margin: 4px 0 8px; }
.entry ul { padding-left: 20px; margin-top: 10px; }

/* --- Skills & Certificates --- */
.skill { margin-bottom: 18px; }
.skill p { margin: 0 0 8px; font-weight: 500; text-align: left; }
.skill-bar { background-color: #e9ecef; border-radius: 5px; height: 8px; width: 100%; overflow: hidden; }
.skill-level { background-color: var(--accent-color); height: 100%; width: 0; border-radius: 5px; transition: width 1.5s ease-out; }
#certificates ul { list-style: none; padding-left: 0; }
#certificates li { margin-bottom: 10px; text-align: left; }
#certificates i { margin-right: 10px; color: var(--accent-color); }

/* --- JavaScript Animations --- */
.scroll-animate { opacity: 0; transform: translateY(30px); transition: opacity 0.8s ease-out, transform 0.8s ease-out; }
.scroll-animate.visible { opacity: 1; transform: translateY(0); }
.anim-fade-in { animation: fadeIn 1s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/*
==============================================
=== RTL SPECIFIC STYLES FOR PERSIAN (FA) ===
==============================================
*/
[dir="rtl"] .subtitle { text-align: right; }
[dir="rtl"] p, [dir="rtl"] li { text-align: justify; }
[dir="rtl"] h2 i { margin-right: 0; margin-left: 12px; }
[dir="rtl"] .contact-info { justify-content: flex-start; }
[dir="rtl"] .contact-info i { margin-right: 0; margin-left: 8px; }
[dir="rtl"] .entry { padding-left: 0; padding-right: 20px; border-left: none; border-right: 3px solid var(--border-color); }
[dir="rtl"] .entry ul { padding-left: 0; padding-right: 20px; }
[dir="rtl"] .skill p { text-align: justify; }
[dir="rtl"] #certificates li { text-align: right; }
[dir="rtl"] #certificates i { margin-right: 0; margin-left: 10px; }
[dir="rtl"] .language-switcher { right: auto; left: 25px; }
[dir="rtl"] .language-switcher i { margin-right: 0; margin-left: 6px; }
[dir="rtl"] .theme-switch-wrapper { right: auto; left: 30px; }

/* --- Responsive Design --- */
@media (max-width: 992px) {
    .content-wrapper { flex-direction: column; }
    h1 { font-size: 2.2em; }
    .container { margin: 20px; padding: 25px; }
}
@media (max-width: 768px) {
    .main-header {
        flex-direction: column;
        text-align: center;
    }
    .profile-pic {
        width: 130px;
        height: 130px;
    }
    .subtitle, .contact-info {
        text-align: center;
        justify-content: center;
    }
    /* START: کد اضافه‌شده برای رفع مشکل */
    [dir="rtl"] .subtitle {
        text-align: center;
    }
    /* END: کد اضافه‌شده برای رفع مشکل */
    .container {
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }
    .contact-info {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
    .language-switcher {
        top: 15px;
        right: 15px;
    }
    [dir="rtl"] .language-switcher {
        right: auto;
        left: 15px;
    }
    .skills-sidebar {
        padding-top: 30px;
    }
}
@media (max-width: 480px) {
    body {
        font-size: 0.95rem; 
    }
    .entry-header { flex-direction: column; align-items: flex-start; }
    .entry .date { margin-top: 4px; font-size: 0.85em; background-color: #f0f3f5; padding: 2px 8px; border-radius: 4px; }
    [dir="rtl"] .entry-header { align-items: flex-start; }
}

/*
================================
=== PROFESSIONAL DARK MODE ===
================================
*/
body[data-theme="dark"] {
    --bg-color: #121212;
    --card-bg-color: #1e1e1e;
    --primary-text-color: #e0e0e0;
    --secondary-text-color: #a0a0a0;
    --border-color: #383838;
    --accent-color: #4a90e2;
    --shadow-color: rgba(0, 0, 0, 0.3);
}
body[data-theme="dark"] .container {
    box-shadow: 0 8px 30px var(--shadow-color);
}
body[data-theme="dark"] .entry .date {
    background-color: #2c2c2c;
}
body[data-theme="dark"] .profile-pic {
    border-color: var(--card-bg-color);
    box-shadow: 0 0 20px rgba(74, 144, 226, 0.15);
}
body[data-theme="dark"] .language-switcher a:hover {
    background-color: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

/* --- Professional Dark Mode Toggle --- */
.theme-switch-wrapper {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.theme-switch {
    display: inline-block;
    height: 34px;
    position: relative;
    width: 60px;
}
.theme-switch input { display:none; }
.slider {
    background-color: #2c3e50;
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: .4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}
.slider:before {
    background-color: #f1c40f;
    bottom: 4px;
    content: "";
    height: 26px;
    left: 4px;
    position: absolute;
    transition: .4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    width: 26px;
    box-shadow: 0 0 10px #f1c40f;
}
input:checked + .slider { background-color: #2c3e50; }
input:checked + .slider:before {
    transform: translateX(26px);
    background-color: #ffffff;
    box-shadow: none;
}
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }
.theme-switch-wrapper.hidden {
    opacity: 0;
    transform: translateY(100px);
    pointer-events: none;
}
