/* ===== Profile Editor Glassmorphism - متجاوب بشكل احترافي ===== */

/* ===== الحالة الافتراضية (Desktop First) ===== */
#profileEditor {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);              /* خلفية داكنة شفافة */
    backdrop-filter: blur(15px);                  /* تأثير الزجاج */
    -webkit-backdrop-filter: blur(15px);
    z-index: 2147483647;
    display: none;                                /* مخفي افتراضيًا */
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;                             /* تمرير المحتوى الطويل */
}

/* الحاوية الداخلية (الكارت الزجاجي) */
#profileEditor > div {
    width: 100%;
    max-width: 550px;                              /* عرض مناسب للديسكتوب */
    background: rgba(10, 10, 10, 0.65);            /* خلفية زجاجية داكنة */
    border: 1px solid rgba(139, 0, 0, 0.7);        /* إطار أحمر شفاف */
    border-radius: 30px;
    padding: 35px;
    text-align: justify;
    box-shadow: 0 25px 70px rgba(237, 10, 10, 0.7), 0 0 40px rgba(139, 0, 0, 0.5);
    animation: modalSlideIn 0.4s ease-out;
    margin: auto;
    position: relative;
    backdrop-filter: blur(5px);                    /* طبقة زجاج إضافية */
    -webkit-backdrop-filter: blur(5px);
    color: #fff;
}

/* الحالة النشطة */
#profileEditor.active,
#profileEditor.is-active {
    display: flex !important;
}

/* ===== تحسينات للتابلت (بين 769px و 992px) ===== */
@media (min-width: 769px) and (max-width: 992px) {
    #profileEditor > div {
        max-width: 500px;
        padding: 30px;
    }
}

/* ===== تحسينات للموبايل (768px وأقل) ===== */
@media (max-width: 768px) {
    #profileEditor {
        padding: 10px;
        background: rgba(0, 0, 0, 0.85);           /* أعمق للموبايل */
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }

    #profileEditor > div {
        max-width: 100%;                            /* يأخذ كامل العرض */
        width: 100%;
        border-radius: 25px;
        padding: 25px 18px;
        box-shadow: 0 15px 50px rgba(0,0,0,0.9), 0 0 30px rgba(139,0,0,0.6);
        max-height: 90vh;
        overflow-y: auto;
        border-width: 1.5px;
    }

    /* زر الإغلاق (على اليسار) */
    #profileEditor button[type="button"][onclick*="hideProfileEditor"] {
        position: absolute;
        top: 12px;
        left: 12px;
        width: 40px;
        height: 40px;
        background: rgba(255,255,255,0.08);
        border: 1px solid rgba(139,0,0,0.4);
        color: #FFD700;
        border-radius: 50%;
        cursor: pointer;
        font-size: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s ease;
        z-index: 100;
        backdrop-filter: blur(5px);
    }

    #profileEditor button[type="button"][onclick*="hideProfileEditor"]:hover {
        background: rgba(139,0,0,0.3);
        border-color: #FFD700;
        transform: scale(1.1);
    }

    /* تبويبات المودال (Tabs) */
    #profileEditor > div > div:first-of-type {
        display: flex;
        gap: 8px;
        margin: 0;
        border-bottom: 1px solid rgba(139, 0, 0, 0.3);
        overflow-x: auto;
        padding-bottom: 12px;
        scrollbar-width: thin;
        scrollbar-color: #8B0000 #222;
    }

    #profileEditor > div > div:first-of-type::-webkit-scrollbar {
        height: 4px;
    }

    #profileEditor > div > div:first-of-type::-webkit-scrollbar-thumb {
        background: #8B0000;
        border-radius: 4px;
    }

    #profileEditor > div > div:first-of-type button {
        flex: 1 0 auto;
        padding: 10px 15px;
        background: transparent;
        border: none;
        color: #ccc;
        font-weight: 600;
        cursor: pointer;
        font-family: 'Cairo', sans-serif;
        border-bottom: 3px solid transparent;
        transition: 0.3s;
        white-space: nowrap;
        font-size: 14px;
        min-width: 70px;
    }

    #profileEditor > div > div:first-of-type button:first-child {
        color: #FFD700;
        border-bottom-color: #FFD700;
    }

    #profileEditor > div > div:first-of-type button:hover {
        color: #FFD700;
        border-bottom-color: rgba(255,215,0,0.5);
    }

    /* محتوى التبويبات */
    #profileEditor > div > div:not(:first-of-type) {
        max-height: calc(120vh - 350px);
        overflow-y: auto;
        padding-right: 10px;
    }

    /* حقول الإدخال */
    #profileEditor input,
    #profileEditor select,
    #profileEditor textarea {
        width: 100%;
        padding: 14px 16px;
        background: rgba(20, 20, 20, 0.7);
        border: 1px solid #8B0000;
        color: #fff;
        border-radius: 16px;
        font-family: 'Cairo', sans-serif;
        font-size: 16px;
        margin-bottom: 15px;
        transition: 0.3s;
        box-sizing: border-box;
        backdrop-filter: blur(4px);
    }

    #profileEditor input:focus,
    #profileEditor select:focus,
    #profileEditor textarea:focus {
        border-color: #FFD700;
        box-shadow: 0 0 15px rgba(255,215,0,0.2);
        outline: none;
        background: rgba(30, 30, 30, 0.9);
    }

    /* أزرار الإجراءات (حفظ / إلغاء) */
    #profileEditor button[type="submit"],
    #profileEditor button[type="button"]:not([onclick*="hideProfileEditor"]) {
   width: 100%;
        padding: 14px;
        background: linear-gradient(145deg, #ff050500, #ff121278);
        color: #ffffff;
        border: 1px solid rgb(255 0 0 / 79%);
        border-radius: 16px;
        font-weight: bold;
        cursor: pointer;
        font-family: 'Cairo', sans-serif;
        transition: all 0.3s ease;
        box-shadow: -20px 6px 20px rgb(139 0 0 / 57%);
        margin-bottom: 10px;
        font-size: 16px;
        letter-spacing: 0.5px;
        backdrop-filter: blur(2px);
    }

    #profileEditor button[type="submit"]:hover,
    #profileEditor button[type="button"]:not([onclick*="hideProfileEditor"]):hover {
        background: linear-gradient(145deg, #a00000, #5a0000);
        transform: translateY(-3px);
        box-shadow: 0 12px 28px rgba(139,0,0,0.7);
        border-color: #FFD700;
    }

    /* حاوية الصورة الرمزية */
    #profileEditor #avatarContainer {
        width: 100px;
        height: 100px;
        margin: 0 auto 20px;
        border-radius: 50%;
        overflow: hidden;
        border: 3px solid #8B0000;
        box-shadow: 0 0 30px rgba(139,0,0,0.6);
        background: linear-gradient(145deg, #8B0000, #2a0000);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #profileEditor #avatarPreview {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

    /* تسميات الحقول */
    #profileEditor label {
        color: #FFD700;
        font-size: 13px;
        display: block;
        margin-bottom: 6px;
        font-weight: 600;
        letter-spacing: 0.3px;
    }

    /* العناوين */
    #profileEditor h3 {
        color: #fff;
        margin: 10px 0 20px;
        text-align: center;
        font-size: 22px;
        text-shadow: 0 2px 10px rgba(139,0,0,0.5);
    }

    /* شريط التمرير داخل المودال */
    #profileEditor > div::-webkit-scrollbar {
        width: 6px;
    }
    #profileEditor > div::-webkit-scrollbar-track {
        background: rgba(255,255,255,0.05);
        border-radius: 10px;
    }
    #profileEditor > div::-webkit-scrollbar-thumb {
        background: #8B0000;
        border-radius: 10px;
    }

    /* تحسين iOS */
    @supports (-webkit-touch-callout: none) {
        #profileEditor {
            -webkit-overflow-scrolling: touch;
        }
    }
}

/* ===== تحسين الهواتف الصغيرة (480px وأقل) ===== */
@media (max-width: 480px) {
    #profileEditor {
        padding: 8px;
    }

    #profileEditor > div {
        padding: 20px 15px;
        border-radius: 22px;
        max-height: 95vh;
    }

    #profileEditor > div > div:first-of-type {
        margin-top: 1px;
        gap: 5px;
    }

    #profileEditor > div > div:first-of-type button {
        padding: 8px 12px;
        font-size: 12px;
        min-width: 60px;
    }

    #profileEditor input,
    #profileEditor select,
    #profileEditor textarea {
        padding: 12px;
        font-size: 15px;
        margin-bottom: 12px;
        border-radius: 14px;
    }

    #profileEditor button[type="submit"],
    #profileEditor button[type="button"]:not([onclick*="hideProfileEditor"]) {
        padding: 12px;
        font-size: 15px;
        border-radius: 14px;
    }

    #profileEditor #avatarContainer {
        width: 85px;
        height: 85px;
        margin: 0 auto 18px;
    }

    #profileEditor h3 {
        font-size: 20px;
        margin-bottom: 15px;
    }

    #profileEditor label {
        font-size: 12px;
    }
}

/* ===== الرسوم المتحركة ===== */
@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===== منع التمرير خلف المودال ===== */
body.prevent-scroll {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
}

/* ===== توافقية مع m-mobile-modal (إن وجد) ===== */
.m-mobile-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    padding: 20px;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.m-mobile-modal.is-active {
    display: flex;
    opacity: 1;
}

.m-modal-content {
    width: 100%;
    max-width: 520px;
    transform: translateY(30px);
    transition: transform 0.4s ease;
}

.m-mobile-modal.is-active .m-modal-content {
    transform: translateY(0);
}

/* إذا استخدم profileEditor مع class m-mobile-modal */
@media (max-width: 768px) {
    #profileEditor.m-mobile-modal {
        padding: 15px;
        background: rgba(0, 0, 0, 0.9);
    }

    #profileEditor.m-mobile-modal > div {
        width: 100%;
        max-width: 100%;
        border-radius: 25px;
        padding: 25px 18px;
        max-height: 90vh;
        overflow-y: auto;
    }

    #profileEditor.m-mobile-modal.is-active {
        display: flex;
        opacity: 1;
    }

    #profileEditor.m-mobile-modal .m-modal-content {
        width: 100%;
        max-width: 100%;
    }
}