:root {
    --primary: #0F172A;
    --primary-dark: #020617;
    --secondary: #1E293B;
    --accent: #3B82F6;
    --accent-light: #60A5FA;
    --light: #F8FAFC;
    --gray-50: #F8FAFC;
    --gray-100: #F1F5F9;
    --gray-200: #E2E8F0;
    --gray-300: #CBD5E1;
    --gray-400: #94A3B8;
    --gray-500: #64748B;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1E293B;
    --gray-900: #0F172A;
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    --spacing-3xl: 4rem;
    --spacing-4xl: clamp(3rem, 6vw, 7rem);
    --radius-sm: 0.125rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    --radius-2xl: 1rem;
    --radius-3xl: 1.5rem;
    --radius-full: 9999px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-cta: 0 8px 24px rgba(59, 130, 246, 0.35);
    --transition-fast: 150ms ease-out;
    --transition-normal: 300ms ease-out;
    --transition-slow: 500ms ease-out;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Cairo', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--gray-700);
    background-color: var(--light);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Cairo', 'Inter', sans-serif;
    line-height: 1.2;
    color: var(--gray-900);
    margin-bottom: var(--spacing-md);
}

h1 { font-size: clamp(2.4rem, 6vw, 4rem); line-height: 1.2; font-weight: 800; }
h2 { font-size: clamp(1.8rem, 4.6vw, 2.6rem); line-height: 1.3; font-weight: 700; }
h3 { font-size: clamp(1.35rem, 3vw, 1.75rem); font-weight: 600; }
h4 { font-size: clamp(1.25rem, 2.5vw, 1.875rem); font-weight: 600; }
h5 { font-size: clamp(1rem, 2vw, 1.5rem); font-weight: 500; }
h6 { font-size: clamp(1rem, 1.5vw, 1.25rem); font-weight: 500; }

.text-primary { color: var(--primary); }
.text-secondary { color: var(--secondary); }
.text-accent { color: var(--accent); }
.text-light { color: var(--light); }
.text-gray { color: var(--gray-500); }
.text-dark { color: var(--gray-800); }

/* Enhanced text colors for better readability */
.hero__content {
    color: var(--light);
}

.about {
    color: var(--light);
}

.footer {
    color: var(--light);
}

.header__nav a {
    color: var(--gray-800);
    font-weight: 600;
}

.header__nav a:hover {
    color: var(--primary);
}

.service p {
    color: var(--gray-600);
}

.form-label {
    color: var(--gray-800);
    font-weight: 600;
}

p {
    color: var(--gray-600);
    line-height: 1.8;
    font-weight: 400;
}

/* Circuit pattern background */
.circuit-pattern {
    background-image:
        radial-gradient(circle at 25% 25%, rgba(59, 130, 246, 0.03) 2px, transparent 2px),
        radial-gradient(circle at 75% 75%, rgba(59, 130, 246, 0.03) 2px, transparent 2px),
        linear-gradient(45deg, rgba(59, 130, 246, 0.02) 1px, transparent 1px),
        linear-gradient(-45deg, rgba(59, 130, 246, 0.02) 1px, transparent 1px);
    background-size: 40px 40px, 40px 40px, 20px 20px, 20px 20px;
    background-position: 0 0, 20px 20px, 0 0, 0 0;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md) var(--spacing-xl);
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: var(--light);
    box-shadow: var(--shadow-cta);
    font-weight: 600;
    padding: var(--spacing-lg) var(--spacing-2xl);
    font-size: 1.125rem;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    background: var(--light);
    color: var(--primary);
    border: 2px solid var(--primary);
    box-shadow: var(--shadow-md);
}

.btn-secondary:hover {
    background: var(--primary);
    color: var(--light);
    transform: translateY(-1px);
}

.section {
    padding: var(--spacing-4xl) 0;
}

.fade-in {
    opacity: 0;
    transform: translateY(2rem);
    animation: fadeInUp 0.8s ease-out forwards;
}

.fade-in.delay-1 { animation-delay: 0.1s; }
.fade-in.delay-2 { animation-delay: 0.2s; }
.fade-in.delay-3 { animation-delay: 0.3s; }

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

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 50;
    transition: background .25s ease, box-shadow .25s ease, border-color .25s ease;
    backdrop-filter: none;
}

.header.scrolled {
    backdrop-filter: blur(14px);
    background: rgba(255,255,255,.6);
    border-bottom: 1px solid rgba(15, 23, 42, .12);
}

.header__container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 4rem;
}

.header__logo {
    height: 2rem;
    width: auto;
}

.header__nav {
    display: flex;
    align-items: center;
    gap: var(--spacing-2xl);
}

.header__nav ul {
    display: flex;
    list-style: none;
    gap: var(--spacing-xl);
}

.header__nav a {
    color: var(--gray-700);
    text-decoration: none;
    font-weight: 500;
    letter-spacing: .025em;
    padding: .75rem 1rem;
    border-radius: .5rem;
    transition: color var(--transition-fast), background var(--transition-fast);
}

.header__nav a:hover,
.header__nav a:focus-visible {
    background: rgba(15,23,42,.06);
}

.header__nav a.active {
    color: #0F172A;
    background: rgba(59,130,246,.12);
}

/* Hero */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, rgba(6,12,24,.55), rgba(6,12,24,.65));
    z-index: -1;
}

.hero video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -2;
}

.hero__fallback-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -2;
    display: none;
}

.hero__container {
    position: relative;
    z-index: 2;
    max-width: 800px;
}

.hero__content {
    text-align: right;
    color: var(--light);
    padding: var(--spacing-xl);
}

.hero__title {
    color: #F8FAFC;
    text-shadow: 0 2px 16px rgba(0,0,0,.45);
    font-size: clamp(2.2rem, 6vw, 4.2rem);
    font-weight: 900;
    line-height: 1.2;
    letter-spacing: .01em;
    margin-bottom: var(--spacing-lg);
}

.hero__subtitle {
    color: #E5EDF5;
    text-shadow: 0 1px 10px rgba(0,0,0,.35);
    font-size: clamp(1rem, 2.2vw, 1.125rem);
    font-weight: 400;
    margin-bottom: var(--spacing-2xl);
    line-height: 1.9;
    max-width: 62ch;
}

.hero__cta {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: var(--light);
    box-shadow: var(--shadow-cta);
    font-weight: 600;
    padding: var(--spacing-lg) var(--spacing-2xl);
    font-size: 1.125rem;
    border: 0;
    border-radius: 999px;
    transition: transform .15s ease, box-shadow .2s ease, opacity .2s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 40px rgba(59, 130, 246, 0.45);
}

.btn-primary:focus-visible {
    outline: 3px solid #93C5FD;
    outline-offset: 3px;
}

/* Services */
.services {
    background: var(--gray-50);
    position: relative;
    padding-block: clamp(4rem, 8vw, 8rem);
}

.services::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--circuit-pattern);
    opacity: 0.3;
    pointer-events: none;
}

.services__container {
    text-align: center;
}

.services__title {
    margin-bottom: var(--spacing-3xl);
}

.services__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3rem;
}

.service {
    background: var(--light);
    padding: 2rem 2rem 2.25rem;
    border-radius: 1.25rem;
    box-shadow: 0 10px 30px rgba(2, 6, 23, 0.06);
    transition: transform .15s, box-shadow .2s;
    text-align: center;
}

.service:hover {
    transform: translateY(-4px);
    box-shadow: 0 18px 50px rgba(2, 6, 23, 0.12);
}

.service__icon {
    width: 5rem;
    height: 5rem;
    border-radius: 999px;
    display: grid;
    place-items: center;
    margin-bottom: 1rem;
    background: radial-gradient(120% 120% at 30% 20%, #3B82F6 0%, #0F172A 100%);
    color: var(--light);
    font-size: 2rem;
}

.service__title {
    margin-bottom: var(--spacing-md);
    font-weight: 700;
    font-size: clamp(1.4rem, 2vw, 1.75rem);
}

.service p {
    color: #4a5568;
    line-height: 1.8;
}

/* About */
.about {
    background: #0B1630;
    color: #E9EDF5;
    padding-block: clamp(4rem, 7vw, 7rem);
}

.about__container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-4xl);
    align-items: center;
}

.about__content h2 {
    margin-bottom: var(--spacing-lg);
}

.about__content p {
    margin-bottom: var(--spacing-xl);
    font-size: 1.125rem;
    line-height: 1.7;
    color: #D8E2F1;
}

.about__image {
    border-radius: 1.25rem;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0,0,0,.3);
}

.about__image img {
    width: 100%;
    height: auto;
    display: block;
    filter: brightness(1.1);
}

.btn-outline {
    background: transparent;
    color: #E9EDF5;
    border: 1px solid rgba(233,237,245,.4);
}

.btn-outline:hover {
    background: rgba(233,237,245,.08);
    border-color: rgba(233,237,245,.6);
}

/* Contact */
.contact {
    background: var(--gray-100);
}

.contact__container {
    max-width: 1000px;
    margin: 0 auto;
    text-align: center;
}

.contact__title {
    margin-bottom: var(--spacing-md);
}

.contact__subtitle {
    margin-bottom: var(--spacing-2xl);
    font-size: 1.125rem;
}

.contact__info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-3xl);
    text-align: center;
}

.contact__info-item {
    background: var(--light);
    padding: var(--spacing-xl);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-lg);
}

.contact__info-icon {
    width: 3rem;
    height: 3rem;
    margin: 0 auto var(--spacing-md);
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: var(--radius-full);
    display: grid;
    place-items: center;
    color: var(--light);
}

.contact__info-title {
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    color: var(--gray-900);
}

.contact__info-text {
    color: var(--gray-600);
    font-size: 1.125rem;
}

.contact__form-container {
    max-width: 500px;
    margin: 0 auto;
}

.contact__form {
    background: var(--light);
    padding: var(--spacing-2xl);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-lg);
}

.form-group {
    margin-bottom: var(--spacing-lg);
    text-align: right;
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 500;
    color: var(--gray-700);
}

.form-input {
    width: 100%;
    padding: .9rem 1rem;
    border: 1px solid #E2E8F0;
    border-radius: .875rem;
    font-size: 1rem;
    line-height: 1.6;
    box-shadow: 0 8px 30px rgba(0,0,0,.05);
    transition: border-color .2s, box-shadow .2s;
}

.form-input:focus {
    outline: 0;
    border-color: #3B82F6;
    box-shadow: 0 0 0 4px rgba(59,130,246,.15);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
}

.form-hint {
    font-size: .85rem;
    color: #64748B;
    margin-top: .375rem;
}

.form-error {
    color: #e11d48;
    font-size: .85rem;
    margin-top: .375rem;
    display: none;
}

.form-group.error .form-error {
    display: block;
}

/* Footer */
.footer {
    background: #0A1222;
    color: rgba(255,255,255,.9);
    padding: 2.5rem 0;
}

.footer__container {
    text-align: center;
}

.footer__title {
    color: #F8FAFC;
    font-weight: 800;
    letter-spacing: .02em;
    margin-bottom: var(--spacing-md);
}

.footer__text {
    color: rgba(255,255,255,.88);
    line-height: 1.9;
    max-width: 70ch;
    margin-inline: auto;
    margin-bottom: var(--spacing-lg);
}

.footer__grid {
    display: grid;
    gap: 1.25rem;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    margin-bottom: var(--spacing-lg);
}

.footer__links {
    display: flex;
    gap: 2rem;
    justify-content: center;
}

.footer__links a {
    color: #CFE3FF;
    text-decoration: none;
    font-weight: 500;
    transition: opacity .2s;
}

.footer__links a:hover {
    color: #ffffff;
    text-decoration: underline;
}

.footer__social {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.footer__social a {
    display: inline-flex;
    align-items: center;
    padding: .4rem;
    border-radius: .5rem;
    color: rgba(255,255,255,.9);
    transition: background .2s;
}

.footer__social a:hover {
    background: rgba(255,255,255,.1);
}

.footer__social a:focus-visible {
    outline: 2px solid #93C5FD;
    outline-offset: 3px;
}

.footer__copyright {
    color: rgba(255,255,255,.65);
    font-size: 0.875rem;
}

/* Mobile Menu */
.mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: var(--light);
    z-index: 999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transform: translateX(100%);
    transition: transform var(--transition-normal);
}

.mobile-menu.active {
    transform: translateX(0);
}

.mobile-menu ul {
    list-style: none;
    text-align: center;
}

.mobile-menu li {
    margin: var(--spacing-lg) 0;
}

.mobile-menu a {
    font-size: 1.5rem;
    color: var(--gray-800);
    text-decoration: none;
    font-weight: 500;
}

.hamburger {
    display: none;
    flex-direction: column;
    cursor: pointer;
    padding: var(--spacing-sm);
}

.hamburger span {
    width: 1.5rem;
    height: 2px;
    background: var(--gray-800);
    margin: 3px 0;
    transition: var(--transition-fast);
    border-radius: 1px;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(-45deg) translate(-5px, 6px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(45deg) translate(-5px, -6px);
}

/* Loading */
.loading {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: currentColor;
    animation: spin 1s ease-in-out infinite;
}

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

/* Alerts */
.alert {
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
    margin-top: var(--spacing-lg);
    font-weight: 500;
    display: none;
}

.alert-success {
    background: #c6f6d5;
    color: #22543d;
    border: 1px solid #9ae6b4;
}

.alert-error {
    background: #fed7d7;
    color: #742a2a;
    border: 1px solid #feb2b2;
}

/* تحسينات إمكانية الوصول */
.btn:focus-visible,
.form-input:focus-visible,
.header__nav a:focus-visible {
    outline: 3px solid #3B82F6;
    outline-offset: 2px;
    border-radius: var(--radius-md);
}

/* تحسينات للقراءة */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* تحسينات للتصميم المتجاوب */
@media (max-width: 1024px) {
    .services__grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }
    
    .about__container {
        gap: var(--spacing-2xl);
    }
    
    .footer__grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
        text-align: center;
    }
}

@media (max-width: 768px) {
    .header__nav ul {
        display: none;
    }

    .hamburger {
        display: flex;
    }

    .hero__container {
        padding: var(--spacing-2xl) 0;
    }

    .hero__title {
        font-size: 2.5rem;
    }

    .about__container {
        grid-template-columns: 1fr;
        gap: var(--spacing-2xl);
    }

    .services__grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .section {
        padding: var(--spacing-3xl) 0;
    }
    
    .contact__info {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
    
    .footer__links {
        flex-direction: column;
        gap: var(--spacing-md);
    }
    
    .footer__social {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 var(--spacing-md);
    }

    .hero__title {
        font-size: 2rem;
    }

    .btn {
        padding: var(--spacing-sm) var(--spacing-lg);
        font-size: 0.9rem;
    }
    
    .service {
        padding: 1.5rem;
    }
    
    .contact__form {
        padding: var(--spacing-xl);
    }
    
    .hero__content {
        padding: var(--spacing-lg);
    }

    /* Hide video and show fallback image on mobile */
    .hero__video {
        display: none;
    }

    .hero__fallback-image {
        display: block;
    }
}

/* تحسينات للأجهزة اللوحية */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding: 0 var(--spacing-xl);
    }
    
    .hero__title {
        font-size: 3rem;
    }
}

/* تحسينات للشاشات الكبيرة */
@media (min-width: 1440px) {
    .container {
        max-width: 1400px;
    }
}

/* تحسينات للطباعة */
@media print {
    .header,
    .footer,
    .btn {
        display: none;
    }
    
    body {
        background: white;
        color: black;
        font-size: 12pt;
    }
    
    .hero {
        min-height: auto;
        color: black;
    }
    
    .hero::before {
        display: none;
    }
    
    .hero video {
        display: none;
    }
}

/* تحسينات للأداء */
img {
    max-width: 100%;
    height: auto;
}

/* تحسينات للتحميل التدريجي */
.lazy-load {
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

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

/* تحسينات للرسوم المتحركة */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* تحسينات للوضع الداكن */
@media (prefers-color-scheme: dark) {
    :root {
        --light: #0F172A;
        --gray-50: #1E293B;
        --gray-100: #334155;
        --gray-200: #475569;
        --gray-300: #64748B;
        --gray-400: #94A3B8;
        --gray-500: #CBD5E1;
        --gray-600: #E2E8F0;
        --gray-700: #F1F5F9;
        --gray-800: #F8FAFC;
        --gray-900: #FFFFFF;
    }
    
    body {
        background-color: var(--light);
        color: var(--gray-700);
    }
    
    .services {
        background: var(--gray-50);
    }
    
    .contact {
        background: var(--gray-50);
    }
    
    .service,
    .contact__info-item,
    .contact__form {
        background: var(--gray-100);
    }
}
