/* General Body Styles */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4; 
    color: #333;
    line-height: 1.6;
    direction: rtl; 
    text-align: right; 
}

.container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 20px;
    background-color: transparent; 
    border-radius: 8px;
    box-shadow: none; 
}

/* "hero2.jpg" هي خلفية الكروت */
.card-and-forms-wrapper {
    background-image: url('/hero2.jpg');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: scroll; 
    border-radius: 8px;
    padding: 20px; 
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2); 
    margin-bottom: 20px; 
}

.card-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.card {
    background-color: rgba(255, 255, 255, 0.9); 
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    padding: 20px;
    text-align: center;
    width: 200px; 
}

.card-img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 10px;
}

.form-container {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.form-container form {
    background-color: rgba(255, 255, 255, 0.9); 
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-container h3 {
    text-align: center;
    color: #007bff;
    margin-bottom: 15px;
}

.form-container input[type="email"],
.form-container input[type="password"],
.form-container input[type="text"],
.form-container input[type="file"],
.form-container select { 
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box; 
    background-color: white; 
}

.form-container button {
    background-color: #007bff;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
}

.form-container button:hover {
    background-color: #0056b3;
}

#message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 4px;
    text-align: center;
}

/* كود تكبير الكارت والصورة */
.container .card {
    max-width: 450px; 
    width: 90%; 
    margin: 1rem auto; 
    padding: 1.5rem; 
}

/* ستايلات كارت المستخدم (الاسم والعائلة والرصيد والمستوى) */
.container .card #user-name,
.container .card #user-family,
.container .card #user-balance,
.container .card #user-level { 
    font-size: 1.25em; 
    font-weight: bold;  
    color: #333;        
    margin: 0.75rem 0; 
}


.container .card .card-img {
    width: 150px;
    height: 150px;
}

/* ستايلات لوحة الأدمن */
.admin-panel-container {
    padding: 20px;
    max-width: 900px;
    margin: 2rem auto;
}
#admin-panel {
    background-color: #f0f0f0;
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 1rem;
    border: 2px dashed #007bff;
    font-size: 1.1em; 
}
#admin-panel h2 {
    text-align: center;
    color: #333;
}
.admin-section {
    margin-top: 1.5rem;
    background: #fafafa;
    padding: 1rem;
    border-radius: 4px;
}
.admin-section h4 {
    border-bottom: 2px solid #007bff;
    padding-bottom: 5px;
}
#admin-search-form {
    display: flex;
    gap: 10px;
    margin-top: 0.5rem;
}
#admin-search-form input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
#admin-search-form button {
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: white;
    background-color: #007bff;
}

#admin-balance-controls {
    display: flex;
    gap: 10px;
    margin-top: 0.5rem;
}
#admin-balance-controls input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
#admin-add-balance-btn, #admin-subtract-balance-btn {
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: white;
    font-weight: bold;
}
#admin-add-balance-btn {
    background-color: #28a745; 
}
#admin-subtract-balance-btn {
    background-color: #ffc107; 
    color: #333;
}

/* 🛑🛑 قسم تعديل المستوى الجديد (للأدمن) 🛑🛑 */
#admin-level-controls {
    display: flex;
    gap: 10px;
    margin-top: 0.5rem;
}
#admin-level-controls input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
#admin-update-level-btn {
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: white;
    background-color: #17a2b8; /* Info Blue */
    font-weight: bold;
}
#admin-update-level-btn:hover {
    background-color: #138496;
}


#admin-delete-user-btn {
    background-color: #dc3545; 
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    margin-top: 1rem;
}

/* 🛑🛑 تنسيق زر عرض QR للأدمن (جديد) 🛑🛑 */
#admin-show-user-qr-btn {
    background-color: #28a745; /* أخضر */
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    margin-top: 1rem; /* مسافة قبل الزر */
    font-weight: bold;
    font-size: 1em;
}
#admin-show-user-qr-btn:hover {
    background-color: #218838;
}


#logout-btn {
    display: none;
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    margin: 1rem auto;
    width: 90%;
    max-width: 400px;
}
/* 🛑 مجموعة الأزرار الرئيسية (لوج أوت، ريفرش، الخ) */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 90%;
    max-width: 450px;
    margin: 1rem auto;
}
.button-group button {
    padding: 12px;
    font-size: 1em;
    font-weight: bold;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
/* تمييز زر كود الحضور */
#show-qr-btn {
    background-color: #28a745 !important;
    color: white !important;
}


#admin-searched-user-card {
    display: none; 
    background: #fff; 
    padding: 1rem; 
    margin-top: 1rem; 
    border-radius: 4px; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
#admin-searched-user-card p {
    margin: 0.5rem 0;
}

/* ستايلات زراير الأسر */
.family-buttons-container {
    display: flex;
    justify-content: space-around;
    gap: 10px;
    flex-wrap: wrap; 
}
.family-btn {
    flex: 1; 
    padding: 10px 15px;
    font-size: 0.9em;
    background-color: #17a2b8; 
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    min-width: 150px; 
}
.family-btn:hover {
    background-color: #138496;
}
#admin-family-results {
    margin-top: 1rem;
    background: #fff;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    max-height: 300px; 
    overflow-y: auto; 
}
#admin-family-results .family-user-item {
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid #eee; padding: 0.5rem 0;
}
#admin-family-results .family-user-item:last-child { border-bottom: none; }
#admin-family-results .user-info {
    cursor: pointer; flex-grow: 1; padding: 5px;
    margin-right: 15px; 
}
#admin-family-results .user-info:hover { background-color: #e9ecef; }
#admin-family-results .mass-update-checkbox {
    margin-right: 15px; transform: scale(1.3); 
}

/* ستايلات التعديل الجماعي */
.mass-update-controls {
    margin-top: 15px;
    padding: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
.mass-update-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}
.mass-update-buttons button {
    padding: 12px 20px; 
    font-size: 1.1em; 
    font-weight: bold;
    flex-grow: 1; 
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: white;
    transition: background-color 0.2s;
}
#mass-update-add-btn {
    background-color: #28a745; 
}
#mass-update-add-btn:hover {
    background-color: #218838;
}
#mass-update-subtract-btn {
    background-color: #dc3545; 
}
#mass-update-subtract-btn:hover {
    background-color: #c82333;
}

/* 🛑🛑 تنسيقات زر العودة للقائمة الرئيسية 🛑🛑 */
#back-to-store-btn {
    background-color: #007bff; /* Primary Blue */
    color: white;
    padding: 12px 25px; 
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: bold;
    display: block; 
    width: fit-content;
    margin-right: auto; 
    transition: background-color 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); 
}
#back-to-store-btn:hover {
    background-color: #0056b3;
}

/* 🛑🛑 تنسيقات زر إضافة عنصر (للأدمن) 🛑🛑 */
form#admin-add-item-form button[type="submit"] {
    background-color: #28a745; /* Success Green */
    color: white;
    padding: 12px 18px; 
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1em; 
    font-weight: bold;
    width: 100%;
    margin-top: 10px;
    transition: background-color 0.2s;
}
form#admin-add-item-form button[type="submit"]:hover {
    background-color: #218838;
}


/* تنسيقات فورم الكويز */
#admin-quiz-form { display: flex; flex-direction: column; gap: 10px; }
#admin-quiz-form input[type="text"],
#admin-quiz-form input[type="number"],
#admin-quiz-form select {
    padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 1em;
}
#admin-quiz-form button {
    background-color: #17a2b8; color: white; padding: 10px;
    border: none; border-radius: 4px; cursor: pointer; font-size: 1.1em;
}
#admin-quiz-form button:hover { background-color: #138496; }

/* تنسيقات فورم الإعلان */
#admin-announcement-form textarea {
    width: 100%; min-height: 80px; padding: 10px;
    border: 1px solid #ccc; border-radius: 4px;
    font-size: 1em; box-sizing: border-box; 
}
#admin-announcement-form button {
    background-color: #ffc107; color: #212529; padding: 10px;
    border: none; border-radius: 4px; cursor: pointer;
    font-size: 1.1em; width: 100%; margin-top: 10px;
}

/* ستايلات الكويز (لليوزر) */
.quiz-container {
    display: none; 
    max-width: 900px; margin: 2rem auto; padding: 20px;
    background-color: #fff; border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); border: 2px solid #007bff;
}
.quiz-container h2 { text-align: center; color: #007bff; margin-top: 0; }
#quiz-question-text {
    font-size: 1.3em; font-weight: bold;
    margin-bottom: 1.5rem; text-align: center;
}
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-option-btn {
    padding: 15px; font-size: 1.1em; background-color: #f0f2f5;
    border: 2px solid #ddd; border-radius: 8px; cursor: pointer;
    text-align: right; transition: background-color 0.2s, border-color 0.2s;
}
.quiz-option-btn:hover { background-color: #e9ecef; border-color: #007bff; }
.quiz-option-btn.selected {
    background-color: #cce5ff; border-color: #007bff; font-weight: bold;
}
#quiz-submit-btn {
    background-color: #28a745; color: white; padding: 12px;
    border: none; border-radius: 4px; cursor: pointer;
    font-size: 1.2em; width: 100%; margin-top: 1.5rem;
}
#quiz-submit-btn:hover { background-color: #218838; }
#quiz-message {
    text-align: center; font-size: 1.1em;
    margin-top: 1rem; font-weight: bold;
}

/* ستايلات لوحة الصدارة */
.leaderboard-container {
    display: none; max-width: 1200px; margin: 2rem auto; padding: 20px;
    background-color: #ffffff; border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.leaderboard-container h2 {
    text-align: center; color: #007bff; margin-top: 0;
    border-bottom: 2px solid #f0f0f0; padding-bottom: 10px;
}
.champions-container {
    display: flex; justify-content: space-around; text-align: center;
    margin: 2rem 0; flex-wrap: wrap;
}
.champion-card { flex-basis: 200px; }
.champion-card .rank { font-size: 2.5em; }
.champion-card .name {
    font-size: 1.2em; font-weight: bold; color: #333; display: block;
}
.champion-card small {
    display: block; color: #555;
}
.leaderboard-columns {
    display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; 
}
.leaderboard-column { flex: 1; min-width: 300px; }
.leaderboard-column h3 {
    color: #333; border-bottom: 1px solid #ccc; padding-bottom: 5px;
    font-size: 1.2em; text-align: center; 
}
.leaderboard-list { list-style: none; padding: 0; margin: 0; }
.leaderboard-list li {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px; border-bottom: 1px solid #f0f0f0;
}
.leaderboard-list li:last-child { border-bottom: none; }

/* 🛑🛑 ستايلات المتجر (معدلة) 🛑🛑 */
.store-container {
    display: none; 
    max-width: 900px; margin: 2rem auto; padding: 20px;
    background-color: #fff; border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); border: 2px solid #28a745;
}
/* 🛑 تغيير اسم المتجر 🛑 */
.store-container h2 { text-align: center; color: #28a745; margin-top: 0; }

/* 🛑🛑 التعديل الرئيسي هنا: استخدام Grid 🛑🛑 */
.store-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 1.5rem;
}

.store-item-card {
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: opacity 0.3s ease; /* 🛑 إضافة transition */
}
.store-item-card img {
    width: 100px;
    height: 100px;
    object-fit: contain;
    margin-bottom: 10px;
    border-radius: 4px;
}
.store-item-card h5 {
    margin: 5px 0;
    color: #333;
    font-size: 1.1em;
}

/* 🛑 ستايل المستوى المطلوب للمنتج 🛑 */
.store-item-card p.level-req {
    font-size: 0.9em;
    color: #dc3545; /* أحمر تحذيري */
    font-weight: bold;
    margin: 5px 0 10px 0;
}

.store-item-card p.price {
    font-weight: bold;
    color: #28a745;
    font-size: 1.2em;
    margin-bottom: 10px;
}
.store-item-card button {
    background-color: #007bff;
    color: white;
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    width: 100%;
}
.store-item-card button:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

/* 🛑 ستايل المنتج المقفول (المستوى غير كافٍ) 🛑 */
.store-item-card.locked {
    opacity: 0.6;
    background-color: #e9ecef;
}
.store-item-card.locked img {
    opacity: 0.7;
}

/* 🛑🛑 ستايلات إدارة المتجر للأدمن (المحسّنة) 🛑🛑 */
#admin-store-items-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.admin-item-card {
    background-color: #ffffff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); 
    border-right: 5px solid #007bff; /* شريط جانبي أزرق */
    border-radius: 8px;
    padding: 15px 20px; 
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease; 
    font-size: 1.1em;
}

.admin-item-card:hover {
    background-color: #f0f8ff; /* لون أزرق فاتح جداً عند التحويم */
    transform: translateY(-2px); /* تأثير رفع خفيف */
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.admin-item-info {
    flex-grow: 1;
    text-align: right;
    margin-left: 20px;
}

.admin-item-info strong {
    display: block;
    font-size: 1.4em; 
    color: #333; 
    margin-bottom: 5px;
}

.admin-item-info small {
    display: block;
    color: #6c757d;
    font-size: 1em; 
    line-height: 1.5;
}

/* 🛑 ستايلات خاصة لأزرار الإدارة (لزر التعديل وحذف) */
.admin-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 190px;
}

.edit-item-btn {
    background-color: #ffc107; /* لون التعديل */
    color: #333;
    padding: 10px 15px;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    transition: background-color 0.2s;
    cursor: pointer;
}
.edit-item-btn:hover {
    background-color: #e0a800;
}

.delete-store-item-btn {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 10px 18px; 
    border-radius: 50px; 
    font-weight: bold;
    min-width: 90px;
    transition: background-color 0.2s, transform 0.2s;
}

.delete-store-item-btn:hover {
    background-color: #c82333; /* أحمر أغمق عند التحويم */
    transform: scale(1.05);
}
/* 🛑🛑 نهاية ستايلات إدارة المتجر للأدمن المحسّنة 🛑🛑 */


/* 🛑🛑 ستايلات النافذة المنبثقة (Modal) الجديدة 🛑🛑 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: #fff;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 400px;
    position: relative;
    text-align: right;
}

.modal-content h3 {
    text-align: center;
    color: #007bff;
    margin-top: 0;
    margin-bottom: 20px;
}

.modal-content label {
    display: block;
    margin-top: 10px;
    font-weight: bold;
    font-size: 0.95em;
}

.modal-content input[type="text"],
.modal-content input[type="number"],
.modal-content input[type="file"] {
    width: 100%;
    padding: 10px;
    margin-top: 5px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.modal-content button {
    width: 100%;
    padding: 12px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1em;
}

.close-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 24px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}
.close-btn:hover {
    color: #333;
}

/* 🛑🛑 ستايل قسم الاستيراد (ملغي حالياً) 🛑🛑 */
#admin-import-form {
    display: none; /* تم إلغاء الميزة مؤقتاً */
}


/* 🛑🛑 ستايل قسم طباعة الـ QR (جديد) 🛑🛑 */
#admin-qr-list-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

#admin-fetch-qr-list-btn {
    background-color: #007bff; /* أزرق */
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: bold;
    transition: background-color 0.2s;
}
#admin-fetch-qr-list-btn:hover {
    background-color: #0056b3;
}

/* 🛑 الزر الجديد للتوليد 🛑 */
#admin-generate-print-cards-btn {
    background-color: #28a745; /* أخضر */
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: bold;
    transition: background-color 0.2s;
}
#admin-generate-print-cards-btn:hover {
    background-color: #218838;
}

/* 🛑 الزر الجديد للتحميل كصورة 🛑 */
#admin-download-cards-as-image-btn {
    background-color: #ffc107; /* أصفر */
    color: #212529;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: bold;
    transition: background-color 0.2s;
}
#admin-download-cards-as-image-btn:hover {
    background-color: #e0a800;
}


#admin-qr-list-results {
    width: 100%;
    min-height: 100px; /* تقليل الارتفاع الافتراضي */
    padding: 10px;
    box-sizing: border-box; 
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: monospace; /* لضمان تنسيق الـ JSON */
    direction: ltr; /* JSON دائمًا من اليسار لليمين */
    text-align: left;
    background-color: #fdfdfd;
    display: none; /* 🛑 مخفي افتراضياً، سنستخدمه للتخزين فقط 🛑 */
}


/*

/* 🛑 حاوية كروت الطباعة 🛑 */
#admin-printable-cards-container {
    /* 🛑 التعديل هنا: نحدد العرض ليكون ضعف عرض A4 تقريباً 🛑 */
    width: 794px !important; 
    
    display: grid;
    /* 🛑 التعديل هنا: نحدد 4 أعمدة ثابتة (بدلاً من auto-fit) 🛑 */
    grid-template-columns: repeat(4, 1fr); 
    
    gap: 15px; /* يمكن أن تبقى كما هي */
    margin-top: 20px;
    padding: 10px;
    border: 1px dashed #007bff;
    background: #fff;
    min-height: 0; 
}

.print-card {
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.print-card-name {
    font-weight: bold;
    font-size: 1.1em;
    margin: 0 0 5px 0;
}
.print-card-family {
    font-size: 0.9em;
    color: #555;
    margin: 0 0 10px 0;
}
.print-card-qr {
    width: 120px;
    height: 120px;
    margin: 0 auto;
    padding: 5px;
    background: white;
    border: 1px solid #eee;
}
/* 🛑 ضمان أن الـ QR يملأ الحاوية المخصصة له */
.print-card-qr img,
.print-card-qr canvas {
    width: 100% !important;
    height: 100% !important;
}


/* 🛑🛑 ستايل قسم مسح الـ QR (جديد) 🛑🛑 */
#admin-scan-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#admin-scan-controls select,
#admin-scan-controls button {
    padding: 10px;
    font-size: 1em;
    border-radius: 4px;
    border: 1px solid #ccc;
}
#start-scan-btn {
    background-color: #db2777; /* وردي غامق */
    color: white;
    font-weight: bold;
    border: none;
    cursor: pointer;
}
#reader {
    /* 🛑 التأكد من أن منطقة القارئ لا تنضغط */
    min-height: 250px; 
}


/* 🛑🛑 ستايلات واجهة الزائر (جديدة) 🛑🛑 */
.guest-container {
    max-width: 600px;
    margin: 2rem auto;
    padding: 20px;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-top: 5px solid #007bff;
}
.guest-container h2 {
    text-align: center;
    color: #007bff;
    margin-top: 0;
}
.guest-family-buttons {
    display: flex;
    justify-content: space-around;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}
.guest-family-btn {
    flex: 1;
    padding: 12px 15px;
    font-size: 1em;
    font-weight: bold;
    background-color: #17a2b8;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    min-width: 150px;
    transition: background-color 0.2s;
}
.guest-family-btn:hover {
    background-color: #138496;
}
.guest-results-container {
    margin-top: 1.5rem;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 10px;
    min-height: 100px;
    background-color: #fdfdfd;
}
/* نستخدم نفس تنسيق لوحة الصدارة */
.guest-results-container .leaderboard-list {
    margin: 0;
}
/* 🛑🛑 كلاس جديد لعرض المدن كـ "تاجز" (Tags) 🛑🛑 */
.city-tag {
    background-color: #007bff; /* نفس لون التطبيق الأساسي */
    color: white;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.85em;
    margin: 3px; /* مسافة صغيرة بين التاجز وبعض */
    display: inline-block; /* عشان الـ padding و margin يشتغلوا صح */
}
/* 🛑🛑 ستايلات قائمة المسح الجماعي 🛑🛑 */
#batch-scan-list {
    list-style: none;
    padding: 0;
    margin: 10px 0;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 4px;
}

.batch-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    border-bottom: 1px solid #eee;
    padding: 8px 10px;
    animation: slideIn 0.3s ease-out;
}

.batch-item:last-child {
    border-bottom: none;
}

.batch-item span {
    font-weight: bold;
    font-size: 0.95em;
    color: #333;
}

/* زر الحذف (X) */
.remove-batch-item {
    background-color: #ff4d4d;
    color: white;
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
}

.remove-batch-item:hover {
    background-color: #cc0000;
}

/* زر التنفيذ */
#submit-batch-rewards-btn {
    background-color: #28a745;
    color: white;
    width: 100%;
    padding: 12px;
    font-size: 1.1em;
    font-weight: bold;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

#submit-batch-rewards-btn:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

/* تأثير وميض للزر */
.pulse-button {
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7); }
    70% { transform: scale(1.02); box-shadow: 0 0 0 10px rgba(40, 167, 69, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(40, 167, 69, 0); }
}

/* =========================================
   ⬇️⬇️⬇️ إضافات الهيدر والشريط والمربعات ⬇️⬇️⬇️
   ========================================= */

/* 1. الهيدر الأزرق (Top Banner) */
.top-banner {
    background-color: #003366; /* أزرق كحلي */
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-right: 8px solid #dc3545; /* الشريط الأحمر */
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.banner-right { width: 25%; text-align: right; font-weight: bold; font-size: 1.2em; }
.banner-center { flex-grow: 1; text-align: center; }
.banner-title-ar { font-size: 1.6em; font-weight: bold; margin-bottom: 2px; }
.banner-title-en { font-size: 1.4em; font-weight: bold; letter-spacing: 1px; text-transform: uppercase; }
.banner-left { width: 25%; text-align: left; font-weight: bold; font-size: 1.2em; }

@media (max-width: 768px) {
    .top-banner { flex-direction: column; gap: 5px; padding: 10px; border-right: none; border-top: 5px solid #dc3545; }
    .banner-right, .banner-left { width: 100%; text-align: center; font-size: 1em; }
    .banner-title-ar { font-size: 1.4em; }
}

/* 2. شريط الأخبار المتحرك (News Ticker) */
.news-ticker-bar {
    background-color: #111; /* أسود */
    color: white;
    height: 40px;
    display: flex;
    align-items: center;
    overflow: hidden;
    border-bottom: 3px solid #b30000;
    direction: rtl;
    position: relative;
    margin-bottom: 10px;
}
.ticker-label {
    background-color: #dc3545;
    color: white;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 15px;
    font-weight: bold;
    font-size: 0.9em;
    z-index: 10;
    position: relative;
    box-shadow: -2px 0 5px rgba(0,0,0,0.5);
    white-space: nowrap;
}
.ticker-wrapper {
    flex-grow: 1;
    height: 100%;
    position: relative;
    overflow: hidden;
    background-color: #222;
}
.ticker-content {
    position: absolute;
    top: 50%;
    white-space: nowrap;
    font-weight: bold;
    font-size: 1.1em;
    color: #fff;
    line-height: 0;
    animation: ticker-scroll 20s linear infinite;
}
@keyframes ticker-scroll {
    0% { right: 100%; transform: translate(0, -50%); }
    100% { right: -100%; transform: translate(100%, -50%); }
}
@media (max-width: 768px) {
    .ticker-label { padding: 0 10px; font-size: 0.8em; }
    .ticker-content { font-size: 0.9em; animation-duration: 12s; }
}

/* 3. شبكة الإحصائيات (Stats Grid) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 15px;
    padding: 10px;
    max-height: 450px;
    overflow-y: auto;
}
.stat-box {
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 15px 10px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 110px;
    transition: transform 0.2s;
}
.stat-box:hover { transform: translateY(-3px); border-color: #007bff; }
.stat-box span.label { font-size: 0.95em; color: #555; margin-bottom: 8px; font-weight: bold; }
.stat-box span.count { font-size: 2.2em; font-weight: 900; color: #333; }
.stat-box.highlight { border-bottom: 4px solid #007bff; }
.stat-box.highlight span.count { color: #007bff; }

/* =========================================
   ⬇️⬇️⬇️ تنسيق أبطال الأسر (الميدالية خلف الصورة) ⬇️⬇️⬇️
   ========================================= */

.champions-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-end;
    gap: 20px;
    margin-bottom: 60px;
    padding-top: 30px;
}

.champion-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    width: 160px;
    text-align: center;
    padding-bottom: 10px;
}

/* الصورة (خليناها في الطبقة العليا) */
.champion-card .card-img {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    object-fit: cover;
    border: 5px solid #fff;
    transition: transform 0.3s;
    
    /* 🛑 التعديل هنا: خلينا الصورة فوق الميدالية 🛑 */
    position: relative;
    z-index: 5; /* رقم كبير عشان تبقى فوق */
    background-color: #fff; /* عشان الميدالية متبانش من وراها لو الصورة شفافة */
    
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* 🥇 المركز الأول */
.champion-card:nth-child(1) {
    order: 2;
    transform: translateY(-25px) scale(1.15);
    z-index: 10;
}
.champion-card:nth-child(1) .card-img {
    border-color: #FFD700;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.6);
}

/* 🥈 المركز الثاني */
.champion-card:nth-child(2) { order: 1; }
.champion-card:nth-child(2) .card-img {
    border-color: #C0C0C0;
    box-shadow: 0 0 15px rgba(192, 192, 192, 0.5);
}

/* 🥉 المركز الثالث */
.champion-card:nth-child(3) { order: 3; }
.champion-card:nth-child(3) .card-img {
    border-color: #cd7f32;
    box-shadow: 0 0 15px rgba(205, 127, 50, 0.5);
}

/* 🛑🛑 تنسيق الميدالية (خليناها في الطبقة الخلفية) 🛑🛑 */
.champion-card .rank {
    position: absolute;
    
    /* نزلناها تحت شوية عشان تبرز من ورا الصورة */
    top: 95px; 
    left: 50%;
    transform: translateX(-50%);
    
    font-size: 4em; 
    line-height: 1;
    text-shadow: 0 4px 8px rgba(0,0,0,0.3);
    
    /* 🛑 التعديل هنا: خليناها ورا الصورة 🛑 */
    z-index: 1; /* رقم صغير عشان ترجع ورا */
    
    background: none;
    border: none;
    box-shadow: none;
}

/* الاسم */
.champion-card .name {
    margin-top: 45px; /* مسافة عشان الميدالية اللي نازلة */
    font-weight: bold;
    color: #333;
    font-size: 1.1em;
    white-space: normal;
    line-height: 1.3;
    width: 100%;
}

.champion-card small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-weight: bold;
}

/* الموبايل */
@media (max-width: 600px) {
    .champions-container { flex-direction: grid; align-items: center; gap: 40px; }
    .champion-card:nth-child(1) { order: 1; transform: scale(1.1); margin-bottom: 20px; }
    .champion-card:nth-child(2) { order: 2; }
    .champion-card:nth-child(3) { order: 3; }
}
/* 🛑 تنسيق السجل القابل للطي 🛑 */
.collapsible-container h4 {
    background-color: #f8f9fa;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #ddd;
    margin-bottom: 0;
    user-select: none; /* يمنع تحديد النص عند الضغط */
}

.collapsible-container h4:hover {
    background-color: #e9ecef;
}

/* 🛑🛑 تنسيق شريط التذييل وحقوق النشر (APP FOOTER - FINAL) 🛑🛑 */
.app-footer {
    /* 🛑 تم تعديل الخلفية لتطابق الهيدر 🛑 */
    background-color: #003366; 
    color: #ddd; /* لون النص الفاتح */
    
    padding: 30px 0 40px;
    text-align: center;
    margin-top: 50px;
    border-top: 3px solid #007bff;
    
    width: 100%;
    display: block; 
}

.social-icons-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
}

.social-icon {
    font-size: 2.5em;
    margin: 0 15px;
    color: #ccc; /* لون أساسي فاتح يظهر على الأزرق الغامق */
    transition: color 0.3s, transform 0.2s;
}

/* 🛑 أيقونة الفيسبوك: تتغير للأزرق 🛑 */
.social-icon.facebook:hover {
    color: #3b5998; /* أزرق الفيسبوك */
    transform: translateY(-5px); 
}

/* 🛑 أيقونة الواتساب: تتغير للأخضر 🛑 */
.social-icon.whatsapp:hover {
    color: #25d366; /* أخضر الواتساب */
    transform: translateY(-5px); 
}

.copyright-info {
    font-size: 0.9em;
    color: #bbb; 
    display: block; 
    margin-top: 5px; 
}

/* 🛑🛑 تنسيقات الطباعة الموحدة المصححة (4x2 = 8 كروت في الصفحة) 🛑🛑 */
@media print {
    
    /* 1. استراتيجية الإخفاء والإظهار الموحدة */
    body * {
        display: none !important;
        visibility: hidden !important;
    }

    /* 🛑 التصحيح الأول 🛑: لا نضع display: block! هنا، بل نعتمد على display: grid في الخطوة التالية. */
    #admin-printable-cards-container, 
    #admin-printable-cards-container * {
        visibility: visible !important;
    }

    /* إخفاء أدوات التحكم والرسائل */
    #admin-qr-list-controls,
    #admin-qr-list-message {
        display: none !important;
    }

    /* 🛑 التصحيح الثاني: إجبار تنسيق 4x2 للـ GRID 🛑 */
    #admin-printable-cards-container {
        display: grid !important; /* إجبار استخدام Grid */
        width: 800px !important; /* عرض ثابت لـ 4 كروت */
        grid-template-columns: repeat(4, 1fr) !important; /* 4 أعمدة متساوية */
        gap: 10px !important; 
        padding: 10px !important;
        margin: 0 auto !important;
        position: relative !important;
        page-break-after: avoid !important;
    }

    /* 🛑 التصحيح الثالث: حاوية تقسيم الـ 8 كروت 🛑 */
    .card-page-group {
        display: contents !important; /* مهم جداً للسماح للـ Grid بالعمل */
    }
    
    /* 🛑 التصحيح الرابع: تنسيق الكارت نفسه (مهم جداً للترتيب الداخلي) 🛑 */
    .print-card {
        display: block !important; /* يمكن إبقاءه block ليناسب الـ Grid */
        height: auto !important; 
        border: 1px solid #ccc !important;
        padding: 5px !important;
        margin: 0 !important;
        text-align: center !important;
        page-break-inside: avoid !important; /* لمنع تقطيع الكارت/الـ QR */
        break-inside: avoid !important; 
    }

    /* 🛑 التصحيح الخامس: تنسيق العناصر الداخلية المفقودة (الاسم والعائلة) 🛑 */
    .print-card-name, 
    .print-card-family, 
    .print-card-qr {
        display: block !important; 
        visibility: visible !important;
    }

    /* تنسيق الاسماء */
    .print-card-name {
        font-size: 18px !important; 
        font-weight: bold !important;
        margin-bottom: 3px !important;
        line-height: 1.2 !important;
    }

    /* تنسيق الاسرة */
    .print-card-family {
        font-size: 14px !important;
        color: #555 !important;
        margin-bottom: 5px !important;
        line-height: 1.2 !important;
    }
    
    /* تنسيق حاوية الـ QR وتوسيطه */
    .print-card-qr {
        display: flex !important; 
        justify-content: center !important;
        align-items: center !important;
        min-height: 250px !important;
        width: auto !important; /* إلغاء التحديدات القاسية */
        height: auto !important;
    }

    /* إجبار توسيط الـ QR Code نفسه */
    .print-card-qr table {
        margin: 0 auto !important; 
        border-collapse: collapse !important; 
    }
    
    /* 🛑 قواعد إضافية لضمان التوافق مع PDF 🛑 */
    .print-card * {
        font-family: sans-serif !important;
        color: #000 !important;
        direction: rtl !important;
        unicode-bidi: embed !important;
        text-shadow: none !important;
    }
}
