/* إعادة تعيين أساسي وتنسيق الخطوط */
* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    list-style: none;
    text-decoration: none;
    scroll-behavior: smooth;
    /* الخطوط: Poppins للإنجليزية، Cairo للعربية. ستحتاج إلى خطوط أخرى للغات الأخرى */
    /* قم باستيرادها من Google Fonts في <head> كل ملف HTML */
    font-family: 'Poppins', 'Cairo', 'Noto Sans SC', 'Noto Sans Devanagari', sans-serif;
}

/* Base body direction will be set by JS or HTML lang attribute */
body {
    background: linear-gradient(135deg, #1a1a1a, #2d2d2d);
    color: #fff; /* لون النص الافتراضي */
    /* direction and text-align are set by JavaScript based on current language */
}

/* Header */
header {
    position: sticky;
    top: 0;
    width: 100%;
    z-index: 1000;
    background: linear-gradient(135deg, #1a1a1a, #2d2d2d);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    padding: 15px 5%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.6s ease;
}

header .logo {
    width: 50px;
    height: auto;
}

header .navlist {
    display: flex;
    gap: 30px;
}

header .navlist a {
    color: #fff;
    font-weight: 600;
    font-size: 1.1em;
    transition: all 0.3s ease;
}

header .navlist a:hover {
    color: #956afa;
    transform: translateY(-3px);
}

/* Language Switcher */
.language-switcher {
    margin-right: 20px; /* Default for RTL */
    position: relative;
    z-index: 1001; /* Above header */
}
[dir="ltr"] .language-switcher {
    margin-left: 20px; /* For LTR */
    margin-right: 0;
}
.language-switcher select {
    background-color: #333;
    color: #fff;
    border: 1px solid #555;
    padding: 8px 15px;
    border-radius: 5px;
    font-size: 1em;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="white" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>'); /* Custom arrow */
    background-repeat: no-repeat;
    background-position: left 10px center; /* Arrow on left for LTR */
    padding-left: 30px; /* Space for text due to arrow */
}
[dir="rtl"] .language-switcher select {
    background-position: right 10px center; /* Arrow on right for RTL */
    padding-right: 30px;
    padding-left: 15px;
}

/* Hero Section */
.hero-section {
    height: 80vh;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 0 5%;
    background-image: url('../png/Test.ico');
    background-size: cover;
    background-position: center;
    position: relative;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 800px;
}

.hero-content h1 {
    font-size: 3.5em;
    margin-bottom: 20px;
    color: #fff;
    text-shadow: 0 0 10px rgba(0, 255, 170, 0.5);
}

.hero-content p {
    font-size: 1.4em;
    margin-bottom: 30px;
    color: rgba(255, 255, 255, 0.8);
}

.btn-primary {
    display: inline-block;
    background-color: #956afa;
    color: #fff;
    padding: 12px 25px;
    border-radius: 8px;
    font-size: 1.1em;
    transition: background-color 0.3s ease, transform 0.3s ease;
}

.btn-primary:hover {
    background-color: #7b4acb;
    transform: translateY(-3px);
}

/* About Section */
.about-section {
    padding: 80px 10%;
    text-align: center;
    background-color: #262626;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.about-section h2 {
    font-size: 2.8em;
    color: #00ffaa;
    margin-bottom: 30px;
    position: relative;
    display: inline-block;
}

.about-section h2::after {
    content: '';
    position: absolute;
    width: 60%;
    height: 3px;
    background: linear-gradient(90deg, transparent, #00ffaa, transparent);
    bottom: -10px;
    /* Adjusted for direction */
    left: 20%;
}
[dir="rtl"] .about-section h2::after {
    right: 20%;
    left: auto;
}
[dir="ltr"] .about-section h2::after {
    left: 20%;
    right: auto;
}


.about-section p {
    font-size: 1.2em;
    line-height: 1.8;
    max-width: 900px;
    margin: 0 auto;
    color: rgba(255, 255, 255, 0.85);
}

/* Tools Section */
.tools-section {
    padding: 80px 5%;
    text-align: center;
}

.tools-section h2 {
    font-size: 2.8em;
    color: #fff;
    margin-bottom: 50px;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.cards-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 40px;
}

.tool-card {
    background: linear-gradient(145deg, #1c1c1c, #2a2a2a);
    border-radius: 15px;
    padding: 30px;
    width: 280px;
    text-align: center;
    color: #fff;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0) 100%);
    z-index: 0;
    pointer-events: none;
}

.tool-card:hover {
    transform: translateY(-10px) scale(1.03);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6);
    border-color: #956afa;
}

.tool-card img {
    width: 120px;
    height: 120px;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 10px rgba(149, 106, 250, 0.6));
    transition: filter 0.3s ease;
}

.tool-card:hover img {
    filter: drop-shadow(0 0 15px #00ffaa);
}

.tool-card h3 {
    font-size: 1.8em;
    margin-bottom: 10px;
    color: #00ffaa;
    text-shadow: 0 0 5px rgba(0, 255, 170, 0.3);
}

.tool-card p {
    font-size: 1em;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.5;
}

/* Footer */
.footer {
    background: #1e1e1e;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    padding: 50px 10%;
    gap: 40px;
    justify-content: space-between;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-box {
    display: flex;
    flex-direction: column;
    /* Default for RTL */
    align-items: flex-end;
}
[dir="ltr"] .footer-box {
    align-items: flex-start; /* For LTR */
}

.footer-box h3 {
    color: #fff;
    font-size: 1.5em;
    font-weight: 700;
    margin-bottom: 20px;
}

.footer-box a {
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 10px;
    transition: all 0.3s ease;
    font-size: 1.1em;
}

.footer-box a:hover {
    /* Default for RTL */
    transform: translateX(5px);
    color: #956afa;
}
[dir="ltr"] .footer-box a:hover {
    transform: translateX(-5px); /* For LTR */
}

.social-links {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.social-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 45px;
    width: 45px;
    background: #956afa;
    color: #fff;
    font-size: 1.4em;
    border-radius: 50%;
    transition: transform 0.4s ease, background-color 0.3s ease;
}

.social-links a:hover {
    transform: rotate(360deg) scale(1.1);
    background-color: #00ffaa;
}

/* Copyright */
.copyright {
    background: #1a1a1a;
    padding: 20px 10%;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.copyright p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.95em;
}

/* Responsive Design */
@media (max-width: 992px) {
    header {
        padding: 15px 3%;
    }
    .hero-content h1 {
        font-size: 2.8em;
    }
    .hero-content p {
        font-size: 1.2em;
    }
    .about-section, .tools-section, .footer, .copyright {
        padding: 60px 5%;
    }
    .about-section h2, .tools-section h2 {
        font-size: 2.2em;
    }
    .tool-card {
        width: 45%;
    }
}

@media (max-width: 768px) {
    header .navlist {
        position: absolute;
        top: 100%;
        /* Adjusted for direction */
        left: 0;
        right: 0;
        background: linear-gradient(135deg, #1a1a1a, #2d2d2d);
        flex-direction: column;
        width: 100%;
        text-align: center;
        padding: 10px 0;
        border-top: 1px solid rgba(255,255,255,0.1);
        display: none;
    }
    header .navlist.active {
        display: flex;
    }
    #menu-icon {
        display: block;
        font-size: 30px;
        cursor: pointer;
        color: #fff;
    }
    /* Header layout for mobile (Hamburger icon side) */
    header {
        justify-content: space-between;
    }
    [dir="rtl"] header {
        flex-direction: row-reverse;
    }
    [dir="ltr"] header {
        flex-direction: row;
    }

    .hero-content h1 {
        font-size: 2.2em;
    }
    .hero-content p {
        font-size: 1em;
    }
    .tool-card {
        width: 80%;
        margin-bottom: 30px;
    }
    .footer {
        grid-template-columns: 1fr;
        text-align: center;
    }
    .footer-box {
        align-items: center;
    }
    .social-links {
        justify-content: center;
    }
}

/* Common styles for content pages (content-page) */
.content-page {
    padding: 80px 10% 50px;
    max-width: 1200px;
    margin: 0 auto;
    /* text-align is set by JavaScript on body */
}
[dir="ltr"] .content-page {
    text-align: left;
}
[dir="rtl"] .content-page {
    text-align: right;
}

.content-page h1 {
    font-size: 3em;
    color: #00ffaa;
    text-align: center;
    margin-bottom: 30px;
}
.content-page h2 {
    font-size: 2em;
    color: #fff;
    margin-top: 40px;
    margin-bottom: 20px;
    /* border-bottom: 2px solid rgba(255,255,255,0.1); */ /* Optional, depending on design */
    padding-bottom: 10px;
}
.content-page p {
    font-size: 1.1em;
    line-height: 1.7;
    margin-bottom: 15px;
    color: rgba(255, 255, 255, 0.85);
}

/* Instructions box */
.instructions {
    background-color: #1e1e1e;
    border-right: 5px solid #956afa; /* Default for RTL */
    padding: 20px;
    margin-top: 30px;
    border-radius: 8px;
    /* text-align is set by JavaScript on body */
}
[dir="ltr"] .instructions {
    border-left: 5px solid #956afa;
    border-right: none;
    text-align: left;
}
[dir="rtl"] .instructions {
    border-right: 5px solid #956afa;
    border-left: none;
    text-align: right;
}

.instructions ul {
    list-style: disc;
    /* Default for RTL */
    margin-right: 25px;
    margin-left: 0;
    color: rgba(255, 255, 255, 0.9);
}
[dir="ltr"] .instructions ul {
    margin-left: 25px;
    margin-right: 0;
}
[dir="rtl"] .instructions ul {
    margin-right: 25px;
    margin-left: 0;
}
.instructions ul li {
    margin-bottom: 5px;
}

/* Privacy Policy specific styles */
.content-page.privacy-policy-page h1 {
    border-bottom: 2px solid rgba(0, 255, 170, 0.3);
    padding-bottom: 15px;
}
.content-page.privacy-policy-page h2 {
    position: relative;
    padding-right: 15px; /* Default for RTL */
}
[dir="ltr"] .content-page.privacy-policy-page h2 {
    padding-left: 15px;
    padding-right: 0;
}

.content-page.privacy-policy-page h2::before {
    content: '';
    position: absolute;
    /* Default for RTL */
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 5px;
    height: 70%;
    background-color: #956afa;
    border-radius: 3px;
}
[dir="ltr"] .content-page.privacy-policy-page h2::before {
    left: 0;
    right: auto;
}
[dir="rtl"] .content-page.privacy-policy-page h2::before {
    right: 0;
    left: auto;
}
.content-page.privacy-policy-page ul {
    list-style: disc;
    /* Default for RTL */
    margin-right: 30px;
    margin-left: 0;
}
[dir="ltr"] .content-page.privacy-policy-page ul {
    margin-left: 30px;
    margin-right: 0;
}
[dir="rtl"] .content-page.privacy-policy-page ul {
    margin-right: 30px;
    margin-left: 0;
}
.content-page.privacy-policy-page .last-updated {
    text-align: center;
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 30px;
}
.content-page.privacy-policy-page a {
    color: #956afa;
    text-decoration: underline;
    transition: color 0.3s ease;
}
.content-page.privacy-policy-page a:hover {
    color: #00ffaa;
}


/* Contact page specific styles */
.contact-form-container {
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}
/* .contact-form .form-group { text-align is set by JavaScript on body } */
[dir="ltr"] .contact-form .form-group {
    text-align: left;
}
[dir="rtl"] .contact-form .form-group {
    text-align: right;
}
.contact-form label {
    display: block;
    margin-bottom: 8px;
    font-size: 1.1em;
    color: #fff;
    font-weight: 600;
}
.contact-form input[type="text"],
.contact-form input[type="email"],
.contact-form textarea {
    width: calc(100% - 20px);
    padding: 12px 10px;
    border: 1px solid #555;
    border-radius: 6px;
    background-color: #1a1a1a;
    color: #eee;
    font-size: 1em;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    resize: vertical;
}
.contact-form input[type="text"]:focus,
.contact-form input[type="email"]:focus,
.contact-form textarea:focus {
    border-color: #956afa;
    box-shadow: 0 0 0 3px rgba(149, 106, 250, 0.3);
    outline: none;
}
.contact-form .btn-primary {
    display: block;
    width: 100%;
    padding: 15px 20px;
    margin-top: 20px;
    font-size: 1.2em;
    background-color: #00ffaa;
    color: #1a1a1a;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.3s ease;
}
.contact-form .btn-primary:hover {
    background-color: #00e69a;
    transform: translateY(-2px);
}
.contact-email {
    text-align: center;
    margin-top: 30px;
    font-size: 1.1em;
    color: rgba(255, 255, 255, 0.7);
}
.contact-email a {
    color: #956afa;
    text-decoration: underline;
    transition: color 0.3s ease;
}
.contact-email a:hover {
    color: #00ffaa;
}

/* Game page specific styles */
.game-embed-container {
    background-color: #1a1a1a;
    border-radius: 15px;
    padding: 20px;
    margin-top: 50px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.5);
    width: 100%;
    max-width: 960px;
    height: 600px;
    margin-left: auto;
    margin-right: auto;
    display: block;
    overflow: hidden;
}
.game-embed-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 10px;
    display: block;
}
.game-instructions {
    background-color: #1e1e1e;
    border-right: 5px solid #956afa; /* Default for RTL */
    padding: 20px;
    margin-top: 30px;
    border-radius: 8px;
    /* text-align is set by JavaScript on body */
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}
[dir="ltr"] .game-instructions {
    border-left: 5px solid #956afa;
    border-right: none;
    text-align: left;
}
[dir="rtl"] .game-instructions {
    border-right: 5px solid #956afa;
    border-left: none;
    text-align: right;
}
.game-instructions h2 {
    font-size: 1.8em;
    color: #fff;
    margin-bottom: 15px;
    border-bottom: none;
    padding-bottom: 0;
}
.game-instructions ul {
    list-style: disc;
    /* Default for RTL */
    margin-right: 25px;
    margin-left: 0;
    color: rgba(255, 255, 255, 0.9);
}
[dir="ltr"] .game-instructions ul {
    margin-left: 25px;
    margin-right: 0;
}
[dir="rtl"] .game-instructions ul {
    margin-right: 25px;
    margin-left: 0;
}
.game-instructions ul li {
    margin-bottom: 8px;
    line-height: 1.6;
}

/* Keyboard Test specific styles */
.keyboard-test-area {
    background-color: #262626;
    border-radius: 15px;
    padding: 30px;
    margin-top: 50px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.5);
    text-align: center;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    border: 1px solid rgba(255,255,255,0.1);
}

.keyboard-options {
    margin-bottom: 25px;
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}
.keyboard-options button {
    background-color: #956afa;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease;
}
.keyboard-options button.active, .keyboard-options button:hover {
    background-color: #00ffaa;
    color: #1a1a1a;
}

.keyboard-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    justify-content: center;
}

.key {
    background-color: #3e3e3e;
    border: 1px solid #5a5a5a;
    border-radius: 6px;
    padding: 10px 5px;
    font-size: 1em;
    font-weight: bold;
    color: #eee;
    cursor: pointer;
    transition: background-color 0.1s ease, border-color 0.1s ease, box-shadow 0.1s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 50px;
    height: 50px;
    box-shadow: inset 0 2px 3px rgba(0,0,0,0.3), 0 3px 5px rgba(0,0,0,0.3);
    position: relative;
}

.key .main-char {
    font-size: 1.2em;
    line-height: 1;
}
.key .sub-char {
    font-size: 0.7em;
    opacity: 0.7;
    line-height: 1;
    margin-top: 2px;
}

.key.active {
    background-color: #00ffaa;
    border-color: #00a2ff;
    color: #1a1a1a;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.5), 0 0 15px #00ffaa;
    transform: translateY(1px);
}

/* Specific key sizes */
.key.fn { width: 45px; }
.key.backspace { width: 90px; }
.key.tab { width: 75px; }
.key.capslock { width: 100px; }
.key.enter { width: 110px; }
.key.shift-left { width: 120px; }
.key.shift-right { width: 130px; }
.key.ctrl-alt { width: 70px; }
.key.meta { width: 70px; }
.key.space { width: 300px; }
.key.arrow { width: 50px; }
.key.num-lock { width: 60px; }
.key.numpad-plus { height: 110px; }
.key.numpad-enter { height: 110px; }

/* Mac layout specific */
.keyboard-mac .key.meta .main-char::after { content: "⌘"; position: absolute; font-size: 0.8em; } /* Visual for Command */
.keyboard-mac .key.alt-option .main-char::after { content: "⌥"; position: absolute; font-size: 0.8em; } /* Visual for Option */
.keyboard-mac .key.shift-left { width: 90px; }
.keyboard-mac .key.enter { width: 90px; }

/* Mouse Test specific styles */
.mouse-test-area {
    background-color: #262626;
    border-radius: 10px;
    padding: 40px;
    margin-top: 50px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    text-align: center;
}
.mouse-buttons-display {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
}
.mouse-button {
    background-color: #3a3a3a;
    border: 2px solid #555;
    border-radius: 8px;
    padding: 20px;
    min-width: 150px;
    text-align: center;
    font-size: 1.2em;
    font-weight: bold;
    color: #eee;
    transition: background-color 0.1s ease, border-color 0.1s ease;
}
.mouse-button.active {
    background-color: #956afa;
    border-color: #00ffaa;
    color: #1a1a1a;
    box-shadow: 0 0 15px #956afa;
}
.scroll-status {
    margin-top: 20px;
    font-size: 1.2em;
    color: #00ffaa;
}
.tracking-area {
    width: 100%;
    height: 300px;
    border: 2px dashed #555;
    border-radius: 10px;
    margin-top: 40px;
    background-color: #3a3a3a;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.6);
    font-size: 1.5em;
}
.tracking-circle {
    width: 20px;
    height: 20px;
    background-color: #00ffaa;
    border-radius: 50%;
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow: 0 0 10px #00ffaa;
}

/* Controller Test specific styles */
.controller-test-area {
    background-color: #262626;
    border-radius: 10px;
    padding: 40px;
    margin-top: 50px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    text-align: center;
}
.controller-status {
    margin-bottom: 30px;
    font-size: 1.3em;
    color: #00ffaa;
    min-height: 30px;
}
.controller-buttons, .controller-axes-container { /* Changed name for clarity */
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}
.controller-button {
    background-color: #3a3a3a;
    border: 2px solid #555;
    border-radius: 5px;
    padding: 10px 15px;
    color: #eee;
    font-size: 0.9em;
    min-width: 80px;
    text-align: center;
    transition: background-color 0.1s ease, border-color 0.1s ease;
}
.controller-button.pressed {
    background-color: #956afa;
    border-color: #00ffaa;
    color: #1a1a1a;
    box-shadow: 0 0 10px #956afa;
}
.axis-display {
    width: 150px;
    height: 150px;
    border: 2px solid #555;
    border-radius: 50%;
    position: relative;
    margin: 20px auto;
    background-color: #3a3a3a;
    display: flex;
    justify-content: center;
    align-items: center;
}
.axis-indicator {
    position: absolute;
    width: 15px;
    height: 15px;
    background-color: #00ffaa;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: transform 0.05s linear;
}

/* Sound Test specific styles */
.sound-test-area {
    background-color: #262626;
    border-radius: 10px;
    padding: 40px;
    margin-top: 50px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    text-align: center;
}
.sound-test-area button {
    background-color: #956afa;
    color: #fff;
    border: none;
    padding: 15px 30px;
    margin: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1em;
    transition: background-color 0.3s ease, transform 0.3s ease;
}
.sound-test-area button:hover {
    background-color: #7b4acb;
    transform: translateY(-3px);
}
.sound-visualization {
    width: 80%;
    height: 100px;
    background-color: #3a3a3a;
    border-radius: 5px;
    margin: 30px auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.6);
    font-size: 1.2em;
    border: 1px solid rgba(255,255,255,0.2);
}
.sound-test-area p#status {
    margin-top: 20px;
    font-size: 1.2em;
    font-weight: bold;
    color: #00ffaa;
}