/* --- الألوان والأنماط --- */
:root {
    --bg-main: #f8f9fa;
    --bg-surface: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e4e4e7;
    --color-primary: #2563eb;
    --color-accent: #f59e0b;
    --glass-bg: rgba(255, 255, 255, 0.95);
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body.dark {
    --bg-main: #0f172a;
    --bg-surface: #1e293b;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --border-color: #334155;
    --color-primary: #60a5fa;
    --color-accent: #fbbf24;
    --glass-bg: rgba(30, 41, 59, 0.95);
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; outline: none; -webkit-tap-highlight-color: transparent; }

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    height: 100vh; height: 100dvh;
    overflow: hidden;
    display: flex; flex-direction: column;
    transition: background-color 0.3s;
}

body[lang="ar"] { font-family: 'Baloo Bhaijaan 2', sans-serif; }

/* --- الهيدر --- */
.header-fixed { position: absolute; top: 1.5rem; left: 50%; transform: translateX(-50%); z-index: 50; width: 90%; max-width: 1100px; }
.header-glass {
    display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1.5rem;
    border-radius: 999px; background-color: var(--glass-bg);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color); box-shadow: var(--shadow);
}
.logo-text { font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; font-size: 1rem; color: var(--text-main); }
.theme-btn, .lang-btn { background: transparent; cursor: pointer; }
.theme-btn { border: none; color: var(--text-main); font-size: 1.1rem; display: flex; align-items: center; }
.lang-btn {
    padding: 0.3rem 1.2rem; border-radius: 999px; font-size: 0.85rem; font-weight: 700;
    border: 1px solid var(--color-primary); color: var(--color-primary); margin-inline-start: 10px;
}
.lang-btn:hover { background: var(--color-primary); color: white; }

/* --- الحاوية الرئيسية --- */
.main-wrapper {
    flex: 1; display: flex; align-items: center; justify-content: center;
    padding: 5rem 1rem 6rem 1rem; overflow: hidden;
}
.glass-card {
    position: relative; width: 100%; height: 100%; max-width: 1100px;
    background-color: var(--bg-surface); border: 1px solid var(--border-color);
    border-radius: 1.5rem; box-shadow: var(--shadow); overflow: hidden; 
    display: flex; flex-direction: column;
}

/* --- الأقسام --- */
.section {
    display: none; flex: 1; overflow-y: auto; padding: 2.5rem;
    opacity: 0; transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    -webkit-overflow-scrolling: touch;
}
.section.active { display: block; opacity: 1; transform: translateY(0); }
.section::-webkit-scrollbar { width: 6px; }
.section::-webkit-scrollbar-thumb { background-color: var(--border-color); border-radius: 3px; }

/* --- الرئيسية --- */
.home-content {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 100%; text-align: center; gap: 2.5rem;
}
@media (min-width: 768px) {
    .home-content { flex-direction: row; text-align: inherit; justify-content: space-around; }
    body[dir="rtl"] .home-content { text-align: right; }
    body[dir="ltr"] .home-content { text-align: left; }
}
.text-area { display: flex; flex-direction: column; gap: 1rem; max-width: 550px; }
.avatar-circle {
    width: 220px; height: 220px; border-radius: 50%;
    background: var(--bg-main); border: 4px solid var(--color-primary);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; box-shadow: var(--shadow); flex-shrink: 0;
}
.hero-title { 
    font-size: 3.5rem; font-weight: 800; margin: 0; line-height: 1.2;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent)); 
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; padding-bottom: 5px;
}
.hero-subtitle { font-size: 1.4rem; color: var(--text-main); font-weight: 600; }
.hero-desc { color: var(--text-muted); font-size: 1.05rem; line-height: 1.7; }
.btn-primary {
    background: var(--color-primary); color: white;
    padding: 0.9rem 2.5rem; border-radius: 999px; font-weight: 600; font-size: 1rem;
    text-decoration: none; display: inline-block; margin-top: 1rem; align-self: center;
    transition: transform 0.2s, box-shadow 0.2s;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 20px -5px rgba(37, 99, 235, 0.4); }
@media (min-width: 768px) { .btn-primary { align-self: flex-start; } body[dir="rtl"] .btn-primary { align-self: flex-start; } }

/* --- شبكة المشاريع --- */
.section-header {
    font-size: 1.5rem; font-weight: 700; color: var(--text-main);
    margin: 2rem 0 1.5rem 0; padding-bottom: 0.5rem; border-bottom: 2px solid var(--border-color);
    display: flex; align-items: center; gap: 10px;
}
.section-header i { color: var(--color-accent); }

.projects-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.5rem;
}
.project-card {
    background: var(--bg-main); border: 1px solid var(--border-color);
    border-radius: 1rem; overflow: hidden; cursor: pointer;
    text-decoration: none; color: inherit; display: flex; flex-direction: column;
    transition: transform 0.2s ease, border-color 0.2s ease; height: 100%;
}
.project-card:hover { transform: translateY(-5px); border-color: var(--color-primary); }
.project-img-container { 
    width: 100%; height: 200px; overflow: hidden; position: relative;
    background: var(--bg-surface); display: flex; align-items: center; justify-content: center;
}
.project-img-container img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s ease; }
.project-card:hover .project-img-container img { transform: scale(1.05); }
.project-icon-placeholder {
    font-size: 3.5rem; color: white; width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
}
.project-body { padding: 1.5rem; flex: 1; display: flex; flex-direction: column; }
.project-title { font-weight: 700; font-size: 1.2rem; margin-bottom: 0.5rem; color: var(--text-main); }
.project-desc { color: var(--text-muted); font-size: 0.95rem; line-height: 1.6; margin-bottom: 1.5rem; flex: 1; }
.tags-row { margin-top: auto; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag {
    font-size: 0.75rem; padding: 0.25rem 0.75rem; font-weight: 600;
    border-radius: 99px; background: var(--bg-surface); border: 1px solid var(--border-color);
    color: var(--text-muted);
}

/* --- MODAL (النافذة المنبثقة) --- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 100;
    display: none; align-items: center; justify-content: center; padding: 20px;
    backdrop-filter: blur(5px);
}
.modal-overlay.active { display: flex; animation: fadeIn 0.2s ease; }

.modal-content {
    background: var(--bg-surface); width: 100%; max-width: 900px; max-height: 90vh;
    border-radius: 1.5rem; overflow-y: auto; position: relative;
    display: flex; flex-direction: column; border: 1px solid var(--border-color);
}
.modal-header {
    padding: 1.5rem; border-bottom: 1px solid var(--border-color);
    display: flex; justify-content: space-between; align-items: center;
    position: sticky; top: 0; background: var(--bg-surface); z-index: 10;
}
.close-modal {
    background: transparent; border: none; font-size: 1.5rem; color: var(--text-muted); cursor: pointer;
}
.modal-body { padding: 2rem; }

/* معرض الصور داخل المودال */
.gallery-container { margin-bottom: 2rem; }
.main-image-frame {
    width: 100%; height: 400px; border-radius: 1rem; overflow: hidden;
    background: var(--bg-main); display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border-color); margin-bottom: 1rem;
}
.main-image-frame img { width: 100%; height: 100%; object-fit: contain; }
.thumbnails-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; }
.thumb {
    width: 80px; height: 60px; border-radius: 8px; cursor: pointer;
    object-fit: cover; border: 2px solid transparent; opacity: 0.6; transition: 0.2s;
}
.thumb:hover, .thumb.active { border-color: var(--color-primary); opacity: 1; }

.modal-details h2 { color: var(--text-main); margin-bottom: 1rem; }
.modal-details p { color: var(--text-muted); line-height: 1.8; margin-bottom: 2rem; }
.visit-btn {
    display: inline-flex; align-items: center; gap: 10px;
    background: var(--color-primary); color: white; padding: 0.8rem 2rem;
    border-radius: 99px; text-decoration: none; font-weight: 600;
}
.visit-btn:hover { opacity: 0.9; }

@media (max-width: 768px) {
    .main-image-frame { height: 250px; }
    .modal-content { max-height: 85vh; }
    .modal-body { padding: 1.5rem; }
}

/* --- المهارات --- */
.skills-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.5rem; padding-bottom: 4rem;
}
.skill-card {
    background: var(--bg-main); border: 1px solid var(--border-color);
    border-radius: 1rem; padding: 1.5rem; transition: 0.3s;
    display: flex; flex-direction: column; gap: 1rem;
}
.skill-card:hover { border-color: var(--color-primary); background: var(--bg-surface); }
.skill-header { display: flex; align-items: center; gap: 12px; color: var(--color-primary); }
.skill-header i { font-size: 1.6rem; }
.skill-header h3 { font-size: 1.1rem; font-weight: 700; color: var(--text-main); margin: 0; }
.skill-list { list-style: none; display: flex; flex-wrap: wrap; gap: 0.8rem; }
.skill-item {
    padding: 0.5rem 1rem; background: var(--bg-surface); border: 1px solid var(--border-color);
    border-radius: 8px; font-size: 0.9rem; font-weight: 500; color: var(--text-muted);
    display: flex; align-items: center; gap: 8px; transition: 0.2s;
}
.skill-item:hover { border-color: var(--color-accent); color: var(--text-main); }
.skill-item i { color: var(--color-accent); font-size: 1rem; }

/* --- التواصل --- */
.contact-container {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 80%; gap: 2.5rem; text-align: center;
}
.social-row { display: flex; gap: 1.5rem; flex-wrap: wrap; justify-content: center; }
.social-btn {
    width: 70px; height: 70px; border-radius: 1.2rem;
    background: var(--bg-main); border: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; color: var(--text-main); text-decoration: none;
    transition: transform 0.2s, background-color 0.2s, color 0.2s;
    box-shadow: var(--shadow);
}
.social-btn:hover { background: var(--color-primary); color: white; transform: translateY(-5px); border-color: var(--color-primary); }

/* --- الناف بار السفلي --- */
.nav-fixed { position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%); z-index: 50; }
.nav-pills {
    display: flex; gap: 0.5rem; padding: 0.5rem;
    background: var(--glass-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-radius: 999px; border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}
.nav-item {
    padding: 0.7rem 1.5rem; border-radius: 999px; border: none;
    background: transparent; color: var(--text-muted); font-weight: 600; cursor: pointer;
    transition: background-color 0.2s, color 0.2s; font-size: 0.9rem;
}
.nav-item.active { background: var(--text-main); color: var(--bg-main); }

@media (max-width: 768px) {
    .main-wrapper { padding: 4.5rem 0 6rem 0; }
    .glass-card { border-radius: 0; border-left: none; border-right: none; box-shadow: none; max-width: 100%; }
    .header-fixed { top: 0.8rem; width: 95%; }
    .nav-fixed { bottom: 1.2rem; width: 92%; }
    .nav-pills { width: 100%; justify-content: space-between; gap: 2px; }
    .nav-item { padding: 0.6rem 0.5rem; font-size: 0.8rem; flex: 1; }
    .hero-title { font-size: 2.5rem; }
    .section { padding: 1.5rem; }
    .projects-grid, .skills-grid { grid-template-columns: 1fr; }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }