/* ==========================================================================
   CSS Variables & Typography
   ========================================================================== */
:root {
    /* Colors */
    --primary-bg: #121212;
    --card-bg: #1e1e1e;
    --accent-color: rgba(243, 157, 12, 1);
    --accent-color-hover: rgba(243, 157, 12, 0.8);
    --text-main: #ffffff;
    --text-muted: #a0a0a0;
    --whatsapp-color: #25d366;
    --whatsapp-hover: #128c7e;

    /* Transitions */
    --transition-fast: 0.2s ease-in-out;
    --transition-normal: 0.3s ease-in-out;
    --transition-slow: 0.5s ease-in-out;
}

body {
    background-color: var(--primary-bg);
    color: var(--text-main);
    font-family: 'Cairo', sans-serif; /* Default AR Font */
    overflow-x: hidden;
}

/* LTR Specific overrides handled via JS / body class */
body[dir="ltr"] {
    font-family: 'Outfit', sans-serif; /* EN Font */
}

/* Typography Helper Classes */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-main);
    font-weight: 700;
}

p {
    color: var(--text-muted);
    font-size: 1.05rem;
    line-height: 1.8;
}

.text-muted {
    color: var(--text-muted) !important;
}

.text-primary-custom {
    color: var(--accent-color) !important;
}

.bg-dark-section {
    background-color: #0d0d0d;
}

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

.py-6 {
    padding-top: 5rem;
    padding-bottom: 5rem;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn-primary-custom {
    background-color: var(--accent-color);
    color: var(--text-main);
    border: 1px solid var(--accent-color);
    font-weight: 600;
    border-radius: 0.5rem;
    transition: var(--transition-normal);
}

.btn-primary-custom:hover, .btn-primary-custom:focus {
    background-color: transparent;
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.btn-secondary-custom {
    background-color: transparent;
    color: var(--text-main);
    border: 1px solid var(--accent-color);
    font-weight: 600;
    border-radius: 0.5rem;
    transition: var(--transition-normal);
}

.btn-secondary-custom:hover, .btn-secondary-custom:focus {
    background-color: var(--accent-color);
    color: var(--text-main);
}

.btn-lang {
    background-color: var(--card-bg);
    color: var(--text-main);
    border: 1px solid #333;
    border-radius: 20px;
    padding: 0.4rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    transition: var(--transition-normal);
}

.btn-lang:hover {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

.btn-whatsapp {
    background-color: var(--whatsapp-color);
    color: #fff;
    border: none;
    transition: var(--transition-normal);
}

.btn-whatsapp:hover {
    background-color: var(--whatsapp-hover);
    color: #fff;
    transform: translateY(-3px);
}

.hover-lift {
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}
.hover-lift:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.3) !important;
}

/* ==========================================================================
   Preloader
   ========================================================================== */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--primary-bg);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
}

#preloader.preloader-hidden {
    opacity: 0;
    visibility: hidden;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(243, 157, 12, 0.2);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ==========================================================================
   Navbar
   ========================================================================== */
.custom-navbar {
    background-color: rgba(18, 18, 18, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: var(--transition-normal);
}

.custom-navbar.scrolled {
    padding-top: 0.8rem !important;
    padding-bottom: 0.8rem !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.nav-link {
    color: var(--text-main) !important;
    font-weight: 500;
    margin: 0 0.5rem;
    position: relative;
    opacity: 0.8;
    transition: var(--transition-normal);
}

.nav-link:hover, .nav-link.active {
    opacity: 1;
    color: var(--accent-color) !important;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background-color: var(--accent-color);
    transition: var(--transition-normal);
}

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

.navbar-toggler {
    border: none;
    box-shadow: none !important;
}

/* ==========================================================================
   Hero Section
   ========================================================================== */
.hero {
    min-height: 100vh;
    padding-top: 190px; /* Increased from 80px to accommodate 150px logo navbar */
    position: relative;
    overflow: hidden;
}

.page-header {
    padding-top: 190px !important; /* Forces the header down away from the tall navbar */
}

.hero-img {
    position: relative;
    z-index: 2;
    transition: transform 0.5s ease;
    animation: float 6s ease-in-out infinite;
    /* Adjust lightness, contrast and saturation for a better blend with dark theme */
    filter: brightness(0.85) contrast(1.15) saturate(1.1);
    border: 1px solid rgba(255, 255, 255, 0.1); /* Subtle layer effect */
}

.hero-image-wrapper {
    position: relative;
}

.glow-effect {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 80%;
    background: radial-gradient(circle, var(--accent-color) 0%, transparent 60%);
    opacity: 0.15;
    filter: blur(50px);
    z-index: 1;
}

.hero-bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(18,18,18,1) 0%, rgba(30,30,30,0.4) 100%);
    z-index: 0;
    pointer-events: none;
}

html[dir="rtl"] .fade-left {
    animation-name: fadeRightAnim; /* Reverse for RTL */
}

/* ==========================================================================
   Section Components
   ========================================================================== */
.section-title {
    position: relative;
    display: inline-block;
}

.title-underline {
    width: 60px;
    height: 3px;
    background-color: var(--accent-color);
    border-radius: 2px;
}

/* ==========================================================================
   Services Section
   ========================================================================== */
.service-card {
    background-color: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: 3px solid transparent;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
}

.service-card:hover {
    transform: translateY(-10px);
    border-bottom-color: var(--accent-color);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}

.icon-wrapper i {
    color: var(--accent-color);
    transition: transform var(--transition-normal);
}

.service-card:hover .icon-wrapper i {
    transform: scale(1.15);
}

/* ==========================================================================
   Portfolio Section
   ========================================================================== */
.portfolio-item {
    cursor: pointer;
}

.portfolio-item img {
    transition: transform var(--transition-slow), filter var(--transition-normal);
    filter: brightness(0.9) contrast(1.1) saturate(1.1);
}

.portfolio-img-fix {
    width: 100%;
    height: 300px;
    object-fit: cover;
}

.portfolio-item:hover img {
    transform: scale(1.08);
    filter: brightness(1) contrast(1.2) saturate(1.2);
}

.portfolio-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(243, 157, 12, 0); /* Transparent initially */
    opacity: 0;
    transition: var(--transition-normal);
}

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

.portfolio-item:hover .portfolio-overlay {
    background-color: rgba(243, 157, 12, 0.85); /* Accent color 80%+ opacity */
    opacity: 1;
}

.portfolio-overlay h4 {
    transform: translateY(20px);
    transition: transform var(--transition-normal);
}

.portfolio-item:hover .portfolio-overlay h4 {
    transform: translateY(0);
}

/* ==========================================================================
   Contact Section
   ========================================================================== */
.contact-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.contact-item:hover .contact-icon {
    background-color: var(--accent-color);
}
.contact-item:hover .contact-icon i {
    color: #fff !important;
}

.map-wrapper iframe {
    filter: grayscale(80%) invert(90%) contrast(80%); /* Dark mode map effect */
    transition: filter var(--transition-normal);
}

.map-wrapper:hover iframe {
    filter: grayscale(20%) invert(90%) contrast(90%);
}

/* ==========================================================================
   Floating Action Button
   ========================================================================== */
.floating-whatsapp {
    position: fixed;
    bottom: 30px;
    right: 30px; /* Default RTL/LTR adjusted via JS or CSS flex if needed, but fixed right is common */
    width: 60px;
    height: 60px;
    background-color: var(--whatsapp-color);
    color: white;
    border-radius: 50%;
    font-size: 2rem;
    z-index: 1000;
    transition: var(--transition-normal);
    animation: pulse 2s infinite;
}

.floating-whatsapp:hover {
    background-color: var(--whatsapp-hover);
    color: white;
    transform: scale(1.1);
    animation: none;
}

html[dir="rtl"] .floating-whatsapp {
    left: 30px;
    right: auto;
}
html[dir="ltr"] .floating-whatsapp {
    right: 30px;
    left: auto;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
    100% { transform: translateY(0px); }
}

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

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(37, 211, 102, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

/* Fade In Animations */
.fade-up {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.fade-up.visible {
    opacity: 1;
    transform: translateY(0);
}

.fade-left {
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.fade-left.visible {
    opacity: 1;
    transform: translateX(0);
}

.fade-right {
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.fade-right.visible {
    opacity: 1;
    transform: translateX(0);
}

.footer {
    border-top: 1px solid rgba(255, 255, 255, 0.05) !important;
}

.social-links a {
    transition: color 0.3s ease-in-out, transform 0.3s;
}

.social-links a:hover {
    color: var(--accent-color) !important;
    transform: translateY(-3px);
}

/* ==========================================================================
   AI Chatbot Widget
   ========================================================================== */
.chatbot-toggler {
    position: fixed;
    bottom: 30px;
    right: 100px; /* Changed from 30px to sit next to WhatsApp */
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    transition: var(--transition-normal);
}

/* Default RTL -> Bottom Left, LTR -> Bottom Right */
body:not([dir="ltr"]) .chatbot-toggler {
    right: auto;
    left: 100px; /* Changed from 30px */
}
body:not([dir="ltr"]) .chatbot-popup {
    right: auto;
    left: 30px;
}

.chatbot-toggler:hover {
    background-color: var(--accent-color-hover);
    transform: scale(1.05);
}

.chatbot-popup {
    position: fixed;
    bottom: 100px;
    right: 30px; /* default LTR right, overridden by left in RTL */
    width: 350px;
    max-width: calc(100vw - 60px);
    background-color: #1E1E1E;
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1050; /* Increased to 1050 to appear OVER the navbar (which is 1030) */
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: var(--transition-normal);
}

.chatbot-popup.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.chat-header {
    background-color: var(--accent-color);
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
}

.chat-body {
    height: 280px; /* Reduced from 350px so it fits better on small laptops/phones without hitting the top */
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-message {
    max-width: 85%;
    padding: 10px 15px;
    border-radius: 15px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.bot-message {
    align-self: flex-start; /* Right in RTL */
    background-color: #2A2A2A;
    color: #A0A0A0;
    border-bottom-right-radius: 2px;
}

.user-message {
    align-self: flex-end; /* Left in RTL */
    background-color: var(--accent-color);
    color: #ffffff;
    border-bottom-left-radius: 2px;
}

.chat-footer {
    display: flex;
    padding: 10px;
    border-top: 1px solid rgba(255,255,255,0.05);
    background-color: #1E1E1E;
}

.chat-footer input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    outline: none;
    padding: 5px 10px;
}

.chat-footer input::placeholder {
    color: rgba(255,255,255,0.3);
}

.chat-footer button {
    background-color: var(--accent-color);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-normal);
}

.chat-footer button:hover {
    background-color: var(--accent-color-hover);
}

/* ==========================================================================
   Responsive Design & Media Queries
   ========================================================================== */
@media (max-width: 991.98px) {
    /* Adjust general padding for mobile/tablet */
    .py-6 {
        padding-top: 3rem;
        padding-bottom: 3rem;
    }
}

@media (max-width: 768px) {
    /* Hero section text scaling */
    .hero h1.display-4 {
        font-size: 2.2rem !important;
    }
    .hero p.lead {
        font-size: 1.1rem;
    }

    /* Logo scaling down on mobile to preserve vertical space */
    .logo-img {
        height: 70px !important;
    }

    /* Adjust portfolio button wrapping so they aren't too bulky */
    #portfolio-flters button {
        font-size: 0.85rem;
        padding: 0.375rem 0.75rem;
    }

    /* Make portfolio images a bit smaller on mobile */
    .portfolio-img-fix {
        height: 250px;
    }

    /* Section titles slightly smaller */
    .section-title {
        font-size: 1.7rem;
    }
}

@media (max-width: 576px) {
    /* Hero section text further scaling */
    .hero h1.display-4 {
        font-size: 1.8rem !important;
    }

    /* Logo even smaller on very small screens */
    .logo-img {
        height: 60px !important;
    }
}
