﻿/*
CSS
File
*/

/* ============ GLOBAL STYLES ============ */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800&display=swap');

:root {
    /* Colors */
    --primary-color: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --secondary-color: #06b6d4;
    --secondary-dark: #0891b2;
    --secondary-light: #22d3ee;
    --dark-color: #0f172a;
    --light-color: #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;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-full: 9999px;
    
    /* Other */
    --header-height: 180px;
}

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

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

body {
    font-family: 'Tajawal', sans-serif;
    background-color: #111827; /* Fondo oscuro */
    color: #e2e8f0; /* Texto claro para modo oscuro */
    line-height: 1.6;
    direction: rtl;
    overflow-x: hidden;
    overflow-y: hidden; /* منع التمرير الرأسي للصفحة */
}

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

ul, ol {
    list-style: none;
}

button, input {
    font-family: 'Tajawal', sans-serif;
    outline: none;
    border: none;
}

button {
    cursor: pointer;
    background: none;
}

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

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
}

/* ============ LAYOUT ============ */
.app-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
}

/* ============ LOADER ============ */
.loader-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--gray-900);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity var(--transition), visibility var(--transition);
}

.loader-wrapper.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader {
    width: 50px;
    height: 50px;
    border: 5px solid var(--gray-200);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ============ MAIN HEADER ============ */
.main-header {
    background-color: #1e293b; /* لون داكن يتناسب مع الخلفية */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    padding: var(--spacing-sm) var(--spacing);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: var(--spacing-xs);
    border-bottom: 1px solid #374151; /* حدود داكنة */
}

.logo {
    display: none; /* Hide the logo div completely */
}

.logo i {
    font-size: 1.3rem;
    color: var(--primary-color);
}

.logo h1 {
    font-size: 1.1rem;
    color: #f1f5f9; /* نص فاتح */
}

/* Search container */
.search-container {
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
    flex: 1;
    justify-content: center;
    padding: 0 10px;
}

/* App counter */
.app-counter {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.95rem;
    margin: 0 15px;
    white-space: nowrap;
    background-color: rgba(40, 44, 55, 0.7);
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#app-count {
    font-weight: 800;
    margin-left: 4px;
    margin-right: 4px;
    color: white;
}

/* Header actions container */
.header-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* ============ SEARCH BOX ============ */
.search-box {
    display: flex;
    align-items: center;
    background-color: #2d3748; /* خلفية داكنة للبحث */
    border-radius: var(--radius-full);
    padding: var(--spacing-xs) var(--spacing-sm);
    width: 100%;
    max-width: 400px;
    transition: all var(--transition);
    border: 2px solid transparent;
}

.search-box:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.3);
}

#search-input {
    flex: 1;
    background: transparent;
    color: #f1f5f9; /* لون نص فاتح */
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.9rem;
}

#search-input::placeholder {
    color: #94a3b8; /* لون نص خافت */
}

#search-btn {
    background-color: var(--primary-color);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

#search-btn:hover {
    background-color: var(--primary-dark);
    transform: scale(1.05);
}

/* ============ VIEW OPTIONS ============ */
.view-options {
    display: flex;
    gap: var(--spacing-xs);
}

.view-btn {
    background-color: var(--gray-100);
    color: var(--gray-600);
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    font-size: 0.9rem;
}

.view-btn:hover, .view-btn.active {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

/* ============ ACTION BUTTONS ============ */
.action-btn {
    background-color: var(--gray-100);
    color: var(--gray-700);
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    font-size: 0.9rem;
}

#batch-install:not(.disabled) {
    background-color: var(--secondary-color);
    color: white;
}

#batch-install:hover:not(.disabled) {
    background-color: var(--secondary-dark);
    transform: translateY(-2px);
}

#clear-selection:not(.disabled) {
    background-color: var(--gray-500);
    color: white;
}

#clear-selection:hover:not(.disabled) {
    background-color: var(--gray-600);
    transform: translateY(-2px);
}

.action-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Selected count display */
.selected-count-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    font-size: 0.85rem;
    color: var(--gray-600);
    background-color: var(--gray-100);
    border-radius: var(--radius);
    width: 32px;
    height: 32px;
    transition: all var(--transition-fast);
}

.selected-count-display i {
    color: var(--secondary-color);
    font-size: 0.85rem;
    display: none;
}

#selected-count {
    font-weight: bold;
}

/* Show icon when count is 0 and hide count */
.selected-count-display:has(#selected-count:not([data-count="0"])) i {
    display: none;
}

.selected-count-display:has(#selected-count[data-count="0"]) #selected-count {
    display: none;
}

.selected-count-display:has(#selected-count[data-count="0"]) i {
    display: block;
}

/* ============ CATEGORIES NAV ============ */
.categories-nav {
    overflow-x: auto;
    white-space: nowrap;
    padding: var(--spacing-xs) 0;
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

.categories-nav::-webkit-scrollbar {
    display: none;
}

.categories-nav ul {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: center;
}

html[dir="rtl"] .categories-nav ul {
    direction: rtl;
    justify-content: center;
}

html[dir="ltr"] .categories-nav ul {
    direction: ltr;
    flex-direction: row;
    justify-content: center;
}

/* تنسيقات إضافية لعكس ترتيب العناصر في اللغة الإنجليزية */
html[dir="ltr"] .categories-nav li:first-child {
    order: 1;
}

html[dir="ltr"] .categories-nav li:nth-child(2) {
    order: 2;
}

html[dir="ltr"] .categories-nav li:nth-child(3) {
    order: 3;
}

html[dir="ltr"] .categories-nav li:nth-child(4) {
    order: 4;
}

html[dir="ltr"] .categories-nav li:nth-child(5) {
    order: 5;
}

html[dir="ltr"] .categories-nav li:nth-child(6) {
    order: 6;
}

html[dir="ltr"] .categories-nav li:nth-child(7) {
    order: 7;
}

html[dir="ltr"] .categories-nav li:nth-child(8) {
    order: 8;
}

.categories-nav li {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 8px 16px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 1rem;
    border: 1px solid transparent;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.categories-nav li::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.categories-nav li:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.categories-nav li:hover::before {
    opacity: 1;
}

.categories-nav li.active {
    filter: brightness(1.2);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    font-weight: 700;
}

.categories-nav li.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40%;
    height: 3px;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-full);
}

.categories-nav li i {
    font-size: 1.1rem;
}

.categories-nav li span {
    font-size: 1rem;
    font-weight: 600;
}

/* ============ CONTENT HEADER ============ */
.content-header {
    padding: var(--spacing-xs) 0;
}

.content-header h2 {
    font-size: 1.2rem;
    color: #f1f5f9;
}

/* ============ MAIN CONTENT ============ */
.main-content {
    flex: 1;
    padding: var(--spacing);
    padding-bottom: calc(var(--spacing) + 60px);
    overflow-y: hidden; /* منع التمرير الرأسي للمحتوى الرئيسي */
}

/* ============ APPS GRID & CARDS ============ */
.apps-container {
    width: 100%;
    max-width: 1540px; /* عرض الحاوية 1540px */
    margin: 0 auto;
    padding: 0;
    position: relative;
    overflow: hidden;
}

.apps-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 بطاقات في كل صف */
    grid-gap: 16px;
    width: 100%;
    max-width: 1540px; /* العرض المطلوب 1540px */
    height: 710px; /* الارتفاع المطلوب 710px */
    overflow-y: scroll;
    overflow-x: hidden;
    padding: 16px;
    position: relative;
    scroll-behavior: smooth;
    
    /* تنظيم العناصر للبداية بدون فراغات */
    grid-auto-flow: row dense;
    justify-items: stretch;
    align-items: start;
    grid-auto-rows: 190px;
    
    /* إخفاء شريط التمرير */
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* إخفاء شريط التمرير */
.apps-grid::-webkit-scrollbar {
    display: none;
}

.scroll-container {
    position: relative;
    width: 100%;
    height: 100%;
    padding-bottom: 20px;
    pointer-events: none; /* منع التفاعل مع الحاوية نفسها */
}

/* التأكد من أن البطاقات المرئية ومؤشر التمرير فقط يمكن النقر عليها */
.app-card.visible, 
.scroll-indicator {
    pointer-events: auto; /* السماح بالتفاعل مع هذه العناصر فقط */
}

/* مؤشر التمرير للأسفل */
.scroll-indicator {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #4f46e5; /* لون صلب بدون شفافية */
    color: white;
    width: auto;
    min-width: 120px;
    height: 42px;
    border-radius: 21px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.3), 0 6px 16px rgba(79, 70, 229, 0.5);
    transition: all 0.3s ease;
    padding: 0 18px;
    animation: pulse-shadow 2s infinite ease-in-out;
    pointer-events: auto; /* التأكد من أن مؤشر التمرير قابل للنقر دائماً */
    /* تحديد مساحة الزر بدقة ومنع التفاعل خارج حدوده */
    max-width: fit-content;
    backdrop-filter: none; /* إزالة تأثير البلور */
    -webkit-backdrop-filter: none; /* إزالة تأثير البلور */
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.scroll-indicator:hover {
    background-color: #4338ca; /* لون صلب بدون شفافية عند التحويم */
    transform: translateX(-50%) scale(1.05);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.5), 0 8px 20px rgba(79, 70, 229, 0.6);
}

.scroll-indicator i {
    font-size: 19px;
    color: white;
    filter: none; /* إزالة تأثير التوهج على الأيقونة */
}

.more-text {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-shadow: none; /* إزالة ظل النص */
}

@keyframes pulse-shadow {
    0% {
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.7), 0 6px 16px rgba(79, 70, 229, 0.5);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(79, 70, 229, 0), 0 6px 16px rgba(79, 70, 229, 0.5);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0), 0 6px 16px rgba(79, 70, 229, 0.5);
    }
}

.apps-grid.list-view ~ .scroll-indicator {
    display: none;
}

/* توافق RTL */
html[dir="rtl"] .scroll-btn {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
}

html[dir="ltr"] .scroll-indicator .more-text {
    font-size: 16px;
    font-weight: 700;
}

html[dir="ltr"] .scroll-btn:hover {
    transform: translateX(-50%) scale(1.1);
}

/* تنسيق شريط التمرير */
.apps-grid::-webkit-scrollbar {
    width: 8px;
}

.apps-grid::-webkit-scrollbar-track {
    background-color: rgba(203, 213, 225, 0.2);
    border-radius: 4px;
}

.apps-grid::-webkit-scrollbar-thumb {
    background-color: rgba(100, 116, 139, 0.5);
    border-radius: 4px;
}

.apps-grid::-webkit-scrollbar-thumb:hover {
    background-color: rgba(71, 85, 105, 0.7);
}

/* تأثيرات الظهور والاختفاء للبطاقات */
.app-card {
    position: relative;
    background-color: var(--card-bg-color);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 190px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    z-index: 1;
    opacity: 0;
    transform: translateY(20px);
    margin: 0;
    will-change: transform, opacity;
    background-image: linear-gradient(to bottom, rgba(0,0,0,0) 60%, rgba(0,0,0,0.4) 100%);
    pointer-events: none; /* تعطيل التفاعل بشكل افتراضي */
}

.app-card.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto; /* تفعيل التفاعل فقط للبطاقات المرئية */
}

.app-card:hover {
    transform: translateY(-5px) !important;
    box-shadow: var(--shadow-md);
    z-index: 5;
}

.app-card.selected {
    border: 2px solid var(--secondary-color);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

/* إضافة علامة صح عند الاختيار */
.app-card::after {
    content: "\f00c"; /* رمز الصح من Font Awesome */
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0);
    transition: none;
    z-index: 10;
    font-size: 0.75rem;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
}

.app-card.selected::after {
    opacity: 1;
    transform: scale(1);
    animation: checkmark-appear 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* تحسين تأثير الحركة عند التحديد */
@keyframes checkmark-appear {
    0% {
        opacity: 0;
        transform: scale(0) translateY(10px);
        box-shadow: 0 0 0 var(--checkmark-bg-color, rgba(0, 0, 0, 0.6));
    }
    40% {
        opacity: 1;
        transform: scale(1.3) translateY(0);
        box-shadow: 0 0 15px var(--checkmark-bg-color, rgba(0, 0, 0, 0.6));
    }
    60% {
        transform: scale(0.9);
        box-shadow: 0 0 5px var(--checkmark-bg-color, rgba(0, 0, 0, 0.6));
    }
    80% {
        transform: scale(1.1);
        box-shadow: 0 0 10px var(--checkmark-bg-color, rgba(0, 0, 0, 0.6));
    }
    100% {
        opacity: 1;
        transform: scale(1);
        box-shadow: 0 0 8px var(--checkmark-bg-color, rgba(0, 0, 0, 0.6));
    }
}

/* تحسين لعرض القائمة عند التحديد */
.apps-grid.list-view {
    grid-template-columns: 1fr;
    mask-image: none;
    height: auto;
    overflow-y: auto;
    padding-right: var(--spacing-sm);
    scrollbar-width: thin;
    scrollbar-color: var(--secondary-color) var(--gray-800);
}

.apps-grid.list-view .app-card {
    opacity: 1 !important;
    transform: none !important;
    flex-direction: row;
    align-items: center;
    height: 100px;
    padding: var(--spacing-sm) var(--spacing);
    gap: var(--spacing-md);
    min-height: 100px;
}

.apps-grid.list-view .app-card::after {
    top: 50%;
    transform: translateY(-50%) scale(0);
    right: 12px;
    background-color: var(--checkmark-bg-color, rgba(0, 0, 0, 0.6));
}

.apps-grid.list-view .app-card.selected::after {
    transform: translateY(-50%) scale(1);
    animation: checkmark-appear-list 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes checkmark-appear-list {
    0% {
        opacity: 0;
        transform: translateY(-50%) scale(0);
        box-shadow: 0 0 0 var(--checkmark-bg-color, rgba(0, 0, 0, 0.6));
    }
    40% {
        opacity: 1;
        transform: translateY(-50%) scale(1.3);
        box-shadow: 0 0 15px var(--checkmark-bg-color, rgba(0, 0, 0, 0.6));
    }
    60% {
        transform: translateY(-50%) scale(0.9);
        box-shadow: 0 0 5px var(--checkmark-bg-color, rgba(0, 0, 0, 0.6));
    }
    80% {
        transform: translateY(-50%) scale(1.1);
        box-shadow: 0 0 10px var(--checkmark-bg-color, rgba(0, 0, 0, 0.6));
    }
    100% {
        opacity: 1;
        transform: translateY(-50%) scale(1);
        box-shadow: 0 0 8px var(--checkmark-bg-color, rgba(0, 0, 0, 0.6));
    }
}

html[dir="ltr"] .apps-grid.list-view .app-card::after {
    right: auto;
    left: 12px;
}

.apps-grid.list-view .app-card-img {
    width: 48px;
    height: 48px;
    margin-bottom: 0;
    flex-shrink: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.apps-grid.list-view .app-card-img img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.apps-grid.list-view .app-card-content {
    flex-direction: column;
    align-items: flex-start;
    padding: 0;
    height: 100%;
}

.apps-grid.list-view .app-card-content h3 {
    font-size: 1.5rem;
    text-align: right;
    margin: 0;
    color: white;
    font-weight: 800;
    margin-bottom: var(--spacing-xs);
    height: auto;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    width: auto;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    letter-spacing: 0.5px;
}

.apps-grid.list-view .app-card-description {
    text-align: right;
    margin: 0;
    font-size: 1rem;
    color: rgba(255, 255, 255, 1);
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    max-height: 2.8em;
    font-weight: 700;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
}

/* No Results */
.no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: var(--spacing-xl) var(--spacing);
    text-align: center;
    color: var(--gray-400);
    background-color: #1f2937; /* Fondo oscuro */
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin: var(--spacing-lg) 0;
}

.no-results i {
    font-size: 3rem;
    margin-bottom: var(--spacing);
    opacity: 0.5;
}

.no-results h3 {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-sm);
    color: var(--gray-700);
}

.no-results p {
    font-size: 1rem;
}

/* ============ MODAL STYLES ============ */
.app-modal, .batch-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), visibility var(--transition);
    backdrop-filter: blur(3px);
}

.app-modal.active .modal-content, .batch-modal.active .modal-content {
    transform: scale(1);
    opacity: 1;
}

.modal-content {
    background-color: #1e293b; /* خلفية داكنة للمودال */
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    position: relative;
    transform: scale(0.95);
    opacity: 0;
    transition: transform var(--transition), opacity var(--transition);
}

.install-command-box {
    background-color: var(--dark-color);
    border-radius: var(--radius);
    padding: var(--spacing);
    position: relative;
    margin-bottom: var(--spacing);
    overflow: hidden;
}

.install-command {
    color: #a5f3fc;
    font-family: monospace;
    font-size: 0.9rem;
    white-space: pre-wrap;
    margin: 0;
    word-break: break-all;
}

.copy-btn, .copy-batch-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    transition: all var(--transition-fast);
}

.copy-btn:hover, .copy-batch-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: var(--dark-color);
    color: white;
    padding: var(--spacing);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    min-width: 300px;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: transform var(--transition), opacity var(--transition), visibility var(--transition);
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background-color: var(--success-color);
    border-radius: 0 0 var(--radius) var(--radius);
    animation: progress 3s linear forwards;
}

/* ============ SELECTION BANNER ============ */
.selection-banner {
    background: linear-gradient(to right, #3b82f6, #2563eb);
    color: white;
    padding: var(--spacing-sm) var(--spacing);
    transition: all var(--transition);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 101;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.2);
    transform: translateY(100%);
    opacity: 0;
    visibility: hidden;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.selection-banner.visible {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.selection-banner-content {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 1400px;
    margin: 0 auto;
    gap: var(--spacing-lg);
}

.selection-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 1rem;
}

.selection-info i {
    font-size: 1.2rem;
    color: #93c5fd;
}

.selection-info strong {
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
}

.selection-actions-banner {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.install-btn {
    background-color: #1d4ed8;
    color: white;
    border-radius: var(--radius);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 1rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
    min-width: 200px;
}

.install-btn .install-icon {
    position: absolute;
    font-size: 1.2rem;
    color: white;
    opacity: 0;
    transition: all 0.3s ease;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(0);
}

.install-btn .install-text {
    transform: translateX(0);
    opacity: 1;
    transition: all 0.3s ease;
}

.install-btn:hover .install-icon {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.install-btn:hover .install-text {
    transform: translateX(100px);
    opacity: 0;
}

.install-btn:hover:not(.disabled) {
    background-color: #1e40af;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.install-btn.disabled {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

.clear-btn {
    background-color: #dc2626; /* تغيير لون الخلفية إلى أحمر */
    color: white;
    border-radius: var(--radius);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    min-width: 150px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.clear-btn .clear-icon {
    position: absolute;
    font-size: 1.2rem;
    color: white;
    opacity: 0;
    transition: all 0.3s ease;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(0);
}

.clear-btn .clear-text {
    transform: translateX(0);
    opacity: 1;
    transition: all 0.3s ease;
}

.clear-btn:hover .clear-icon {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.clear-btn:hover .clear-text {
    transform: translateX(100px);
    opacity: 0;
}

.clear-btn:hover {
    background-color: #b91c1c; /* لون أحمر داكن عند المرور */
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(220, 38, 38, 0.3);
}

@media (max-width: 768px) {
    .selection-banner-content {
        flex-direction: column;
        gap: var(--spacing-sm);
        padding: var(--spacing-sm) 0;
    }
    
    .selection-actions-banner {
        width: 100%;
        justify-content: center;
        gap: var(--spacing);
    }
    
    /* Add more bottom padding on mobile */
    .main-content {
        padding-bottom: calc(var(--spacing) + 120px);
    }

    .categories-nav li {
        padding: 8px 14px;
    }

    .categories-nav li span {
        font-size: 0.95rem;
    }
}

@media (max-width: 576px) {
    .selection-actions-banner {
        flex-direction: column;
        width: 100%;
        gap: var(--spacing-sm);
    }
    
    .install-btn, .clear-btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Add even more bottom padding on small devices */
    .main-content {
        padding-bottom: calc(var(--spacing) + 160px);
    }
}

/* أزلنا أي تعليقات قد تشير إلى تطبيق اللون من مكان آخر */

/* قاعدة مهمة جدًا لضمان أن أي تطبيق للون من JavaScript يأخذ الأولوية */
.app-card[style*="background-color"] {
    background-color: var(--important-bg-color) !important;
}

#current-category-title {
    display: none !important;
}

/* ============ LANGUAGE SWITCHER ============ */
.language-switcher {
    position: relative;
    margin-right: 10px;
}

.lang-btn {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 20px;
    padding: 6px 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
    position: relative;
    overflow: hidden;
}

.lang-btn::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: all 0.5s ease;
}

.lang-btn:hover::before {
    left: 100%;
}

.lang-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 7px 20px rgba(59, 130, 246, 0.4);
}

.lang-btn:active {
    transform: translateY(1px);
}

.lang-btn i {
    font-size: 1rem;
    animation: rotate 10s linear infinite;
}

.lang-btn.switching i {
    animation: rotateQuick 1s ease-in-out;
}

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

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

/* RTL and LTR specific styles */
html[dir="rtl"] .lang-btn {
    flex-direction: row;
}

html[dir="ltr"] .lang-btn {
    flex-direction: row-reverse;
}

/* اتجاه النص في مربع البحث */
html[dir="ltr"] #search-input {
    text-align: left;
}

html[dir="rtl"] #search-input {
    text-align: right;
}

/* التباعد في منطقة البحث والإجراءات */
html[dir="ltr"] .search-container {
    margin-left: auto;
    margin-right: 20px;
}

html[dir="ltr"] .language-switcher {
    margin-right: 0;
    margin-left: 10px;
}

/* تصحيح موضع أيقونة البحث */
html[dir="ltr"] #search-btn {
    left: auto;
    right: 0;
}

/* محاذاة التفاصيل في وضع LTR */
html[dir="ltr"] .app-description,
html[dir="ltr"] .installation-section h3 {
    text-align: left;
}

/* Transition animations for language change */
.language-transition {
    transition: all 0.5s ease;
    opacity: 0;
    transform: translateY(20px);
}

.language-ready {
    opacity: 1;
    transform: translateY(0);
}

/* تنسيقات البطاقات في وضع LTR */
html[dir="ltr"] .app-card {
    direction: ltr;
}

html[dir="ltr"] .app-card-content h3,
html[dir="ltr"] .app-card-description {
    text-align: center;
}

html[dir="ltr"] .select-checkbox {
    right: auto;
    left: 8px;
}

html[dir="ltr"] .close-modal, 
html[dir="ltr"] .close-batch-modal {
    left: auto;
    right: 15px;
}

html[dir="ltr"] .copy-btn, 
html[dir="ltr"] .copy-batch-btn {
    left: auto;
    right: 8px;
}

html[dir="ltr"] .categories-nav ul {
    justify-content: center;
}

/* تنسيقات شريط التحديد في وضع LTR */
html[dir="ltr"] .selection-banner {
    direction: ltr;
}

html[dir="ltr"] .selection-info {
    direction: ltr;
}

html[dir="ltr"] .modal-app-header {
    flex-direction: row;
}

html[dir="ltr"] .app-info-main {
    flex-direction: row;
}

html[dir="ltr"] .selection-banner-content {
    direction: ltr;
}

html[dir="ltr"] .batch-modal .modal-body h2,
html[dir="ltr"] .batch-modal .modal-body p,
html[dir="ltr"] .batch-modal .modal-body h3 {
    text-align: left;
}

.batch-app-item {
    display: flex;
    align-items: center;
    gap: var(--spacing);
    padding: var(--spacing-sm) var(--spacing);
    border-radius: var(--radius);
    margin-bottom: var(--spacing-xs);
    background-color: #1e293b;
    transition: background-color var(--transition-fast);
}

.batch-app-item:hover {
    background-color: #2d3748;
}

.batch-app-item img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.batch-app-info {
    flex: 1;
}

.batch-app-name {
    font-size: 1rem;
    direction: ltr;
    unicode-bidi: isolate;
    font-weight: 500;
    color: white;
}

/* تحسين تنسيق صورة التطبيق في النافذة المنبثقة */
.app-info-main img {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    object-fit: contain;
    box-shadow: var(--shadow);
}

.batch-script-box {
    background-color: #0f172a; /* Fondo oscuro para el script */
    border-radius: var(--radius);
    padding: var(--spacing);
    margin-bottom: var(--spacing);
    position: relative;
    overflow: hidden;
}

#batch-script {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: #a5f3fc; /* Color claro para el código */
    white-space: pre-wrap;
    word-break: break-all;
    overflow-y: auto;
    max-height: 200px;
    padding-bottom: var(--spacing);
}

/* Estilos para los botones de batch */
.batch-actions {
    display: flex;
    gap: var(--spacing);
    margin-top: var(--spacing);
}

#download-script-btn, #run-script-btn {
    flex: 1;
    background-color: #2d3748; /* Fondo de botón más oscuro */
    color: #f1f5f9;
    border: none;
    border-radius: var(--radius);
    padding: var(--spacing-sm) var(--spacing);
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    transition: all var(--transition-fast);
}

#run-script-btn {
    background-color: var(--primary-color);
}

#download-script-btn:hover {
    background-color: #3f4a5c; /* Color hover más claro */
}

#run-script-btn:hover {
    background-color: var(--primary-dark);
}

/* Mejoras para la selección de texto */
::selection {
    background-color: var(--primary-color);
    color: white;
}

.close-modal, .close-batch-modal {
    position: absolute;
    top: 15px;
    left: 15px;
    background-color: #374151; /* خلفية داكنة */
    color: #e2e8f0; /* نص فاتح */
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    z-index: 10;
}

.close-modal:hover, .close-batch-modal:hover {
    background-color: var(--danger-color);
    color: white;
    transform: rotate(90deg);
}

.modal-body {
    padding: var(--spacing-lg);
}

.app-description {
    line-height: 1.8;
    color: #e2e8f0; /* نص فاتح */
}

.installation-section {
    background-color: #111827; /* خلفية داكنة */
    border-radius: var(--radius);
    padding: var(--spacing);
}

.installation-section h3 {
    font-size: 1.1rem;
    margin-bottom: var(--spacing);
    color: #f1f5f9; /* نص فاتح */
}

/* App modal styles */
.modal-app-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--spacing-lg);
}

.app-info-main {
    display: flex;
    gap: var(--spacing);
}

.app-info-main img {
    width: 80px;
    height: 80px;
    border-radius: var(--radius);
    object-fit: cover;
    box-shadow: var(--shadow);
}

.app-info-main h2 {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-xs);
    color: #f1f5f9; /* نص فاتح */
    direction: ltr;
    unicode-bidi: isolate;
}

.app-actions {
    display: flex;
    gap: var(--spacing-sm);
}

.select-app-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    background-color: #374151; /* خلفية داكنة */
    color: #e2e8f0; /* نص فاتح */
    padding: var(--spacing-sm) var(--spacing);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.select-app-btn:hover {
    background-color: #4b5563; /* خلفية أفتح عند التمرير */
    transform: translateY(-2px);
}

.select-app-btn.selected {
    background-color: var(--secondary-color);
    color: white;
}

.download-btn {
    display: block;
    width: 100%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: var(--spacing-sm) var(--spacing);
    font-size: 1rem;
    cursor: pointer;
    font-weight: 600;
    transition: background-color var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
}

.download-btn:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
}

/* اتجاه عرض بطاقات التطبيقات حسب اللغة */
html[dir="rtl"] .apps-grid {
    direction: rtl;
}

html[dir="ltr"] .apps-grid {
    direction: ltr;
}

/* تحسين ظهور وصف التطبيق في البطاقة */
.app-card-description {
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 0;
    margin-top: -3px;
    color: rgba(255, 255, 255, 1);
    text-align: center;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    height: 6em;
    width: 100%;
    font-weight: 700;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
}

/* تحسين عرض البطاقات في عرض القائمة حسب اللغة */
html[dir="rtl"] .apps-grid.list-view .app-card {
    text-align: right;
}

html[dir="ltr"] .apps-grid.list-view .app-card {
    text-align: left;
}

html[dir="rtl"] .apps-grid.list-view .app-card-content {
    align-items: flex-start;
}

html[dir="ltr"] .apps-grid.list-view .app-card-content {
    align-items: flex-start;
}

html[dir="rtl"] .apps-grid.list-view .app-card-content h3 {
    text-align: right;
}

html[dir="ltr"] .apps-grid.list-view .app-card-content h3,
html[dir="ltr"] .app-info-main h2,
html[dir="ltr"] .batch-app-name,
html[dir="ltr"] .app-card-description {
    text-align: center;
    font-weight: bold;
}

html[dir="rtl"] .apps-grid.list-view .app-card-description {
    text-align: right;
}

html[dir="ltr"] .apps-grid.list-view .app-card-description {
    text-align: left;
    font-weight: bold;
}

/* تحسين عرض أسماء التطبيقات في النافذة المنبثقة */
.app-info-main h2 {
    direction: ltr;
    unicode-bidi: isolate;
}

/* تحسين عرض أسماء التطبيقات في قائمة التثبيت المجمع */
.batch-app-name {
    direction: ltr;
    unicode-bidi: isolate;
}

/* في واجهة RTL، نحافظ على اتجاه عرض صحيح للأسماء */
html[dir="rtl"] .app-card-content h3,
html[dir="rtl"] .app-info-main h2,
html[dir="rtl"] .batch-app-name {
    text-align: center;
}

/* في واجهة LTR، نعرض النص بشكل طبيعي */
html[dir="ltr"] .app-card-content h3,
html[dir="ltr"] .app-info-main h2,
html[dir="ltr"] .batch-app-name {
    text-align: center;
    font-weight: bold;
}

/* تحسين مساحة صورة التطبيق */
.app-card-img {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 48px;
    margin-bottom: var(--spacing-sm);
    margin-top: var(--spacing-sm);
}

.app-card-img img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.app-card:hover .app-card-img img {
    transform: scale(1.1);
}

/* تحسين عرض الأيقونات في عرض القائمة */
.apps-grid.list-view .app-card-img {
    width: 48px;
    height: 48px;
    margin-bottom: 0;
    flex-shrink: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.apps-grid.list-view .app-card-img img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

/* تأثير الريبل عند النقر */
.app-card {
    position: relative;
    overflow: hidden;
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(0);
    animation: ripple-animation 0.6s linear;
    pointer-events: none;
    z-index: 2;
}

@keyframes ripple-animation {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* تحسين أحجام البطاقات في مختلف الشاشات */
@media (max-width: 992px) {
    .apps-grid {
        grid-template-columns: repeat(3, 1fr);
        height: calc(4 * (190px + var(--spacing)));
    }
}

@media (max-width: 768px) {
    .apps-grid {
        grid-template-columns: repeat(2, 1fr);
        height: calc(6 * (190px + var(--spacing)));
    }
}

@media (max-width: 576px) {
    .apps-grid {
        grid-template-columns: 1fr;
        height: calc(12 * (190px + var(--spacing)));
    }
    
    .app-card {
        height: 180px;
    }
}

/* تعديل موضع علامة الاختيار حسب اللغة */
html[dir="ltr"] .app-card::after {
    right: auto;
    left: 10px;
}

/* تحسين مظهر البطاقة في وضع القائمة */
.apps-grid.list-view .app-card {
    flex-direction: row;
    align-items: center;
    height: 100px;
    padding: var(--spacing-sm) var(--spacing);
    gap: var(--spacing-md);
    min-height: 100px;
}

.apps-grid.list-view .app-card::after {
    top: 50%;
    transform: translateY(-50%) scale(0);
    right: 12px;
    background-color: inherit;
}

.apps-grid.list-view .app-card.selected::after {
    transform: translateY(-50%) scale(1);
    animation: checkmark-appear-list 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

html[dir="ltr"] .apps-grid.list-view .app-card::after {
    right: auto;
    left: 12px;
}

/* إزالة دائرة التحديد */
.select-checkbox {
    display: none;
}

.app-card-content h3 {
    font-size: 1.4rem;
    color: white;
    text-align: center;
    font-weight: 800;
    margin: 0;
    line-height: 1.3;
    height: 2.4em;
    width: 100%;
    direction: ltr;
    unicode-bidi: isolate;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 2px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    letter-spacing: 0.5px;
}

/* ============ FLOATING APP ICONS BACKGROUND ============ */
.floating-icons-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    opacity: 1;
    background-color: transparent;
    visibility: visible;
}

.floating-icon {
    position: absolute;
    width: 64px;
    height: 64px;
    border-radius: 12px;
    background-color: transparent;
    box-shadow: none;
    animation: float-icon 15s linear infinite;
    opacity: 0.20; /* شفافية بسيطة جدًا للأيقونات */
    backdrop-filter: none;
    background-size: 60%;
    background-position: center;
    background-repeat: no-repeat;
    border: none;
}

@keyframes float-icon {
    0% {
        transform: translateY(100vh) rotate(0deg);
    }
    100% {
        transform: translateY(-100px) rotate(360deg);
    }
}

/* تحريك الأيقونات بسرعات مختلفة */
.floating-icon:nth-child(2n) {
    animation-duration: 20s;
}

.floating-icon:nth-child(3n) {
    animation-duration: 25s;
}

.floating-icon:nth-child(5n) {
    animation-duration: 18s;
}

/* تحريك الأيقونات بحجم مختلف */
.floating-icon:nth-child(2n+1) {
    width: 48px;
    height: 48px;
}

.floating-icon:nth-child(3n+1) {
    width: 72px;
    height: 72px;
}

/* تأثير اللمعان على الأيقونات */
.floating-icon::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent; /* إزالة تأثير اللمعان تمامًا */
    z-index: 1;
    border-radius: 12px;
}

/* إظهار جزء من الأيقونة في موضع مختلف لكل أيقونة */
.floating-icon:nth-child(1) { left: 10%; animation-delay: 0s; }
.floating-icon:nth-child(2) { left: 20%; animation-delay: 2s; }
.floating-icon:nth-child(3) { left: 30%; animation-delay: 5s; }
.floating-icon:nth-child(4) { left: 40%; animation-delay: 1s; }
.floating-icon:nth-child(5) { left: 50%; animation-delay: 7s; }
.floating-icon:nth-child(6) { left: 60%; animation-delay: 3s; }
.floating-icon:nth-child(7) { left: 70%; animation-delay: 8s; }
.floating-icon:nth-child(8) { left: 80%; animation-delay: 4s; }

/* تحسين وضوح النصوص الإنجليزية */
html[dir="ltr"] .app-card-description {
    font-size: 1rem;
    line-height: 1.7;
    font-weight: 800;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
    letter-spacing: 0.6px;
}

html[dir="ltr"] .apps-grid.list-view .app-card-description {
    font-size: 1.1rem;
    text-align: left;
    font-weight: 800;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
    letter-spacing: 0.6px;
}

/* تعزيز وضوح النصوص في النافذة المنبثقة */
html[dir="ltr"] .app-description {
    font-weight: 700;
    font-size: 1.1rem;
    line-height: 1.8;
    color: white;
    text-shadow: 0 2px 3px rgba(0, 0, 0, 0.7);
    letter-spacing: 0.5px;
}

/* زر عرض السكريبت في الشريط العلوي */
.search-container .show-script-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background-color: #212431;
    color: white;
    border: 1px solid rgba(107, 126, 254, 0.3);
    border-radius: var(--radius);
    padding: 8px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 10px;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    height: 38px;
    min-width: 130px;
    overflow: hidden;
    position: relative;
}

.search-container .show-script-btn:hover {
    background-color: #2c3242;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    border-color: rgba(107, 126, 254, 0.5);
}

.search-container .show-script-btn .script-icon {
    position: absolute;
    font-size: 1.2rem;
    color: #6b7efe;
    opacity: 0;
    transition: all 0.3s ease;
    /* مركز تماماً */
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(0);
}

.search-container .show-script-btn:hover .script-icon {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.search-container .show-script-btn .show-script-text {
    display: block;
    transition: all 0.3s ease;
    opacity: 1;
    transform: translateX(0);
}

.search-container .show-script-btn:hover .show-script-text {
    transform: translateX(100px);
    opacity: 0;
}

/* تنسيقات RTL و LTR للزر */
html[dir="rtl"] .search-container .show-script-btn {
    margin-right: 10px;
    margin-left: 0;
}

html[dir="ltr"] .search-container .show-script-btn {
    margin-left: 10px;
    margin-right: 0;
}

/* نافذة CMD */
.cmd-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cmd-modal.active {
    opacity: 1;
    visibility: visible;
}

.cmd-window {
    width: 80%;
    max-width: 800px;
    height: 60%;
    max-height: 600px;
    background-color: #0C0C0C;
    border: 1px solid #4e4e4e;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
    transform: scale(0.95);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    position: relative;
    margin: 0 auto; /* تأكيد المركزية */
}

.cmd-modal.active .cmd-window {
    transform: scale(1);
    opacity: 1;
}

.cmd-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #1f1f1f;
    padding: 4px 15px;
    height: 36px;
    user-select: none;
    border-bottom: 1px solid #333;
}

.cmd-title {
    color: #f1f1f1;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Segoe UI', Arial, sans-serif;
    flex: 1;
    text-align: center;
}

.cmd-controls {
    display: flex;
    gap: 5px;
    position: absolute;
    right: 10px;
    top: 7px;
}

.cmd-controls button {
    width: 22px;
    height: 22px;
    border: none;
    background-color: transparent;
    color: #cccccc;
    font-size: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    border-radius: 3px;
    transition: background-color 0.2s, color 0.2s;
}

.cmd-close {
    background-color: #e81123 !important;
    color: white !important;
}

.cmd-close:hover {
    background-color: #f13343 !important;
    transform: scale(1.1);
}

.cmd-content {
    height: calc(100% - 36px);
    padding: 0;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 15px;
    line-height: 1.6;
    color: #f1f1f1;
    background-color: #0C0C0C;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}

#cmd-script-content {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-all;
    font-family: 'Consolas', 'Courier New', monospace;
    font-weight: normal;
    letter-spacing: 0.5px;
    text-align: left;
    flex: 1;
    overflow-y: auto;
    padding: 10px 20px;
    direction: ltr;
    max-width: 100%;
    box-sizing: border-box;
}

/* تخصيص شريط التمرير لمحتوى النافذة */
#cmd-script-content::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

#cmd-script-content::-webkit-scrollbar-track {
    background: #0c0c0c;
    border-radius: 4px;
}

#cmd-script-content::-webkit-scrollbar-thumb {
    background: #4ade80; /* لون أخضر تفاحي فاتح */
    border-radius: 4px;
    border: 2px solid #0c0c0c;
}

#cmd-script-content::-webkit-scrollbar-thumb:hover {
    background: #22c55e; /* لون أخضر تفاحي أغمق قليلاً عند المرور */
}

.cmd-copy-container {
    display: flex;
    justify-content: center;
    padding: 15px;
    border-top: 1px solid #333;
    background-color: #0C0C0C;
}

.cmd-copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #2d5cb6;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    gap: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    min-width: 180px;
    position: relative;
    overflow: hidden;
}

.cmd-copy-btn:hover {
    background-color: #3b6fd4;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.cmd-copy-btn .copy-icon {
    position: absolute;
    font-size: 1.2rem;
    color: white;
    opacity: 0;
    transition: all 0.3s ease;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(0);
}

.cmd-copy-btn:hover .copy-icon {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.cmd-copy-btn .copy-text {
    display: block;
    transition: all 0.3s ease;
    opacity: 1;
    transform: translateX(0);
}

.cmd-copy-btn:hover .copy-text {
    transform: translateX(100px);
    opacity: 0;
}

/* توافق RTL/LTR لنافذة CMD */
html[dir="rtl"] .cmd-controls {
    right: auto;
    left: 10px;
}

/* تأثير المؤشر لمحتوى CMD - إزالة المؤشر الوامض */
.cmd-content::after {
    display: none;
}

/* نص السكريبت CMD يجب أن يكون LTR حتى في تخطيط RTL */
#cmd-script-content {
    direction: ltr;
    font-weight: normal;
}

html[dir="rtl"] .cmd-copy-container,
html[dir="ltr"] .cmd-copy-container {
    justify-content: center;
}

/* RTL/LTR for CMD window */
html[dir="rtl"] .cmd-title {
    margin-right: 15px;
}

html[dir="ltr"] .cmd-title {
    margin-left: 15px;
}

/* زر التواصل الاجتماعي المنبثق */
.social-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px !important; /* تثبيت الزر دائماً على اليمين بغض النظر عن اللغة */
    left: auto !important; /* تأكيد عدم استخدام اليسار أبداً */
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #38bdf8; /* تغيير لون الدائرة إلى الأزرق الفاتح */
    color: white; /* إرجاع لون علامة + للأبيض */
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 10px rgba(56, 189, 248, 0.4); /* تعديل ظل الزر ليتناسب مع اللون الجديد */
    cursor: pointer;
    z-index: 1010;
    transition: transform 0.3s, background-color 0.3s;
    border: none;
    font-size: 19px; /* حجم علامة + */
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5); /* توهج خفيف للعلامة */
}

.social-toggle:hover {
    background-color: #0ea5e9; /* لون أغمق قليلاً عند التحويم */
    transform: scale(1.05);
}

.social-toggle.active {
    transform: rotate(45deg);
}

.social-menu {
    position: fixed;
    bottom: 70px;
    right: 20px !important; /* تثبيت القائمة دائماً على اليمين بغض النظر عن اللغة */
    left: auto !important; /* تأكيد عدم استخدام اليسار أبداً */
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1009;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
}

.social-menu.active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: all;
}

.social-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease, box-shadow 0.3s ease;
    border: none;
    opacity: 0;
    transform: translateY(20px);
    will-change: transform, opacity;
}

.social-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.social-btn.twitter {
    background-color: #000000;
    position: relative;
    overflow: hidden;
}

.social-btn.twitter i {
    display: none;
}

.social-btn.twitter::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('https://img.icons8.com/?size=100&id=A4DsujzAX4rw&format=png&color=FFFFFF');
    background-size: 55%;
    background-position: center;
    background-repeat: no-repeat;
}

.social-btn.youtube {
    background-color: #FF0000;
}

.social-btn.youtube i {
    font-size: 18px;
}

.social-btn.discord {
    background-color: #5865F2;
}

.social-btn.discord i {
    font-size: 18px;
}

/* تأثير بصري لترقب الضغط على الزر */
@keyframes pulse-social {
    0% {
        box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.5);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(56, 189, 248, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(56, 189, 248, 0);
    }
}

.social-toggle {
    animation: pulse-social 3s infinite;
}

.social-toggle.active {
    animation: none;
}

/* توافق RTL و LTR */
html[dir="ltr"] .social-toggle {
    right: 20px;
    left: auto;
}

html[dir="ltr"] .social-menu {
    right: 20px;
    left: auto;
}

html[dir="rtl"] .social-toggle {
    left: 20px;
    right: auto;
}

html[dir="rtl"] .social-menu {
    left: 20px;
    right: auto;
}

/* تأثير الخلفية عند فتح القائمة */
.social-backdrop {
    display: none; /* إخفاء الخلفية تماماً */
}

.social-backdrop.active {
    display: none; /* إخفاء الخلفية تماماً حتى عندما تكون نشطة */
}

/* التأكد من عدم وجود تفاعل مع البطاقات المخفية */
.apps-grid:after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100px; /* منطقة أمان للتأكد من عدم وجود تفاعل */
    z-index: 10;
    pointer-events: none;
}

/* منطقة الأمان لمنع التفاعل مع البطاقات غير المرئية */
.grid-safety-zone {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    z-index: 40; /* تقليل z-index ليكون أقل من مؤشر التمرير */
    pointer-events: auto;
    cursor: default; /* تغيير المؤشر ليكون افتراضي بدلاً من pointer */
    /* إزالة الحدود المرئية */
    border-top: none;
}

/* توافق RTL و LTR */
html[dir="ltr"] .social-toggle {
    right: 20px;
    left: auto;
}

html[dir="ltr"] .social-menu {
    right: 20px;
    left: auto;
}

html[dir="rtl"] .social-toggle {
    left: 20px;
    right: auto;
}

html[dir="rtl"] .social-menu {
    left: 20px;
    right: auto;
}

/* تأكيد موقع ثابت لزر المشاركة على جهة اليمين في كل الحالات */
html[dir="ltr"] .social-toggle,
html[dir="rtl"] .social-toggle,
html[dir="ltr"] .social-menu,
html[dir="rtl"] .social-menu {
    right: 20px !important;
    left: auto !important;
}

/* تعديل موضع زر الـ + عندما يظهر شريط التحديد */
.selection-banner.visible ~ .social-toggle {
    bottom: 70px !important; /* تحريك زر + للأعلى عندما يظهر شريط التحديد */
    transition: bottom 0.3s ease, transform 0.3s, background-color 0.3s;
}

.selection-banner.visible ~ .social-menu.active {
    bottom: 120px !important; /* تحريك قائمة التواصل الاجتماعي للأعلى أيضاً */
}

/* تعديل حجم شريط التحديد ليكون أكثر تنظيماً */
@media (min-width: 769px) {
    .selection-banner {
        padding: 10px 0;
    }
    
    .selection-banner-content {
        max-width: 1200px;
        margin: 0 auto;
        padding: 0 20px;
    }
    
    .selection-banner.visible ~ .social-toggle {
        bottom: 80px !important; /* زيادة المسافة قليلاً في الشاشات الكبيرة */
    }
    
    .selection-banner.visible ~ .social-menu.active {
        bottom: 130px !important;
    }
}

/* تعديل موضع زر الـ + على الأجهزة المحمولة */
@media (max-width: 768px) {
    .selection-banner.visible ~ .social-toggle {
        bottom: 120px !important; /* زيادة المسافة في الشاشات الصغيرة لأن الشريط يكون أكبر */
    }
    
    .selection-banner.visible ~ .social-menu.active {
        bottom: 170px !important;
    }
}

@media (max-width: 576px) {
    .selection-banner.visible ~ .social-toggle {
        bottom: 170px !important; /* زيادة المسافة أكثر في الشاشات الأصغر */
    }
    
    .selection-banner.visible ~ .social-menu.active {
        bottom: 220px !important;
    }
}
