/* =====================================================
   التخطيط - Layout (Sidebar, Header, Content Area)
   ===================================================== */

.app-shell {
    display: block;
    /* vh على الجوّال يحسب الشاشة بشريط المتصفّح مطوياً، فيزيد الطول
       عن المرئي ويظهر تمرير زائد. dvh يتبع المساحة الحقيقية، والسطر
       الذي قبله احتياطٌ لمتصفّحٍ لا يعرفه. */
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
}

/* ===========================================
   الشريط الجانبي - Sidebar (Drawer Mode)
   =========================================== */
.app-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    background: linear-gradient(180deg, #0a3d2e 0%, #0d2a20 100%);
    color: var(--color-cream);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: var(--z-modal);
    box-shadow: -20px 0 60px rgba(10, 61, 46, 0.35);
    transform: translateX(100%);
    transition: transform 450ms cubic-bezier(0.16, 1, 0.3, 1);
    /* لا will-change دائمة: تُبقي طبقة تركيب لعنصر ٣٢٠×١٠٠vh بتدرّجين
       طول عمر الصفحة. تُفعَّل عند الفتح وحده أدناه. */
}

.app-sidebar.is-open {
    transform: translateX(0);
    /* الطبقة تُنشأ لحظة الحاجة إليها لا طول عمر الصفحة */
    will-change: transform;
}

.app-sidebar::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 10%, rgba(201, 169, 97, 0.15), transparent 40%),
        radial-gradient(circle at 80% 90%, rgba(212, 175, 55, 0.08), transparent 40%);
    pointer-events: none;
}

.app-sidebar::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 30px,
            rgba(201, 169, 97, 0.025) 30px,
            rgba(201, 169, 97, 0.025) 60px
        );
    pointer-events: none;
}

.sidebar-brand {
    position: relative;
    z-index: 2;
    padding: var(--space-8) var(--space-6) var(--space-6);
    text-align: center;
    border-bottom: 1px solid rgba(201, 169, 97, 0.15);
}

/* سطر الاسم: الاسم في الوسط، وزرّ الإغلاق على طرفه بمحاذاة منتصفه */
.sidebar-brand__row {
    position: relative;
    margin-bottom: var(--space-1);
    padding-inline: 2.75rem;
}

.sidebar-brand__name {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--color-cream);
    letter-spacing: 0.02em;
}

.sidebar-brand__tagline {
    font-size: var(--text-xs);
    color: var(--color-gold-shimmer);
    /* 400 لا 300: الوزن الخفيف غير محمَّل، وتحميل وجهٍ عربيٍّ كامل
       لسطرٍ واحد لا يستحقّ عشرات الكيلوبايتات. */
    font-weight: 400;
    letter-spacing: 0.08em;
}

/* Navigation Menu */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-4) 0;
    position: relative;
    z-index: 2;
    scrollbar-width: thin;
    scrollbar-color: rgba(201, 169, 97, 0.3) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(201, 169, 97, 0.3);
    border-radius: var(--radius-full);
    border: none;
}

.sidebar-nav__list {
    list-style: none;
}

.sidebar-nav__item {
    margin-bottom: var(--space-1);
}

.sidebar-nav__link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-6);
    color: rgba(250, 247, 240, 0.75);
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all var(--transition-base);
    position: relative;
}

.sidebar-nav__link::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(201, 169, 97, 0.1));
    opacity: 0;
    transition: opacity var(--transition-base);
}

/*
 * خطٌّ ذهبيّ واحد يدلّ على الصفحة: الشريط المستدير (::after في interactions.css).
 * كان معه حدٌّ أيمن ملوّن أيضاً فيظهر خطّان متلاصقان.
 */
.sidebar-nav__link:hover {
    color: var(--color-cream);
}

.sidebar-nav__link:hover::before {
    opacity: 1;
}

.sidebar-nav__link.is-active {
    color: var(--color-gold-shimmer);
    background: linear-gradient(90deg, transparent, rgba(201, 169, 97, 0.15));
}

.sidebar-nav__link.is-active .sidebar-nav__icon {
    color: var(--color-gold-bright);
    transform: scale(1.1);
}

.sidebar-nav__icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-gold-soft);
    transition: all var(--transition-base);
}

.sidebar-nav__icon svg {
    width: 100%;
    height: 100%;
    stroke-width: 1.5;
}

.sidebar-nav__label {
    flex: 1;
    position: relative;
    z-index: 1;
}

/* Section Heading inside Nav */
.sidebar-nav__heading {
    padding: var(--space-4) var(--space-6) var(--space-2);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-gold-shimmer);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.8;
}

/* Social section in sidebar */
.sidebar-social {
    position: relative;
    z-index: 2;
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid rgba(201, 169, 97, 0.15);
    background: rgba(13, 42, 32, 0.5);
}

.sidebar-social__title {
    font-size: var(--text-xs);
    color: var(--color-gold-shimmer);
    font-weight: 600;
    margin-bottom: var(--space-3);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.sidebar-social__links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

/*
 * أزرار التواصل تملأ عرض القائمة: زرٌّ واحد بالعرض كاملاً، وأكثر من زرّ
 * تتقاسم السطر بالتساوي (وتلتفّ إن ضاق بها).
 */
.sidebar-social__link {
    flex: 1 1 0;
    min-width: 2.75rem;
    height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-cream);
    background: rgba(201, 169, 97, 0.1);
    border-radius: var(--radius-md);
    border: 1px solid rgba(201, 169, 97, 0.15);
    transition: all var(--transition-base);
}

.sidebar-social__link:hover {
    background: linear-gradient(135deg, var(--color-gold-soft), var(--color-gold-deep));
    color: var(--color-emerald-deep);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(201, 169, 97, 0.4);
    border-color: transparent;
}

.sidebar-social__link svg {
    width: 18px;
    height: 18px;
}

/* ===========================================
   منطقة المحتوى الرئيسية - Main Content
   =========================================== */
.app-main {
    width: 100%;
    min-width: 0;
    /* بطول الشاشة على الأقل: في الصفحة القصيرة يبقى التذييل الأخضر
       ملتصقاً بأسفلها، لا معلّقاً فوق شريطٍ فاتحٍ فارغ */
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/*
 * التعتيم عند فتح القائمة بطبقة فوق المحتوى لا بمرشّح عليه.
 *
 * `filter: brightness()` على `.app-main` يشمل المستند كلّه، فيُلزم
 * المتصفّح برسم كامل ارتفاع الصفحة في نسيج واحد وإعادة رسترته في كل
 * إطار من إطارات الانتقال — وعلى صفحة طويلة يتجاوز ذلك الحدّ الأقصى
 * لحجم النسيج فيسقط إلى رسترة مبلّطة على الخيط الرئيسي. أمّا عتامة
 * طبقة فهي خاصية مركّبة تتولّاها بطاقة الرسم بلا إعادة رسم.
 */
.app-main::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(26, 20, 16, 0.08);
    opacity: 0;
    pointer-events: none;
    transition: opacity 350ms ease;
    z-index: 1;
}

.app-shell.sidebar-is-open .app-main::after {
    opacity: 1;
}

/* Header */
.app-header {
    height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    /*
     * خلفية معتمة بلا تمويه: الترويسة لاصقة، فكل إطار تمرير كان يُلزم
     * المتصفّح بقراءة ما تحتها على كامل العرض وتمويهه — قراءة عكسية من
     * بطاقة الرسم لا تُخزَّن لأن ما تحتها يتغيّر باستمرار.
     */
    background: rgba(250, 247, 240, 0.98);
    /* لا will-change هنا: الترويسة لا تتحرّك أصلاً (position: sticky
       يتولّاه المتصفّح)، فالطبقة تُنشأ وتبقى بلا فائدة. */
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    align-items: center;
    padding: 0 var(--space-8);
}

.app-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: var(--space-6);
}

.header-mobile-toggle {
    display: none;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: background var(--transition-fast);
}

.header-mobile-toggle:hover {
    background: var(--color-cream-warm);
}

.app-header__title {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.app-header__breadcrumb {
    color: var(--text-tertiary);
    font-size: var(--text-sm);
    margin-top: 2px;
}

.app-header__breadcrumb a {
    color: var(--text-tertiary);
}

.app-header__breadcrumb a:hover {
    color: var(--color-gold-deep);
}

.app-header__actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* Main Content Area */
.app-content {
    flex: 1;
    padding: var(--space-8);
    position: relative;
}

/* ===========================================
   التذييل — خريطة موقع لا سطران
   ===========================================
   كان سطرَين موسَّطين: اسمٌ واقتباس. وصار ثلاثة أعمدة تحمل صفحات
   الموقع كلَّها، فلا يعود الزائر إلى أعلى الصفحة ليفتح الدرج.

   والشبكة auto-fit لا أعمدةٌ معدودة: تنهار من ثلاثة إلى واحد بلا
   استعلام وسائط، فلا تنكسر عند مقاسٍ لم نختبره.
   =========================================== */
.app-footer {
    position: relative;
    background:
        radial-gradient(120% 90% at 100% 0%, rgba(212, 175, 55, 0.10), transparent 55%),
        linear-gradient(160deg, var(--color-emerald-deep) 0%, #072e22 70%, #062519 100%);
    color: var(--color-cream);
    padding: var(--space-12) var(--space-8) var(--space-6);
    margin-top: var(--space-16);
}

/* خيطٌ ذهبيّ يفصل التذييل عن الصفحة */
.app-footer::before {
    content: '';
    position: absolute;
    inset-inline: 0;
    top: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--color-gold-soft) 20%, var(--color-gold-bright) 50%, var(--color-gold-soft) 80%, transparent);
}

/* حلقة التركيز الخضراء لا تُرى على الأخضر */
.app-footer :focus-visible {
    outline: 2px solid var(--color-gold-shimmer);
    outline-offset: 2px;
}

.app-footer__inner {
    max-width: var(--container-max);
    margin: 0 auto;
}

/*
 * عمود الاسم ثمّ ثلاثة أعمدة روابط.
 * الهاتف: الاسم سطرٌ كامل والروابط عمودان — عمودٌ واحد يجعل التذييل
 *   أطول من الشاشة، والعناوين العربية القصيرة تتّسع لنصف السطر.
 * اللوحيّ: الاسم سطرٌ كامل والروابط ثلاثة.
 * الواسع: الأربعة في سطرٍ واحد، وللاسم نصيبٌ ونصف.
 */
.app-footer__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-8) var(--space-6);
    align-items: start;
}

.app-footer__brand-col {
    grid-column: 1 / -1;
}

@media (min-width: 768px) {
    .app-footer__grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: var(--space-8) var(--space-10);
    }
}

@media (min-width: 1024px) {
    .app-footer__grid { grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr)); }
    .app-footer__brand-col { grid-column: auto; }
}

.app-footer__brand {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--color-cream);
    margin-bottom: var(--space-3);
}

.app-footer__blurb {
    font-size: var(--text-sm);
    color: rgba(250, 247, 240, 0.72);
    line-height: var(--leading-relaxed);
    max-width: 34ch;
    margin-bottom: var(--space-5);
}

/* أزرار التواصل تملأ العرض: زرٌّ واحد بالعرض كاملاً، وأكثر تتقاسمه بالتساوي */
.app-footer__social {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    list-style: none;
    padding: 0;
    margin: 0;
}

.app-footer__social > li {
    flex: 1 1 0;
    min-width: 2.75rem;
}

.app-footer__social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    /* ٤٤ بكسل ارتفاعاً: أدنى مساحة لمسٍ مريحة، لا تصغر على الجوّال */
    inline-size: 100%;
    block-size: 2.75rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(250, 247, 240, 0.16);
    color: var(--color-gold-shimmer);
    background: rgba(250, 247, 240, 0.06);
    transition: background var(--transition-fast), border-color var(--transition-fast),
                color var(--transition-fast), transform var(--transition-fast);
}

.app-footer__social-link:hover,
.app-footer__social-link:focus-visible {
    background: var(--color-gold-bright);
    border-color: var(--color-gold-bright);
    color: var(--color-emerald-deep);
    transform: translateY(-2px);
}

.app-footer__social-link svg { inline-size: 1.15rem; block-size: 1.15rem; }

.app-footer__heading {
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--color-gold-shimmer);
    margin-bottom: var(--space-4);
}

.app-footer__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.app-footer__link {
    font-size: var(--text-sm);
    color: rgba(250, 247, 240, 0.78);
    text-decoration: none;
    /* هدفُ لمسٍ مقبول بلا أن يتباعد السطران بصرياً */
    padding-block: 0.35rem;
    display: inline-block;
    transition: color var(--transition-fast);
}

.app-footer__link:hover,
.app-footer__link:focus-visible {
    color: var(--color-gold-shimmer);
}

.app-footer__bottom {
    margin-top: var(--space-10);
    padding-top: var(--space-5);
    border-top: 1px solid rgba(250, 247, 240, 0.12);
}

.app-footer__copy {
    font-size: var(--text-sm);
    color: rgba(250, 247, 240, 0.6);
    text-align: center;
}

@media (max-width: 480px) {
    .app-footer { padding-inline: var(--space-5); }
    .app-footer__grid { gap: var(--space-5) var(--space-4); }
    .app-footer__heading { margin-bottom: var(--space-2); }
    .app-footer__bottom { margin-top: var(--space-6); }
}

/* ===========================================
   نافذة الزجاج الضبابي خلف السايدبار
   Frosted Glass Overlay (covers main content when sidebar opens)
   =========================================== */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg,
        rgba(10, 61, 46, 0.18),
        rgba(26, 20, 16, 0.35));
    /*
     * التمويه يبقى ثابتاً ولا يدخل في الانتقال: تحريكه كان يُعيد تمويه
     * نافذة العرض كاملةً في كل إطار من الثلاثمئة والخمسين مليّ ثانية.
     */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: calc(var(--z-modal) - 1);
    opacity: 0;
    pointer-events: none;
    transition: opacity 350ms ease;
    cursor: pointer;
}

.sidebar-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

/* ===========================================
   زر إغلاق السايدبار (داخله)
   =========================================== */
/* داخل سطر الاسم: منتصفه على منتصف الاسم (translate مستقلّ فلا يتعارض مع دوران التحويم) */
.sidebar-close {
    position: absolute;
    top: 50%;
    left: 0;
    translate: 0 -50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(201, 169, 97, 0.12);
    border: 1px solid rgba(201, 169, 97, 0.25);
    border-radius: 50%;
    color: var(--color-gold-shimmer);
    cursor: pointer;
    z-index: 10;
    transition: all var(--transition-fast);
}

.sidebar-close:hover {
    background: rgba(212, 175, 55, 0.25);
    border-color: var(--color-gold-soft);
    color: var(--color-gold-bright);
    transform: rotate(90deg);
}

.sidebar-close svg {
    width: 16px;
    height: 16px;
}

/* ===========================================
   زر toggle السايدبار (في الهيدر) — ظاهر دائماً
   =========================================== */
.header-mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    width: auto;
    min-width: 44px;
    height: 44px;
    padding: 0 var(--space-3);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    background: transparent;
    border: 1px solid var(--color-border-light);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.header-mobile-toggle:hover {
    background: var(--color-cream-warm);
    border-color: var(--color-gold-soft);
    color: var(--color-emerald-deep);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(201, 169, 97, 0.15);
}

.header-mobile-toggle svg {
    width: 22px;
    height: 22px;
}

.header-mobile-toggle__label {
    font-size: var(--text-sm);
    font-weight: 600;
    display: none;
}

@media (min-width: 768px) {
    .header-mobile-toggle__label {
        display: inline;
    }
}

/* عند فتح السايدبار، الزر يلوّن ذهبياً */
.app-shell.sidebar-is-open .header-mobile-toggle {
    background: linear-gradient(135deg, var(--color-emerald-deep), var(--color-emerald-mid));
    color: var(--color-gold-shimmer);
    border-color: var(--color-emerald-deep);
}

/* ===========================================
   Responsive
   =========================================== */
/* ٧٦٨ لا ٦٤٠: كانت هذه العتبة وحيدةً في المشروع كلّه، فتُعاد ضبط
   الترويسة والمحتوى والدرج ثلاث مرّات عند ثلاث عتباتٍ متقاربة
   (٤٨٠ و٦٤٠ و٧٦٨) ويصعب تتبّع أيُّها غلب. */
@media (max-width: 768px) {
    .app-content {
        padding: var(--space-4);
    }

    .app-header {
        padding: 0 var(--space-4);
    }

    .app-header__title {
        font-size: var(--text-md);
    }

    .app-sidebar {
        width: 88vw;
        max-width: var(--sidebar-width);
    }

    h1 { font-size: var(--text-3xl); }
    h2 { font-size: var(--text-2xl); }
}
