/* ==================== CSS Variables (Loaded from theme.json) ==================== */
:root {
    /* Colors */
    --color-primary: #3b82f6;
    --color-secondary: #8b5cf6;
    --color-accent: #06b6d4;
    --color-background: #ffffff;
    --color-surface: #f8fafc;
    --color-text: #1e293b;
    --color-text-secondary: #64748b;
    --color-border: #e2e8f0;
    --color-success: #10b981;
    --color-error: #ef4444;
    --color-warning: #f59e0b;
    
    /* Fonts */
    --font-heading: 'Cairo', sans-serif;
    --font-body: 'Tajawal', sans-serif;
    --font-monospace: 'Courier New', monospace;
    
    /* Typography */
    --font-size-base: 16px;
    --font-size-h1: 3rem;
    --font-size-h2: 2.25rem;
    --font-size-h3: 1.875rem;
    --font-size-h4: 1.5rem;
    --line-height: 1.6;
    
    /* Spacing */
    --container-max-width: 1200px;
    --section-padding: 4rem;
    --card-padding: 1.5rem;
    --border-radius: 0.75rem;
    
    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --transition-speed: 0.3s;
}

/* RTL Support */
[dir="rtl"] {
    direction: rtl;
}

/* RTL Timeline Fix */
[dir="rtl"] .timeline::before {
    left: auto;
    right: 50%;
}

[dir="rtl"] .timeline-item {
    justify-content: flex-start;
}

[dir="rtl"] .timeline-item:nth-child(even) {
    justify-content: flex-end;
    margin-left: 0;
    margin-right: 50%;
}

[dir="rtl"] .timeline-item::before {
    left: auto;
    right: -6px;
}

[dir="rtl"] .timeline-item:nth-child(even)::before {
    right: auto;
    left: -6px;
}

/* RTL Navigation */
[dir="rtl"] .navbar .container {
    flex-direction: row-reverse;
}

/* ==================== Reset & Base Styles ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: var(--font-size-base);
}

body {
    font-family: var(--font-body);
    color: var(--color-text);
    background-color: var(--color-background);
    line-height: var(--line-height);
    overflow-x: hidden;
}

/* ==================== Loading Screen ==================== */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--color-background);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.3s, visibility 0.3s;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== Typography ==================== */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1rem;
}

h1 { font-size: var(--font-size-h1); }
h2 { font-size: var(--font-size-h2); }
h3 { font-size: var(--font-size-h3); }
h4 { font-size: var(--font-size-h4); }

p {
    margin-bottom: 1rem;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-speed);
}

a:hover {
    color: var(--color-secondary);
}

/* ==================== Container ==================== */
.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 2rem;
}

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all var(--transition-speed);
    text-decoration: none;
}

.btn-primary {
    background-color: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--color-secondary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-outline {
    background-color: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
}

.btn-outline:hover {
    background-color: var(--color-primary);
    color: white;
}

/* ==================== Navigation ==================== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: var(--color-background);
    box-shadow: var(--shadow-sm);
    z-index: 1000;
    transition: all var(--transition-speed);
}

.navbar.scrolled {
    box-shadow: var(--shadow-md);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
}

.nav-brand {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-link {
    color: var(--color-text);
    font-weight: 500;
    transition: color var(--transition-speed);
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--color-primary);
    transition: width var(--transition-speed);
}

.nav-link:hover,
.nav-link.active {
    color: var(--color-primary);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--color-text);
    cursor: pointer;
}

/* ==================== Hero Section ==================== */
.hero-section {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 80px;
    overflow: hidden;
}

.hero-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    z-index: -2;
}

.hero-background video,
.hero-background img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
}

.hero-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: center;
}

.hero-text {
    color: white;
}

.hero-title {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
    animation: fadeInUp 0.8s ease-out;
}

.hero-subtitle {
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 1rem;
    animation: fadeInUp 0.8s ease-out 0.2s backwards;
}

.hero-bio {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 2rem;
    animation: fadeInUp 0.8s ease-out 0.4s backwards;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    animation: fadeInUp 0.8s ease-out 0.6s backwards;
}

.social-links {
    display: flex;
    gap: 1rem;
    animation: fadeInUp 0.8s ease-out 0.8s backwards;
}

.social-link {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: white;
    font-size: 1.2rem;
    transition: all var(--transition-speed);
    backdrop-filter: blur(10px);
}

.social-link:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-3px);
}

.hero-image {
    display: flex;
    justify-content: center;
    animation: fadeInUp 0.8s ease-out 0.4s backwards;
}

.profile-photo {
    width: 100%;
    max-width: 400px;
    height: auto;
    border-radius: 50%;
    border: 5px solid rgba(255, 255, 255, 0.3);
    box-shadow: var(--shadow-lg);
    object-fit: cover;
    aspect-ratio: 1;
}

.scroll-indicator {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 2rem;
    animation: bounce 2s infinite;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    40% {
        transform: translateX(-50%) translateY(-10px);
    }
    60% {
        transform: translateX(-50%) translateY(-5px);
    }
}

/* ==================== Sections ==================== */
.section {
    padding: var(--section-padding) 0;
}

.section.bg-surface {
    background-color: var(--color-surface);
}

.section-title {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
    padding-bottom: 1rem;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    border-radius: 2px;
}

/* ==================== About Section ==================== */
.about-content {
    max-width: 800px;
    margin: 0 auto;
}

.about-text {
    font-size: 1.1rem;
    color: var(--color-text-secondary);
    text-align: center;
    line-height: 1.8;
}

/* ==================== Timeline (Experience & Education) ==================== */
.timeline {
    position: relative;
    padding: 2rem 0;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--color-border);
}

.timeline-item {
    position: relative;
    margin-bottom: 3rem;
    display: flex;
    justify-content: flex-end;
    width: 50%;
}

.timeline-item:nth-child(even) {
    align-self: flex-end;
    justify-content: flex-start;
    margin-left: 50%;
}

.timeline-content {
    position: relative;
    background-color: var(--color-background);
    padding: var(--card-padding);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    width: calc(100% - 0.9rem);
    transition: all var(--transition-speed);
}

.timeline-content:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.timeline-content::before {
    content: '';
    position: absolute;
    left: -28px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    background-color: var(--color-primary);
    border-radius: 50%;
    border: 3px solid var(--color-background);
    box-shadow: var(--shadow-md);
    z-index: 10;
}

.timeline-item:nth-child(even) .timeline-content::before {
    left: auto;
    right: -28px;
}

.timeline-date {
    display: inline-block;
    background-color: var(--color-primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.timeline-title {
    font-size: 1.25rem;
    color: var(--color-text);
    margin-bottom: 0.25rem;
}

.timeline-subtitle {
    color: var(--color-text-secondary);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.timeline-location {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.timeline-description {
    color: var(--color-text-secondary);
    line-height: 1.6;
}

/* ==================== Skills Section ==================== */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.skill-card {
    background-color: var(--color-background);
    padding: var(--card-padding);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-speed);
}

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

.skill-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.skill-name {
    font-weight: 600;
    color: var(--color-text);
}

.skill-level {
    font-weight: 600;
    color: var(--color-primary);
}

.skill-bar {
    height: 8px;
    background-color: var(--color-border);
    border-radius: 4px;
    overflow: hidden;
}

.skill-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    border-radius: 4px;
    transition: width 1s ease-out;
    width: 0;
}

.skill-card.animate .skill-progress {
    width: var(--skill-width);
}

/* ==================== Projects Section ==================== */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.project-card {
    background-color: var(--color-background);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-speed);
}

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

.project-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background-color: var(--color-surface);
}

.project-content {
    padding: var(--card-padding);
}

.project-name {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.project-description {
    color: var(--color-text-secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.project-technologies {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tech-tag {
    background-color: var(--color-surface);
    color: var(--color-primary);
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.project-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: white;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    font-weight: 600;
    transition: all var(--transition-speed);
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-family: inherit;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
    width: 100%;
    margin-top: 1rem;
}

.project-link:hover {
    gap: 0.75rem;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* ==================== Certificates Section ==================== */
.certificates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

.certificate-card {
    background-color: var(--color-background);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-speed);
    cursor: pointer;
}

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

.certificate-image {
    width: 100%;
    height: 250px;
    object-fit: cover;
    background-color: var(--color-surface);
}

.certificate-content {
    padding: 1.5rem;
}

.certificate-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.certificate-issuer {
    color: var(--color-text-secondary);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.certificate-date {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.certificate-link {
    display: inline-block;
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color var(--transition-speed);
}

.certificate-link:hover {
    color: var(--color-secondary);
}

/* Certificate Modal */
.certificate-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.certificate-modal.active {
    display: flex;
}

.certificate-modal-content {
    max-width: 90%;
    max-height: 90%;
}

.certificate-modal-image {
    width: 100%;
    height: auto;
    max-height: 90vh;
    object-fit: contain;
}

.certificate-modal-close {
    position: absolute;
    top: 20px;
    right: 40px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.certificate-modal-close:hover {
    color: var(--color-primary);
}

/* Project Modal */
.project-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1001;
    align-items: center;
    justify-content: center;
}

.project-modal.active {
    display: flex;
}

.project-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.project-modal-content {
    position: relative;
    background-color: var(--color-background);
    border-radius: var(--border-radius);
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    z-index: 1002;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.project-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 2rem;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: color 0.3s;
    z-index: 1003;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-surface);
    border-radius: 50%;
}

.project-modal-close:hover {
    color: var(--color-primary);
}

.project-modal-body {
    padding: 2rem;
}

.project-modal-image {
    width: 100%;
    height: 300px;
    object-fit: cover;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
}

.project-modal-title {
    font-size: 2rem;
    color: var(--color-text);
    margin-bottom: 1rem;
}

.project-modal-technologies {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.project-modal-details {
    color: var(--color-text-secondary);
    line-height: 1.8;
    margin-bottom: 2rem;
    white-space: pre-line;
}

.project-modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.project-modal-actions .btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s;
}

.project-modal-actions .btn-primary {
    background-color: var(--color-primary);
    color: white;
}

.project-modal-actions .btn-primary:hover {
    background-color: var(--color-secondary);
    transform: translateY(-2px);
}

/* ==================== Contact Section ==================== */
.contact-content {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

.contact-info {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.contact-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    font-size: 1.1rem;
    color: var(--color-text);
}

.contact-item i {
    color: var(--color-primary);
    font-size: 1.5rem;
}

.contact-social {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* ==================== Footer ==================== */
.footer {
    background-color: var(--color-text);
    color: white;
    padding: 2rem 0;
    text-align: center;
}

.footer p {
    margin-bottom: 0.5rem;
}

.footer-link a {
    color: var(--color-primary);
}

/* ==================== Scroll to Top Button ==================== */
.scroll-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background-color: var(--color-primary);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-speed);
    z-index: 999;
}

.scroll-top.visible {
    opacity: 1;
    visibility: visible;
}

.scroll-top:hover {
    background-color: var(--color-secondary);
    transform: translateY(-3px);
}

/* ==================== Lazy Loading ==================== */
.lazy-load {
    opacity: 0;
    transition: opacity 0.3s;
}

.lazy-load.loaded {
    opacity: 1;
}

/* ==================== Responsive Design ==================== */
@media (max-width: 768px) {
    :root {
        --font-size-h1: 2rem;
        --font-size-h2: 1.75rem;
        --font-size-h3: 1.5rem;
        --section-padding: 3rem;
    }

    .nav-menu {
        position: fixed;
        left: -100%;
        top: 70px;
        flex-direction: column;
        background-color: var(--color-background);
        width: 100%;
        text-align: center;
        transition: left 0.3s;
        box-shadow: var(--shadow-lg);
        padding: 2rem 0;
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-toggle {
        display: block;
    }

    .hero-content {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .hero-image {
        order: -1;
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .hero-buttons {
        flex-direction: column;
    }

    .social-links {
        justify-content: center;
    }

    .timeline::before {
        left: 0;
    }

    .timeline-item,
    .timeline-item:nth-child(even) {
        width: 100%;
        margin-left: 0;
        margin-right: 0;
        justify-content: flex-start;
        padding-left: 2rem;
    }

    .timeline-item::before,
    .timeline-item:nth-child(even)::before {
        left: -6px;
        right: auto;
    }

    /* RTL Mobile Timeline */
    [dir="rtl"] .timeline::before {
        left: auto;
        right: 0;
    }

    [dir="rtl"] .timeline-item,
    [dir="rtl"] .timeline-item:nth-child(even) {
        padding-left: 0;
        padding-right: 2rem;
    }

    [dir="rtl"] .timeline-item::before,
    [dir="rtl"] .timeline-item:nth-child(even)::before {
        left: auto;
        right: -6px;
    }

    /* RTL Mobile Nav */
    [dir="rtl"] .nav-menu {
        left: auto;
        right: -100%;
        transition: right 0.3s;
    }

    [dir="rtl"] .nav-menu.active {
        right: 0;
        left: auto;
    }

    .projects-grid {
        grid-template-columns: 1fr;
    }

    .skills-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 1rem;
    }

    .hero-title {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: 1.25rem;
    }
}
