/* ==========================================================================
   1. الهيكل العام والخلفية (Layout & Base)
   ========================================================================== */
#content {
    background-repeat: no-repeat !important;
    background-size: 100% 100% !important;
    position: relative;
    min-height: 100vh;
    transition: all 0.3s ease;
}

/* تقليص عرض الشات وضمان الإخفاء الكامل عبر السايد بار */
#sidebar {
    min-width: 320px !important;
    max-width: 320px !important;
    background: #1e1b2e !important;
    box-sizing: border-box !important;
    transition: all 0.3s ease !important;
}

/* إخفاء السايد بار بالكامل جهة اليسار دون ترك أي حواف */
#sidebar.active {
    margin-left: -320px !important;
}

/* ==========================================================================
   2. مشغل الفيديو والإعلانات (Player & Video UI)
   ========================================================================== */
.my_video_class {
    width: 90%;
    margin-left: 5% !important;
    margin-top: 60px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.plyr, #my_video_1 {
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    aspect-ratio: 16 / 9 !important;
    object-fit: cover;
}

#ad-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99;
    display: none;
    border-radius: 8px;
    overflow: hidden;
}

:root {
    --plyr-color-main: #f5692c;
}

button:focus, video:focus {
    outline: none;
    box-shadow: none;
}

/* ==========================================================================
   3. نظام المحادثة والشات (Chat System UI)
   ========================================================================== */
/* صندوق تحديث الاسم العلوي */
.username-update-container {
    padding: 15px 15px 5px 15px !important;
    background: #1e1b2e !important;
}

.modern-username-group {
    display: flex !important;
    align-items: center !important;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 25px !important;
    padding: 2px 4px 2px 15px !important;
    width: 100% !important;
    transition: border-color 0.2s ease;
}

.modern-username-group:focus-within {
    border-color: #f5692c !important;
}

#username {
    flex: 1 !important;
    background: transparent !important;
    border: none !important;
    color: #ffffff !important;
    font-size: 13px !important;
    padding: 6px 5px !important;
    outline: none !important;
    box-shadow: none !important;
    height: auto !important;
}

#username::placeholder {
    color: rgba(255, 255, 255, 0.3) !important;
}

#update-username {
    background: #f5692c !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 20px !important;
    padding: 6px 14px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: background 0.2s ease !important;
}

#update-username:hover {
    background: #e0591f !important;
}

/* صندوق المحادثات الرئيسي والقائمة */
.chat {
    list-style: none;
    padding: 15px !important;
    margin: 0;
    height: calc(100vh - 165px) !important;
    overflow-y: auto;
    box-sizing: border-box !important;
}

.chat li.chatfiled {
    margin-bottom: 12px !important;
    padding: 12px 14px !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border-left: 3px solid #f5692c;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.chat li .primary-font {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #f5692c !important;
    display: block;
    margin-bottom: 5px;
}

.chat li .chat-body p {
    margin: 0 !important;
    color: #ffffff !important;
    font-size: 14px !important;
    line-height: 1.5;
    word-break: break-word;
}

.chat-time {
    display: block;
    font-size: 10px;
    color: #a0a0a0;
    text-align: right;
    margin-top: 5px;
}

/* شريط التمرير (Scrollbar) الخاص بالشات */
.chat::-webkit-scrollbar {
    width: 5px !important;
}
.chat::-webkit-scrollbar-track {
    background: transparent !important;
}
.chat::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.15) !important;
    border-radius: 10px !important;
}

/* حاوية الإرسال السفلي */
.chat-input-footer {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    padding: 12px 15px !important;
    background: #181625 !important;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 999 !important;
    box-sizing: border-box !important;
}

.modern-chat-container {
    display: flex !important;
    align-items: center !important;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 30px !important;
    padding: 4px 6px 4px 15px !important;
    width: 100% !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box !important;
}

.modern-chat-container:focus-within {
    border-color: #f5692c !important;
    box-shadow: 0 0 8px rgba(245, 105, 44, 0.2);
}

#message {
    flex: 1 !important;
    background: transparent !important;
    border: none !important;
    color: #ffffff !important;
    font-size: 14px !important;
    padding: 8px 5px !important;
    height: auto !important;
    max-height: 100px !important;
    outline: none !important;
    box-shadow: none !important;
}

#message::placeholder {
    color: rgba(255, 255, 255, 0.4) !important;
}

.input-actions {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

#emoji-trigger {
    background: transparent !important;
    border: none !important;
    color: #a0a0a0 !important;
    font-size: 20px !important;
    cursor: pointer !important;
    padding: 4px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: color 0.2s ease, transform 0.2s ease !important;
}

#emoji-trigger:hover {
    color: #f5692c !important;
    transform: scale(1.1);
}

#btn-chat {
    width: 38px !important;
    height: 38px !important;
    background: #f5692c !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: background 0.2s ease, transform 0.1s ease !important;
    box-shadow: 0 2px 6px rgba(245, 105, 44, 0.3) !important;
}

#btn-chat:hover {
    background: #e0591f !important;
    transform: scale(1.04);
}

#btn-chat i {
    font-size: 15px !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* ==========================================================================
   4. تخصيص نافذة الإيموجي (Picmo Picker Custom Styles)
   ========================================================================== */
.picmo__picker {
    background-color: #1e1b2e !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6) !important;
    width: 265px !important;
    max-width: 265px !important;
    height: 250px !important;
    grid-template-rows: 38px 1fr !important;
    font-family: inherit !important;
    overflow-x: hidden !important;
}

.picmo__categoryTab {
    color: #ffffff !important;
    opacity: 0.75 !important;
    transition: opacity 0.2s ease, color 0.2s ease;
    padding: 4px !important;
}

.picmo__categoryTab:hover, .picmo__categoryTabActive {
    color: #f5692c !important;
    opacity: 1 !important;
}

.picmo__categoryTabs {
    background-color: #141220 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    padding: 2px 4px !important;
}

.picmo__searchContainer, .picmo__previewContainer {
    display: none !important;
}

.picmo__emojiArea {
    padding: 8px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    max-height: 210px !important;
}

.picmo__emojiGrid {
    grid-template-columns: repeat(6, 1fr) !important;
    gap: 4px !important;
    width: 100% !important;
}

.picmo__emoji {
    font-size: 16px !important;
    width: 30px !important;
    height: 30px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: transform 0.1s ease;
}

.picmo__emoji:hover {
    background-color: rgba(255, 255, 255, 0.08) !important;
    transform: scale(1.18);
    border-radius: 6px;
}

.picmo__emojiArea::-webkit-scrollbar {
    width: 4px !important;
}

.picmo__emojiArea::-webkit-scrollbar-track {
    background: transparent !important;
}

.picmo__emojiArea::-webkit-scrollbar-thumb {
    background-color: rgba(245, 105, 44, 0.3) !important;
    border-radius: 4px !important;
}

/* ==========================================================================
   5. أزرار التحكم والعدادات العلوية (Modern Pill Badges)
   ========================================================================== */
.on-air {
    position: absolute;
    z-index: 10;
    margin: 20px 0 0 20px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

.bt {
    background: rgba(30, 27, 46, 0.7) !important;
    backdrop-filter: blur(8px) !important;
    color: #ffffff !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    margin: 0 !important;
    padding: 6px 14px !important;
    border-radius: 30px !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    transition: all 0.2s ease !important;
    height: 32px !important;
}

.bt.custom-menu {
    cursor: pointer !important;
    border: 1px solid rgba(245, 105, 44, 0.2) !important;
}

.bt.custom-menu:hover {
    background: #f5692c !important;
    border-color: #f5692c !important;
    box-shadow: 0 4px 12px rgba(245, 105, 44, 0.35) !important;
}

.bt.custom-menu button {
    background: none !important;
    border: none !important;
    color: inherit !important;
    font-size: inherit !important;
    font-weight: inherit !important;
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
}

.bt-live-status {
    border-left: 3px solid #f5692c !important;
}

.bt-live-status i {
    color: #f5692c !important;
}

.bt-viewers i {
    color: #a0a0a0;
}

/* ==========================================================================
   6. التذييل والتجاوب مع الشاشات (Footer & Responsive)
   ========================================================================== */
.footer-wrapper {
    text-align: center;
    background: #43405d;
    color: white;
    position: absolute;
    width: 100%;
    bottom: 0;
    padding: 7px 0 !important;
    z-index: 5;
}

@media only screen and (max-width: 768px) {
    #sidebar {
        min-width: 100% !important;
        max-width: 100% !important;
        position: fixed !important;
        height: 100% !important;
        height: -webkit-fill-available !important; /* iOS full screen height fix */
        z-index: 999999 !important;
        left: 0 !important;
        top: 0 !important;
        margin-left: -100% !important;
        transition: margin-left 0.3s ease-in-out !important;
        display: flex !important;
        flex-direction: column !important;
        background: #1e1b2e !important;
    }
    #sidebar.active {
        margin-left: 0 !important;
    }
    #sidebar .sidebar-header {
        height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
    }
    /* Make the chat lists scrollable on iOS devices */
    .chat {
        flex: 1 !important;
        height: auto !important;
        max-height: calc(100% - 150px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important; /* smooth iOS momentum scrolling */
        padding-bottom: 20px !important;
    }
    /* Sticky footer inputs always above keyboard and safe margins */
    .chat-input-footer {
        position: relative !important;
        width: 100% !important;
        margin-top: auto !important;
        padding: 10px 15px 25px 15px !important; /* bottom padding space for iOS home indicator */
        background: #181625 !important;
        border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
        z-index: 1000000 !important;
    }
    .wrapper {
        position: relative !important;
        overflow-x: hidden !important;
    }
    .my_video_class {
        width: 96% !important;
        margin-left: 2% !important;
        margin-top: 50px !important;
        height: auto !important;
    }
    .on-air {
        left: 10px !important;
        top: 10px !important;
        z-index: 9999 !important;
    }
    .username-update-container {
        padding: 10px !important;
    }
    #emoji-trigger {
        display: none !important;
    }
    /* Prevents emoji picker from going off-screen on small viewports */
    .picmo__popupPicker {
        max-width: 90vw !important;
        z-index: 9999999 !important; /* higher than sidebar */
    }
}
