:root {
    --cyber-green: #00ff41;
    --cyber-blue: #0080ff;
    --cyber-red: #ff0040;
    --matrix-bg: #0d1117;
    --terminal-bg: rgba(13, 17, 23, 0.95);
    --vh: 1vh; /* متغير لارتفاع الشاشة */
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Fira Code", "Tajawal", monospace;
    background: var(--matrix-bg);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    color: var(--cyber-green);
    overflow: hidden;
    position: relative;
    /* منع التمرير والتحريك */
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* منع السحب */
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    /* تثبيت الصفحة */
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Matrix Rain Effect */
#matrix {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: 0.3;
}

/* Cyber Grid Background */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
            90deg,
            transparent 24%,
            rgba(0, 255, 65, 0.03) 25%,
            rgba(0, 255, 65, 0.03) 26%,
            transparent 27%,
            transparent 74%,
            rgba(0, 255, 65, 0.03) 75%,
            rgba(0, 255, 65, 0.03) 76%,
            transparent 77%,
            transparent
        ),
        linear-gradient(
            transparent 24%,
            rgba(0, 255, 65, 0.03) 25%,
            rgba(0, 255, 65, 0.03) 26%,
            transparent 27%,
            transparent 74%,
            rgba(0, 255, 65, 0.03) 75%,
            rgba(0, 255, 65, 0.03) 76%,
            transparent 77%,
            transparent
        );
    background-size: 50px 50px;
    z-index: 0;
}

/* Identity Terminal */
.cyber-identity {
    position: fixed;
    top: 20px;
    left: 20px;
    background: var(--terminal-bg);
    border: 2px solid var(--cyber-green);
    border-radius: 8px;
    padding: 12px 15px;
    font-family: "Fira Code", monospace;
    font-size: clamp(9px, 1.2vw, 12px);
    line-height: 1.3;
    color: var(--cyber-green);
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.3);
    z-index: 1000;
    width: clamp(250px, 25vw, 350px);
    max-height: 40vh;
    overflow: hidden;
    animation: terminalGlow 2s ease-in-out infinite alternate;
    /* تثبيت الاتجاه من اليسار إلى اليمين دائماً */
    direction: ltr !important;
    text-align: left !important;
}

.cyber-identity h4 {
    margin: 0 0 8px 0;
    color: var(--cyber-blue);
    text-shadow: 0 0 10px var(--cyber-blue);
    font-size: clamp(11px, 1.4vw, 14px);
    text-align: center;
    direction: ltr !important;
}

.cyber-identity .terminal-line {
    margin: 2px 0;
    opacity: 0;
    animation: typewriter 0.5s forwards;
    font-size: clamp(8px, 1vw, 11px);
    word-break: break-word;
    direction: ltr !important;
    text-align: left !important;
}

/* خط خاص للنصوص العربية في صندوق الهوية */
.cyber-identity .arabic-text {
    font-family: "Tajawal", "Fira Code", monospace !important;
    font-weight: 500;
}

/* تثبيت خط Tajawal للغة العربية - سيتم تطبيقه عبر class */
.arabic-lang body,
.arabic-lang .card-title,
.arabic-lang .form-label,
.arabic-lang .btn-primary,
.arabic-lang .dropdown-item,
.arabic-lang .alert-danger {
    font-family: "Tajawal", "Fira Code", monospace !important;
}

.cyber-identity .terminal-line:nth-child(2) {
    animation-delay: 0.5s;
}
.cyber-identity .terminal-line:nth-child(3) {
    animation-delay: 1s;
}
.cyber-identity .terminal-line:nth-child(4) {
    animation-delay: 1.5s;
}
.cyber-identity .terminal-line:nth-child(5) {
    animation-delay: 2s;
}
.cyber-identity .terminal-line:nth-child(6) {
    animation-delay: 2.5s;
}
.cyber-identity .terminal-line:nth-child(7) {
    animation-delay: 3s;
}

.cyber-identity .blinking-cursor::after {
    content: "█";
    animation: blink 1s infinite;
    color: var(--cyber-green);
}

/* Login Card Styling */
.login-container {
    position: relative;
    z-index: 100;
    width: 100%;
    max-width: clamp(320px, 90vw, 450px);
    margin: 0 auto;
}

.card {
    background: var(--terminal-bg);
    backdrop-filter: blur(15px);
    border: 2px solid var(--cyber-green);
    border-radius: 15px;
    box-shadow: 0 0 30px rgba(0, 255, 65, 0.4), inset 0 0 30px rgba(0, 255, 65, 0.1);
    animation: cardPulse 3s ease-in-out infinite alternate;
    margin: clamp(5px, 1vh, 20px); /* تقليل المارجن */
}

.card-body {
    padding: clamp(20px, 4vw, 40px) !important;
}

.card-title {
    color: var(--cyber-blue);
    font-weight: 700;
    text-shadow: 0 0 15px var(--cyber-blue);
    font-family: "Fira Code", monospace;
    font-size: clamp(16px, 3vw, 24px) !important;
}

.card .text-muted {
    color: var(--cyber-green) !important;
    opacity: 0.8;
    font-size: clamp(12px, 2.5vw, 16px);
}

/* Form Styling */
.form-control {
    background: rgba(13, 17, 23, 0.8);
    border: 2px solid rgba(0, 255, 65, 0.3);
    border-radius: 8px;
    color: var(--cyber-green);
    font-family: "Fira Code", monospace;
    transition: all 0.3s ease;
    font-size: clamp(12px, 2vw, 16px);
    padding: clamp(8px, 1.5vw, 12px);
    /* منع الزوم عند التركيز */
    font-size: 16px !important; /* منع الزوم في iOS */
    transform-origin: left top;
    zoom: 1;
    /* السماح بالتحديد والكتابة فقط */
    touch-action: manipulation;
    -webkit-touch-callout: default;
    -webkit-user-select: text;
    -khtml-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

.form-control:focus {
    background: rgba(13, 17, 23, 0.9);
    border-color: var(--cyber-green);
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.5);
    color: var(--cyber-green);
}

.form-control::placeholder {
    color: rgba(0, 255, 65, 0.5);
}

.form-label {
    color: var(--cyber-green);
    font-family: "Fira Code", monospace;
    font-weight: 500;
    font-size: clamp(11px, 2vw, 14px);
}

.btn-primary {
    background: linear-gradient(45deg, var(--cyber-green), var(--cyber-blue));
    border: 2px solid var(--cyber-green);
    color: var(--matrix-bg);
    font-family: "Fira Code", monospace;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    font-size: clamp(12px, 2.5vw, 16px);
    padding: clamp(10px, 2vw, 15px) clamp(20px, 4vw, 30px);
}

.btn-primary:hover {
    background: linear-gradient(45deg, var(--cyber-blue), var(--cyber-green));
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.6);
    transform: translateY(-2px);
}

/* Animations */
@keyframes terminalGlow {
    0% {
        box-shadow: 0 0 20px rgba(0, 255, 65, 0.3);
    }
    100% {
        box-shadow: 0 0 30px rgba(0, 255, 65, 0.6);
    }
}

@keyframes typewriter {
    to {
        opacity: 1;
    }
}

@keyframes blink {
    0%,
    50% {
        opacity: 1;
    }
    51%,
    100% {
        opacity: 0;
    }
}

@keyframes cardPulse {
    0% {
        box-shadow: 0 0 30px rgba(0, 255, 65, 0.4), inset 0 0 30px rgba(0, 255, 65, 0.1);
    }
    100% {
        box-shadow: 0 0 50px rgba(0, 255, 65, 0.6), inset 0 0 50px rgba(0, 255, 65, 0.2);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .cyber-identity {
        position: relative;
        top: auto;
        left: auto;
        margin: 10px auto 10px auto; /* تقليل المسافة السفلية من 20px إلى 10px */
        width: 95%;
        max-width: none;
        font-size: 10px;
        padding: 10px;
    }

    .cyber-identity h4 {
        font-size: 12px;
    }

    .cyber-identity .terminal-line {
        font-size: 9px;
        margin: 1px 0;
    }

    body {
        padding: 10px;
        overflow: hidden !important; /* منع التمرير تماماً */
        flex-direction: column;
        justify-content: flex-start;
        padding-top: 15px; /* تقليل من 20px إلى 15px */
        position: fixed;
        height: 100vh;
        /* منع أي حركة */
        touch-action: none !important;
        -webkit-overflow-scrolling: none;
        overscroll-behavior: none;
    }

    .container {
        padding: 0;
        margin-top: -10px; /* إضافة مارجن سالب لتقليل المسافة */
        overflow: hidden;
    }

    .row {
        margin: 0;
        overflow: hidden;
    }

    .card-body {
        padding: 20px !important;
    }

    /* تقليل المسافة في min-vh-100 للشاشات الصغيرة */
    .min-vh-100 {
        min-height: auto !important;
        overflow: hidden;
    }

    /* منع التمرير في جميع العناصر */
    * {
        overscroll-behavior: none;
        -webkit-overflow-scrolling: none;
    }
}

@media (max-width: 480px) {
    .cyber-identity {
        font-size: 8px;
        padding: 8px;
        margin: 0px auto 60px auto; /* تقليل المسافات أكثر */
    }

    .cyber-identity h4 {
        font-size: 10px;
        margin-bottom: 5px;
    }

    .cyber-identity .terminal-line {
        font-size: 7px;
    }

    .card-body {
        padding: 15px !important;
    }

    body {
        padding: 8px;
        padding-top: 10px;
    }

    .container {
        margin-top: -15px; /* مارجن سالب أكبر للشاشات الصغيرة جداً */
    }

    /* تحسين للبطاقة في الشاشات الصغيرة */
    .card {
        margin: 5px;
    }
}

@media (min-width: 1200px) {
    .cyber-identity {
        width: 320px;
        font-size: 13px;
        top: 30px;
        left: 30px;
    }

    .cyber-identity h4 {
        font-size: 15px;
    }

    .login-container {
        max-width: 500px;
    }
}

@media (min-width: 1600px) {
    .cyber-identity {
        width: 380px;
        font-size: 14px;
        top: 40px;
        left: 40px;
        padding: 20px;
    }

    .cyber-identity h4 {
        font-size: 16px;
    }

    .cyber-identity .terminal-line {
        font-size: 12px;
        margin: 3px 0;
    }
}

.flag-icon {
    background-size: contain;
    background-position: 50%;
    background-repeat: no-repeat;
}

/* Dropdown styling */
.dropdown-menu {
    background: var(--terminal-bg);
    border: 2px solid var(--cyber-green);
    border-radius: 8px;
    font-size: clamp(11px, 2vw, 14px);
}

.dropdown-item {
    color: var(--cyber-green);
    font-family: "Fira Code", monospace;
    padding: clamp(5px, 1vw, 10px) clamp(10px, 2vw, 15px);
}

.dropdown-item:hover {
    background: rgba(0, 255, 65, 0.1);
    color: var(--cyber-green);
}

.dropdown-toggle {
    font-size: clamp(11px, 2vw, 14px) !important;
    color: var(--cyber-green) !important;
}

/* Alert styling */
.alert-danger {
    background: rgba(255, 0, 64, 0.1);
    border: 2px solid var(--cyber-red);
    color: var(--cyber-red);
    font-family: "Fira Code", monospace;
    font-size: clamp(11px, 2vw, 14px);
    padding: clamp(8px, 1.5vw, 12px);
    border-radius: 8px;
}

/* Logo responsive */
.logo-img {
    max-height: clamp(40px, 8vw, 70px) !important;
    filter: drop-shadow(2px 2px 3px rgba(0, 0, 0, 0.3));
}
