/* --- الجزء المحدث للقائمة الجانبية (Sidebar) --- */
.sidebar {
    position: fixed; 
    top: 0; 
    left: -110%; 
    width: 300px; 
    height: 100%; 
    background: var(--card-dark); /* اللون الافتراضي للوضع الداكن */
    color: var(--text-dark);
    box-shadow: none; 
    z-index: 1000; 
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 25px; 
    overflow-y: auto;
    text-align: right;
    visibility: hidden; 
    box-sizing: border-box;
}

/* إصلاح لون الخلفية والنصوص في الوضع الفاتح */
body.light-mode .sidebar {
    background: var(--card-light) !important;
    color: var(--text-light) !important;
    border-right: 1px solid rgba(0,0,0,0.1);
}

/* ضمان ظهور نصوص العناوين داخل السايد بار باللون الصحيح */
body.light-mode .sidebar h3, 
body.light-mode .sidebar h4, 
body.light-mode .sidebar label {
    color: var(--text-light) !important;
}

.sidebar.active { 
    left: 0; 
    visibility: visible;
    box-shadow: 10px 0 30px rgba(0,0,0,0.5); 
}

body.light-mode .sidebar.active { 
    box-shadow: 10px 0 30px rgba(0,0,0,0.1); 
}

/* --- تنسيق إدارة الجوائز (إضافة وحذف) --- */
.setting-item { 
    margin-bottom: 25px; 
    width: 100%; 
}

.group-btns {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%; 
}

#new-prize-input {
    flex: 1; /* تعديل لضمان المحاذاة وعدم الخروج عن الشاشة */
    min-width: 0; 
    border: 1px solid var(--gray);
    outline: none;
    transition: 0.3s;
    font-family: inherit;
    background: rgba(128,128,128,0.1);
    color: inherit;
    padding: 10px;
    border-radius: 8px;
}

#new-prize-input:focus {
    border-color: var(--primary-orange);
    background: rgba(255, 107, 0, 0.05);
}

/* تعديل لون علامة الزائد (+) وتناسق الزر */
.mini-btn.btn-add {
    background-color: var(--primary-orange) !important;
    color: #FFFFFF !important; /* اللون الأبيض الصريح للعلامة */
    border: none;
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
}

/* تحسين شكل أزرار الأيقونات داخل السايد بار */
.setting-item .group-btns .mini-btn {
    padding: 10px;
    font-size: 1.1rem;
}

/* إصلاح خلفية قائمة الجوائز للوضع الداكن والفاتح */
.prize-dropdown {
    width: 100%;
    margin-top: 10px;
}

.prize-dropdown option {
    background-color: var(--card-dark); 
    color: var(--text-dark);
}

body.light-mode .prize-dropdown option {
    background-color: var(--card-light);
    color: var(--text-light);
}

/* --- الجذور والمتغيرات --- */
:root {
    --primary-orange: #FF6B00;
    --bg-dark: #121212; 
    --card-dark: #1E1E1E; 
    --text-dark: #E0E0E0;
    --bg-light: #F4F4F4; 
    --card-light: #FFFFFF; 
    --text-light: #1A1A1A;
    --gray: #444;
    --accent-green: #2ecc71;
    --disabled-gray: #555555;
}
/* التحكم في إظهار وإخفاء الشاشات */
#login-screen, #app-screen { display: none; }
.visible { display: block !important; }

body { 
    margin: 0; 
    font-family: 'Segoe UI', Tahoma, sans-serif; 
    transition: 0.3s; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    min-height: 100vh; 
    box-sizing: border-box;
}

body.dark-mode { background-color: var(--bg-dark); color: var(--text-dark); }
body.light-mode { background-color: var(--bg-light); color: var(--text-light); }

/* --- شريط التحكم والبحث --- */
.mode-lang-ctrl { 
    width: 100%;
    padding: 15px 20px;
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    box-sizing: border-box;
    position: sticky;
    top: 0;
    z-index: 100;
}

.mini-btn { 
    background: rgba(128,128,128,0.2); 
    border: 1px solid #555; 
    color: inherit; 
    padding: 10px 15px; 
    font-size: 14px; 
    border-radius: 8px; 
    cursor: pointer; 
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

/* --- هيدر القائمة الجانبية المطور لمنع تداخل النص مع الزر --- */
.sidebar-header { 
    display: flex; 
    align-items: center; 
    border-bottom: 1px solid rgba(128,128,128,0.2);
    margin-bottom: 25px; 
    padding-bottom: 15px;
    position: relative; 
    min-height: 50px;
    box-sizing: border-box;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.1rem;
    width: 100%;
    /* زيادة الحماية من الجهتين لضمان عدم ملامسة النص للزر في أي لغة */
    padding-left: 60px;  /* مساحة كافية للزر جهة اليسار */
    padding-right: 60px; /* توازن بصري لمنع النص من الالتصاق بالحافة اليمنى */
    text-align: center;
    box-sizing: border-box;
    line-height: 1.2;
    word-wrap: break-word; /* لضمان كسر الكلمات الطويلة جداً إذا لزم الأمر */
}

/* تنسيق زر الإغلاق المطور مع إطار */
.sidebar-header .mini-btn {
    position: absolute !important;
    left: 15px; /* مسافة بسيطة من الحافة اليسرى */
    top: 50%;
    transform: translateY(-50%);
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    
    /* إضافة الإطار والخلفية ليشبه زر الحذف */
    background: rgba(255, 77, 77, 0.05) !important; 
    border: 1px solid #ff4d4d !important; 
    color: #ff4d4d !important;
    
    border-radius: 8px; /* حواف دائرية متناسقة */
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

/* تأثير عند مرور الماوس على زر الإغلاق */
.sidebar-header .mini-btn:hover {
    background: #ff4d4d !important;
    color: white !important;
    box-shadow: 0 0 10px rgba(255, 77, 77, 0.3);
}

.setting-item label { display: block; margin-bottom: 10px; font-weight: bold; font-size: 0.95rem; }

/* تحسين شريط تمرير حجم الشعار */
input[type="range"] {
    width: 100%;
    cursor: pointer;
}

.prize-dropdown {
    background-color: rgba(128,128,128,0.1);
    color: inherit;
    border: 1px solid var(--gray);
    padding: 12px;
    border-radius: 8px;
    font-size: 1rem;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='grey' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 10px center;
}

/* --- شعار التطبيق والعناصر الرئيسية --- */
.logo-box-top { margin: 20px 0; display: flex; justify-content: center; }
#logo-img { max-width: 100%; height: auto; transition: width 0.3s ease; cursor: pointer; }

.app-icon-wrapper svg {
    width: 60px !important;
    height: 60px !important;
    margin-bottom: 10px;
    color: var(--primary-orange);
}

/* تنسيق الأيقونة والخط الفاصل العلوي */
.app-header-inside {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 1px solid rgba(128, 128, 128, 0.2); /* هذا هو الخط الفاصل */
    padding-bottom: 15px;
}

.container { 
    padding: 2rem; 
    border-radius: 20px; 
    width: 90%; 
    max-width: 650px; /* تم تصغيره من 750 إلى 650 ليطابق QR */
    text-align: center; 
    position: relative; 
    transition: 0.3s; 
    margin-bottom: 40px; 
}

body.dark-mode .container { background: var(--card-dark); box-shadow: 0 10px 40px rgba(0,0,0,0.6); }
body.light-mode .container { background: var(--card-light); box-shadow: 0 10px 40px rgba(0,0,0,0.1); }

.stats-bar {
    margin-bottom: 20px;
    margin-top: 20px;
    font-weight: 500;
}

.main-draw-btn {
    background: var(--primary-orange); color: white; border: none;
    padding: 22px; font-size: 1.5rem; font-weight: bold;
    border-radius: 18px; cursor: pointer; width: 100%;
    box-shadow: 0 8px 20px rgba(255, 107, 0, 0.3); transition: 0.4s;
    margin-top: 10px;
}

/* --- سجل الفائزين وتنسيق الأزرار --- */
.winners-history {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.winners-history ul {
    width: 100%;
    padding: 0;
    list-style: none;
}

.reset-btn {
    margin: 20px auto 0 auto; 
    display: block;
    min-width: 150px;
}

#main-title { font-size: 2.5rem; margin: 0; color: var(--primary-orange); font-weight: bold; }
.secondary-title { font-size: 1.1rem; opacity: 0.8; margin: 10px 0; line-height: 1.6; }

.prize-tag-line {
    background: rgba(255, 107, 0, 0.1);
    padding: 10px 30px; border-radius: 50px;
    display: inline-block; margin-top: 15px;
    border: 1px solid var(--primary-orange);
    color: var(--primary-orange); font-weight: bold;
}

.upload-box {
    margin: 25px 0; padding: 30px;
    border: 2px dashed var(--gray); border-radius: 20px;
}

.custom-file-upload {
    display: inline-block; padding: 14px 35px;
    cursor: pointer; background: var(--primary-orange);
    color: white; border-radius: 12px; font-weight: bold; transition: 0.3s;
}

.tabs-mini { display: flex; gap: 5px; margin-bottom: 20px; background: rgba(0,0,0,0.1); padding: 5px; border-radius: 10px; }
.tabs-mini button { flex: 1; padding: 10px; border: none; cursor: pointer; border-radius: 7px; color: inherit; background: transparent; transition: 0.3s; }
.tabs-mini button.active { background: var(--primary-orange); color: white; }

.color-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.color-row input[type="color"] { border: none; width: 40px; height: 40px; cursor: pointer; background: none; }

/* --- الجزء المعدل للفوتر لإزالة الخط واللون الأزرق --- */
.main-footer { padding: 40px 0; text-align: center; }

#footer-text { 
    text-decoration: none !important; 
    color: inherit !important; 
    opacity: 0.7; 
    transition: 0.3s;
    font-size: 0.9rem;
}

#footer-text:hover {
    opacity: 1;
    color: var(--primary-orange) !important;
}

@media (max-width: 600px) {
    #main-title { font-size: 1.8rem; }
    .container { padding: 1.5rem; }
    .sidebar { width: 85%; }
}
/* --- تنسيق إطار إعلان الفائز النهائي --- */
.winner-card {
    background: rgba(255, 107, 0, 0.08); /* خلفية برتقالية شفافة جداً */
    border: 3px solid var(--primary-orange);
    border-radius: 20px;
    padding: 30px;
    margin-top: 25px;
    animation: fadeInScale 0.6s ease-out;
    box-shadow: 0 10px 30px rgba(255, 107, 0, 0.15);
}

#winner-name {
    font-size: 4rem; /* حجم كبير جداً للاسم */
    font-weight: 900;
    color: var(--primary-orange);
    margin: 15px 0;
    text-shadow: 2px 2px 10px rgba(0,0,0,0.1);
}

@keyframes fadeInScale {
    0% { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.history-container {
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
    margin: 15px 0;
}

/* --- التنسيق النهائي والمضمون لسجل الفائزين --- */
.history-container {
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
    margin: 20px 0;
    padding: 5px;
    /* إخفاء شريط التمرير القبيح في المتصفحات */
    scrollbar-width: thin;
    scrollbar-color: var(--primary-orange) transparent;
}

#winners-list {
    width: 100%;
    padding: 0;
    margin: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(128, 128, 128, 0.1);
    border-radius: 12px;
    border-right: 5px solid var(--primary-orange);
    transition: transform 0.2s;
}

/* لتمييز الفائز الأخير في السجل */
.history-item:first-child {
    background: rgba(255, 107, 0, 0.1);
    border-right-width: 8px;
}

.winner-name { 
    font-weight: bold; 
    font-size: 1.1rem;
    color: inherit;
}

.winner-prize { 
    color: var(--primary-orange); 
    font-weight: 600;
    font-size: 1rem;
}

/* ستايل شاشة تسجيل الدخول الموحد */
#login-screen {
    text-align: center;
}

#login-screen h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    font-weight: normal;
    color: inherit;
}

/* المدخلات بأسلوب كيو آر كود */
#passInput {
    width: 100%; 
    padding: 10px; 
    margin: 8px 0; 
    border: 1px solid #555; 
    border-radius: 6px;
    background: rgba(255,255,255,0.05); 
    color: inherit; 
    box-sizing: border-box; 
    font-size: 14px;
    text-align: center;
}

/* زر الدخول البرتقالي بأسلوب كيو آر كود */
#btn-login-action {
    background: var(--primary-orange); 
    color: white; 
    border: none; 
    padding: 13px; 
    border-radius: 8px; 
    cursor: pointer; 
    width: 100%; 
    max-width: none !important; /* غيرها من 320px إلى none ليمتد الزر */
    font-weight: bold; 
    margin-top: 15px; 
    transition: 0.3s;
}

/* الكود الذي وضعته أنت الآن لضمان العرض الكامل */
#btn-login-action {
    width: 100% !important;
    max-width: none !important;
}

/* أعد إضافة هذا السطر تحته مباشرة للحفاظ على تأثير التفاعل */
#btn-login-action:hover {
    filter: brightness(1.2);
}


div#result-section {
    margin-top: 20px;
}