/* ================================================= */
/* 1. التنسيقات العامة والأساسية                     */
/* ================================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, sans-serif;
}

html, body {
    height: 100%;
    width: 100%;
    overflow-x: hidden;
}

body {
    background-color: #f4f4f4;
    background-image: url('khalilgames.jpg');
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 5000px 5000px;
    background-attachment: fixed;
    color: #1f2937;
    direction: rtl;
    text-align: right;
}

/* ================================================= */
/* 2. الشريط العلوي (Navbar)                        */
/* ================================================= */
.custom-navbar {
    background: linear-gradient(135deg, #e91e63, #c2185b);
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    direction: ltr;
    box-shadow: 0 4px 20px rgba(233, 30, 99, 0.3);
}

.logo-text {
    color: #ffffff;
    font-size: 26px;
    font-weight: bold;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
}

/* ================================================= */
/* 3. تنسيق الشعار (Logo) ورأس الصفحة (بدون ظلال)   */
/* ================================================= */
.logo-container {
    background-color: transparent;
    padding: 15px 10px;
    border: none;
    box-shadow: none;
    display: block;
    text-align: center;
    margin: 0 auto;
    width: 100%;
    max-width: 600px;
}

.game-logo {
    width: 300px;
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    filter: none;
    transition: none;
}

.site-header {
    text-align: center;
    margin-bottom: 25px;
    padding: 0 15px;
}

.site-header h1 {
    color: #7c3aed;
    font-size: 2.2rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.site-header p {
    color: #6b7280;
    font-size: 0.95rem;
    margin-top: 5px;
}

/* ================================================= */
/* 4. لوحة معلومات التخزين وشريط التقدم              */
/* ================================================= */
.storage-selector-section {
    text-align: center;
    margin: 20px 0;
    padding: 0 15px;
}

.storage-selector-section h3 {
    margin-bottom: 10px;
    color: #374151;
}

.storage-selector-section button {
    background-color: #ffffff;
    color: #7c3aed;
    border: 2px solid #7c3aed;
    border-radius: 10px;
    font-weight: bold;
    padding: 10px 22px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 5px;
    font-size: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.04);
}

.storage-selector-section button:hover {
    background-color: #7c3aed;
    color: #ffffff;
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(124, 58, 237, 0.3);
}

.storage-selector-section button:active {
    transform: translateY(-1px);
}

.storage-selector-section button.active {
    background-color: #dc2626 !important;
    color: #ffffff !important;
    border-color: #dc2626 !important;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4) !important;
}

.storage-dashboard {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 22px;
    border-radius: 16px;
    text-align: center;
    max-width: 450px;
    margin: 0 auto 25px auto;
    border: 1px solid rgba(229, 231, 235, 0.8);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    width: 90%;
    transition: all 0.3s ease;
}

.storage-dashboard h3 {
    color: #4b5563;
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.storage-meter {
    font-size: 2.5rem;
    color: #7c3aed;
    font-weight: bold;
}

.storage-meter .unit {
    font-size: 1.2rem;
    color: #9ca3af;
}

.storage-progress-container {
    width: 100%;
    background-color: #e5e7eb;
    border-radius: 10px;
    height: 14px;
    margin: 15px 0 10px 0;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.06);
}

/* تحديث شريط التقدم بتدرج متحرك وعصري */
@keyframes gradientMove {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.storage-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(270deg, #7c3aed, #e91e63, #a855f7);
    background-size: 200% 200%;
    animation: gradientMove 4s ease infinite;
    border-radius: 10px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.dashboard-buttons {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
}

.reset-btn, .whatsapp-btn {
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    border: none;
    transition: all 0.25s ease;
}

.reset-btn {
    background-color: #e5e7eb;
    color: #374151;
}

.reset-btn:hover {
    background-color: #d1d5db;
    transform: translateY(-2px);
}

/* إضافة تأثير نبض مميز لزر الواتساب */
@keyframes buttonPulse {
    0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.5); }
    70% { box-shadow: 0 0 0 10px rgba(37, 211, 102, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

.whatsapp-btn {
    background-color: #25d366 !important;
    color: white;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
    animation: buttonPulse 2.5s infinite;
}

.whatsapp-btn:hover {
    background-color: #20ba5a !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 211, 102, 0.4);
    animation: none;
}

.selected-games-counter {
    background-color: #f3f4f6;
    color: #4b5563;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: bold;
    border: 1px solid #e5e7eb;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* ================================================= */
/* 5. حاوية الألعاب والشبكة                         */
/* ================================================= */
.games-container {
    max-width: 1100px;
    margin: 0 auto 40px auto;
    padding: 0 15px;
}

.games-container h2 {
    margin-bottom: 20px;
    border-right: 4px solid #7c3aed;
    padding-right: 12px;
    color: #1f2937;
    font-size: 1.5rem;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 18px;
}

/* ================================================= */
/* 6. بطاقات الألعاب والتأثيرات البصرية (Animations) */
/* ================================================= */
.game-card {
    background-color: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    /* تحسين حركة الـ 3D عند التمرير */
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s ease, border-color 0.4s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    position: relative;
}

.game-card:hover {
    border-color: #a855f7;
    transform: translateY(-8px) scale(1.03);
    box-shadow: 0 15px 30px rgba(168, 85, 247, 0.25), 0 5px 15px rgba(0, 0, 0, 0.08);
}

@keyframes selectPulse {
    0% { box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(124, 58, 237, 0); }
    100% { box-shadow: 0 0 0 0 rgba(124, 58, 237, 0); }
}

.game-card.selected {
    border-color: #7c3aed;
    background: linear-gradient(145deg, #ffffff, #f5f3ff);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.5), 0 8px 20px rgba(124, 58, 237, 0.2) !important;
    animation: selectPulse 0.5s ease;
}

.game-card.disabled {
    opacity: 0.4;
    pointer-events: none;
    filter: grayscale(1);
    cursor: not-allowed;
    transform: none !important;
}

.game-img {
    width: 100%;
    height: 210px;
    overflow: hidden;
    background-color: #111;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.game-card:hover .game-img img {
    transform: scale(1.08);
}

.game-info {
    padding: 12px;
    text-align: center;
    background: #ffffff;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.game-info h4 {
    font-size: 0.95rem;
    margin-bottom: 6px;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-info .game-size {
    font-size: 0.85rem;
    color: #7c3aed;
    font-weight: bold;
    margin-bottom: 8px;
}

.select-badge {
    display: block;
    background: #f3f4f6;
    padding: 7px;
    text-align: center;
    border-radius: 8px;
    font-size: 0.75rem;
    color: #4b5563;
    transition: all 0.3s ease;
}

.game-card.selected .select-badge {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: #ffffff;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(124, 58, 237, 0.3);
}

.status-normal {
    color: #059669;
    font-weight: 500;
}

/* ================================================= */
/* 7. تصميم زر الـ 3 شحطات والنافذة الجانبية (Drawer) */
/* ================================================= */
.menu-toggle-btn {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 22px;
    position: relative;
    background: transparent;
    border: none;
}

.menu-toggle-btn span:not(.cart-badge) {
    display: block;
    height: 3px;
    width: 100%;
    background-color: white;
    border-radius: 3px;
    transition: all 0.3s ease;
}

.cart-badge {
    position: absolute;
    top: -8px;
    left: -10px;
    background-color: #dc2626;
    color: white;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.cart-drawer {
    position: fixed;
    top: 0;
    left: -350px;
    width: 350px;
    max-width: 90%;
    height: 100%;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    direction: rtl;
    text-align: right;
    border-left: 1px solid rgba(168, 85, 247, 0.2);
}

.cart-drawer.open {
    left: 0;
}

.cart-drawer-header {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-drawer-header h3 {
    font-size: 1.1rem;
    margin: 0;
}

.close-drawer-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 26px;
    cursor: pointer;
    line-height: 1;
}

.cart-drawer-body {
    padding: 15px;
    overflow-y: auto;
    flex-grow: 1;
}

.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.drawer-overlay.open {
    display: block;
    opacity: 1;
}

/* ================================================= */
/* 8. مؤثرات حركية عامة (Shake & Fade Out)           */
/* ================================================= */
@keyframes shake {
    0% { transform: translateX(0); }
    20% { transform: translateX(-10px); }
    40% { transform: translateX(10px); }
    60% { transform: translateX(-10px); }
    80% { transform: translateX(10px); }
    100% { transform: translateX(0); }
}

.shake {
    animation: shake 0.4s ease-in-out;
}

@keyframes fadeOutScale {
    0% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.1); }
}

.fade-out {
    animation: fadeOutScale 0.5s ease forwards;
}

#access-code-input {
    transition: all 0.3s ease;
    background-color: #f9fafb;
}

#access-code-input:focus {
    background-color: #fff;
    border-color: #a855f7 !important;
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.4);
}

/* ================================================= */
/* 9. الاستجابة للشاشات (Media Queries)             */
/* ================================================= */
@media (max-width: 768px) {
    .games-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }

    .game-img {
        height: 140px;
    }

    .game-info { padding: 6px; }
    .game-info h4 { font-size: 0.75rem; }
    .game-info .game-size { font-size: 0.7rem; }
    .select-badge { font-size: 0.65rem; padding: 4px; }

    .storage-dashboard {
        position: relative;
        width: 95%;
        margin: 15px auto;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
        background: #ffffff;
    }

    .games-container {
        margin-bottom: 30px;
    }
    
    .storage-meter { font-size: 2rem; }
}

/* تنسيق غلاف الفيسبوك المتحرك لتعبئة الشاشة بالكامل دون فراغات */
.facebook-cover-container {
    width: 100%;
    height: 220px;
    background-color: #1a1a1a;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.cover-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 1s ease-in-out;
    object-fit: cover; /* تغطية المساحة بالكامل وإلغاء الفراغات السوداء الجانبية */
    background-color: #1a1a1a;
}

.cover-slide.active {
    opacity: 1;
}