/* Shared 80/20 side-chat page shell (header + footer inside main column) */

.home-layout-with-side {
  display: block;
  width: 100%;
}

.home-layout-chat {
  display: none;
}

body.xsr-chat-side-dock .home-layout-with-side {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(0, 4fr);
  align-items: start;
  gap: 0;
  width: 100%;
  max-width: none;
  min-height: 100dvh;
  height: auto;
  max-height: none;
  flex: 1 1 auto;
  overflow: visible;
}

body.xsr-chat-side-dock .home-layout-main {
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 2;
  min-width: 0;
  min-height: 100dvh;
  max-height: none;
  height: auto;
  overflow: visible;
  order: 2;
}

body.xsr-chat-side-dock .home-layout-chat {
  display: flex;
  flex-direction: column;
  order: 1;
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 0;
  height: 100dvh;
  max-height: 100dvh;
  border-inline-end: 1px solid rgba(15, 23, 42, 0.1);
  background:
    linear-gradient(180deg, rgba(248, 250, 252, 0.98) 0%, rgba(241, 245, 249, 0.96) 100%);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.5);
  z-index: 1;
  overflow: hidden;
}

body.xsr-chat-side-dock .home-layout-main .dashboard-header {
  position: relative;
  width: 100%;
  max-width: 100%;
  left: auto;
  right: auto;
  inset-inline: auto;
}

body.xsr-chat-side-dock .home-layout-main .xsr-workspace-footer,
body.xsr-chat-side-dock .home-layout-main .xsr-footerbar.xsr-workspace-footer {
  left: auto !important;
  right: auto !important;
  width: 100% !important;
  max-width: 100% !important;
  inset-inline: auto !important;
}

body.xsr-chat-side-dock .xsr-home-main {
  padding-inline: 1rem;
}

/* صفحات التعلم العامة: المحتوى أطول من الشاشة — اسمح بالتمرير وثبّت سكة الشات */
body.learn-workspace.xsr-chat-side-dock .home-layout-with-side {
  height: auto;
  min-height: 100dvh;
  max-height: none;
  overflow: visible;
  align-items: start;
}

body.learn-workspace.xsr-chat-side-dock .home-layout-main {
  height: auto;
  max-height: none;
  overflow: visible;
  min-height: 100dvh;
}

body.learn-workspace.xsr-chat-side-dock .home-layout-chat {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100dvh;
  max-height: 100dvh;
}

/* الرئيسية: نفس سلوك التمرير مع الشات الجانبي */
body.xsr-home-page.xsr-chat-side-dock .home-layout-with-side {
  height: auto;
  min-height: 100dvh;
  max-height: none;
  overflow: visible;
  align-items: start;
}

body.xsr-home-page.xsr-chat-side-dock .home-layout-main {
  height: auto;
  max-height: none;
  overflow: visible;
  min-height: 100dvh;
}

body.xsr-home-page.xsr-chat-side-dock .home-layout-chat {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100dvh;
  max-height: 100dvh;
}

/* لوحة تعلم الإدارة: المحتوى صف أفقي (sidebar | main) وليس عموداً رأسياً */
body.learn-admin-workspace .home-layout-with-side {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body.learn-admin-workspace .home-layout-main {
  display: flex;
  flex-direction: row;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

/* عند الـ dock: تمرير المستند مثل الرئيسية/التعلم + سكة شات sticky */
body.learn-admin-workspace.xsr-chat-side-dock {
  height: auto !important;
  max-height: none !important;
  min-height: 100dvh;
  overflow: auto !important;
}

body.learn-admin-workspace.xsr-chat-side-dock .home-layout-with-side {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(0, 4fr);
  flex: 1 1 auto;
  min-height: 100dvh;
  height: auto;
  max-height: none;
  overflow: visible;
  align-items: start;
}

body.learn-admin-workspace.xsr-chat-side-dock .home-layout-main {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
  min-width: 0;
  min-height: 100dvh;
  height: auto;
  max-height: none;
  overflow: visible;
  order: 2;
}

body.learn-admin-workspace.xsr-chat-side-dock .home-layout-chat {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100dvh;
  max-height: 100dvh;
}

body.learn-admin-workspace.xsr-chat-side-dock .home-layout-main .xsr-footerbar,
body.learn-admin-workspace.xsr-chat-side-dock .home-layout-main .xsr-workspace-footer {
  position: sticky;
  bottom: 0;
  flex: 1 0 100%;
  width: 100% !important;
  max-width: 100% !important;
  left: auto !important;
  right: auto !important;
  inset-inline: auto !important;
  z-index: 40;
  margin-top: 0;
}

@media (max-width: 900px) {
  /* الشات الجانبي يبقى ظاهراً على الهاتف مثل الديسكتوب */

  body.learn-admin-workspace:not(.xsr-chat-side-dock) .home-layout-with-side,
  body.learn-admin-workspace:not(.xsr-chat-side-dock) .home-layout-main {
    display: block;
    height: auto;
    max-height: none;
    overflow: visible;
    flex: none;
  }
}
