/* مودّة — لمسات تجربة التطبيق على الجوال (RTL, Safe Area, WCAG touch targets) */

/* ===== الشريط العلويّ على الجوال (أقصر + Sticky + فاصل) ===== */
@media (max-width: 991.98px) {
    .navbar {
        position: sticky; top: 0; z-index: 1035;
        padding: 10px 0 !important;
        min-height: 60px;
        border-bottom: 1px solid var(--border-subtle);
        box-shadow: 0 2px 8px rgba(13, 47, 58, 0.05) !important;
    }
    .navbar .container { align-items: center; }
    .navbar-brand img { height: 32px !important; }
    .mwd-menu-btn {
        width: 44px; height: 44px; padding: 0;
        display: inline-flex; align-items: center; justify-content: center;
        font-size: 1.25rem; color: var(--text-primary);
        background: transparent; border-radius: 12px;
    }
    .mwd-menu-btn:active { background: var(--bg-subtle); }
    .mwd-menu-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
}

/* ===== الدرج الجانبيّ (Off-Canvas) ===== */
.mwd-drawer.offcanvas-start {
    width: 85vw; max-width: 360px;
    background: var(--bg-surface);
    z-index: 1090; /* أعلى من الشريط العلويّ والسفليّ */
}
.mwd-drawer .offcanvas-header { border-bottom: 1px solid var(--border-subtle); padding: 14px 18px; }
.mwd-drawer .offcanvas-body { display: flex; flex-direction: column; padding: 12px 12px 18px; }
.mwd-drawer-list { list-style: none; margin: 0; padding: 0; }
.mwd-drawer-list > li > a,
.mwd-drawer-list .mwd-sub-toggle {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; width: 100%;
    min-height: 46px; padding: 10px 14px;
    color: var(--text-primary); text-decoration: none;
    background: none; border: 0; border-radius: 12px;
    font-size: 1rem; font-weight: 500;
}
.mwd-drawer-list > li > a > span:first-child { display: inline-flex; align-items: center; gap: 12px; }
.mwd-drawer-list > li > a i:first-child,
.mwd-sub-toggle i:first-child { color: var(--primary); width: 20px; text-align: center; }
.mwd-drawer-list > li > a:active,
.mwd-sub-toggle:active,
.mwd-drawer-list > li > a[aria-current="page"] { background: var(--bg-subtle); }
.mwd-drawer-list > li > a:focus-visible,
.mwd-sub-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.mwd-sub-toggle .mwd-caret { transition: transform .2s ease; font-size: .8rem; }
.mwd-sub-toggle[aria-expanded="true"] .mwd-caret { transform: rotate(180deg); }
.mwd-submenu { list-style: none; margin: 2px 0 4px; padding: 0 8px; }
.mwd-submenu > li > a {
    display: flex; align-items: center; gap: 10px;
    min-height: 42px; padding: 8px 16px; border-radius: 10px;
    color: var(--text-muted); text-decoration: none; font-size: .95rem;
}
.mwd-submenu > li > a i { color: var(--primary); width: 18px; text-align: center; }
.mwd-submenu > li > a:active { background: var(--bg-subtle); }
.mwd-drawer-sep { height: 1px; background: var(--border-subtle); margin: 10px 6px; }
.mwd-drawer-bottom { margin-top: auto; padding-top: 12px; }

/* حركة الدرج 200–250ms + احترام تقليل الحركة */
.mwd-drawer.offcanvas { transition: transform .22s ease-in-out; }
@media (prefers-reduced-motion: reduce) {
    .mwd-drawer.offcanvas, .mwd-sub-toggle .mwd-caret { transition: none !important; }
}

/* ===== التنقّل السفليّ ===== */
.mwd-bottom-nav { display: none; }

@media (max-width: 991.98px) {
    .mwd-bottom-nav {
        display: flex;
        position: fixed;
        inset-inline: 0;
        bottom: 0;
        z-index: 1030;
        background: var(--bg-surface);
        border-top: 1px solid var(--border-subtle);
        box-shadow: 0 -4px 20px rgba(13, 47, 58, 0.08);
        padding-bottom: env(safe-area-inset-bottom, 0);
        justify-content: space-around;
        align-items: flex-end;
    }
    .mwd-bn-item, .mwd-bn-center {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        min-height: 56px;
        padding: 8px 2px;
        text-decoration: none;
        color: var(--text-muted);
        font-size: 0.7rem;
    }
    .mwd-bn-item i { font-size: 1.15rem; }
    .mwd-bn-item.active { color: var(--primary); font-weight: 600; }
    .mwd-bn-item.active i { color: var(--primary); }
    .mwd-bn-item:active { background: var(--bg-subtle); }
    .mwd-bn-item:focus-visible, .mwd-bn-center:focus-visible { outline: 2px solid var(--primary); outline-offset: -3px; border-radius: 10px; }

    /* تعتيم/تعطيل الشريط السفليّ أثناء فتح الدرج */
    body.drawer-open .mwd-bottom-nav { opacity: .35; pointer-events: none; transition: opacity .2s; }

    .mwd-bn-center { position: relative; }
    .mwd-bn-fab {
        position: absolute;
        top: -18px;
        width: 50px; height: 50px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--primary), var(--c-night-800));
        display: flex; align-items: center; justify-content: center;
        box-shadow: 0 6px 16px rgba(13, 47, 58, 0.26);
        border: 3px solid var(--bg-surface);
    }
    .mwd-bn-fab img { width: 30px; height: 30px; }

    /* مساحة أسفل الصفحة كي لا يغطّي الشريط المحتوى */
    body.has-bottom-nav { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0)); }

    /* إخفاء الفوتر الطويل على الجوال لتجربة أقرب للتطبيق (يبقى في DOM لـSEO) */
    body.app-mobile footer { display: none; }

    /* إخفاء الشريط السفليّ داخل شاشات المحادثة عند فتح لوحة المفاتيح */
    body.chat-active .mwd-bottom-nav { display: none; }
    body.chat-active.has-bottom-nav { padding-bottom: 0; }
}

/* ===== شريط تثبيت PWA ===== */
#mwd-install-bar {
    position: fixed;
    inset-inline: 12px;
    bottom: calc(72px + env(safe-area-inset-bottom, 0));
    z-index: 1040;
}
@media (min-width: 992px) { #mwd-install-bar { inset-inline: auto; inset-inline-end: 20px; bottom: 20px; max-width: 360px; } }
.mwd-install-inner {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 10px 14px;
    box-shadow: 0 8px 30px rgba(13, 47, 58, 0.18);
    font-size: 0.9rem; color: var(--text-primary);
}
.mwd-install-inner span { flex: 1; }
#mwd-install-yes { background: var(--primary); color: #fff; border: 0; border-radius: 20px; padding: 8px 18px; font-weight: 600; }
#mwd-install-no { background: none; border: 0; color: var(--text-muted); font-size: 1rem; }

/* ===== شاشات الحساب (دخول/تسجيل) بلمسة تطبيق ===== */
.auth-wrap {
    min-height: 85vh;
    display: flex;
    align-items: center;
    padding: 32px 0;
    background: linear-gradient(135deg, var(--bg-canvas) 0%, var(--highlight) 140%);
}
.auth-wrap--tall { align-items: flex-start; min-height: 100vh; }
.auth-card {
    width: 100%;
    background: var(--bg-surface);
    border-radius: 24px;
    padding: 44px;
    box-shadow: 0 12px 44px rgba(13, 47, 58, 0.12);
    border: 1px solid var(--border-subtle);
}
.auth-card .btn-primary[data-submit-btn] { min-height: 50px; font-weight: 700; border-radius: 26px; }

@media (max-width: 575.98px) {
    .auth-wrap { padding: 0; align-items: stretch; }
    .auth-wrap .container, .auth-wrap .row, .auth-wrap [class^="col-"] { padding-inline: 0; }
    .auth-card {
        border-radius: 0;
        border: 0;
        box-shadow: none;
        padding: 28px 20px calc(28px + env(safe-area-inset-bottom, 0));
        min-height: 100vh;
    }
}

/* ===== لمسات app-first عامّة على الجوال ===== */
@media (max-width: 991.98px) {
    /* أهداف لمس ≥44px للأزرار الأساسيّة */
    .btn-lg { min-height: 48px; }
    /* منع التمرير الأفقيّ */
    html, body { overflow-x: hidden; }
}
