/* ═══════════════════════════════════════════════════
   MOH — Layout System
   نظام التخطيط — Grid + Flexbox
   ═══════════════════════════════════════════════════ */

/* ─── Container ─── */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-4);
}

/* ─── Main App Layout (3-Column) ─── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr var(--right-panel-width);
  gap: 0;
  min-height: calc(100vh - var(--navbar-height));
  margin-top: var(--navbar-height);
  max-width: 1440px;
  margin-left: auto;
  margin-right: auto;
}

/* ─── Sidebar ─── */
.app-sidebar {
  position: sticky;
  top: var(--navbar-height);
  height: calc(100vh - var(--navbar-height));
  overflow-y: auto;
  padding: var(--space-4);
  border-left: 1px solid var(--border-light);
  background: var(--sidebar-bg);
}

/* ─── Main Content ─── */
.app-main {
  min-height: calc(100vh - var(--navbar-height));
  padding: var(--space-6) var(--space-4);
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

.app-main--full {
  max-width: 100%;
  padding: var(--space-6);
}

/* ─── Right Panel ─── */
.app-right-panel {
  position: sticky;
  top: var(--navbar-height);
  height: calc(100vh - var(--navbar-height));
  overflow-y: auto;
  padding: var(--space-4);
  border-right: 1px solid var(--border-light);
  background: var(--sidebar-bg);
}

/* ─── Auth Layout (Split Screen) ─── */
.auth-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

.auth-layout__visual {
  position: relative;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.auth-layout__form {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  background: var(--bg-primary);
}

/* ─── Chat Layout (2-Column) ─── */
.chat-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: calc(100vh - var(--navbar-height));
  margin-top: var(--navbar-height);
}

/* ─── Admin Layout ─── */
.admin-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - var(--navbar-height));
  margin-top: var(--navbar-height);
}

/* ─── Profile Layout ─── */
.profile-layout {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4);
}

/* ─── Flex Utilities ─── */
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-start {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.flex-end {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.flex-col-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.flex-wrap {
  flex-wrap: wrap;
}

.flex-1 {
  flex: 1;
}

.flex-shrink-0 {
  flex-shrink: 0;
}

.items-start {
  align-items: flex-start;
}

.items-center {
  align-items: center;
}

.items-end {
  align-items: flex-end;
}

/* ─── Grid Utilities ─── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}

/* ─── Width Utilities ─── */
.w-full { width: 100%; }
.w-auto { width: auto; }
.max-w-sm { max-width: 24rem; }
.max-w-md { max-width: 28rem; }
.max-w-lg { max-width: 32rem; }
.max-w-xl { max-width: 36rem; }
.max-w-2xl { max-width: 42rem; }

/* ─── Position Utilities ─── */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed    { position: fixed; }
.sticky   { position: sticky; }

/* ─── Overflow ─── */
.overflow-hidden  { overflow: hidden; }
.overflow-auto    { overflow: auto; }
.overflow-y-auto  { overflow-y: auto; }
.overflow-x-hidden { overflow-x: hidden; }

/* ═══════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════ */

/* ─── Tablet (≤1024px) ─── */
@media (max-width: 1024px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    display: none;
  }

  .app-right-panel {
    display: none;
  }

  .app-main {
    max-width: 100%;
    padding: var(--space-4);
  }

  .chat-layout {
    grid-template-columns: 1fr;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .auth-layout {
    grid-template-columns: 1fr;
  }

  .auth-layout__visual {
    display: none;
  }

  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ─── Mobile (≤768px) ─── */
@media (max-width: 768px) {
  :root {
    --navbar-height: 56px;
  }

  .container {
    padding: 0 var(--space-3);
  }

  .app-main {
    padding: var(--space-3);
    margin-bottom: var(--bottom-nav-height);
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .grid-3 {
    grid-template-columns: 1fr;
  }

  .grid-4 {
    grid-template-columns: 1fr;
  }

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

  .profile-layout {
    padding: var(--space-3);
  }

  /* Show/Hide for mobile */
  .hide-mobile { display: none !important; }
  .show-mobile { display: block !important; }
  .show-mobile-flex { display: flex !important; }
}

/* ─── Desktop Only ─── */
@media (min-width: 1025px) {
  .hide-desktop { display: none !important; }
  .show-desktop { display: block !important; }
}

/* ─── Mobile Only Classes (hidden by default) ─── */
.show-mobile,
.show-mobile-flex {
  display: none;
}
