/* =========================================
   1. CSS Variables & Theme Setup
   ========================================= */
   :root {
    /* Colors - Light Mode (Default) */
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --bg-body: #ffffff;
    --bg-card: #f8f9fa;
    --text-main: #333333;
    --text-muted: #6c757d;
    --border-color: #e9ecef;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --hero-overlay: rgba(255, 255, 255, 0.85);
    
    /* Layout */
    --container-width: 1200px;
    --header-height: 70px;
}

[data-theme="dark"] {
    /* Colors - Dark Mode */
    --primary-color: #3a8fdc; /* Slightly lighter for dark mode contrast */
    --primary-hover: #5aa4e6;
    --bg-body: #121212;
    --bg-card: #1e1e1e;
    --text-main: #e0e0e0;
    --text-muted: #b0b0b0;
    --border-color: #333333;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
    --hero-overlay: rgba(0, 0, 0, 0.7);
}

/* =========================================
   2. Reset & Base Styles
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    direction: var(--dir, ltr); /* Default LTR, will be overridden by HTML attribute */
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

img {
    max-width: 100%;
    display: block;
}

/* =========================================
   3. Typography
   ========================================= */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 20px;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; position: relative; margin-bottom: 40px; }
h3 { font-size: 1.5rem; }

/* Section Titles */
.section-title {
    text-align: center;
    margin-bottom: 60px;
}

.section-title span {
    color: var(--primary-color);
}

/* =========================================
   4. Utility Classes
   ========================================= */
.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 20px;
}

.btn {
    display: inline-block;
    padding: 12px 30px;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
    font-family: inherit;
    font-size: 1rem;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 123, 255, 0.3);
}

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

.btn-outline:hover {
    background-color: var(--primary-color);
    color: #fff;
    transform: translateY(-2px);
}

/* =========================================
   5. Components
   ========================================= */

/* Loading Screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-body);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.loader {
    width: 50px;
    height: 50px;
    border: 3px solid var(--bg-card);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-text {
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 1px;
}

/* Navbar */
header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    background-color: rgba(var(--bg-body-rgb), 0.95); /* We'll need RGB vars for this properly, but simple solid is safer for now */
    background-color: var(--bg-body);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    height: var(--header-height);
    display: flex;
    align-items: center;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 20px;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.nav-links {
    display: flex;
    gap: 30px;
}

.nav-links a {
    font-weight: 600;
    position: relative;
}

.nav-links a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -5px;
    left: 0; /* Changed from right to left for LTR default support, RTL will specific */
    background-color: var(--primary-color);
    transition: width 0.3s;
}

html[dir="rtl"] .nav-links a::after {
    right: 0;
    left: auto;
}

.nav-links a:hover::after {
    width: 100%;
}

.nav-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.theme-toggle, .lang-switch {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
}

/* Hero Section */
.hero {
    height: 100vh;
    display: flex;
    align-items: center;
    position: relative;
    padding-top: var(--header-height);
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-body) 100%);
    overflow: hidden;
}

.hero-content {
    max-width: 600px;
    z-index: 2;
}

.hero p {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 30px;
}

.hero-btns {
    display: flex;
    gap: 15px;
}

/* Services */
.services {
    padding: 100px 0;
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
}

.service-card {
    background-color: var(--bg-card);
    padding: 30px;
    border-radius: 15px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.3s;
    border: 1px solid var(--border-color);
}

.service-card:hover {
    transform: translateY(-10px);
}

.service-icon {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 20px;
}

/* Portfolio */
.portfolio {
    padding: 100px 0;
    background-color: var(--bg-card);
}

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

/* Portfolio Filter */
.portfolio-filters {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 20px;
    border: 2px solid var(--primary-color);
    border-radius: 25px;
    background: transparent;
    color: var(--text-main);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.filter-btn:hover,
.filter-btn.active {
    background-color: var(--primary-color);
    color: #fff;
}

/* Portfolio Grid Animation */
.portfolio-item {
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: var(--shadow);
    background-color: var(--bg-body);
    transition: all 0.4s ease;
}

.portfolio-item.hide {
    display: none;
}

.portfolio-item.show {
    display: block;
    animation: fadeIn 0.5s ease forwards;
}

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

.portfolio-img {
    width: 100%;
    height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ddd; /* Placeholder color */
    color: #555;
    font-weight: bold;
    overflow: hidden;
}

.portfolio-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s;
}

.portfolio-item:hover .portfolio-img img {
    transform: scale(1.1);
}

.portfolio-content {
    padding: 20px;
}

.portfolio-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.portfolio-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 15px;
}

.portfolio-tags span {
    display: inline-block;
    background-color: var(--primary-color);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    margin-right: 5px; /* RTL fix needed later? */
}

html[dir="rtl"] .portfolio-tags span {
    margin-right: 0;
    margin-left: 5px;
}

/* About */
.about {
    padding: 100px 0;
}

.about-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 50px;
    align-items: center;
}

.about-text p {
    margin-bottom: 20px;
    color: var(--text-muted);
}

.social-links {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

.social-link {
    font-size: 1.5rem;
    color: var(--text-main);
}

.social-link:hover {
    color: var(--primary-color);
}

/* Contact */
.contact {
    padding: 100px 0;
    background-color: var(--bg-card);
}

.contact-wrapper {
    max-width: 800px;
    margin: 0 auto;
}

.contact-form {
    display: grid;
    gap: 20px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: inherit;
}

.form-group textarea {
    height: 150px;
    resize: vertical;
}

.contact-methods {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 50px;
}

.contact-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

/* Footer */
footer {
    padding: 30px 0;
    text-align: center;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
}

/* Floating Action Button (FAB) */
.fab-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 15px;
}

/* For RTL Layout */
html[dir="rtl"] .fab-container {
    right: auto;
    left: 30px;
}

.fab-main {
    width: 60px;
    height: 60px;
    background-color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.8rem;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.4);
    cursor: pointer;
    transition: transform 0.3s, background-color 0.3s;
    border: none;
}

.fab-main:hover {
    transform: scale(1.1);
}

.fab-menu {
    display: flex;
    flex-direction: column;
    gap: 15px;
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    transition: all 0.3s ease;
}

.fab-container:hover .fab-menu,
.fab-menu.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.fab-item {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.4rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: transform 0.2s;
    text-decoration: none;
}

.fab-item:hover {
    transform: scale(1.1);
}

.fab-whatsapp { background-color: #25D366; }
.fab-telegram { background-color: #0088cc; }
.fab-email { background-color: #EA4335; }

/* Animations Logic classes */
.hidden-el {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s ease-out;
}

.show-el {
    opacity: 1;
    transform: translateY(0);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* =========================================
   6. Media Queries & Mobile
   ========================================= */
@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.8rem; }
    
    .nav-links {
        position: fixed;
        top: var(--header-height);
        right: -100%; /* LTR default */
        width: 100%;
        height: calc(100vh - var(--header-height));
        background-color: var(--bg-body);
        flex-direction: column;
        justify-content: center;
        align-items: center;
        transition: right 0.3s;
        border-top: 1px solid var(--border-color);
    }
    
    html[dir="rtl"] .nav-links {
        right: auto;
        left: -100%;
        transition: left 0.3s;
    }
    
    .nav-links.active {
        right: 0;
    }
    
    html[dir="rtl"] .nav-links.active {
        left: 0;
    }
    
    .mobile-menu-btn {
        display: block;
        font-size: 1.5rem;
        cursor: pointer;
    }
    
    .about-content {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 769px) {
    .mobile-menu-btn {
        display: none;
    }
}
