/* --- المتغيرات الأساسية للألوان --- */
:root {
    --color-dark-blue: #0a192f;  /* لون كحلي غامق (بديل للأسود) */
    --color-gold: #d4af37;        /* درجة لون ذهبي فخم */
    --color-light-gray: #f8f9fa;  /* أبيض مائل للرمادي */
    --color-text: #adb5bd;        /* لون النص العادي */

    /* تحديد ألوان Bootstrap الأساسية بألواننا */
    --bs-body-bg: var(--color-dark-blue);
    --bs-body-color: var(--color-text);
}

/* --- خط عربي احترافي --- */
body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
}

/* --- تعديل شريط التنقل --- */
.navbar {
    background-color: var(--color-dark-blue) !important;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
}

.navbar-brand img {
    max-height: 40px;
}

.nav-link {
    color: var(--color-light-gray) !important;
    font-weight: 500;
}
.nav-link:hover, .nav-link.active {
    color: var(--color-gold) !important;
}

/* زر تبديل اللغة */
.lang-switcher a {
    color: var(--color-gold);
    text-decoration: none;
    font-weight: bold;
    font-size: 0.9rem;
}

/* --- قسم الـ Hero (الرئيسي) --- */
.hero-section {
    padding: 100px 0;
    min-height: 80vh;
    display: flex;
    align-items: center;
    background: linear-gradient(180deg, var(--color-dark-blue) 70%, rgba(10, 25, 47, 0.8) 100%);
    position: relative;
    overflow: hidden;
}

.hero-section h1 {
    font-size: 3.5rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 1rem;
}
/* لتأثير الكتابة الآلية */
.hero-section .typed-text {
    color: var(--color-gold);
    border-bottom: 3px solid var(--color-gold);
}

.hero-section .lead {
    font-size: 1.25rem;
    color: var(--color-light-gray);
    margin-bottom: 2rem;
}

/* --- زر الـ Call to Action (الاحترافي) --- */
.btn-cta {
    background-color: var(--color-gold);
    color: #000;
    border: none;
    padding: 12px 30px;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.2);
}

.btn-cta:hover {
    background-color: #fff;
    color: #000;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
}

/* صورة مرئية بجانب النص */
.hero-visual {
    text-align: center;
    position: relative;
}
.hero-visual img {
    max-width: 100%;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    /* تأثير بسيط لجذب الانتباه */
    animation: float 6s ease-in-out infinite;
}

/* أنيميشن بسيط */
@keyframes float {
	0% { transform: translateY(0px); }
	50% { transform: translateY(-10px); }
	100% { transform: translateY(0px); }
}

/* --- قسم العدادات --- */
.counters-section {
    background-color: #0a1422; /* أغمق درجة بسيطة */
    padding: 80px 0;
    color: #fff;
}
.counter-box {
    text-align: center;
}
.counter-box .icon {
    font-size: 3rem;
    color: var(--color-gold);
}
.counter-box .number {
    font-size: 3rem;
    font-weight: 700;
    margin: 10px 0;
}
.counter-box .text {
    font-size: 1.1rem;
    color: var(--color-text);
}

/* --- قسم المميزات --- */
.features-section {
    padding: 100px 0;
}
.features-section .section-title, .counters-section .section-title {
    color: #fff;
    font-weight: 700;
    margin-bottom: 50px;
}
.feature-card {
    background-color: #0a1422;
    padding: 30px;
    border-radius: 10px;
    border: 1px solid rgba(212, 175, 55, 0.1);
    transition: all 0.3s ease;
    height: 100%;
}
.feature-card:hover {
    transform: translateY(-5px);
    border-color: rgba(212, 175, 55, 0.5);
}
.feature-card .icon {
    font-size: 2.5rem;
    color: var(--color-gold);
    margin-bottom: 20px;
}
.feature-card h3 {
    color: #fff;
    font-size: 1.5rem;
    margin-bottom: 15px;
}

/* --- قسم الـ CTA الثانوي --- */
.secondary-cta-section {
    background-color: #0a1422;
    padding: 80px 0;
    text-align: center;
}
.secondary-cta-section h2 {
    color: #fff;
    font-weight: 700;
    margin-bottom: 30px;
}

/* --- الفوتر --- */
.footer {
    padding: 40px 0;
    text-align: center;
    border-top: 1px solid rgba(212, 175, 55, 0.2);
}


/* ... (باقي كود الـ CSS) ... */

/* --- تصميم لوحة التحكم (Dashboard) --- */

.bg-dark-blue-footer {
    background-color: #0a1422; /* نفس لون الخلفية الأغمق */
    border-top: 1px solid rgba(212, 175, 55, 0.2);
    color: var(--color-text);
}

.footer .text-muted {
    color: var(--color-text) !important;
    font-size: 0.9rem;
}



/* تحديد ألوان خلفية لوحة التحكم */
.dashboard-body {
    background-color: #0a192f; /* كحلي غامق جداً */
    color: var(--color-text);
    /* إضافة padding علوي لترك مساحة للـ Navbar الثابت */
    padding-top: 60px; /* (يجب أن يساوي ارتفاع الـ Navbar) */
}

.bg-dark-blue-header {
    background-color: #0a1422 !important; /* أغمق درجة */
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    height: 60px;
}

.bg-dark-blue-sidebar {
    background-color: #0a1422; /* نفس لون الهيدر */
    border-right: 1px solid rgba(212, 175, 55, 0.2);
}

/* زر تبديل الشريط الجانبي */
.btn-outline-gold {
    color: var(--color-gold);
    border-color: var(--color-gold);
}
.btn-outline-gold:hover {
    color: #000;
    background-color: var(--color-gold);
    border-color: var(--color-gold);
}

/* --- تخطيط الصفحة (Sidebar + Content) --- */
.page-wrapper {
    display: flex;
}

#main-sidebar {
    width: 250px; /* عرض القائمة الجانبية */
    height: calc(100vh - 60px); /* (ارتفاع الشاشة - ارتفاع الـ Navbar) */
    position: fixed;
    top: 60px; /* أسفل الـ Navbar */
    left: 0;
    z-index: 1000;
    transition: transform 0.3s ease-in-out;
    overflow-y: auto;
}

.main-content {
    flex-grow: 1; /* يأخذ باقي المساحة */
    margin-left: 250px; /* ترك مساحة للقائمة الجانبية */
    padding: 20px;
    transition: margin-left 0.3s ease-in-out;
}

/* --- تنسيقات القائمة الجانبية --- */
.sidebar-sticky {
    padding-top: 20px;
}
#main-sidebar .nav-link {
    color: var(--color-text);
    font-size: 1rem;
    padding: 10px 20px;
}
#main-sidebar .nav-link:hover,
#main-sidebar .nav-link.active {
    color: #fff;
    background-color: rgba(212, 175, 55, 0.1); /* لمسة ذهبية خفيفة */
}
#main-sidebar .nav-link .bi {
    color: var(--color-gold);
}
#main-sidebar .nav-item-header {
    padding: 10px 20px;
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
}
#main-sidebar .nav-item-divider {
    height: 1px;
    background-color: rgba(212, 175, 55, 0.1);
    margin: 10px 0;
}

/* --- حالة إخفاء القائمة (Toggle) --- */
body.sidebar-toggled #main-sidebar {
    transform: translateX(-250px); /* إخفاء القائمة لليسار */
}
body.sidebar-toggled .main-content {
    margin-left: 0; /* المحتوى يملأ الشاشة */
}

/* (لغة RTL) - عكس اتجاهات القائمة والمحتوى */
[dir="rtl"] #main-sidebar {
    left: auto;
    right: 0; /* القائمة على اليمين */
    border-right: none;
    border-left: 1px solid rgba(212, 175, 55, 0.2);
}
[dir="rtl"] .main-content {
    margin-left: 0;
    margin-right: 250px; /* ترك مساحة للقائمة على اليمين */
}
[dir="rtl"] body.sidebar-toggled #main-sidebar {
    transform: translateX(250px); /* إخفاء القائمة لليمين */
}
[dir="rtl"] body.sidebar-toggled .main-content {
    margin-right: 0;
}



/* --- صفحة اختيار القالب --- */
.template-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}
.template-card {
    background-color: #0a1422;
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.3s ease;
}
.template-card:hover {
    transform: translateY(-5px);
    border-color: var(--color-gold);
    box-shadow: 0 5px 20px rgba(212, 175, 55, 0.2);
}
.template-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
}
.template-card-body {
    padding: 15px;
    text-align: center;
}
.template-card-body h5 {
    color: #fff;
    margin-bottom: 10px;
}
.template-card .btn-cta {
    padding: 8px 20px;
    font-size: 0.9rem;
}

/* --- صفحة المحرر --- */
.editor-controls {
    background-color: #0a1422;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid rgba(212, 175, 55, 0.2);
    height: 100%; /* لجعلها تملأ العمود */
}
.editor-controls h5 {
    color: #fff;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    padding-bottom: 10px;
}
.editor-controls .form-label {
    color: var(--color-text);
    font-size: 0.9rem;
}
.editor-controls .form-control,
.editor-controls .form-select {
    background-color: #0a192f;
    border-color: #304a6e;
    color: #fff;
}
.editor-controls .form-control:focus,
.editor-controls .form-select:focus {
    background-color: #0a192f;
    border-color: var(--color-gold);
    box-shadow: none;
    color: #fff;
}
.color-suggestion-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #fff;
    cursor: pointer;
    margin: 0 5px;
    padding: 0;
}
#current_element_label {
    color: var(--color-gold);
    font-weight: 700;
}

/* --- لوحة التصميم (Canvas) --- */
#certificate_preview {
    position: relative;
    width: 100%;
    /* النسبة الذهبية للشهادات (A4) */
    aspect-ratio: 1.414 / 1; 
    background-size: cover;
    background-position: center;
    border: 1px dashed var(--color-gold);
    overflow: hidden; /* لمنع العناصر من الخروج */
}


/* * كلاس مشترك لكل العناصر القابلة للتعديل
 * (النصوص واللوجو)
*/
.editable_element {
    position: absolute;
    border: 1px dashed rgba(212, 175, 55, 0.5);
    cursor: move;
    touch-action: none;
    width: auto; /* (هام) */
    height: auto; /* (هام) */
    direction: rtl; /* لجعل النصوص العربية من اليمين لليسار */
}

.editable_text {
    background-color: transparent;
    overflow: hidden;
    resize: none; 
    pointer-events: none;
    
    /* (مهم) سنحدد عرض افتراضي هنا */
    width: 400px;
    height: auto; /* الارتفاع دائماً auto */
    
    /* بقية التنسيقات */
    font-family: 'Cairo', sans-serif;
    text-align: center;
    padding: 5px;
    color: inherit; /* (جديد) اجعله يرث اللون من الحاوية */
}



/* 3. (جديد) وضع التحرير (عند الدبل كليك) */
.editable_text.editing {
    border: 2px solid var(--color-gold);
    cursor: text;
    pointer-events: auto; /* السماح بالكتابة والنقر */
    background-color: rgba(255, 255, 255, 0.1);
}



.editable_text:focus {
    /* عند التركيز، أظهر حدوداً واضحة */
    border: 2px solid var(--color-gold);
    outline: none;
    background-color: rgba(255, 255, 255, 0.1); /* خلفية خفيفة جداً للمساعدة */
    cursor: text; /* تغيير المؤشر إلى "نص" */
}


/* * تنسيق حاوية اللوجو (جديد)
*/
#logo_container {
    touch-action: none;
    pointer-events: auto; /* السماح باللمس دائماً */
    width: 150px; /* عرض افتراضي */
    height: 150px; /* ارتفاع افتراضي */
 }



#logo_container img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* للحفاظ على أبعاد اللوجو */
}



/* 5. (جديد) تصميم مقبض تغيير الحجم */
.resize-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--color-gold);
    border: 1px solid #fff;
    border-radius: 50%; /* دائرة ذهبية */
    bottom: -5px;
    right: -5px;
    cursor: se-resize;
    display: none; /* إخفاؤه افتراضياً */
}





/* إظهار المقبض فقط عند تحديد العنصر */
.editable_element.selected {
    border: 2px solid var(--color-gold);
}
.editable_element.selected .resize-handle {
    display: block;
}

/* إخفاء كل شيء عند التصدير */
.exporting .editable_element {
    border: none !important;
}
.exporting .resize-handle {
    display: none !important;
}


/* * كلاس نضيفه عند التحميل لإخفاء كل أدوات التحكم
*/
.exporting #logo_container,
.exporting .editable_text {
    border: none !important; /* إخفاء الحدود */
}




/* أماكن مبدئية للعناصر (يمكنك إزالتها أو تعديلها) */
#el_title_wrapper { top: 15%; left: calc(50% - 200px); }
#el_authority_wrapper { top: 25%; left: calc(50% - 200px); }
#el_recipient_wrapper { top: 40%; left: calc(50% - 200px); }
#el_reason_wrapper { top: 55%; left: calc(50% - 200px); }
#el_signature_wrapper { top: 75%; left: calc(50% - 150px); width: 300px; }






/* --- (جديد) تنسيقات رسالة التحذير للموبايل --- */
.mobile-warning-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.mobile-warning-modal {
    background-color: #0a1422; /* نفس لون الكروت */
    border: 1px solid var(--color-gold);
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    color: #fff;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.mobile-warning-modal h2 {
    color: var(--color-gold);
    font-weight: 700;
    margin-bottom: 20px;
}
.mobile-warning-modal p {
    font-size: 1.1rem;
    color: var(--color-text);
    margin-bottom: 30px;
}
.mobile-warning-modal .btn-cta {
    width: 100%;
}





/* --- (جديد) شريط الأدوات العائم --- */
#floating-toolbar {
    position: absolute; /* (هام) لجعله يطفو */
    display: none;      /* (هام) مخفي افتراضياً */
    z-index: 10001;     /* فوق كل شيء */
    
    background-color: #0a1422;
    border: 1px solid var(--color-gold);
    border-radius: 8px;
    padding: 8px;
    
    display: flex; /* لترتيب الأدوات أفقياً */
    align-items: center;
    gap: 8px; /* مسافات بين الأدوات */
    
    /* لمنع إخفاء الشريط عند النقر عليه */
    pointer-events: auto;
}

/* تنسيق الأدوات داخل الشريط */
#floating-toolbar .form-select-sm {
    width: 130px; /* تحديد عرض قائمة الخطوط */
    background-color: #0a192f;
    border-color: #304a6e;
    color: #fff;
}
#floating-toolbar .form-control-color {
    width: 40px; /* تحديد عرض منتقي الألوان */
}
#floating-toolbar .color-suggestions {
    display: flex;
    border-left: 1px solid #304a6e;
    padding-left: 8px;
}
#floating-toolbar .color-suggestion-btn {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid #fff;
    cursor: pointer;
    margin: 0 3px;
    padding: 0;
}






/* تنسيق أزرار الشريط (مثل زر Bold) */
.btn-toolbar {
    background-color: #0a192f;
    border: 1px solid #304a6e;
    color: #fff;
    width: 40px;
    height: 38px; /* ليتناسب مع ارتفاع قائمة الخطوط */
    font-size: 1.1rem;
}
.btn-toolbar:hover {
    background-color: #304a6e;
    color: #fff;
}
/* (جديد) كلاس "نشط" لزر Bold */
.btn-toolbar.active {
    background-color: var(--color-gold);
    color: #000;
    border-color: var(--color-gold);
}

/* (جديد) تنسيق قائمة الألوان */
#toolbar_color_toggle {
    width: 40px;
}
#toolbar-color-palette-menu {
    background-color: #0a1422;
    border: 1px solid var(--color-gold);
    padding: 10px;
    min-width: 150px; /* عرض القائمة */
}
.color-palette-row {
    display: flex;
    gap: 8px;
    justify-content: center;
}
.palette-color-btn {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    border: 2px solid #fff;
    cursor: pointer;
    padding: 0;
}
.palette-color-btn:hover {
    opacity: 0.8;
}
#toolbar-color-palette-menu .dropdown-item-text {
    color: var(--color-text);
}
#toolbar_font_color_picker {
    width: 100%;
    height: 35px;
    cursor: pointer;
}